/* nestbox.pet: the device as the one bold thing on a quiet bench; tokens in DESIGN.md. Mobile first.
   Without the scene (no script, reduced motion, a short window) the page is a plain column. With it, one device stays
   pinned while the story changes around it; while the day plays in the hero, paper and ink follow the pet's clock. */
:root {
  --paper: #e3e4e0;
  --ink: #1d2433;
  --ink-soft: #596071;
  --hairline: color-mix(in srgb, var(--ink) 22%, var(--paper));
  --accent: #d87450;
  --accent-mark: #c4603c;
  --night: #1d2433;
  --night-rim: #4a556a;
  --night-text: #e9eae6;
  --night-soft: #9aa3b6;
  --screen: #1b1d20;

  --white: #ebebe5;
  --cream: #e8dbb7;
  --pink: #f0d6d9;
  --orange: #f99963;
  --blue: #a4d0df;
  --sage: #d2debb;
  --grey: #9b9ea0;
  --charcoal: #3b3d40;

  --sans: 'Barlow', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  --gutter: 16px;
  --width: 1360px;
  --section: 88px;
  --radius: 8px;
  --top: 56px;
  --spot-w: min(56vw, 280px);
}
@media (min-width: 720px) { :root { --gutter: 40px; --section: 128px; --top: 76px; } }
html.case-wide { --spot-w: min(84vw, 360px); }
@media (min-width: 720px) { :root { --spot-w: min(46vw, 380px); } html.case-wide { --spot-w: min(64vw, 500px); } }
@media (min-width: 1000px) { :root { --spot-w: min(34vw, 460px); } html.case-wide { --spot-w: min(42vw, 600px); } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
@media (min-width: 720px) { body { font-size: 17px; line-height: 1.53; } }
img, video { max-width: 100%; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.015em; text-wrap: balance; }
p { text-wrap: pretty; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 8px 14px; border-radius: var(--radius); background: var(--ink); color: var(--paper); }
.skip:focus { top: 8px; }

/* ---- the frame: the page's width, and the top bar ---- */
.frame, .footer { max-width: var(--width); margin: 0 auto; padding: 0 var(--gutter); }
.frame { position: relative; }
.top { display: flex; align-items: center; justify-content: space-between; height: var(--top); }
.wordmark { font-weight: 500; font-size: 19px; letter-spacing: -0.01em; text-decoration: none; }
.top nav { display: flex; gap: 22px; font-size: 15px; }
.top nav a { color: var(--ink-soft); text-decoration: none; }
.top nav a:hover { color: var(--ink); }
@media (min-width: 720px) { .top nav { gap: 28px; } }

/* ---- the hero: a line of words, the device big and alone, and its day ---- */
.intro h1 { font-size: 30px; line-height: 1.15; padding-top: 4px; }
.intro .lead { margin-top: 10px; color: var(--ink-soft); max-width: 34em; }
@media (min-width: 960px) {
  .intro { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 40px; padding-top: 8px; }
  .intro h1 { font-size: 44px; line-height: 1.1; padding: 0; }
  .intro .lead { justify-self: end; margin: 0; font-size: 18px; }
}
.slot { position: relative; margin: 16px 0 0; }
.ghost { visibility: hidden; }
.slot .ghost { width: min(100%, 520px); aspect-ratio: var(--ar, 1.12); margin: 0 auto; }

/* the device: a render with its screen warped onto it, the day and the requests sharing that screen */
.device { position: relative; }
.device-render { display: block; width: 100%; height: auto; }
.screen-surface { position: absolute; left: 0; top: 0; width: 280px; height: 240px; overflow: hidden; transform-origin: 0 0; background: var(--screen); }
.screen-surface video { position: absolute; inset: 0; display: block; width: 280px; height: 240px; max-width: none; object-fit: cover;
  opacity: 0; transition: opacity .2s; }
.device[data-mode="day"] .day-clip, .device[data-mode="talk"] .talk-clip.front { opacity: 1; }
.device .talk-clip:not(.front) { visibility: hidden; }
.live { position: absolute; left: 0; top: 0; z-index: 2; margin: 0; transform-origin: 0 0; will-change: transform; pointer-events: none;
  opacity: 0; transition: opacity .3s; }
.placed .live { opacity: 1; }

/* the day: a pause, the moment, a thin track of the day's times, and the request behind the moment */
.day { display: flex; align-items: flex-start; gap: 14px; width: 100%; max-width: 1080px; margin: 16px auto 0; }
.day-body { flex: 1; min-width: 0; }
.pause { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--ink);
  border-radius: 50%; background: none; color: var(--ink); cursor: pointer; }
.pause svg { display: block; fill: currentColor; }
.pause .i-pause, .pause.playing .i-play { display: none; }
.pause.playing .i-pause { display: inline; }
.now { font-weight: 500; line-height: 20px; padding-top: 2px; }
.now time { margin-right: 6px; color: var(--ink-soft); font-weight: 400; font-variant-numeric: tabular-nums; }
.track { position: relative; height: 22px; margin: 6px 0 0; padding: 0; list-style: none; cursor: grab; touch-action: pan-y; user-select: none; }
.track::before, .track::after { content: ''; position: absolute; left: 0; top: 10px; height: 1px; }
.track::before { right: 0; background: var(--hairline); }
.track::after { width: calc(var(--progress, 0) * 100%); background: var(--ink); }
.track li { position: absolute; top: 0; left: calc(var(--at) * 100%); transform: translateX(-50%); }
.track button { position: relative; display: block; width: 24px; height: 22px; padding: 0; border: 0; background: none; color: var(--ink-soft); cursor: pointer; }
.track button::before { content: ''; position: absolute; left: 50%; top: 5px; width: 1px; height: 11px; background: currentColor; }
.track button[aria-current]::before { left: calc(50% - 5px); width: 11px; height: 11px; border-radius: 50%; background: var(--accent-mark); box-shadow: 0 0 0 2.5px var(--paper); }
.track button:hover { color: var(--ink); }
.track.dragging, .track.dragging button { cursor: grabbing; }
.track time, .track span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.caption { margin-top: 8px; color: var(--ink-soft); min-height: 3em; }
@media (min-width: 720px) { .day { gap: 20px; margin-top: 12px; } }
@media (min-width: 1100px) {
  .now { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .track { height: 64px; margin-top: 0; }
  .track::before, .track::after { top: 22px; }
  .track button { width: 48px; height: 64px; }
  .track button::before { top: 17px; }
  .track time { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; margin-top: 34px;
    font-size: 13px; font-variant-numeric: tabular-nums; }
  .track button[aria-current] { color: var(--ink); }
  .track button[aria-current] span { position: absolute; top: -10px; left: 50%; width: auto; height: auto; overflow: visible; clip: auto;
    transform: translateX(-50%); font-size: 15px; font-weight: 500; }
  .track li:first-child { transform: translateX(-12px); }
  .track li:last-child { transform: translateX(calc(-100% + 12px)); }
  .track li:first-child button[aria-current] span { left: 0; transform: none; }
  .track li:last-child button[aria-current] span { left: auto; right: 0; transform: none; }
  .caption { margin-top: 2px; min-height: 1.5em; }
}

/* ---- the chapters beside the device ---- */
.panel.talk, .panel.build { margin-top: var(--section); }
.panel h2 { font-size: 24px; line-height: 1.25; }
.panel .say { margin-top: 8px; color: var(--ink-soft); max-width: 36em; }
.panel .links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 14px; }
@media (min-width: 960px) {
  .panel h2 { font-size: 30px; line-height: 1.2; }
  .panel .say { margin-top: 12px; }
}

/* anything can talk to it: the request, typed out, in step with the device's screen */
.terminal { position: relative; min-width: 0; margin-top: 16px; padding: 14px 16px 16px; border-radius: 12px; background: var(--night);
  box-shadow: inset 0 0 0 1px var(--night-rim); color: var(--night-text); font: 12px/1.6 var(--mono); }
.terminal pre { margin: 0; min-height: 5.1em; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 56px; }
.terminal code::before { content: '$ '; color: var(--night-soft); }
.terminal .field { transition: color .2s, background-color .2s; border-radius: 3px; }
.terminal .field.on { color: color-mix(in srgb, var(--c, #f4f1d0) 70%, white); background: color-mix(in srgb, var(--c, #f4f1d0) 12%, transparent); }
.reply { min-height: 1.7em; margin-top: 6px; color: var(--night-soft); overflow-wrap: anywhere; }
.copy { position: absolute; top: 12px; right: 12px; min-height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none;
  color: var(--night-text); font: 500 13px var(--sans); box-shadow: inset 0 0 0 1px var(--night-rim); cursor: pointer; }
/* the pieces a request is built from; the ones the current request uses light up as it lands */
.pieces { display: flex; align-items: flex-start; gap: 14px; margin-top: 14px; }
.blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 18px; flex: 1; min-width: 0; margin: 0; }
.blocks div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.blocks dt, .blocks dd { margin: 0; }
.blocks code { display: inline-block; padding: 1px 6px; border-radius: 4px; font: 13px/1.5 var(--mono); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--hairline); transition: background-color .2s, color .2s, box-shadow .2s; }
.blocks dd { font-size: 14px; line-height: 1.4; color: var(--ink-soft); white-space: nowrap; transition: color .2s; }
.blocks .on code { background: var(--ink); color: var(--paper); box-shadow: none; }
.blocks .on dd { color: var(--ink); }
.from { margin-top: 14px; font-size: 15px; color: var(--ink-soft); max-width: 40em; }
@media (min-width: 960px) {
  .terminal { padding: 20px 24px; font-size: 14px; line-height: 2; }
  .blocks { column-gap: 28px; }
}

/* build one: the case, worn by the device itself, and where to start */
.looks { display: grid; gap: 14px; justify-items: start; margin-top: 22px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--hairline); }
.segmented button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 6px; background: none; color: var(--ink-soft);
  font: 500 15px var(--sans); cursor: pointer; }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.swatches { display: flex; flex-wrap: wrap; gap: 2px; margin-left: -6px; }
.swatches[hidden] { display: none; }
.swatch { position: relative; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.swatch::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgb(29 36 51 / .28); }
.swatch[aria-checked="true"]::before { box-shadow: inset 0 0 0 1px rgb(29 36 51 / .28), 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.swatch:focus-visible { outline-offset: 0; border-radius: 50%; }
.swatch.white { --sw: var(--white); } .swatch.cream { --sw: var(--cream); } .swatch.pink { --sw: var(--pink); }
.swatch.orange { --sw: var(--orange); } .swatch.blue { --sw: var(--blue); } .swatch.sage { --sw: var(--sage); }
.swatch.grey { --sw: var(--grey); } .swatch.charcoal { --sw: var(--charcoal); }
.swatch.stand-black { --sw: #1c1c1f; } .swatch.stand-darkgrey { --sw: #4a4b50; } .swatch.stand-white { --sw: #edede8; }
.swatch.stand-cream { --sw: var(--cream); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.button { display: inline-flex; align-items: center; min-height: 46px; padding: 0 20px; border-radius: var(--radius);
  font: 500 16px var(--sans); text-decoration: none; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.button.primary { background: var(--ink); color: var(--paper); box-shadow: none; }
.fine { max-width: 40em; margin-top: 16px; font-size: 14px; color: var(--ink-soft); }

/* where the device rests beside the chapters, and its caption */
.spot { display: none; }
.dock-note { margin-top: 10px; text-align: center; font-size: 15px; color: var(--ink-soft); opacity: var(--note, 0); }

/* ---- the scene: the device pinned, the chapters changing beside it ---- */
.mark { position: absolute; left: 0; width: 1px; height: 1px; pointer-events: none; }
.scene-on .scene { position: relative; height: calc(100svh + var(--travel, 280svh)); }
.scene-on .pin { position: sticky; top: 0; height: 100svh; overflow: hidden; }
.scene-on .frame { display: flex; flex-direction: column; height: 100%; }
.scene-on .hero { display: flex; flex-direction: column; flex: 1; min-height: 0; padding-bottom: 12px; }
.scene-on .slot { flex: none; height: var(--slot-h, min(56svh, calc((100vw - 32px) / 1.12), 571px)); margin: 16px 0 0; }
.scene-on .hero .day { margin-bottom: auto; }
.scene-on .slot .ghost { position: absolute; left: 50%; top: 50%; width: var(--ghost-w, 300px); margin: 0; transform: translate(-50%, -50%); }
.scene-on .panel.talk, .scene-on .panel.build { position: absolute; left: var(--gutter); right: var(--gutter); margin: 0;
  top: calc(var(--top) + var(--spot-w) / var(--ar, 1.12) + 28px); }
.scene-on .spot { display: block; position: absolute; left: 50%; top: calc(var(--top) + 4px); width: var(--spot-w); transform: translateX(-50%); }
.scene-on .spot .ghost { width: 100%; aspect-ratio: var(--ar, 1.12); }
.scene-on .spot .dock-note { display: none; }
.scene-on .panel { opacity: var(--o, 1); transform: translate3d(0, var(--y, 0px), 0); }
.scene-on .panel.talk, .scene-on .panel.build { opacity: var(--o, 0); }
.scene-on .panel.hero { transform: none; }
.scene-on .hero .intro, .scene-on .hero .day { transform: translate3d(0, var(--y, 0px), 0); }
.scene-on .panel.off { pointer-events: none; }
@media (min-width: 1000px) {
  .scene-on .spot { left: auto; right: var(--gutter); top: 50%; transform: translateY(-50%); }
  .scene-on .spot .dock-note { display: block; }
  .scene-on .panel.talk, .scene-on .panel.build { right: auto; top: 50%; width: min(640px, calc(100% - var(--spot-w) - 2 * var(--gutter) - 72px));
    transform: translate3d(0, calc(-50% + var(--y, 0px)), 0); }
}

/* ---- footer ---- */
.footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; padding-top: var(--section); padding-bottom: 36px;
  font-size: 15px; color: var(--ink-soft); }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }

/* ---- 404 ---- */
.lost { min-height: 100vh; display: grid; place-content: center; justify-items: start; gap: 14px; padding: var(--gutter); max-width: 520px; margin: 0 auto; }
.lost video { width: 280px; height: auto; border: 8px solid var(--screen); border-radius: 8px; }
.lost h1 { font-size: 44px; line-height: 1.1; }
.lost p { color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
