/* Brief section: the styles, all inside #brief (the shared page's contract).
   A plain white section under the black hero: the words on the right, Lumi and its chat window
   on the left, three steps that keep playing, and my part as one stamp.
   One stage, real parts: Lumi (the page's shared critter.js) and the chat window (the page's
   shared ccs.css).
   ONE UNIT, as the hero built it: every size and place is a count of --u, and --u follows the
   section's width and the stage's height, so the section scales as one picture.
   Computer picture 100 x 60 units, phone picture 100 x 220.
   No overflow, clip-path or mask on the stage. At rest Lumi sits whole on white here, or where
   the hero put it up there; it crosses the room's edge only while it travels. The stage has no
   ground of its own: the page is white, and one Lumi is drawn in the hero's layers, under this
   section's words and window, so it must show through. */

#brief {
  /* The page opens at its top, on the hero, so the first scroll shows Lumi's whole trip down:
     the panel lands on this section, and this margin holds that landing a full screen higher. */
  scroll-margin-top: 100svh;

  /* This section paints over the next one. When the one Lumi sets off for section 3 it is drawn
     by that section (its grey would cut a Lumi drawn up here), and it must still pass under this
     section's words and chat window, as it sat under them at rest. Nothing else of section 3
     reaches up here. A section is not a layer of its own, so each section's stage (z-index 1)
     stacks with the others in page order; this has to sit above the next stage, hence 2. */
  z-index: 2;

  /* ---- the stage ---- */
  .b2 {
    --hh: clamp(40rem, 100svh, 54rem); --u: min(1cqw, calc(var(--hh) / 60)); --fh: 60;
    --pad: calc(5 * var(--u));
    --edge: calc((100% - 100 * var(--u)) / 2);
    --ink: var(--neutral-950); --inv: var(--neutral-0);
    --em: var(--neutral-600); /* the quiet step names: neutral-500 failed contrast on white (2.6 to 1) */
    --sub: var(--neutral-600); --rule: var(--neutral-300); --soft: var(--neutral-150);
    --ww: 22.5rem;
    /* the heading is section 3's size (6.72 units), so the two read as one page; both stay under the hero's title (7.19) */
    --title: 6.72; --tw: 41; --part-w: 34;
    /* The chat leads and Lumi looks over it: Lumi up and back, its eyes clear above the window */
    --ls: 50; --lx: 21; --ly: 0.38;      /* Lumi: size, middle across, middle down */
    --wx: 28; --wb: 0.06; --wk: 1.4;     /* its window: middle across, bottom edge, size */
    --lumi-from: translate(14%, 10%) scale(0.5);
    /* When the frame runs wider than centred (page.css
       sets a smaller --edge), Lumi and the window move left with it, as the words move right, but only
       as far as keeps Lumi's whole drawing a step in from the screen's side. Centred (phones) --wide is 0. */
    --edge0: calc((100% - 100 * var(--u)) / 2);
    --wide: min(0px, max(calc(var(--edge) - var(--edge0)), calc(var(--ls) * var(--u) / 2 + var(--space-400) - var(--edge0) - var(--lx) * var(--u))));
    /* The white space above and below is the page's one section padding (page.css): this
       section sets none of its own. */
    position: relative; z-index: 1; box-sizing: border-box;
    height: calc(var(--fh) * var(--u));
    background: none; color: var(--ink);
  }

  /* the words: one column on the right, set like the chat's first lines */
  .b-type {
    position: absolute; z-index: 3; inset: var(--pad) calc(var(--edge) + var(--pad));
    display: flex; justify-content: flex-end; pointer-events: none;
  }
  .b-col {
    width: calc(var(--tw) * var(--u)); max-width: 100%; min-height: 100%;
    display: flex; flex-direction: column; justify-content: center; text-align: left;
    transition: opacity var(--duration-flourish) var(--ease-default), transform var(--duration-expressive) var(--ease-emphasized);
  }
  .b2:not([data-on~="type"]) .b-col { opacity: 0; transform: translateY(var(--space-500)); }
  .b-title {
    margin: 0; font-family: var(--font-display); font-weight: var(--display-weight);
    font-size: calc(var(--title) * var(--u)); line-height: var(--line-display); letter-spacing: var(--display-tight);
    text-wrap: balance;
  }
  .b-lead {
    margin: calc(var(--leadz, 1.5) * var(--u) * 0.8) 0 0;
    font-size: calc(var(--leadz, 1.5) * var(--u)); font-weight: var(--weight-medium); line-height: var(--line-snug);
    color: var(--sub); text-wrap: pretty;
  }

  /* The guard: three steps. Each plays its own exchange in the window, and they keep playing
     a line fills under the step that is on, over a quiet track under all three.
     No play or pause button: a tap on a step, or on the picture, holds it there. */
  .b-steps {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start;
    gap: 0 calc(var(--stepz, 1.25) * var(--u) * 0.7);
    margin: calc(var(--stepz, 1.25) * var(--u) * 1.3) 0 0; padding: 0; list-style: none; pointer-events: auto;
  }
  .b-steps li { display: flex; align-items: center; gap: calc(var(--stepz, 1.25) * var(--u) * 0.7); }
  .b-steps li + li::before { content: "\2192"; font-size: calc(var(--stepz, 1.25) * var(--u)); line-height: 1; color: var(--em); }
  .b-step {
    position: relative; display: inline-flex; align-items: center; min-height: 2.75rem;
    margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: calc(var(--stepz, 1.25) * var(--u)); font-weight: var(--weight-semibold); line-height: var(--line-title);
    color: var(--em);
    /* No nowrap (20 Nov 2026, chat READABILITY FIX): a step sits on one line wherever its row has room, which is
       every width at default settings; under WCAG 1.4.12 text spacing on a phone "Not written, not said" is wider than
       the row, and held to one line it ran off the screen. */
  }
  .b-step::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0.45rem; height: 2px; background: var(--rule); }
  .b-step::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0.45rem; height: 2px; background: var(--ink);
    transform: scaleX(0); transform-origin: left; transition: transform var(--duration-slow) var(--ease-emphasized);
  }
  .b-step[aria-selected="true"] { color: var(--ink); }
  .b-step[aria-selected="true"]::after { transform: scaleX(1); }
  .b-step:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: var(--radius-sm); }
  @media (prefers-reduced-motion: no-preference) {
    .b2:not([data-held]) .b-step[aria-selected="true"]::after { transition: none; animation: b-brief-fill var(--step-t, 4.3s) linear both; }
  }

  /* my part: one box, like a stamp */
  .b-part-b {
    display: grid; gap: calc(var(--partz, 1.25) * var(--u) * 0.5); text-align: left;
    margin-top: var(--part-mt, calc(2.6 * var(--u))); align-self: var(--part-x, auto); width: 100%; max-width: calc(var(--part-w) * var(--u));
  }
  .pb {
    margin: 0; padding: calc(var(--partz, 1.25) * var(--u) * 0.6) calc(var(--partz, 1.25) * var(--u) * 0.95);
    font-size: calc(var(--partz, 1.25) * var(--u) * var(--pbk, 1.2)); font-weight: var(--weight-medium); line-height: var(--line-title); text-wrap: balance;
    display: grid; gap: calc(var(--partz, 1.25) * var(--u) * 0.35); justify-self: start; background: var(--soft); color: var(--ink);
    border-radius: calc(var(--partz, 1.25) * var(--u) * 0.8); box-shadow: inset 0 0 0 1px var(--rule);
  }
  .pb .pb-l.ai { font-weight: var(--weight-regular); color: var(--color-text-secondary); white-space: nowrap; }
  .b-logo { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -0.18em; margin-right: 0.3em; }

  /* One Lumi travels behind this section's words. A line never sits over it: while Lumi's body is
     behind a line, that line waits, unseen (brief.js sets data-under), then comes back.
     A line that holds the keyboard's place always shows. data-under: Lumi on its way here from
     the hero. data-pass: Lumi on its way from here to section 3 (that section's script sets it);
     that move clears only the lines just ahead of it, so those go quicker and come back slower.
     data-gone on the stage: Lumi has left for section 3, so its place here is empty; the chat
     window stays open, so nothing he is reading shuts. */
  .b-title, .b-lead, .b-steps, .b-part-b { transition: opacity var(--duration-slow) var(--ease-default); }
  [data-under]:not(:focus-within), [data-pass]:not(:focus-within) { opacity: 0; }
  [data-pass]:not(:focus-within) { transition-duration: var(--duration-base); }
  .b2[data-gone] .b-lumi { visibility: hidden; }

  /* Lumi's place in this section. One Lumi's canvas lives up in the hero's layers and this box
     only marks where it lands (brief.js measures it). With motion off the canvas lives here. */
  .b-lumi-w {
    position: absolute; z-index: 1; pointer-events: none;
    left: calc(50% + (var(--lx) - 50) * var(--u) + var(--wide)); top: calc(100% * var(--ly)); width: calc(var(--ls) * var(--u)); aspect-ratio: 1;
    translate: -50% -50%;
  }
  .b-lumi {
    display: block; width: 100%; height: 100%;
    transition: opacity var(--duration-flourish) var(--ease-default), transform var(--duration-expressive) var(--ease-emphasized);
  }
  .b2:not([data-on~="lumi"]) .b-lumi { opacity: 0; transform: var(--lumi-from); }

  /* The chat window: the real one, over Lumi. It grows up from its bottom edge. */
  .b-win { position: absolute; z-index: 4; left: calc(50% + (var(--wx) - 50) * var(--u) + var(--wide)); bottom: calc(100% * var(--wb)); translate: -50% 0; width: calc(var(--ww) * var(--k, 1) * var(--wk)); }
  .b-win-m { zoom: calc(var(--k, 1) * var(--wk)); position: relative; text-align: left; transition: opacity var(--duration-slow) var(--ease-default), transform var(--duration-expressive) var(--ease-emphasized); }
  .b2:not([data-on~="win"]) .b-win-m { opacity: 0; transform: translateY(var(--space-500)); }
  .b-win .ccs-win { position: relative; inset: auto; }
  .b-win .ccs-log { justify-content: flex-start; -webkit-mask-image: none; mask-image: none; }
  .b-win .ccs-msg--bot { align-items: flex-start; }
  .b-src { display: block; margin-top: var(--space-100); font-size: var(--size-xs); color: var(--color-text-secondary); text-decoration: underline; text-underline-offset: 0.2em; }
  .b-src.strong { color: var(--color-text-primary); font-weight: var(--weight-semibold); }
  /* the wrong answer, crossed out, above the right one */
  .b-wrong s { color: var(--color-text-primary); text-decoration: line-through 2px transparent; transition: text-decoration-color var(--duration-moderate) var(--ease-default), color var(--duration-moderate) var(--ease-default); }
  .b-wrong[data-struck] s { color: var(--color-text-secondary); text-decoration-color: var(--color-text-primary); }
  .b-wrong .b-why { opacity: 0; transition: opacity var(--duration-moderate) var(--ease-default); }
  .b-wrong[data-struck] .b-why { opacity: 1; }
  .b-why { display: block; margin-top: var(--space-100); font-family: var(--font-mono); font-size: var(--size-2xs); color: var(--color-text-secondary); }

  .b2[data-snap] *, .b2[data-snap] { transition: none !important; }
  @media (prefers-reduced-motion: reduce) { .b2 *, .b2 { transition: none !important; } }

  /* =====================================================================
     PHONE: its own stack. Words, then Lumi and its window, then my part.
     ===================================================================== */
  @container row (max-width: 1000px) {
    .b2 {
      --hh: clamp(43.5rem, 104svh, 68rem); --u: min(1cqw, calc(var(--hh) / 220)); --fh: 220;
      --pad: calc(6 * var(--u)); --ww: 18.75rem; --leadz: 4.27; --stepz: 3.47; --partz: 4.0; --pbk: 1;
      --part-mt: auto; --part-x: stretch; --part-w: 88; --tw: 88;
      --title: 12; /* a section heading is 12 units at most on a phone (the page's rule); the hero's is larger */
      --ls: 100; --lx: 40; --ly: 0.4; --wk: 1.25; --wx: 50; --wb: 0.19;
      --lumi-from: translate(8%, 10%) scale(0.5);
    }
    .b-type { justify-content: flex-start; }
    .b-col { width: 100%; justify-content: flex-start; }
    /* one row always: a second row would sit on Lumi; the joining arrows go, the gaps stay */
    .b-steps { flex-wrap: nowrap; gap: 0 calc(3.4 * var(--u)); }
    .b-steps li + li::before { content: none; }
    .b-lead { text-wrap: balance; }
  }
}

/* the line that fills under the step that is on */
@keyframes b-brief-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
