/* #where: one live industry stage, scrubbed by scroll. Owned by W6.
   Default (no JS, reduced motion, fx-fail): the seven drawings as a flowing grid, each at its settled pose, all copy in flow.
   Cinematic (html.js:not(.fx-fail):not(.static)): the pinned stage shows ONE industry at a time; its force diagram moves with scroll
   (scenes/where.mjs writes the poses from fbd.mjs). The index on the frame only shows where you are; nothing on it is pressed.
     desktop  copy in a light left column, the stage and its rail on the right.
     phone    the stage on top, the rail under it, the copy below on a solid bone plate.
   Nothing here loops; the one CSS animation is a finite fade when the industry changes. */

/* Scroll length: seven drawings share the track (the home page's total length is budgeted in tests/e2e/checks/budgets.mjs). */
#where { --sc: 3.85; }

/* ---- copy ------------------------------------------------------------------------------------------------------ */
.where__head { display: grid; gap: 1.6rem 4vw; align-items: end; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.where__title h2 { font-size: clamp(1.45rem, min(2.3vw, 5svh), 2.7rem); font-weight: 650; letter-spacing: -.035em; line-height: 1.02; text-wrap: balance; }
.where__title .label { margin-bottom: 1.1rem; }
.where__intro { max-width: 36ch; font-size: clamp(.92rem, 1vw, 1.05rem); line-height: 1.5; color: var(--mut); }
/* The foot is its own block: a rule above it, the closer, the button, then the quiet link last. */
.where__foot { display: grid; justify-items: start; gap: .8rem; margin-top: 1.5rem; padding-top: 1.2rem; border-top: 1px solid transparent; max-width: 46rem; position: relative; }
/* the rule is its own layer: the dust plate (a negative-z ::before) would paint over a border */
.where__foot::after { content: ''; position: absolute; z-index: 1; left: 0; right: 0; top: -1px; height: 1px; background: var(--line); pointer-events: none; }
.where__closer { max-width: 30ch; font-family: var(--font-display); font-size: clamp(1rem, 1.3vw, 1.25rem); font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.where__next { font-family: var(--font-mono); font-size: .74rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--fg); text-decoration: none; border-bottom: 2px solid transparent; padding-bottom: .15rem; }
.where__next::after { content: ' \2193'; }
.where__next:hover { border-bottom-color: var(--fg); }
.where__next:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }
.where__base { margin: .9rem 0 0; max-width: 36ch; font-size: .74rem; letter-spacing: .03em; line-height: 1.45; color: var(--mut); padding-left: .7rem; border-left: 3px solid var(--signal); }

/* ---- the stages (default: a grid of six settled drawings) ------------------------------------------------------- */
.where__panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.4rem 3rem; margin-block: 2rem; }
@media (max-width: 700px) { .where__panels { grid-template-columns: minmax(0, 1fr); } }
#where .panel { position: relative; color: var(--fg); }
#where .panel__in { position: relative; display: grid; gap: 1rem; align-content: start; min-height: 0; --cap: 5rem; }
#where .panel__cap { position: relative; display: grid; gap: .45rem; align-content: start; padding-right: 0; }
#where .panel__in h3 { font-family: var(--font-display); font-size: clamp(1.05rem, 1.7vw, 1.6rem); font-weight: 650; letter-spacing: -.025em; line-height: 1.1; }
#where .panel__in h3 a { text-decoration: none; }
/* The caption is the link (it opens the intake with that industry preselected); the drawing stays plain art. Standard hover: an underline; focus: the outline. */
#where .panel__go::after { content: ''; position: absolute; inset: 0; }
#where .panel__go:hover { text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 2px; }
#where .panel__go:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }
#where .panel__sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem 1rem; }
#where .panel__kicker { margin: 0; font-size: .7rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--mut); }
#where .panel__note { margin: 0; font-size: .8rem; line-height: 1.3; color: var(--mut); }

/* The scoreboard: three KPI tiles in flow under the drawing. Name large, then an ultramarine direction arrow and the unit as a chip; definitions live in the title attribute only. */
#where .panel__kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem 1rem; margin: 0; padding-top: .9rem; border-top: 1px solid var(--line); }
#where .kpi { display: grid; gap: .55rem; align-content: start; padding: .75rem .9rem .8rem; background: color-mix(in srgb, var(--signal) 11%, var(--bone)); border-left: 3px solid var(--signal); }
#where .kpi dt { font-family: var(--font-display); font-size: clamp(1.35rem, 1.5vw, 1.6rem); font-weight: 650; letter-spacing: -.025em; line-height: 1.1; }
#where .kpi__u { display: flex; align-items: center; gap: .5rem; margin: 0; font-family: var(--font-mono); font-size: .76rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--signal-d); }
#where .kpi__g { display: inline-block; flex: none; width: .8rem; height: 1rem; background: var(--signal); }
#where .kpi__g[data-dir="up"] { clip-path: polygon(50% 0, 100% 46%, 66% 46%, 66% 100%, 34% 100%, 34% 46%, 0 46%); }
#where .kpi__g[data-dir="down"] { clip-path: polygon(34% 0, 66% 0, 66% 54%, 100% 54%, 50% 100%, 0 54%, 34% 54%); --from: -6px; }
#where .kpi__c { padding: .2rem .5rem; background: var(--signal-d); color: #fff; line-height: 1.2; }
#where .panel__art { display: block; width: 100%; height: auto; min-height: 0; color: var(--fg); }
#where .where__rail { display: none; }

/* ---- the diagrams ------------------------------------------------------------------------------------------------ */
.fbd-gap { transform-box: fill-box; transform-origin: center; }
/* The momentum cart (scenes/where.mjs): it rides the rule above the index and gains speed through the section. Static (reduced motion, no JS): a small
   settled cart, streaks out, at the right of the panels. Cinematic: positioned on the rule by script. */
#where .where__cart { display: block; width: 56px; height: auto; margin: -1rem 0 0 auto; color: var(--fg); pointer-events: none; overflow: visible; }
html.js:not(.fx-fail):not(.static) #where .where__cart { position: absolute; z-index: 2; margin: 0; width: clamp(46px, 5.2vw, 76px); will-change: transform; }
/* The far layer (the setting behind the subject) is a crisp solid 1.5 px mid-ink line: no opacity, so a stroke never blurs or doubles where lines cross. */
#where .fbd-far { stroke: color-mix(in srgb, var(--fg) 66%, var(--bone)); }

/* ---- cinematic: the pinned stage -------------------------------------------------------------------------------- */
@keyframes where-in { from { opacity: 0; } }
html.js:not(.fx-fail):not(.static) #where .stage {
  display: grid; grid-template-columns: minmax(0, 24%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; column-gap: clamp(1.1rem, 2.2vw, 2.2rem);
  padding-top: clamp(76px, 9.5svh, 100px); padding-bottom: clamp(18px, 4svh, 40px);
}
html.js:not(.fx-fail):not(.static) #where .where__head { grid-column: 1; grid-row: 1; grid-template-columns: minmax(0, 1fr); align-items: start; align-content: start; gap: 1.6rem; }
html.js:not(.fx-fail):not(.static) #where .where__lede { margin-top: -.4rem; }
html.js:not(.fx-fail):not(.static) #where .where__foot { grid-column: 1; grid-row: 2; margin-top: auto; }
html.js:not(.fx-fail):not(.static) #where .where__live {
  position: relative; grid-column: 2; grid-row: 1 / 3; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; align-content: center; gap: clamp(.6rem, 1.6vh, 1.2rem);
  padding: clamp(.9rem, 2vh, 1.6rem) clamp(1rem, 1.8vw, 1.8rem) clamp(.8rem, 1.6vh, 1.2rem); border: 1px solid color-mix(in srgb, var(--fg) 22%, transparent);
}
/* Frame corners: four short ink ticks sit just outside the hairline, the same grammar as the drawings' ground ticks. */
html.js:not(.fx-fail):not(.static) #where .where__live::before, html.js:not(.fx-fail):not(.static) #where .where__live::after {
  content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none; border: 0 solid var(--fg);
}
html.js:not(.fx-fail):not(.static) #where .where__live::before { top: -1px; left: -1px; border-width: 2.5px 0 0 2.5px; }
html.js:not(.fx-fail):not(.static) #where .where__live::after { bottom: -1px; right: -1px; border-width: 0 2.5px 2.5px 0; }
html.js:not(.fx-fail):not(.static) #where .where__panels { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 1180px; justify-self: center; min-height: 0; height: 100%; margin: 0; gap: 0; }
html.js:not(.fx-fail):not(.static) #where .panel { grid-area: 1 / 1; display: none; min-height: 0; }
html.js:not(.fx-fail):not(.static) #where .panel[data-front] { display: block; animation: where-in .35s ease-out; }
/* The caption is out of flow here, so the drawing is the same size for every industry and nothing shifts when the stage changes. */
html.js:not(.fx-fail):not(.static) #where .panel__in { grid-template-rows: minmax(0, 1fr) auto auto; height: 100%; gap: .8rem; padding-top: var(--cap); }
html.js:not(.fx-fail):not(.static) #where .panel__cap { position: absolute; top: 0; left: 0; right: 0; }
html.js:not(.fx-fail):not(.static) #where .panel__art { height: 100%; justify-self: center; }

/* Desktop: the frame hugs the drawing. All drawings share one 240 x 142 frame (fbd.mjs, cropped to the ink), so the art box is that shape: as wide as the column
   allows, no wider than the viewport height carries (26.4rem = stage padding, caption, scoreboard, index, the cart's lane, frame padding). No dead band; 1280 x 720 gets 680 px. */
@media (min-width: 901px) {
  html.js:not(.fx-fail):not(.static) #where { --art-w: min(1180px, calc((100svh - 26.4rem) * 240 / 142)); --pad-x: clamp(1rem, 1.8vw, 1.8rem); }
  html.js:not(.fx-fail):not(.static) #where .where__live {
    align-self: center; justify-self: center; width: min(100%, calc(var(--art-w) + 2 * var(--pad-x))); grid-template-rows: auto auto; align-content: start; padding-inline: var(--pad-x);
  }
  html.js:not(.fx-fail):not(.static) #where .where__panels { width: 100%; max-width: none; height: auto; }
  html.js:not(.fx-fail):not(.static) #where .panel__in { height: auto; grid-template-rows: auto; }
  html.js:not(.fx-fail):not(.static) #where .panel__art { width: 100%; height: auto; aspect-ratio: 240 / 142; }
}

/* The swarm's dust stays off the words: the left copy column, the industry caption and (phone) the copy plates sit on a feathered bone plate.
   Each feather is no wider than its overhang, so the text box is always on full bone. --fx and --fy are the feather widths across and down. */
html.js:not(.fx-fail):not(.static) #where :is(.where__head, .where__foot, .panel__cap, .panel__kpis, .where__base) { isolation: isolate; }
html.js:not(.fx-fail):not(.static) #where :is(.where__head, .where__foot, .panel__kpis, .where__base) { position: relative; }   /* the caption is already absolutely placed */
html.js:not(.fx-fail):not(.static) #where :is(.where__head, .where__foot, .panel__cap, .panel__kpis, .where__base)::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none; background: var(--bone);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fx), #000 calc(100% - var(--fx)), transparent), linear-gradient(0deg, transparent, #000 var(--fy), #000 calc(100% - var(--fy)), transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, transparent, #000 var(--fx), #000 calc(100% - var(--fx)), transparent), linear-gradient(0deg, transparent, #000 var(--fy), #000 calc(100% - var(--fy)), transparent);
  mask-composite: intersect;
}
html.js:not(.fx-fail):not(.static) #where .where__head { align-self: stretch; }
html.js:not(.fx-fail):not(.static) #where :is(.where__head, .where__foot)::before { --fx: 2.4rem; --fy: .75rem; inset: -.75rem -2.4rem -.75rem calc(var(--gutter) * -1); }
html.js:not(.fx-fail):not(.static) #where :is(.panel__cap, .panel__kpis, .where__base)::before { --fx: 1rem; --fy: .5rem; inset: -.5rem -1rem -.5rem -1rem; }
@media (max-width: 900px) {
  html.js:not(.fx-fail):not(.static) #where :is(.where__head, .where__foot)::before { inset: 0; }   /* already full-bleed solid plates */
}

/* When an industry comes to the front its three direction glyphs draw in, one after the other, once. */
@keyframes kpi-draw { from { opacity: 0; transform: translateY(var(--from, 6px)); } }
html.js:not(.fx-fail):not(.static) #where .panel[data-front] .kpi__g { animation: kpi-draw .45s cubic-bezier(.2, .8, .2, 1) both; }
html.js:not(.fx-fail):not(.static) #where .panel[data-front] .kpi:nth-child(1) .kpi__g { animation-delay: .25s; }
html.js:not(.fx-fail):not(.static) #where .panel[data-front] .kpi:nth-child(2) .kpi__g { animation-delay: .4s; }
html.js:not(.fx-fail):not(.static) #where .panel[data-front] .kpi:nth-child(3) .kpi__g { animation-delay: .55s; }

/* The index: the six industries as a row under the drawing, the active one in full ink with its tick drawn out, and an ink rule above it filling
   as you move through the six. It is an indicator only and is all ink: vermilion belongs to the gap inside the drawing. */
html.js:not(.fx-fail):not(.static) #where .where__rail {
  position: relative; display: flex; justify-content: space-between; align-self: end; gap: .8rem; width: 100%;
  margin: 1.3rem 0 0; padding: .9rem 0 0; list-style: none; pointer-events: none; counter-reset: ix;
}
#where .where__rail::before, #where .where__rail::after { content: ''; position: absolute; left: 0; top: 0; height: 2px; }
#where .where__rail::before { right: 0; background: var(--fg); opacity: .35; }
#where .where__rail::after { width: calc(var(--p, 0) * 100%); background: var(--fg); }
#where .where__rail li { position: relative; display: flex; align-items: center; gap: .55rem; counter-increment: ix; }
#where .where__rail i { display: none; width: 18px; height: 3px; background: var(--fg); opacity: .4; transform-origin: left; transform: scaleX(.4); transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .35s; }
#where .where__rail span { white-space: nowrap; font-family: var(--font-mono); font-size: clamp(.72rem, .88vw, .92rem); font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: color-mix(in srgb, var(--fg) 86%, var(--bone)); transition: color .35s; }
#where .where__rail span::before { content: counter(ix, decimal-leading-zero) ' '; }
#where .where__rail li[data-on] i { opacity: 1; transform: none; }
#where .where__rail li[data-on]::before { content: ''; position: absolute; left: 0; right: 0; top: -.9rem; height: 4px; background: var(--fg); }
#where .where__rail li[data-on] span { color: var(--fg); font-weight: 800; }

/* phone: the stage on top, the rail under it, the copy under that on a solid plate that nothing shows through */
@media (max-width: 900px) {
  #where { --sc: 4.6; }
  html.js:not(.fx-fail):not(.static) #where .stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto auto; padding-top: max(64px, 8svh); padding-bottom: 0; }
  html.js:not(.fx-fail):not(.static) #where .where__live { grid-column: 1; grid-row: 1; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: .6rem; padding: .6rem .7rem .5rem; }
  html.js:not(.fx-fail):not(.static) #where .where__cart { width: 40px; }
  html.js:not(.fx-fail):not(.static) #where .where__rail { margin-top: 1rem; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; padding: .55rem 0 0; }
  #where .where__rail li { display: grid; justify-items: center; gap: .35rem; }
  #where .where__rail i { display: block; width: 2px; height: 12px; transform: scaleY(.5); transform-origin: top; }
  /* seven names do not fit one row at 390 px: inactive ticks show their number, the lit one names itself under the rule */
  #where .where__rail span { font-size: 0; }
  #where .where__rail span::before { content: counter(ix, decimal-leading-zero); font-size: .7rem; letter-spacing: .04em; opacity: 1; }
  #where .where__rail li { padding-bottom: 1rem; }
  #where .where__rail li[data-on]::before { top: -.55rem; right: 0; }
  #where .where__rail li[data-on] span { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font-size: .72rem; opacity: 1; }
  #where .where__rail li[data-on] span::before { content: none; }
  html.js:not(.fx-fail):not(.static) #where .where__head { grid-column: 1; grid-row: 2; }
  html.js:not(.fx-fail):not(.static) #where .where__foot { grid-column: 1; grid-row: 3; }
  html.js:not(.fx-fail):not(.static) #where .where__head,
  html.js:not(.fx-fail):not(.static) #where .where__foot { margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); background: var(--bone); }
  html.js:not(.fx-fail):not(.static) #where .where__head { padding-top: .9rem; padding-bottom: .9rem; gap: .7rem; }
  .where__lede { padding-bottom: .2rem; }
  html.js:not(.fx-fail):not(.static) #where .where__foot { padding-block: .6rem max(.8rem, env(safe-area-inset-bottom)); gap: .6rem 1rem; }
  .where__head { grid-template-columns: minmax(0, 1fr); }
  .where__title h2 { font-size: clamp(1.15rem, 5.6vw, 1.6rem); }
  .where__title .label { margin-bottom: .35rem; }
  .where__intro { font-size: .8rem; line-height: 1.38; }
  .where__lede { gap: .4rem; }
  .where__closer { font-size: .88rem; max-width: none; }
  .where__closer br { display: none; }
  .where__next { font-size: .66rem; }
  html.js:not(.fx-fail):not(.static) #where .where__next { display: none; }   /* the definitions took its line; the page below is one scroll away */
  html.js:not(.fx-fail):not(.static) #where .panel__in { --cap: 3.7rem; }
  html.js:not(.fx-fail):not(.static) #where .panel__cap { padding-right: 0; gap: .15rem; }
  html.js:not(.fx-fail):not(.static) #where .panel__in h3 { font-size: 1.05rem; }
  #where .panel__note { font-size: .74rem; }
  /* one line per KPI: the name left, the direction arrow and unit chip right */
  #where .panel__kpis { grid-template-columns: minmax(0, 1fr); gap: .3rem; padding-top: .45rem; }
  #where .kpi { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: .7rem; gap: 0 .7rem; padding: .3rem .55rem; }
  #where .kpi dt { font-size: 1.08rem; letter-spacing: -.03em; }
  #where .kpi__u { font-size: .62rem; letter-spacing: .02em; white-space: nowrap; }
  #where .kpi__g { width: .6rem; height: .78rem; }
  html.js:not(.fx-fail):not(.static) #where .where__base { display: none; }
  html.js:not(.fx-fail):not(.static) #where .panel__in { gap: .5rem; }
  html.js:not(.fx-fail):not(.static) #where .where__rail span { font-family: var(--font-body); font-weight: 600; letter-spacing: 0; text-transform: none; }
  html.js:not(.fx-fail):not(.static) #where .where__rail span::before { font-family: var(--font-mono); }
}
/* a short phone keeps the stage large: the extra line and the bridge link give way */
@media (max-width: 900px) and (max-height: 760px) {
  .where__next { display: none; }
  #where .where__rail li { padding-bottom: .75rem; }
  html.js:not(.fx-fail):not(.static) #where .where__head { padding-top: .65rem; padding-bottom: .65rem; gap: .5rem; }
  html.js:not(.fx-fail):not(.static) #where .panel__in { --cap: 3.4rem; }
  html.js:not(.fx-fail):not(.static) #where .panel__note, html.js:not(.fx-fail):not(.static) #where .where__intro { display: none; }
  #where .kpi { padding-block: .2rem; }
}
