/* JWS Start — funnel chrome.
   Concept: "The Specimen Book" (library/DESIGN.md part A).
   Faces come from library/templates/library.css. Nothing here touches the preview,
   which owns its own custom properties inside the iframe. */

:root {
  --ui-bg:         #101210;   /* press-room black-green */
  --ui-surface:    #181B18;
  --ui-line:       #2C312C;
  --ui-ink:        #F1F3EE;
  --ui-muted:      #9BA69B;
  --ui-accent:     #CDFF4F;
  --ui-accent-ink: #101210;
  --ui-bad:        #FFB3A0;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --body:    "Public Sans", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --cat:     "Space Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --stage-h: 34dvh;   /* DESIGN.md: preview pinned to the top third on mobile */
  --rail-w: 178px;
  --chooser-w: 380px;
  --in: cubic-bezier(.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { overflow-x: clip; overscroll-behavior: none; }
body {
  margin: 0;
  height: 100dvh;      /* capped so the chooser scrolls inside its own row */
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--ui-bg);
  color: var(--ui-ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-family: var(--display); font-weight: 800; line-height: 1.02; letter-spacing: -.03em; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }

/* the catalogue voice */
.code, .kicker, .stage-label, .slug, .disclaimer, .rail b, .pin, .recap dt, .f span, .chip-code {
  font-family: var(--cat); font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
}

.skip { position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--ui-accent); color: var(--ui-accent-ink); padding: 10px 16px; font-weight: 700; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- step 0 — the open ---------- */
.splash {
  position: fixed; inset: 0; z-index: 50; background: var(--ui-bg);
  display: grid; align-content: center; gap: 26px; padding: 6vw;
}
.splash[hidden] { display: none; }
.splash .code { position: absolute; top: 22px; left: 22px; color: var(--ui-muted); }
.splash h1 { font-size: clamp(34px, 6.6vw, 82px); max-width: 16ch; }
.splash h1 em { font-style: normal; color: var(--ui-accent); }
.splash-note { color: var(--ui-muted); font-size: 14px; }
.btn-lime {
  font: 700 17px/1 var(--body); cursor: pointer; justify-self: start;
  padding: 20px 30px; border: 0; border-radius: 0;
  background: var(--ui-accent); color: var(--ui-accent-ink);
  box-shadow: 6px 6px 0 var(--ui-surface); transition: transform .14s ease-out, box-shadow .14s ease-out;
}
.btn-lime:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ui-surface); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 18px; border-bottom: 1px solid var(--ui-line);
}
.brand { display: flex; align-items: center; gap: 9px; font-family: var(--cat);
  font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.brand em { font-style: normal; color: var(--ui-accent); }
.mark { width: 9px; height: 17px; background: var(--ui-accent); display: block; }
.topcode { color: var(--ui-muted); }

/* ---------- shell ----------
   Mobile rows: rail / stage sized by its own content / chooser takes the rest.
   The proof frame claims --stage-h directly so leftover space can't starve it. */
.shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; }
.rail  { order: 1; }
.stage { order: 2; }
.chooser { order: 3; }

/* ---------- bench rail ---------- */
.rail { border-bottom: 1px solid var(--ui-line); overflow-x: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail ol { display: flex; gap: 0; list-style: none; margin: 0; padding: 0 12px; }
.rail li { flex: 0 0 auto; }
.rail button {
  font: inherit; cursor: pointer; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 11px 12px; color: var(--ui-muted); display: flex; align-items: baseline; gap: 7px; white-space: nowrap;
}
.rail button[disabled] { cursor: default; opacity: .45; }
.rail b { font-weight: 400; color: inherit; }
.rail .nm { font-size: 14px; }
.rail .val { display: none; }
.rail li.at button { color: var(--ui-ink); border-bottom-color: var(--ui-accent); }
.rail li.done button { color: var(--ui-ink); }

/* ---------- chooser ---------- */
.chooser { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0;
  background: var(--ui-surface); border-top: 1px solid var(--ui-line); }
.steps { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 22px 18px 10px; }
.step { position: relative; }
.step[hidden] { display: none; }
/* giant outlined catalogue numeral behind the question */
.step::before {
  content: attr(data-num); position: absolute; right: -6px; top: -22px; z-index: 0;
  font-family: var(--display); font-weight: 800; font-size: 116px; line-height: 1;
  color: transparent; -webkit-text-stroke: 2px var(--ui-accent); opacity: .22; pointer-events: none;
}
.step > * { position: relative; z-index: 1; }
.kicker { color: var(--ui-accent); margin-bottom: 10px; }
.step h2 { font-size: clamp(25px, 5.6vw, 33px); margin-bottom: 11px; max-width: 17ch; }
.lede { color: var(--ui-muted); margin-bottom: 22px; max-width: 44ch; }

.step-in { animation: stepIn 220ms var(--in) 40ms both; }
@keyframes stepIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- option cards ---------- */
.opts { display: grid; gap: 13px; }
.opt {
  display: block; position: relative; cursor: pointer; background: var(--ui-bg);
  border: 1px solid var(--ui-line); padding: 15px 15px 15px 15px;
  transition: transform .14s ease-out, box-shadow .14s ease-out, border-color 90ms;
  box-shadow: 4px 4px 0 var(--ui-line);
}
.opt:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ui-line); }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.opt:has(input:checked) { border: 2px solid var(--ui-accent); padding: 14px; }
.opt:has(input:focus-visible) { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.opt-head { display: flex; align-items: baseline; gap: 10px; }
.chip-code {
  color: var(--ui-muted); border: 1px solid var(--ui-line); padding: 2px 6px; flex: 0 0 auto;
}
.opt:has(input:checked) .chip-code {
  background: var(--ui-accent); color: var(--ui-accent-ink); border-color: var(--ui-accent);
}
.opt .t { font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.02em; }
.opt .d { display: block; color: var(--ui-muted); font-size: 14px; margin-top: 7px; }
.opt .motifs { margin: 11px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.opt .motifs li { font-size: 12px; color: var(--ui-muted); padding-left: 13px; position: relative; }
.opt .motifs li::before { content: ""; position: absolute; left: 0; top: .62em; width: 7px; height: 1px; background: var(--ui-accent); }
.opt .sig { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin-top: 13px; }

.sw { display: flex; gap: 5px; margin-top: 11px; }
.sw span { width: 30px; height: 30px; border: 1px solid var(--ui-line); }
.spec-d { font-size: 28px; line-height: 1.05; margin-top: 9px; color: var(--ui-ink); }
.spec-b { font-size: 14px; color: var(--ui-muted); }

/* ---------- section stack ---------- */
.stack { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; }
.row { border: 1px solid var(--ui-line); background: var(--ui-bg); padding: 12px 13px; }
.row.off { opacity: .48; }
.row.pinned .mv { visibility: hidden; }
.row-head { display: flex; align-items: center; gap: 9px; }

/* drag to reorder (pointer path; the arrows remain the keyboard/touch path) */
.grip { cursor: grab; color: var(--ui-muted); font-size: 15px; line-height: 1; padding: 2px 1px; }
.grip:active { cursor: grabbing; }
.row.dragging { opacity: .4; }
.row.over-before { box-shadow: 0 -3px 0 var(--ui-accent); }
.row.over-after  { box-shadow: 0 3px 0 var(--ui-accent); }
.row.flip { transition: transform 200ms cubic-bezier(.2, 0, 0, 1); }
.row-head .lab { font-family: var(--display); font-weight: 700; font-size: 16px; flex: 1; }
.row-head .pin { color: var(--ui-muted); }
.iconbtn {   /* 40px on touch — the arrows are the only reorder path without drag */
  font: inherit; cursor: pointer; width: 40px; height: 40px; line-height: 1;
  background: transparent; color: var(--ui-ink); border: 1px solid var(--ui-line);
}
.iconbtn[disabled] { opacity: .4; cursor: default; }   /* disabled: contrast-exempt, but keep it readable */
.iconbtn.drop { width: auto; padding: 0 9px; font-size: 12px; color: var(--ui-muted); }
.variants { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.variants label { position: relative; }
.variants input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.variants .chip {
  display: flex; gap: 6px; align-items: baseline; font-size: 13px; padding: 6px 10px;
  border: 1px solid var(--ui-line); color: var(--ui-muted);
}
.variants .chip i { font-family: var(--cat); font-style: normal; font-size: 10px; letter-spacing: .08em; }
.variants input:checked + .chip { border-color: var(--ui-accent); color: var(--ui-accent-ink); background: var(--ui-accent); }
.variants input:focus-visible + .chip { outline: 2px solid var(--ui-accent); outline-offset: 3px; }

/* ---------- fields ---------- */
.fields { display: grid; gap: 15px; max-width: 34rem; }
.f span { display: block; color: var(--ui-muted); margin-bottom: 6px; }
.f span b { color: var(--ui-accent); }
.f span i { font-style: normal; text-transform: none; letter-spacing: 0; }
.f input, .f textarea {
  font: 16px/1.5 var(--body); width: 100%; padding: 12px 13px; color: var(--ui-ink);
  background: var(--ui-bg); border: 1px solid var(--ui-line); border-radius: 0;
}
.f input:focus, .f textarea:focus { border-color: var(--ui-accent); }
.f textarea { resize: vertical; }
.f input::placeholder, .f textarea::placeholder { color: #7C877C; }   /* 4.9:1 on --ui-bg */
.err { color: var(--ui-bad); margin-top: 15px; }

.link-btn { font: inherit; background: none; border: 0; padding: 6px 0; margin-top: 16px;
  cursor: pointer; color: var(--ui-muted); text-decoration: underline; text-underline-offset: 4px; }
.link-btn:hover { color: var(--ui-ink); }

.recap { margin: 0 0 22px; display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; }
.recap dt { color: var(--ui-muted); padding-top: 3px; }
.recap dd { margin: 0; }

/* ---------- nav ---------- */
.navbar { display: flex; gap: 9px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ui-line); background: var(--ui-surface); }
.nav { font: 700 16px/1 var(--body); cursor: pointer; padding: 17px 22px;
  border: 1px solid var(--ui-line); background: transparent; color: var(--ui-ink); }
.nav.next { flex: 1; background: var(--ui-accent); color: var(--ui-accent-ink); border-color: var(--ui-accent); }
.nav.next[disabled] { opacity: .55; cursor: default; }
.nav[hidden] { display: none; }

/* ---------- the proof ---------- */
.stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0; padding: 0 14px 12px; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; }
.stage-label { color: var(--ui-muted); }
.device { display: flex; gap: 5px; }
.dev { font: 12px/1 var(--body); padding: 7px 11px; cursor: pointer;
  background: transparent; color: var(--ui-muted); border: 1px solid var(--ui-line); }
.dev.is-on { color: var(--ui-accent-ink); background: var(--ui-accent); border-color: var(--ui-accent); }

.proof { position: relative; min-height: 0; height: var(--stage-h); background: var(--ui-surface);
  border: 1px solid var(--ui-line); box-shadow: 7px 7px 0 var(--ui-surface); }
.reg { position: absolute; width: 12px; height: 12px; pointer-events: none; z-index: 2; }
.reg.tl { top: -1px; left: -1px; border-top: 1px solid var(--ui-muted); border-left: 1px solid var(--ui-muted); }
.reg.tr { top: -1px; right: -1px; border-top: 1px solid var(--ui-muted); border-right: 1px solid var(--ui-muted); }
.reg.bl { bottom: -1px; left: -1px; border-bottom: 1px solid var(--ui-muted); border-left: 1px solid var(--ui-muted); }
.reg.br { bottom: -1px; right: -1px; border-bottom: 1px solid var(--ui-muted); border-right: 1px solid var(--ui-muted); }

.frame-hold { position: relative; height: 100%; overflow-y: auto; overflow-x: hidden; }
.sizer { width: 1px; }
#preview { position: absolute; top: 0; left: 0; border: 0; display: block; transform-origin: 0 0; background: #fff; }

.slug { color: var(--ui-muted); padding-top: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.disclaimer { color: var(--ui-muted); text-transform: none; letter-spacing: .02em;
  line-height: 1.5; padding-top: 5px; max-width: 68ch; opacity: .82; }
/* Mobile: the frame must outweigh the furniture around it, so the disclaimer
   drops to its first clause and the full-screen control sits on the frame. */
.disclaimer .long { display: none; }
.fs-toggle { position: absolute; right: 8px; bottom: 8px; z-index: 3;
  font: 11px/1 var(--cat); letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  background: var(--ui-accent); color: var(--ui-accent-ink); border: 0; padding: 8px 11px; }

/* full-screen proof (mobile especially — a third of a phone is not enough to judge a design) */
body.fs .stage { position: fixed; inset: 0; z-index: 40; background: var(--ui-bg); padding: 10px 12px; }
body.fs .chooser { position: fixed; inset: auto 0 0 0; z-index: 41; max-height: 46dvh;
  border-top: 1px solid var(--ui-line); }
body.fs .rail, body.fs .disclaimer { display: none; }
/* The proof is pinned to --stage-h everywhere else; in full screen it has to give
   that up and stretch into its grid row, or "See it full screen" shows the same slice. */
body.fs .proof { height: auto; }

/* mobile: keep the rail strip from clipping a tab with no scroll affordance */
.rail { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
        mask-image: linear-gradient(90deg, #000 88%, transparent); }

/* mobile: compress the vibe cards so more than one is comparable at a glance */
@media (max-width: 719px) {
  .steps { padding-top: 16px; }
  .kicker { margin-bottom: 5px; }
  .step h2 { font-size: 23px; margin-bottom: 6px; }
  .lede { margin-bottom: 13px; font-size: 14.5px; }
  .step::before { font-size: 84px; top: -14px; }
  .opt { padding: 13px; }
  .opt:has(input:checked) { padding: 12px; }
  .opt .sig { height: 124px; aspect-ratio: auto; margin-top: 9px; }
  .opt .d { margin-top: 5px; font-size: 13.5px; }
  .opt .motifs { margin-top: 7px; gap: 3px; }
  .opt .motifs li { font-size: 11.5px; }

  /* Vibe picker only: the 2-wide/2-offset grid becomes an index of rows, so more
     than one option is on screen at a time. Code + thesis stay; motifs drop. */
  .opts-vibe { gap: 10px; }
  .opts-vibe .opt {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-areas: "img head" "img thesis";
    align-content: center; gap: 5px 14px; padding: 10px;
  }
  .opts-vibe .opt:has(input:checked) { padding: 9px; }   /* 9+2px border == 10+1px unchecked */
  .opts-vibe .opt-head { grid-area: head; }
  .opts-vibe .d {
    grid-area: thesis; margin: 0; font-size: .8125rem; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  }
  .opts-vibe .sig { grid-area: img; height: auto; aspect-ratio: 1; margin: 0; }
  .opts-vibe .motifs { display: none; }
}

/* ---------- tablet ---------- */
@media (min-width: 720px) {
  :root { --stage-h: 46vh; }
  .steps { padding: 26px 26px 10px; }
  .navbar { padding: 14px 26px; }
  .stage { padding: 0 22px 14px; }
  .disclaimer .long { display: inline; }
  .rail { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- desktop ---------- */
@media (min-width: 1100px) {
  .shell {
    grid-template-columns: var(--rail-w) var(--chooser-w) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }
  .rail, .chooser, .stage { order: 0; }
  .rail { border-bottom: 0; border-right: 1px solid var(--ui-line); overflow-y: auto; overflow-x: hidden; }
  .rail ol { display: block; padding: 18px 0; }
  .rail button { width: 100%; display: block; text-align: left; padding: 10px 18px;
    border-bottom: 0; border-left: 2px solid transparent; }
  .rail li.at button { border-left-color: var(--ui-accent); }
  .rail .val { display: block; font-size: 12px; color: var(--ui-muted);
    text-transform: none; letter-spacing: 0; font-family: var(--body);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chooser { border-top: 0; border-right: 1px solid var(--ui-line); }
  .step h2 { font-size: 34px; }
  .step::before { font-size: 132px; top: -28px; }
  .fs-toggle { display: none; }
  .proof { height: auto; }                  /* fills the column instead of a fixed slice */
  .iconbtn { width: 32px; height: 32px; }   /* drag is the primary path here */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
