/* Case study: motion-forward sections. Loaded after the page's base styles. */

/* ---------- header controls ---------- */
.top .right { display: flex; align-items: center; gap: 6px; }
.motion-toggle svg { width: 18px; height: 18px; }

/* ---------- restrained scroll reveals (only when JS runs; content is visible without it) ---------- */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity var(--dur-move) var(--ease-settle), transform var(--dur-move) var(--ease-settle); }
.js .reveal.in { opacity: 1; transform: none; }
.js .horizon::before { transform-origin: left center; transform: scaleX(0); transition: transform 900ms var(--ease-settle); }
.js .horizon.in::before { transform: scaleX(1); }
:root[data-motion="reduced"] .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } .js .horizon::before { transform: none; } }
:root[data-motion="reduced"] .horizon::before { transform: none !important; }

/* hero headline: lines settle in one after another, once */
/* phones: the headline wraps naturally and fades in as one piece;
   from 641px the three lines are set as written and settle in one after another */
.js .opening h1 .ln { opacity: 0; animation: lineIn var(--dur-move) var(--ease-settle) forwards; }
@media (min-width: 641px) {
  .js .opening h1, .js .opening .lede { max-width: 26ch; }
  .js .opening h1 .ln { display: block; transform: translateY(10px); }
}
.js .opening h1 .ln:nth-child(2) { animation-delay: 90ms; }
.js .opening h1 .ln:nth-child(3) { animation-delay: 180ms; }
.js .opening .tag { opacity: 0; transform: translateY(10px); animation: lineIn var(--dur-move) var(--ease-settle) 300ms forwards; }
@keyframes lineIn { to { opacity: 1; transform: none; } }
:root[data-motion="reduced"] .opening h1 .ln, :root[data-motion="reduced"] .opening .tag { animation: none !important; opacity: 1 !important; transform: none !important; }
@media (prefers-reduced-motion: reduce) { .js .opening h1 .ln, .js .opening .tag { animation: none; opacity: 1; transform: none; } }
.opening .tag { font-family: var(--serif); font-size: 22px; color: var(--ink-2); margin: 14px 0 0; font-weight: var(--display-weight, 400); letter-spacing: var(--display-tracking, -0.01em); }

/* hero art */
.hero-art keel-lottie { width: 100%; aspect-ratio: 640 / 360; }
.hero-art { margin: 36px 0 0; }

/* ---------- comparison (clarity) ---------- */
.compare { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: center; margin: 32px 0; }
.compare keel-lottie { width: 100%; aspect-ratio: 640 / 400; border: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--canvas); }
@media (min-width: 761px) { .compare { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); } }

/* ---------- IA: progressive drawing ---------- */
.js .ia-draw .draw { stroke-dasharray: 1200; stroke-dashoffset: 1200; }
.js .ia-draw.in .draw { transition: stroke-dashoffset 1200ms var(--ease-settle); stroke-dashoffset: 0; }
.js .ia-draw .node { opacity: 0; transition: opacity var(--dur-card) var(--ease-settle); }
.js .ia-draw.in .node { opacity: 1; }
:root[data-motion="reduced"] .ia-draw .draw { stroke-dashoffset: 0 !important; transition: none !important; }
:root[data-motion="reduced"] .ia-draw .node { opacity: 1 !important; }
@media (prefers-reduced-motion: reduce) { .ia-draw .draw { stroke-dashoffset: 0 !important; } .ia-draw .node { opacity: 1 !important; } }

/* ---------- lo-fi to hi-fi comparison ---------- */
.lohi { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: center; }
.lohi-stage { position: relative; width: 100%; max-width: 300px; aspect-ratio: 390 / 844; border-radius: 22px; overflow: hidden; border: 1px solid var(--rule); background: #fff; contain: layout paint; }
.lohi-stage img, .lohi-stage .wf { position: absolute; inset: 0; width: 100%; height: 100%; }
.lohi-stage .wf { border: 0; border-radius: 0; aspect-ratio: auto; padding: 22px 16px; }
.lohi-stage .hi { clip-path: inset(0 0 0 var(--cut, 50%)); will-change: clip-path; }   /* own layer: the hover sweep repaints only this */
.lohi-stage .seam { position: absolute; top: 0; bottom: 0; left: var(--cut, 50%); width: 2px; background: var(--accent); transform: translateX(-1px); pointer-events: none; }
.lohi input[type=range] { width: 100%; max-width: 300px; accent-color: var(--accent); margin-top: 12px; }
@media (min-width: 641px) { .lohi { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); } }

/* ---------- illustration system ---------- */
.materials { list-style: none; margin: 24px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); border-top: 1px solid var(--rule); }
.materials li { padding: 16px 12px 16px 0; border-bottom: 1px solid var(--rule); }
.materials .tri { display: grid; grid-template-columns: 1fr 1fr 1fr; height: 44px; border-radius: 6px; overflow: hidden; border: 1px solid var(--rule); margin-bottom: 10px; }
.materials b { display: block; font-size: 15px; }
.materials span { font-size: 14px; color: var(--ink-2); }
.illo-grid { display: grid; grid-template-columns: 1fr; gap: 0; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.illo-grid figure { margin: 0; padding: 18px; }
.illo-grid figure + figure { border-top: 1px solid var(--rule); }
.illo-grid keel-lottie { width: 100%; }
.illo-grid figcaption { font-size: 14.5px; color: var(--ink-2-on-surface); margin-top: 8px; }
.illo-grid figcaption b { color: var(--ink); display: block; }
@media (min-width: 721px) { .illo-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .illo-grid figure + figure { border-top: 0; border-left: 1px solid var(--rule); } }
.strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.strip figure { margin: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--canvas); }
.strip figure:last-child { border-right: 0; }
.strip keel-lottie { width: 100%; }
.strip figcaption { font-size: 13px; color: var(--ink-2); padding: 6px 10px 8px; border-top: 1px solid var(--rule); line-height: 1.35; }
.strip figcaption b { display: block; color: var(--ink); font-size: 13.5px; }
@media (min-width: 721px) { .strip { grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); } .strip figure { border-bottom: 0; } }

/* ---------- principles ---------- */
.mprinciples { list-style: none; margin: 28px 0; padding: 0; display: grid; grid-template-columns: 1fr; border-top: 1.5px solid var(--ink); }
.mprinciples li { padding: 16px 16px 18px 0; border-bottom: 1px solid var(--rule); }
.mprinciples b { font-family: var(--serif); font-weight: 500; font-size: 22px; display: block; font-weight: var(--display-weight, 400); letter-spacing: var(--display-tracking, -0.01em); }
.mprinciples span { font-size: 14.5px; color: var(--ink-2); }
@media (min-width: 521px) { .mprinciples { grid-template-columns: 1fr 1fr; } .mprinciples li + li { padding-left: 16px; border-left: 1px solid var(--rule); } .mprinciples li:nth-child(odd) { padding-left: 0; border-left: 0; } }
@media (min-width: 901px) { .mprinciples { grid-template-columns: repeat(5, minmax(0, 1fr)); } .mprinciples li + li:nth-child(odd) { padding-left: 16px; border-left: 1px solid var(--rule); } }

/* ---------- Motion Gallery: editorial, alternating ---------- */
.gallery { margin: 40px 0 0; }
.g-item { display: grid; grid-template-columns: 1fr; gap: 20px 48px; padding: 36px 0; border-top: 1px solid var(--rule); align-items: start; }
.g-item .g-sb { order: 3; }
.g-stage { position: relative; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 24px; display: grid; place-items: center; min-height: 240px; }
.g-stage keel-lottie { width: 100%; max-height: 360px; }
.g-stage svg.chart { width: 100%; max-width: 440px; height: auto; overflow: visible; }
.g-stage .rows { width: 100%; max-width: 440px; background: var(--canvas); }
.g-num { font-family: var(--serif); color: var(--ink-3); font-size: 18px; font-variant-numeric: lining-nums; }
.g-item h3 { margin: 2px 0 6px; font-size: 28px; }
.g-tech { display: inline-block; font-size: 13.5px; color: var(--ink-2); border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 2px 8px; margin-bottom: 14px; }
.g-tech.lottie { border-color: var(--accent-ink); color: var(--accent-ink); }
.g-item .intent { font-size: 17px; line-height: 1.55; text-wrap: pretty; margin: 0 0 12px; }
.g-item .problem { color: var(--ink-2); font-size: 15.5px; margin: 0 0 14px; }
.g-specs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14.5px; margin: 0 0 16px; padding: 12px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.g-specs dt { color: var(--ink-3); }
.g-specs dd { margin: 0; }
.g-ctrl { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: center; }
.g-ctrl .btn { min-height: 40px; padding: 0 14px; font-size: 14.5px; }
.g-more { margin-top: 8px; }
.g-more summary { cursor: pointer; font-weight: 600; font-size: 15px; padding: 8px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.g-more summary::-webkit-details-marker { display: none; }
.g-more summary::before { content: ""; width: 8px; height: 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur-card) var(--ease-settle); }
.g-more[open] summary::before { transform: rotate(45deg); }
.g-more pre { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 12px 14px; overflow-x: auto; font-size: 13px; margin: 6px 0 10px; }
.g-sb { grid-column: 1 / -1; }
@media (min-width: 901px) {
  .g-item { grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); padding: 48px 0; }
  .g-item.flip { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
  .g-item.flip .g-stage { order: 2; }
}

/* ---------- Motion Playground ---------- */
.pg { display: grid; grid-template-columns: 1fr; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); margin-top: 28px; }
.pg > section { padding: 22px 22px 24px; border-bottom: 1px solid var(--rule); min-width: 0; }
.pg h3 { margin: 0 0 4px; font-size: 21px; }
.pg .why { font-size: 14.5px; color: var(--ink-2-on-surface); margin: 0 0 16px; }
.pg .why b { color: var(--ink); font-weight: 600; }
.pg .demo { background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-md); padding: 16px; display: grid; gap: 12px; min-height: 150px; align-content: center; }
.pg .ctrls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pg .btn { min-height: 44px; font-size: 15px; padding: 0 16px; }
.pg keel-lottie { width: 100%; }
.pg input[type=range] { width: 100%; accent-color: var(--accent); }
@media (min-width: 821px) { .pg { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pg > section:nth-child(odd) { border-right: 1px solid var(--rule); } }

/* button feedback demo */
.fb-btn { position: relative; min-width: 190px; }
.fb-btn keel-lottie { position: absolute; inset: 0; margin: auto; width: 70px; height: 28px; }
.fb-btn.loading .lbl { visibility: hidden; }
.fb-btn.done { background: var(--positive); color: #fff; }
:root[data-theme="dark"] .fb-btn.done { color: var(--canvas); }

/* navigation demo */
.nav-demo { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--rule); }
.nav-demo button { background: none; border: 0; padding: 10px 0; font: 600 14.5px var(--sans); color: var(--ink-2); cursor: pointer; }
.nav-demo button[aria-selected="true"] { color: var(--ink); }
.nav-demo .ind { position: absolute; bottom: -1px; left: 0; height: 3px; width: 33.333%; background: var(--accent); border-radius: 2px; transform: translateX(calc(var(--i, 0) * 100%)); transition: transform var(--dur-move) var(--ease-settle); }
.nav-panels { position: relative; min-height: 64px; }
.nav-panels p { position: absolute; inset: 0; margin: 0; padding-top: 12px; opacity: 0; transform: translateY(10px); transition: opacity var(--dur-move) var(--ease-settle), transform var(--dur-move) var(--ease-settle); color: var(--ink-2); font-size: 15px; }
.nav-panels p.on { opacity: 1; transform: none; }

/* equilibrium demo */
.eq-svg { width: 100%; height: auto; display: block; }

/* ---------- Experience KEEL ---------- */
.exp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 18px; }
.seg { display: inline-flex; border: 1px solid var(--control); border-radius: var(--r-md); padding: 3px; background: var(--surface); }
.seg button { border: 0; background: none; min-height: 40px; padding: 0 16px; border-radius: 7px; font: 600 15px var(--sans); color: var(--ink-2-on-surface); cursor: pointer; transition: background-color var(--dur-hover) var(--ease-standard), color var(--dur-hover) var(--ease-standard); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.exp-links { display: flex; gap: 8px; flex-wrap: wrap; }
.exp-links .btn { min-height: 40px; font-size: 15px; padding: 0 14px; }
.exp { display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; align-items: start; }
.exp.desktop { grid-template-columns: 1fr; }
.frame-shell { position: relative; }
.frame-shell.mobile { width: 100%; padding: 6px; border-radius: 34px; background: var(--device); border: 1px solid var(--hairline); box-shadow: var(--lift); }
.frame-shell.mobile .viewport { width: 100%; height: 844px; border-radius: 28px; }
.frame-shell.desktop { width: 100%; border-radius: 14px; border: 1px solid var(--rule); box-shadow: var(--lift); overflow: hidden; background: var(--surface); }
.frame-shell.desktop .chrome { height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 14px; border-bottom: 1px solid var(--rule); background: var(--surface); font-size: 13px; color: var(--ink-2); }
.frame-shell.desktop .chrome i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--rule); }
.frame-shell.desktop .chrome span { margin-left: 10px; }
.frame-shell.mobile .chrome { display: none; }
.viewport { position: relative; overflow: hidden; background: var(--canvas); }
.viewport iframe { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: var(--canvas); }
.frame-state { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; background: var(--canvas); text-align: center; padding: 24px; transition: opacity var(--dur-card) var(--ease-standard); }
.frame-state[hidden] { display: none; }
.frame-state keel-lottie { width: 150px; aspect-ratio: 200 / 80; }
.exp-side .walk { margin-top: 0; }
@media (min-width: 461px) {
  .frame-shell.mobile { width: 410px; padding: 10px; border-radius: 44px; }
  .frame-shell.mobile .viewport { width: 390px; border-radius: 34px; }
}
@media (min-width: 1101px) { .exp { grid-template-columns: auto minmax(0, 1fr); } }

/* ---------- application design screens ---------- */
.screens { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 28px 0; }
.screens figure { margin: 0; }
.screens img { width: 100%; height: auto; border-radius: 18px; border: 1px solid var(--rule); background: var(--surface); }
.screens figcaption { font-size: 14.5px; margin-top: 10px; color: var(--ink-2); }
.screens figcaption b { display: block; color: var(--ink); }
.screens.wide { grid-template-columns: 1fr; }
.screens.wide img { border-radius: 10px; }
@media (min-width: 901px) { .screens { grid-template-columns: repeat(4, minmax(0, 1fr)); } .screens.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- design system demos ---------- */
.ds { display: grid; grid-template-columns: 1fr; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); margin-top: 24px; }
.ds > div { padding: 20px; border-bottom: 1px solid var(--rule); min-width: 0; }
.ds h4 { margin: 0 0 12px; }
.ds .stack { display: grid; gap: 10px; justify-items: start; }
.ds .btn { min-height: 44px; font-size: 15px; }
.ds .note2 { font-size: 13.5px; color: var(--ink-2-on-surface); margin-top: 10px; }
.status-row { display: grid; gap: 8px; }
.status { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; }
.status svg { width: 16px; height: 16px; flex: none; }
.status.pos { color: var(--positive); } .status.neg { color: var(--negative); } .status.warn { color: var(--warning); } .status.info { color: var(--info); }
.dsw { width: 46px; height: 28px; border-radius: 14px; border: 1px solid var(--control); background: var(--canvas); position: relative; cursor: pointer; transition: background-color var(--dur-press) var(--ease-standard); }
.dsw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 10px; background: var(--ink-2); transition: transform var(--dur-card) var(--ease-settle); }
.dsw[aria-checked="true"] { background: var(--accent); }
.dsw[aria-checked="true"]::after { transform: translateX(18px); background: var(--on-accent); }
.dsfield { display: flex; align-items: center; border: 1px solid var(--control); border-radius: var(--r-md); background: var(--canvas); padding: 0 12px; min-height: 48px; width: 100%; }
.dsfield:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dsfield input { border: 0; background: none; font: 500 16px var(--sans); color: var(--ink); width: 100%; height: 46px; outline: none; }
.dsfield[aria-invalid="true"] { border-color: var(--negative); }
@media (min-width: 561px) { .ds { grid-template-columns: 1fr 1fr; } .ds > div { border-right: 1px solid var(--rule); } .ds > div:nth-child(2n) { border-right: 0; } }
@media (min-width: 901px) { .ds { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ds > div:nth-child(2n) { border-right: 1px solid var(--rule); } .ds > div:nth-child(3n) { border-right: 0; } }

/* ---------- deliverables ---------- */
.state-word { font-size: 14px; font-weight: 600; white-space: nowrap; }
.closing { margin: 56px 0 0; text-align: center; }
.closing keel-lottie { width: min(100%, 520px); aspect-ratio: 640 / 240; margin: 0 auto; }

/* disabled state, shared with the app's definition */
.btn:disabled, .btn[aria-disabled="true"] { background: var(--disabled-bg); color: var(--disabled-ink); border-color: transparent; cursor: not-allowed; transform: none; }

/* touch targets: text buttons and sliders reach 44px (SC 2.5.5 guidance, beyond the 2.5.8 minimum) */
.btn-text { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; background: none; border: 0; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: var(--accent-ink); text-underline-offset: 3px; border-radius: var(--r-sm); }
.btn-text:hover { background: var(--tertiary-hover); }
.btn-text:disabled { color: var(--disabled-ink); text-decoration: none; cursor: not-allowed; background: none; }
input[type=range] { min-height: 44px; }
.ds h3.ds-h { font-family: var(--sans); font-size: 17px; font-weight: 600; margin: 0 0 12px; letter-spacing: 0; }

/* images keep their aspect ratio: width/height attributes reserve space, CSS sets the height */
img { height: auto; }
.lohi-stage img { height: 100%; }

/* ---------- Rive demo ---------- */
.rive-demo { display: grid; grid-template-columns: 1fr; gap: 32px; align-items: start; margin-top: 16px; }
.rive-stage { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 22px; --ink-2: var(--ink-2-on-surface); --ink-3: var(--ink-2-on-surface); }
.rive-row { display: flex; align-items: center; gap: 12px; font-weight: 600; }
/* The file's artboard is mostly transparent around the switch: the button is a 72 x 44 window
   onto the centre of the canvas, so it never reaches past its card. */
.rive-switch { position: relative; flex: none; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 14px; width: 72px; height: 44px; overflow: hidden; }
.rive-switch:disabled { cursor: progress; }
.rive-switch canvas { position: absolute; left: 50%; top: 50%; width: 168px; height: 112px; transform: translate(-50%, -50%); display: block; }
.rv-read { margin: 14px 0 6px; font-size: 16px; }
@media (min-width: 761px) { .rive-demo { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); } }

/* Rive: Keel's four state machines */
.rive-four { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
.rv4 { margin: 0; display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 18px; --ink-2: var(--ink-2-on-surface); --ink-3: var(--ink-2-on-surface); }
.rv4-stage { background: var(--canvas); border-radius: var(--r-md, 10px); overflow: hidden; }
.rv4-canvas { position: relative; }
.rv4-canvas canvas { display: block; width: 100%; height: auto; }
.rv4-ticks, .rv4-axis { position: absolute; inset: 0; pointer-events: none; font-size: 12px; color: var(--ink-2-on-surface); font-variant-numeric: tabular-nums; }
.rv4-ticks span { position: absolute; left: 68.8%; transform: translateY(-50%); }
.rv4-ticks span:first-child { transform: translateY(-12%); } /* "Payday" sits just under the waterline, as in the app */
.rv4-ticks b { color: var(--ink); }
.rv4-axis span { position: absolute; right: 88.5%; transform: translateY(-50%); }
.rv4-ctl { display: flex; flex-direction: column; gap: 8px; }
.rv4-ctl label { font-weight: 600; }
.rv4-ctl output { font-variant-numeric: tabular-nums; }
.rv4-btns { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.rv4-read { margin: 0; }
.rv4 figcaption { font-size: 14px; color: var(--ink-2); }
.rv4 figcaption b { display: block; color: var(--ink); }
@media (min-width: 761px) { .rive-four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rv4 input[type=range] { width: 100%; accent-color: var(--accent); }
/* Header: on phones the toggles are icon-only and the link reads "prototype"
   (the full labels stay as accessible names); full labels from 721px, where they fit */
#motion-label, #theme-label, .open-pre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.top .theme-toggle { min-width: 44px; padding: 0 10px; }
.top .open { font-size: 14px; display: inline-flex; align-items: center; min-height: 44px; }
/* citation markers: a larger tap area without moving the text */
a[href^="#ref-"] { padding: 6px 3px; margin: -6px -3px; }
@media (min-width: 721px) {
  #motion-label, #theme-label, .open-pre { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; }
  .open-pre { white-space: pre; }
  .top .theme-toggle { min-width: auto; padding: 0 12px; }
  .top .open { font-size: 15px; }
}
.rv4-canvas { container-type: inline-size; }
/* labels stay 12px; in a narrow card the "+3 days" tick drops its label so nothing collides */
.rv4-ticks span:nth-child(2) { display: none; }
@container (min-width: 381px) { .rv4-ticks span:nth-child(2) { display: inline; } }

/* Site switcher (case study | design system). Phones and tablets: its own row under the
   header bar. From 961px, where the section list moves to the sidebar, it joins the bar. */
.top .in { flex-wrap: wrap; row-gap: 0; }
.site-nav { order: 3; flex: 1 0 100%; display: flex; gap: 2px; margin: 0 -10px; padding-bottom: 2px; }
.site-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 8px; }
@media (min-width: 961px) {
  .top .in { flex-wrap: nowrap; }
  .site-nav { order: 0; flex: none; margin: 0 auto 0 8px; padding: 0 0 0 16px; border-left: 1px solid var(--rule); }
  .top .by { display: none; }
}
@media (min-width: 1280px) { .top .by { display: inline; order: 1; } .site-nav { order: 0; } }

/* Research synthesis: proto-personas and key flows */
.personas { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .personas { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.persona { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 22px 22px 20px; min-width: 0;
  box-shadow: 0 1px 2px rgba(17, 35, 88, 0.04); transition: transform var(--dur-spring, 560ms) var(--ease-spring, ease), box-shadow var(--dur-hover) var(--ease-standard); }
@media (hover: hover) { .persona:hover { transform: translateY(-3px); box-shadow: var(--lift); } }
.p-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.p-head h4 { margin: 0; font-size: 21px; }
.p-place { margin: 2px 0 0; font-size: 14px; color: var(--ink-2-on-surface); }
.p-tags { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.p-tags li { font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); color: var(--ink); }
.persona .p-situation { margin: 0 0 14px; font-size: 15px; }

/* Persona avatars: flat, brand colors, a slow breath, a head tilt, a blink and a bobbing keel badge.
   Decorative (the card says who it is); still with reduced motion. */
.av { width: 76px; height: 76px; flex: none; overflow: visible; }
.av-bg { fill: var(--illo-water); }
.av-eyes circle { fill: #112358; }
.av-mouth { fill: none; stroke: #112358; stroke-width: 1.6; stroke-linecap: round; }
.av-badge circle { fill: var(--color-deep); stroke: var(--surface); stroke-width: 2; }
.av-badge path:first-of-type { fill: var(--color-signal); }
.av-badge path + path, .av-badge ellipse { fill: var(--color-fog); }
.av-body { transform-origin: 48px 96px; animation: av-breathe 5.2s var(--av-delay, 0s) ease-in-out infinite; }
.av-head { transform-origin: 48px 66px; animation: av-tilt 7.4s var(--av-delay, 0s) ease-in-out infinite; }
.av-eyes circle { transform-box: fill-box; transform-origin: center; animation: av-blink 5.6s var(--av-delay, 0s) infinite; }
.av-badge { animation: av-bob 3.8s var(--av-delay, 0s) ease-in-out infinite; }
@keyframes av-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.015, 1.03); } }
@keyframes av-tilt { 0%, 100% { transform: rotate(0deg) translateY(0); } 35% { transform: rotate(-3deg) translateY(-0.6px); } 70% { transform: rotate(2deg) translateY(0.4px); } }
@keyframes av-blink { 0%, 44%, 50%, 100% { transform: scaleY(1); } 47% { transform: scaleY(0.12); } }
@keyframes av-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@media (prefers-reduced-motion: reduce) { :root:not([data-motion="full"]) .av * { animation: none; } }
:root[data-motion="reduced"] .av * { animation: none; }
.persona dl { margin: 0; display: grid; gap: 10px; }
.persona dt { font-weight: 600; font-size: 14px; }
.persona dd { margin: 2px 0 0; font-size: 14.5px; color: var(--ink-2-on-surface); }
.flows { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .flows { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.flows > div { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 18px 20px; min-width: 0; }
.flows h4 { margin: 0 0 10px; font-size: 17px; }
.flows ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; }
.flows li { display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; }
.flows li span { padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); }
.flows li + li::before { content: "→"; color: var(--ink-2-on-surface); }
.compare-apps td b { color: var(--ink); }
