/* advent — the New Year layer over the paper kit. Load after design/paper/tokens.css + components.css.
   Same paper rules (desk, sheets, no borders, colour comes from content); the desk turns warm,
   the ink turns plum, the one accent turns candle-gold. Festive colours are measured from the candle reference.
   Project additions live here so design/paper stays an untouched copy of the library kit
   (candidates to carry back: .ui-swatches, .ui-range). */

:root {
  /* festive palette — read from the candle reference (two prints: plum night, peach day) */
  --x-plum: #2d141c;
  --x-peach: #f7c4ad;
  --x-green: #1d5a3b;
  --x-gold: #eba64b;
  --x-pink: #f78bd3;
  --x-red: #d7302b;
  --x-cream: #fbe5d6;
  --x-vermilion: #ee5539; /* the gouache stars reference (03) */
  --x-tomato: #de4a33; /* the gift posters (05): vermilion backdrop, sky boxes, dusty kraft, crimson package */
  --x-sky: #a9d6f2;
  --x-kraft: #c8a194;
  --x-crimson: #b8000b;
  --x-night: #1d0b10; /* the sky of the calendar building (07), measured */
  --x-board: #260e16; /* the ground of the advent-door posters (08), measured */
  /* the book-tree poster (14), measured from refs/illustration.webp: pure colours on true black */
  --x-black: #000000;
  --x-leaf: #009259;
  --x-paper: #fbf3e4;
  --x-cobalt: #0849f9;
  --x-scarlet: #f71e19;
  --x-orchid: #fb6fd3;
  --x-sun: #fdca00;
  --x-shelf: #1d1919; /* the plank and unread layers on black */
  --x-unlit: #2a2525;
  /* the book-tree poster (15), read from a Swiss stack-of-books print: flat bars on white (the rest of its palette lives in experiments/15-book-tree/tree.js) */
  --x-poster: #ffffff;
  --x-ink: #0b1517;
  --font-compressed: 'Oswald', 'Arial Narrow', sans-serif; /* the stretched poster headline (14) */
  --font-grotesk: 'Onest', var(--font); /* the poster's Cyrillic grotesk (14) */

  /* type for posters and big moments */
  --font-poster: 'Unbounded', 'Arial Black', sans-serif; /* book spines (06), covers (07) */
  --text-hero: clamp(40px, 5.6vw, 92px); /* the calendar headline (07) */
  --tracking-wide: 0.32em; /* spaced caps kicker over a hero */

  /* doors (08) swing slower than paper moves: they have weight and hinges */
  --door-swing: 900ms;
  --door-ease: cubic-bezier(0.3, 0.9, 0.25, 1);

  /* paper, warmed up */
  --bg: #efe6df;
  --tile: #fbf6f2;
  --tile-hover: #fffdfb;
  --raised: #fffdfb;
  --well: #f2e9e3;
  --well-hover: #eaded6;
  --ink: #2a1219;
  --muted: #6b555b;
  --faint: #b3a2a6;
  --accent: #eba64b;
  --accent-hover: #f1b765;
  --on-accent: #2a1219;
  --mark: #f7cf7d;
  --focus: #2a1219;
  --track: #e2d5ce;
  --chrome: #2a1219;
  --on-chrome: #fbe5d6;
  --on-chrome-muted: #c4a8ad;
  --scrim: rgb(239 230 223 / 0.72);
  --tone-lime: #f6d58f;
  --tone-pink: #f8d6e6;
  --tone-peach: #f9dccd;
  --tone-mint: #cfe3d4;
  --tone-mint-ink: #12402a;
  --tone-mint-muted: #2f5e45;
  --tone-dark: #2d141c;
  --shadow-paper: 0 0.5px 1px rgb(42 18 25 / 0.05), 0 3px 8px -2px rgb(42 18 25 / 0.06), 0 16px 34px -10px rgb(42 18 25 / 0.14);
  --shadow-lift: 0 1px 2px rgb(42 18 25 / 0.06), 0 10px 22px -6px rgb(42 18 25 / 0.13), 0 32px 60px -16px rgb(42 18 25 / 0.24);
  --shadow-sm: 0 0.5px 1px rgb(42 18 25 / 0.08), 0 2px 6px -1px rgb(42 18 25 / 0.08);
  --shadow-float: 0 30px 80px -20px rgb(42 18 25 / 0.3), 0 10px 30px -10px rgb(42 18 25 / 0.15);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1a0c11; --tile: #26141a; --tile-hover: #2e1920; --raised: #321b22; --well: #331c24; --well-hover: #3d232c;
    --ink: #fbe5d6; --muted: #b89ea3; --faint: #6e555b; --focus: #fbe5d6; --track: #4a2f37;
    --chrome: #3a2129; --on-chrome: #fbe5d6; --on-chrome-muted: #c4a8ad;
    --accent: #eba64b; --accent-hover: #f1b765; --mark: #e9b65a;
    --tone-dark: #0f0609;
    --scrim: rgb(26 12 17 / 0.72);
    --shadow-paper: 0 0.5px 0 rgb(255 255 255 / 0.04) inset, 0 3px 8px -2px rgb(0 0 0 / 0.4), 0 16px 34px -10px rgb(0 0 0 / 0.55);
    --shadow-lift: 0 0.5px 0 rgb(255 255 255 / 0.06) inset, 0 10px 22px -6px rgb(0 0 0 / 0.5), 0 32px 60px -16px rgb(0 0 0 / 0.7);
    --shadow-sm: 0 2px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-float: 0 30px 80px -20px rgb(0 0 0 / 0.8);
  }
}
:root[data-theme='dark'] {
  --bg: #1a0c11; --tile: #26141a; --tile-hover: #2e1920; --raised: #321b22; --well: #331c24; --well-hover: #3d232c;
  --ink: #fbe5d6; --muted: #b89ea3; --faint: #6e555b; --focus: #fbe5d6; --track: #4a2f37;
  --chrome: #3a2129; --on-chrome: #fbe5d6; --on-chrome-muted: #c4a8ad;
  --accent: #eba64b; --accent-hover: #f1b765; --mark: #e9b65a;
  --tone-dark: #0f0609;
  --scrim: rgb(26 12 17 / 0.72);
  --shadow-paper: 0 0.5px 0 rgb(255 255 255 / 0.04) inset, 0 3px 8px -2px rgb(0 0 0 / 0.4), 0 16px 34px -10px rgb(0 0 0 / 0.55);
  --shadow-lift: 0 0.5px 0 rgb(255 255 255 / 0.06) inset, 0 10px 22px -6px rgb(0 0 0 / 0.5), 0 32px 60px -16px rgb(0 0 0 / 0.7);
  --shadow-sm: 0 2px 6px -1px rgb(0 0 0 / 0.5);
  --shadow-float: 0 30px 80px -20px rgb(0 0 0 / 0.8);
}

/* Swatches — colour picker from radios: <div class="ui-swatches"><label><input type="radio" name="c" value="red"><span style="--c: var(--x-red)"></span></label>…</div>
   Picked = an ink ring with a gap of paper, like a sticker pressed onto the sheet. */
.ui-swatches { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.ui-swatches label { position: relative; display: block; cursor: pointer; }
.ui-swatches input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.ui-swatches span {
  display: block; width: var(--h-sm); height: var(--h-sm); border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgb(42 18 25 / 0.08);
  transition: box-shadow var(--fast) var(--ease), transform var(--fast) var(--ease-pop);
}
.ui-swatches label:hover span { transform: scale(1.08); }
.ui-swatches input:checked + span { box-shadow: 0 0 0 2px var(--paper, var(--tile)), 0 0 0 4px var(--ink); }
.ui-swatches input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 5px; }
.ui-swatches input:disabled + span { opacity: 0.25; cursor: not-allowed; }

/* Range — <input type="range" class="ui-range">: a recessed groove on paper, an ink bead to drag */
.ui-range { appearance: none; -webkit-appearance: none; width: 100%; height: var(--h-sm); margin: 0; background: transparent; cursor: pointer; }
.ui-range::-webkit-slider-runnable-track { height: 6px; border-radius: var(--r-pill); background: var(--field, var(--well)); }
.ui-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: var(--ink); box-shadow: var(--shadow-sm); transition: transform var(--fast) var(--ease-pop);
}
.ui-range:active::-webkit-slider-thumb { transform: scale(1.18); }
.ui-range::-moz-range-track { height: 6px; border-radius: var(--r-pill); background: var(--field, var(--well)); }
.ui-range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: var(--ink); }
.ui-range:focus-visible { outline: 0; }
.ui-range:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--focus); outline-offset: 3px; }
.ui-range:focus-visible::-moz-range-thumb { outline: 2px solid var(--focus); outline-offset: 3px; }

/* Switcher — the dark pill that walks between the lab's pages; lib/lab.js fills it from the one list of experiments.
   <nav class="ui-switcher" data-lab-nav aria-label="Experiments"></nav>
   It keeps its place while the page under it changes (cross-document view transition), so the lab reads as one app. */
.ui-switcher { display: flex; min-height: calc(var(--h-md) + 8px); margin-bottom: var(--s-7); view-transition-name: lab-switcher; }
.ui-switcher .ui-btn { text-decoration: none; }
.ui-switcher .ui-mono { opacity: 0.7; }
.ui-switcher [aria-current='page'] .ui-mono { opacity: 1; }
.ui-toolbar .ui-btn[aria-current='page'] { --btn-fg: var(--on-chrome); --btn-bg: rgb(255 255 255 / 0.14); --btn-hover: rgb(255 255 255 / 0.14); }
.ui-switcher-sep { width: 1px; height: var(--s-6); margin: 0 var(--s-1); background: rgb(255 255 255 / 0.14); }
/* the pill outgrows narrower windows: it scrolls inside itself (lib/lab.js brings the current page into view), the page never scrolls sideways */
.ui-switcher .ui-toolbar { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.ui-switcher .ui-toolbar::-webkit-scrollbar { display: none; }
/* on a phone only the page you're on keeps its name */
@media (max-width: 600px) {
  .ui-switcher .ui-btn:not([aria-current='page']) .ui-switcher-name { display: none; }
  /* with three or more experiments the pill outgrows a phone: drop the separators, and never push past the gutter */
  .ui-switcher-sep { display: none; }
}

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--base); animation-timing-function: var(--ease); }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* Door — an advent window drawn by lib/doors.js (Advent.doors.html(door)):
   <div class="ui-door" data-state="shut | open"> room + frame (svg) · leaves (div > two svg faces) · hinges (svg)
   The leaves really swing on their hinges (CSS 3D): the front face turns away, the back face — the door's colour in
   shadow, with the day number — turns to us. Lights in the room come on once the doors are half open.
   Inside a hovered link / button a shut door peeks open a little. Set --door-depth for the perspective (px). */
.ui-door { position: relative; aspect-ratio: 200 / 250; perspective: var(--door-depth, 640px); perspective-origin: 50% 42%; }
.ui-door > svg, .ui-door-leaf, .ui-door-face { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ui-door > svg { pointer-events: none; }
.ui-door-leaf { transform-style: preserve-3d; transition: transform var(--door-swing) var(--door-ease); pointer-events: none; }
.ui-door-face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.ui-door-face + .ui-door-face { transform: rotateY(180deg); }
.ui-door[data-state='open'] .ui-door-leaf[data-side='l'] { transform: rotateY(-124deg); }
.ui-door[data-state='open'] .ui-door-leaf[data-side='r'] { transform: rotateY(124deg); }
:where(a, button, label):hover > .ui-door[data-state='shut'] .ui-door-leaf { transition-duration: var(--slow); }
:where(a, button, label):hover > .ui-door[data-state='shut'] .ui-door-leaf[data-side='l'] { transform: rotateY(-16deg); }
:where(a, button, label):hover > .ui-door[data-state='shut'] .ui-door-leaf[data-side='r'] { transform: rotateY(16deg); }
.ui-door-light { opacity: 0; transition: opacity var(--slow) var(--ease); }
.ui-door[data-state='open'] .ui-door-light { opacity: 1; transition-delay: calc(var(--door-swing) * 0.35); }
.ui-door [data-twinkle] { animation: ui-door-twinkle 2.4s ease-in-out infinite alternate; }
.ui-door [data-flicker] { animation: ui-door-twinkle 0.7s ease-in-out infinite alternate; }
.ui-door[data-state='shut'] :is([data-twinkle], [data-flicker]) { animation-play-state: paused; }
@keyframes ui-door-twinkle { from { opacity: 1; } to { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  .ui-door-leaf, .ui-door-light { transition: none; }
  .ui-door :is([data-twinkle], [data-flicker]) { animation: none; }
}

/* Drop — a recessed well that takes a file: <label class="ui-drop"><input type="file"><span class="ui-drop-thumb"></span><span>…</span></label>
   Dragging a file over it lights it like hover (set data-over from script). */
.ui-drop {
  position: relative; display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3); border-radius: var(--r-md);
  background: var(--field, var(--well)); cursor: pointer; transition: background var(--fast) var(--ease);
}
.ui-drop:hover, .ui-drop[data-over] { background: var(--field-hover, var(--well-hover)); }
.ui-drop input[type='file'] { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.ui-drop:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.ui-drop-thumb {
  flex: none; width: 52px; aspect-ratio: 2 / 3; border-radius: 2px; background: var(--track) center / cover no-repeat;
  box-shadow: var(--shadow-sm);
}

/* Book cover — a generated cover in its room's colour (10 · Room; 07's book page draws the same idea as .cal-cover).
   <figure class="ui-bookcover" style="--c: …; --on-c: …"><span class="ui-bookcover-title">…</span><span class="ui-bookcover-author">…</span>
     <span class="ui-bookcover-sticker"><b>12</b><span>Looking</span></span></figure>
   Title and author sit at the top (the lower edge stays free for a pill laid over it).
   The arch of the door it came from sits low right, the spine darkens the left edge, the sticker is the record-sleeve
   kind: a round label with the day and the book's perspective. Type scales with the cover (container units). */
.ui-bookcover {
  --c: var(--x-red); --on-c: var(--x-cream);
  position: relative; container-type: inline-size; display: flex; flex-direction: column; gap: 5cqw;
  aspect-ratio: 2 / 3; margin: 0; padding: 11% 9% 10% 13%; overflow: hidden; /* % — container units would measure the page, not this cover */
  border-radius: var(--r-sm); background: var(--c); color: var(--on-c); box-shadow: var(--shadow-lift);
}
.ui-bookcover::before { /* the door it came from */
  content: ''; position: absolute; right: 14%; bottom: 16%; width: 38%; aspect-ratio: 1 / 1.55;
  border-radius: var(--r-pill) var(--r-pill) 0 0; background: color-mix(in srgb, var(--on-c) 22%, var(--c));
}
.ui-bookcover::after { /* the spine */
  content: ''; position: absolute; inset: 0 auto 0 0; width: 6%;
  background: color-mix(in srgb, var(--x-night) 18%, transparent);
}
.ui-bookcover-title { position: relative; max-width: 92%; font: 800 13cqw / 1.06 var(--font-poster); letter-spacing: -0.01em; overflow-wrap: anywhere; text-wrap: balance; }
.ui-bookcover-author { position: relative; max-width: 55%; font-size: 7.5cqw; line-height: 1.25; font-weight: var(--weight-ui); opacity: 0.85; }
.ui-bookcover-sticker {
  position: absolute; z-index: 1; right: 7%; top: 44%; width: 37cqw; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-content: center; text-align: center; gap: 1cqw; transform: rotate(-12deg);
  background: var(--sticker, var(--x-gold)); color: var(--x-night); box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
}
.ui-bookcover-sticker b { font: 800 12.5cqw / 1 var(--font-poster); }
.ui-bookcover-sticker span { font: var(--weight-ui) 4.4cqw / 1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.ui-bookcover[data-read] .ui-bookcover-sticker::after { /* read: a gold star pressed onto the label */
  content: ''; position: absolute; right: -4cqw; top: -4cqw; width: 13cqw; aspect-ratio: 1; background: var(--x-vermilion);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

/* Player — the one dark pill under a day (10 · Room): an action, the day's line, previous / next.
   <div class="ui-player"><button class="ui-player-act">icon</button><span class="ui-player-text"><span class="ui-player-title">…</span>
   <span class="ui-player-meta">…</span></span><button class="ui-btn" data-icon>‹</button><button class="ui-btn" data-icon>›</button></div> */
.ui-player {
  display: inline-flex; align-items: center; gap: var(--s-4); max-width: 100%; padding: 6px var(--s-2) 6px 6px;
  border-radius: var(--r-pill); background: var(--chrome); color: var(--on-chrome); box-shadow: var(--shadow-float);
}
.ui-player-act {
  flex: none; display: grid; place-items: center; width: var(--h-lg); height: var(--h-lg); padding: 0; border: 0; border-radius: 50%;
  background: var(--on-chrome); color: var(--chrome); cursor: pointer; transition: transform var(--fast) var(--ease-pop);
}
.ui-player-act:hover { transform: scale(1.06); }
.ui-player-act:active { transform: scale(0.94); }
.ui-player-act:focus-visible { outline: 2px solid var(--on-chrome); outline-offset: 3px; }
.ui-player-act svg { width: 20px; height: 20px; }
.ui-player-act[aria-disabled='true'] { background: rgb(255 255 255 / 0.14); color: var(--on-chrome); cursor: not-allowed; }
.ui-player-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ui-player-title { font-size: var(--text-lg); font-weight: var(--weight-ui); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-player-meta { font-size: var(--text-sm); color: var(--on-chrome-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ui-player .ui-btn { --btn-bg: transparent; --btn-fg: var(--on-chrome-muted); --btn-hover: rgb(255 255 255 / 0.1); --btn-shadow: none; border-radius: var(--r-pill); flex: none; }
.ui-player .ui-btn:hover { --btn-fg: var(--on-chrome); }
