/*
  SchemeReady: the How it works timeline and its demos
  (docs/DESIGN-how-it-works.md 5.8). Builds on tokens.css and site.css.
  Load after pages.css. The app's own rules for what a demo shows are in
  moments-app.css, made by tools/build_moments.py; assets/moments.js plays
  the demos.
*/

/* At a glance: a soft band; the times as one panel, "Who does what" as four
   cards. Each item's badge is ::before and its icon ::after, a mask of the
   file named in --glance-icon, so each list keeps only its dt and dd. */
.glance { background: var(--sr-bg-soft); padding-block: clamp(2rem, 5vw, 3.25rem); }
.glance .h3 { margin-top: 0; }
.glance .glance-who { margin-top: clamp(2.25rem, 5vw, 3.25rem); }
.glance-times, .who-grid { display: grid; margin: 1rem 0 0; }
.glance-times, .who-grid > div { background: var(--sr-surface); border: 1px solid var(--sr-line); border-radius: var(--sr-radius); box-shadow: var(--sr-shadow); }
.glance-times { margin-bottom: .85rem; }
.glance-times > div, .who-grid > div { position: relative; --gp: 1.5rem; padding: 1.35rem var(--gp) 1.4rem calc(var(--gp) + 60px); }
.glance-times > div + div { border-top: 1px solid var(--sr-line); }
.glance-times dt { font-size: var(--sr-fs-sm); color: var(--sr-muted); }
.glance-times dd { margin: .3rem 0 0; font-size: 1.2rem; font-weight: 700; line-height: 1.3; color: var(--sr-heading); }
.glance-times > div::before, .who-grid > div::before, .glance-times > div::after, .who-grid > div::after { content: ""; position: absolute; }
.glance-times > div::before, .who-grid > div::before { left: var(--gp); top: 1.35rem; width: 44px; height: 44px; border-radius: 10px; background: var(--sr-amber-tint); }
.glance-times > div::after, .who-grid > div::after { left: calc(var(--gp) + 10px); top: calc(1.35rem + 10px); width: 24px; height: 24px; background: var(--sr-amber-text); -webkit-mask: var(--glance-icon) center / 100% no-repeat; mask: var(--glance-icon) center / 100% no-repeat; }
.who-grid { gap: 1rem; }
.who-grid dt { font-size: 1.1rem; font-weight: 700; line-height: 1.3; color: var(--sr-heading); padding-top: .55rem; }
.who-grid dd { margin: .55rem 0 0; }
/* SchemeReady's own: a navy badge and an amber tick, swapped in the dark theme. */
.who-grid > .who-us { --us-badge: var(--ds-sr-hero); --us-ink: var(--ds-sr-accent); }
:root[data-theme="dark"] .who-grid > .who-us { --us-badge: var(--ds-sr-accent); --us-ink: var(--ds-sr-hero); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .who-grid > .who-us { --us-badge: var(--ds-sr-accent); --us-ink: var(--ds-sr-hero); } }
.who-grid > .who-us::before { background: var(--us-badge); }
.who-grid > .who-us::after { background: var(--us-ink); }
.t-key { --glance-icon: url("icon-glance-key.svg"); }
.t-all { --glance-icon: url("icon-glance-all.svg"); }
.t-report { --glance-icon: url("icon-glance-report.svg"); }
.who-you { --glance-icon: url("icon-who-you.svg"); }
.who-team { --glance-icon: url("icon-who-team.svg"); }
.who-us { --glance-icon: url("icon-who-us.svg"); }
.who-others { --glance-icon: url("icon-who-others.svg"); }
@media (min-width: 760px) {
  .glance-times { grid-template-columns: repeat(3, 1fr); }
  .glance-times > div + div { border-top: 0; border-left: 1px solid var(--sr-line); }
  .who-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
}
/* On a phone the icon sits above the words, so they keep the width. */
@media (max-width: 519px) {
  .glance-times > div, .who-grid > div { --gp: 1.15rem; }
  .who-grid > div { padding: calc(1.15rem + 56px) 1.15rem 1.25rem; }
  .who-grid dt { padding-top: 0; }
}

/* The timeline. One rule runs down the left edge through all three phases;
   each list's counter agrees with its start attribute. */
.journey-line { position: relative; }
.journey-line::before {
  content: ""; position: absolute; left: calc(1.25rem - 1px); top: 1.25rem; bottom: 1.25rem;
  width: 2px; background: var(--sr-line);
}
.journey-phase { position: relative; padding-left: 3.75rem; margin: clamp(2.5rem, 6vw, 4rem) 0 1.5rem; }
.journey-line > .journey-phase:first-child { margin-top: 0; }
.journey-phase::before {
  content: ""; position: absolute; left: calc(1.25rem - 6px); top: .45em; width: 12px; height: 12px;
  border-radius: 50%; background: var(--sr-bg); border: 2px solid var(--sr-line-strong);
}
.journey { list-style: none; padding: 0; margin: 0; counter-reset: stop; display: grid; gap: clamp(2rem, 4vw, 3rem); }
.journey[start="3"] { counter-reset: stop 2; }
.journey[start="7"] { counter-reset: stop 6; }
.journey > li + li { margin-top: 0; }
.stop { counter-increment: stop; position: relative; padding-left: 3.75rem; }
.stop::before, .after-points > li::before {
  position: absolute; left: 0; top: 0; width: 2.5rem; height: 2.5rem;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
  background: var(--sr-navy); color: var(--ds-sr-on-brand); border: 1px solid var(--ds-sr-surface-brand-hover); font-weight: 800;
}
.stop::before { content: counter(stop); }
.stop-text { min-width: 0; max-width: 44rem; }
.stop-text h3 { margin: .35rem 0 .5rem; }
.stop-text > :last-child { margin-bottom: 0; }

/* Who and Time, as a term and description pair on one line each. */
.stop-meta { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; margin: 0 0 1rem; font-size: var(--sr-fs-sm); }
.stop-meta > div { display: flex; gap: .4rem; }
.stop-meta dd { margin: 0; color: var(--sr-muted); }

/* A stop with a figure: text and figure side by side from 980px, the figure
   under the text below that. A stop without one runs full width. */
.moment { margin: 1.5rem 0 0; min-width: 0; }
@media (min-width: 980px) {
  .stop:has(> .moment) { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2.5rem; align-items: start; }
  .stop:has(> .moment) > .moment { margin-top: 0; }
}

/* Frames: a plain bordered screen in tokens redefined for dark. The browser
   frame's top bar shows the address. */
.moment-screen {
  position: relative; overflow: hidden; background: var(--sr-surface);
  border: 1px solid var(--sr-line-strong); border-radius: var(--sr-radius);
}
.moment-browser::before {
  content: "schemeready.co.uk/app"; display: block; padding: .3rem .85rem; border-bottom: 1px solid var(--sr-line);
  background: var(--sr-bg-soft); color: var(--sr-muted); font-size: .75rem; line-height: 1.4;
}
.moment-browser[data-url]::before { content: attr(data-url); }
/* The phone frame: a rounded rectangle about 9 by 19.5, 300px wide, and
   260px or less on a phone. Its screen is a 390 by 844 phone's, drawn
   smaller, so the walk lays out as it does on a phone. */
.moment-phone { --z: .62; width: max-content; margin-inline: auto; padding: 7px; border-width: 2px; border-radius: 34px; background: var(--sr-bg-soft); }
@media (min-width: 600px) { .moment-phone { --z: .72; } }
@media (max-width: 332px) { .moment-phone { --z: .55; } }
.moment-phone .moment-states {
  width: 390px; height: 844px; margin: 0 calc(390px * (var(--z) - 1)) calc(844px * (var(--z) - 1)) 0;
  transform: scale(var(--z)); transform-origin: 0 0; border-radius: 40px; overflow: hidden;
}

/* A demo: every state in one box, a container, so the app's width rules
   (moments-app.css) follow the frame. The final state is in the flow and
   sets the frame's height; the others lie over it, cut off at its foot like
   a screen showing the top of a page, so a change of state never moves the
   page. Only the final state shows until moments.js stages the demo. */
.moment-states { position: relative; container: moment / inline-size; }
.moment-states > * {
  position: relative; min-width: 0; padding-block: 1rem 1.25rem;
  background: var(--sr-bg); color: var(--sr-text); font-size: var(--sr-fs-base);
}
.moment-states > :not([data-final]), .moment-phone .moment-states > * { position: absolute; inset: 0; overflow: hidden; }
.moment-phone .moment-states > * { padding: .5rem 0 0; }
.moment-states > [data-scroll] { container-type: size; }
.moment-states > :not([data-final]), .is-live .moment-states > * { visibility: hidden; opacity: 0; }
.is-live .moment-states > .is-at { visibility: visible; opacity: 1; z-index: 1; }
/* The tap ring, shown by a tap step. */
.moment-stage [data-tap] { position: relative; }
.moment-stage [data-tap]::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 3px solid var(--ds-sr-accent-edge); border-radius: 50%; opacity: 0; pointer-events: none;
  background: color-mix(in srgb, var(--ds-sr-accent) 35%, transparent);
}
/* Words that aren't public, such as a licensed question, as grey bars. */
.moment-redact { display: block; min-width: 9em; }
.moment-redact > i { display: block; height: .6em; margin: calc(.5lh - .3em) 0; border-radius: 1em; background: var(--sr-line-strong); opacity: .4; }
.moment-redact > i:last-child:not(:first-child) { width: 62%; }
.moment-redact > i:only-child { width: 12em; max-width: 100%; }
/* The email that follows a request, as one plain inbox row. */
.moment-inbox {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .7rem; margin-top: 1rem; padding: .75rem 1rem;
  font-size: var(--sr-fs-sm); background: var(--sr-surface); border: 1px solid var(--sr-line-strong); border-radius: var(--sr-radius-sm);
}
.moment-inbox b { color: var(--sr-heading); }
.moment-envelope, .moment-envelope::before { position: relative; border: 1.5px solid var(--sr-muted); }
.moment-envelope { flex: none; width: 1.3rem; height: .95rem; overflow: hidden; border-radius: 2px; }
.moment-envelope::before { content: ""; position: absolute; left: 50%; top: -.62rem; width: .9rem; height: .9rem; transform: translateX(-50%) rotate(45deg); }
/* The control's room is kept from the first paint, only where there'll be one. */
.moment-controls { display: flex; }
@media (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .moment-controls { min-height: 2.75rem; padding-top: .5rem; }
}
/* Until the player picks a demo up, it shows where it will start, not how it
   ends: a demo already on screen at load, from a link to its stop, would
   otherwise show the answer and then rewind. Every timeline starts on state 1.
   Without scripts, with reduced motion, and in print, the final state stays. */
@media screen and (scripting: enabled) and (prefers-reduced-motion: no-preference) {
  .moment[data-timeline]:not(.is-live) .moment-states > [data-final] { visibility: hidden; opacity: 0; }
  .moment[data-timeline]:not(.is-live) .moment-states > [data-state="1"] { visibility: visible; opacity: 1; z-index: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  /* The next state fades in over the last, which goes once it's covered. */
  .is-live .moment-states > * { transition: opacity 0s var(--ds-motion-slow), visibility 0s var(--ds-motion-slow); }
  .is-live .moment-states > .is-at { transition: opacity var(--ds-motion-slow) var(--ds-motion-ease); }
  .is-playing .is-at [data-enter] { animation: moment-rise var(--ds-motion-slow) var(--ds-motion-ease) both; }
  .is-playing .is-at [data-enter="late"] { animation-delay: .5s; }
  .is-playing .is-at [data-slide] { animation: moment-slide var(--ds-motion-slow) var(--ds-motion-ease) both; }
  .is-tap .is-at [data-tap]::after { animation: moment-tap .4s ease-out both; }
  /* A scroll step takes a long state to its foot. */
  .is-scroll [data-scroll] > * { transform: translateY(min(0px, 100cqh - 100%)); transition: transform .9s var(--ds-motion-ease); }
  .moment.is-playing .ring-fill { transition-duration: .9s; }
  /* A jump (staging, Play again, sent to the end) shows its state at once.
     .is-at is named so this outranks the fade in above. */
  .is-jump .moment-states > *, .is-jump .moment-states > .is-at, .is-jump .moment-states > * > *,
  .is-jump .is-at [data-enter], .is-jump .is-at [data-slide] { transition: none; animation: none; }
  @keyframes moment-rise { from { opacity: 0; transform: translateY(8px); } }
  @keyframes moment-slide { from { transform: translateY(100%); } }
  @keyframes moment-tap { 0% { opacity: 0; transform: scale(.5); } 30% { opacity: 1; transform: scale(.85); } 100% { opacity: 0; transform: scale(1.3); } }
}

/* The welcome email, drawn as a plain message with no mail client around it. */
.moment-email-head { padding: .75rem 1.1rem; border-bottom: 1px solid var(--sr-line); background: var(--sr-bg-soft); font-size: var(--sr-fs-sm); }
.moment-email-head p { margin: 0; display: grid; grid-template-columns: 4.25rem 1fr; }
.moment-email-head p + p { margin-top: .2rem; }
.moment-email-label { color: var(--sr-muted); }
.moment-email-body { padding: 1.1rem 1.25rem 1.25rem; font-size: var(--sr-fs-sm); }
.moment-email-body p { margin: 0 0 .9rem; }
.moment-email-body > :last-child { margin-bottom: 0; }
.moment-email-button {
  display: inline-block; padding: .55rem 1.1rem; border-radius: var(--sr-radius-sm);
  background: var(--sr-navy); color: var(--ds-sr-on-brand); font-weight: 600;
}
.moment-email-link { color: var(--sr-link); text-decoration: underline; text-underline-offset: .15em; overflow-wrap: anywhere; }

/* The documents list: name, format chips, size, then the product's own line. */
.moment .file-list { margin: 0; }
.moment .file-list .chip { font-weight: 600; }
.moment .file-desc { flex: 1 0 100%; margin: 0; color: var(--sr-muted); font-size: var(--sr-fs-sm); }

/* After you complete: three points, across from 820px, down on a phone. */
.after-points { list-style: none; padding: 0; margin: 0 0 1.5rem; counter-reset: after; display: grid; gap: 1.25rem; }
.after-points > li { counter-increment: after; position: relative; padding-left: 2.5rem; margin: 0; }
.after-points > li::before { content: counter(after); top: .1rem; width: 1.5rem; height: 1.5rem; font-size: .8rem; }
.after-points .after-label { display: block; font-weight: 700; color: var(--sr-heading); margin-bottom: .25rem; }
.after-points p { margin: 0; }
@media (min-width: 820px) {
  .after-points { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.75rem; }
}
.after-points ~ p { max-width: 46rem; }

@media (max-width: 480px) {
  .stop, .journey-phase { padding-left: 3.25rem; }
}

@media print {
  .journey-line::before, .journey-phase::before { display: none; }
  .journey-phase { padding-left: 0; }
  .stop { break-inside: avoid; }
  .moment-screen { border: 1px solid var(--sr-line-strong); break-inside: avoid; }
  .moment-controls { display: none; }
  .is-live .moment-states > .is-at:not([data-final]) { visibility: hidden; opacity: 0; }
  .is-live .moment-states > [data-final] { visibility: visible; opacity: 1; z-index: 1; }
}
