/* ==========================================================================
   Quad-State · phones (loaded only at max-width 720px, see index.html)
   The desktop page is one section per screen; on a phone it is one long
   read. This file keeps that read short: card stacks become swipe rows,
   charts answer to taps, and nothing waits for a hover that never comes.
   ========================================================================== */

/* no bar at the top on a phone: the sections run to the top edge and a chip floats at the bottom */
:root { --navh: 0px; --qn-h: 40px; }
.nav, .index { display: none !important; }
.sec.hero { padding-top: 36px; }
.as-badge { bottom: calc(16px + var(--qn-h) + 14px + env(safe-area-inset-bottom)); }

/* ── the chip: ‹ · 02 The dataset · ›, always on screen, centred under either thumb. A yellow
   hairline fills as you read the section; tap the name and the index grows out of it (mobile.js). ── */
.qnav {
  position: fixed; z-index: 57; left: 0; right: 0; bottom: calc(16px + env(safe-area-inset-bottom));
  /* centred by auto margins, so it is as wide as its content (left: 50% would cap it at half the screen) */
  display: flex; align-items: stretch; width: max-content; max-width: calc(100vw - 32px); margin-inline: auto; height: var(--qn-h);
  background: var(--ink); color: var(--chalk);
}
.qnav button { appearance: none; border: 0; background: none; color: inherit; padding: 0; cursor: pointer; font: inherit; }
.qnav button:focus-visible, .qnav-up a:focus-visible { outline: 2px solid var(--cf); outline-offset: -4px; }
.qnav-step { flex: none; width: 36px; display: grid; place-items: center; font: 400 20px/1 var(--sans); color: var(--chalk); }
.qnav-step:disabled { opacity: .2; cursor: default; }
.qnav-here {
  min-width: 0; display: flex; align-items: center; gap: 4px; padding: 0 8px; overflow: hidden;
}
/* the name on the left, its number at the right end; both slide in when the section changes (mobile.js) */
.qnav-name { flex: none; max-width: calc(100vw - 210px); font: 700 13px/1 var(--sans); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qnav-here b { flex: none; font: 400 13px/1 var(--pixel); color: var(--cf); }
/* the index key: three bars that fold into an × while the index is open */
.qnav-here i { flex: none; align-self: stretch; display: grid; place-items: center; margin-left: 8px; color: var(--chalk); }
.qnav-here i svg { display: block; overflow: visible; }
.qnav-here i rect { transform-box: fill-box; transform-origin: center; transition: rotate .35s var(--ease), translate .35s var(--ease), scale .35s var(--ease), opacity .2s; }
.qnav.open .qnav-here i .b1 { translate: 0 5px; rotate: 45deg; }
.qnav.open .qnav-here i .b2 { opacity: 0; scale: .2 1; }
.qnav.open .qnav-here i .b3 { translate: 0 -5px; rotate: -45deg; }
.qnav::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: calc(var(--w, 0) * 100%); background: var(--cf); pointer-events: none; transition: width .3s var(--ease); }

/* the index: grows up out of the chip, as wide as the chip, every row on screen at once; names on the left,
   numbers at the right end, the current number in yellow */
.qnav-up {
  position: fixed; z-index: 57; left: 0; right: 0; bottom: calc(16px + var(--qn-h) + 8px + env(safe-area-inset-bottom));
  width: max-content; min-width: var(--chip-w, 0); margin-inline: auto;
  background: var(--ink); color: var(--chalk);
  translate: 0 10px; scale: .96; transform-origin: 50% 100%; opacity: 0; visibility: hidden;
  transition: translate .35s var(--ease), scale .35s var(--ease), opacity .2s, visibility 0s .35s;
}
.qnav-up.open { translate: 0 0; scale: 1; opacity: 1; visibility: visible; transition: translate .35s var(--ease), scale .35s var(--ease), opacity .2s, visibility 0s; }
.qnav-up ol { list-style: none; margin: 0; padding: 4px 0; }
.qnav-up a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; padding: 0 14px; text-decoration: none; }
.qnav-up a:active { background: rgba(255,255,255,.07); }
.qnav-up b { flex: none; font: 400 13px/1 var(--pixel); color: rgba(255,255,255,.4); }
.qnav-up span { font: 600 14px/1.2 var(--sans); color: rgba(255,255,255,.82); }
.qnav-up li.now b { color: var(--cf); }
.qnav-up li.now span { color: #fff; }
.qnav-up li.now a { box-shadow: inset 3px 0 0 var(--cf); }
@media (prefers-reduced-motion: reduce) { .qnav-up, .qnav-here i rect, .qnav::after { transition-duration: .01s; } }

/* ── type & rhythm ────────────────────────────────────────────────────── */
.title { font-size: clamp(26px, 7.4vw, 32px); line-height: 1.08; }
.lede, .about-left .lede, .sec-aside .lede { font-size: 15.5px; line-height: 1.55; text-align: left; hyphens: manual; }
.sec-head { margin-bottom: 16px; }
.sec-aside { gap: 12px; margin-top: 10px; }
.note { font-size: 12px; }

/* the section label stays on one line */
.crumb { gap: 10px; margin-bottom: 14px; font-size: 11px; }
.crumb i:not(.grow) { width: 18px; }
.crumb i.grow { display: none; }
.crumb > span:last-of-type { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* source tooltips need a hover; on a phone the numbers stand on their own */
.src { text-decoration: none; cursor: auto; }
.src:hover::after, .src:focus-visible::after { content: none; }

/* hover lifts stick after a tap: keep buttons still */
.btn:hover, .btn-yellow:hover, .btn-ghost:hover { translate: none; box-shadow: none; }
.btn-ghost:hover { background: none; }

/* controls: finger-sized */
.seg-btn { min-height: 44px; padding: 10px 10px; font-size: 11px; letter-spacing: .03em; line-height: 1.25; }
.tool-btn { min-height: 44px; padding: 10px 16px; }
/* a segmented control whose labels are too long to share a line stacks instead of wrapping inside its buttons */
#forms .toolbar .seg, .results .sec-aside .seg, #problem .toolbar .seg:first-child { flex-direction: column; width: 100%; }
#forms .toolbar .seg-btn + .seg-btn, .results .sec-aside .seg-btn + .seg-btn, #problem .toolbar .seg:first-child .seg-btn + .seg-btn { border-left: 0; border-top: 1px solid var(--ink); }

/* ── swipe rows: card stacks become one row of cards, the next one peeking in ── */
.mc {
  display: grid !important; grid-auto-flow: column; grid-template-columns: none !important; grid-auto-columns: 86%;
  gap: 12px; align-items: stretch;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  margin-inline: calc(var(--gutter) * -1); padding: 2px var(--gutter) 6px; scroll-padding-inline: var(--gutter);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.mc::-webkit-scrollbar { display: none; }
.mc > * { scroll-snap-align: start; min-width: 0; }
.mc-dots { display: flex; justify-content: center; gap: 0; margin: 4px 0 0; }
.mc-dots button {
  appearance: none; border: 0; padding: 14px 8px; background: none; cursor: pointer;
}
.mc-dots button::before { content: ""; display: block; width: 7px; height: 7px; background: var(--ink-3); opacity: .35; transition: width .25s var(--ease), opacity .25s, background .25s; }
.mc-dots button[aria-current="true"]::before { width: 20px; opacity: 1; background: var(--blue); }
.s-blue .mc-dots button::before { background: #fff; }
.s-blue .mc-dots button[aria-current="true"]::before { background: var(--cf); }

/* ── 00 hero ──────────────────────────────────────────────────────────── */
.display { font-size: clamp(38px, 11.6vw, 52px); }
.kicker { margin-bottom: 18px; }
.morph-block { margin-top: 26px; }
.morph-lead { font-size: 16px; }
/* the word on one line, its family tag always on the next: the block keeps its height while the word changes */
.morph-line { font-size: clamp(22px, 7vw, 30px); gap: 6px 6px; }
.morph-line::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
.morph-tag { order: 2; margin: 0; padding: 5px 8px; font-size: 10.5px; }
/* the character inspector: a fixed register of 8 × 2 slots (mobile.js fills the empty ones) */
.cells {
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 4px;
  max-width: none; min-height: 0; margin-top: 14px;
}
.cells li { padding: 7px 0 6px; }
.cells .g { font-size: 17px; height: 19px; }
.cells .cp { margin-top: 5px; font-size: 8px; letter-spacing: 0; }
.cells li.pad { border: 1px dashed rgba(255,255,255,.2); animation: none; }
.insp-note { min-height: calc(2em * 1.55); margin-top: 12px; font-size: 12px; line-height: 1.55; }
.hero-actions { display: grid; gap: 10px; margin-top: 24px; }
.hero-actions .btn { justify-content: space-between; padding: 16px 20px; font-size: 16px; }
.hero-meta { gap: 6px 18px; margin-top: 22px; padding-top: 14px; }
/* the outside links keep their look but get a finger-sized hit area */
.hero-meta .links a, .src-links a { padding-block: 12px; margin-block: -12px; border-bottom: 0; text-decoration: underline; text-decoration-color: rgba(255,255,255,.45); text-underline-offset: 4px; }
.hero-meta .links a:hover, .src-links a:hover { text-decoration-color: var(--cf); }
.author-name { padding-block: 9px; margin-block: -9px; }
.hero-grid { gap: 32px; }

/* ── 01 motivation ────────────────────────────────────────────────────── */
.glance dt { font-size: clamp(24px, 7.6vw, 30px); }
.glance dd { font-size: 10px; letter-spacing: .04em; }
.sources > li { padding: 14px 16px; }
.sources-col .note { margin-top: 6px; }

/* ── 02 ASRD ──────────────────────────────────────────────────────────── */
.seedstrip { padding: 10px 12px; gap: 10px; }
.toolbar .seg { width: 100%; }
.toolbar .seg-btn { flex: 1; }
.own-input { width: 100%; }
.own-input input { width: 100%; min-height: 44px; font-size: 16px; }   /* 16px: iOS does not zoom into the field */
.stepper button { padding: 8px 0 12px; }
.form-meta, .form-out { padding: 16px; }
.fm-name { font-size: 24px; }
.fo-text { font-size: 16px; min-height: 0; }
.fo-stats { gap: 8px 20px; }
.fo-stats dd { font-size: 19px; }

/* ── 03 rubric ────────────────────────────────────────────────────────── */
.tree { padding: 14px 12px; }
.tree-h { flex-direction: column; gap: 5px; }
.tree-tip { opacity: .7; }
.fq { padding-left: 10px; }
/* answers in one column of equal buttons, the state they lead to on the right */
.fq-opts { gap: 6px; }
.rubric-grid > * { min-width: 0; }
.fq-opt { grid-template-columns: 92px minmax(8px, 1fr) auto; gap: 6px; }
.fq-opt button { width: 100%; min-width: 0; min-height: 40px; padding: 6px 8px; font-size: 10.5px; line-height: 1.2; letter-spacing: .03em; }
.fq-state { padding: 6px 8px; font-size: 12.5px; }
.qcard { padding: 16px; }
.qcard h3 { font-size: 21px; }

/* ── 04 evaluation ────────────────────────────────────────────────────── */
#stack { width: min(220px, 58vw); }
.anatomy .layers { gap: 2px; }
.layers button { padding: 5px 0; }
.layers .t { font-size: 16px; }
.layer-card { min-height: 0; padding: 16px; }
.mx th, .mx td { padding: 6px 7px; }

/* ── 05 results ───────────────────────────────────────────────────────── */
.results .sec-aside .seg { width: 100%; }
.results .sec-aside .seg-btn { flex: 1; }
.chart-card { padding: 14px 12px; }
.tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; min-height: 40px; padding: 0 12px; }
.chart-top { margin-bottom: 12px; }
.hc-row, .xlabels { margin-left: 28px; }
.hc-row span { font-size: 9px; letter-spacing: -.02em; }
.plot { margin-left: 28px; height: 300px; }
.grid span { left: -28px; font-size: 10px; }
.tip { min-width: 0; width: max-content; padding: 10px 12px; font-size: 11.5px; white-space: nowrap; }
.tip .r { gap: 12px; }
.tip b { font-size: 14px; }
.chart-cap { font-size: 14px; }
.statcol { gap: 0 14px; }
.statcol dt { font-size: 28px; }
.statcol dd { font-size: 12.5px; }

/* ── 06 paired transitions ────────────────────────────────────────────── */
.flow-card { padding: 14px 14px 10px; }
.flow-card h3 small { float: none; display: block; margin: 6px 0 0; }
.flow-card svg { min-height: 0; max-height: none; }
#problem .toolbar { gap: 8px; }
#problem .toolbar .seg { width: 100%; }
#problem .toolbar .seg-btn { flex: 1; }

/* ── 07 behaviors ─────────────────────────────────────────────────────── */
.beh { padding: 16px; }
.beh-no { font-size: 44px; }
.flip, .collapse-viz, .drift { height: 170px; }
.collapse-viz { height: auto; }

/* ── 08 models ────────────────────────────────────────────────────────── */
.prints { gap: 10px; }
/* five cards in two columns: the fifth (Mistral, the outlier) takes the full row */
.prints:not(.six) > .print:nth-child(5) { grid-column: 1 / -1; }
.print { padding: 10px 12px; }
.print h3 { font-size: 16px; }
.print .p-sub { white-space: normal; font-size: 10.5px; }
.print .p-badge { font-size: 9.5px; right: 6px; }
.p-bars { height: 120px; }
.print dd { font-size: 14px; }
.toggle { min-height: 44px; font-size: 11px; line-height: 1.35; }
.tg-box { flex: none; }

/* ── 09 conclusion & limitations ──────────────────────────────────────── */
.concl-lead { font-size: 23px; }
.limits-grid { gap: 26px; }
.lims summary { font-size: 15.5px; padding-right: 30px; }
.lims details p { padding-right: 8px; }

/* ── 10 get the dataset ───────────────────────────────────────────────── */
.get .ds-src > li { padding: 14px 16px; }
.get .ds-src h3 { font-size: 19px; }
.src-links { gap: 4px 18px; padding-top: 8px; }
.ds-badges { gap: 8px; }
.ds-badges a { padding: 10px 10px; font-size: 10.5px; }

/* ── 11 cite: the BibTeX keeps its shape and scrolls sideways ─────────── */
.bib { padding: 14px 14px 12px; }
.bib-h { margin-bottom: 14px; }
.bib pre { white-space: pre; overflow-wrap: normal; overflow-x: auto; padding-bottom: 6px; font-size: 11.5px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent; }
.copy { top: 8px; right: 8px; min-height: 38px; padding: 0 14px; }

/* ── footer ───────────────────────────────────────────────────────────── */
.foot { padding-top: 48px; padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
.foot-cols { gap: 24px 20px; padding-bottom: 48px; }
.foot h3 { margin-bottom: 6px; }
.foot-cols a { margin: 0; padding: 9px 0; }
/* the e-mail address gets the full width instead of breaking mid-word */
.foot-cols > div:last-child { grid-column: 1 / -1; }
.foot-cols a { overflow-wrap: normal; }
.readas { flex-wrap: wrap; gap: 6px; }
.readas > span { flex-basis: 100%; margin: 0 0 2px; }
.readas button { min-width: 48px; min-height: 40px; }
.foot-bottom { align-items: flex-end; }
.foot-bottom p { flex: 1 1 200px; font-size: 13px; }
.to-top { width: 48px; height: 48px; }

/* ── the narrowest phones ─────────────────────────────────────────────── */
/* the longest family note (F6) runs to three lines below 375px: reserve them so the hero does not jump */
@media (max-width: 374px) { .insp-note { min-height: calc(3em * 1.55); } }
@media (max-width: 359px) {
  .cells .cp { font-size: 7.5px; }
  .fq-opt { grid-template-columns: 76px minmax(0, 1fr) auto; }
  .fq-wire { visibility: hidden; }
  .fq-state small { display: none; }
  .hc-row span { font-size: 8px; }
  .hc-row span small { font-size: 8px; }
}
