/* TRILL: a white page drawn by hand. Black wobbly lines, flat fills, one green word for good, one red word for dump. */
@font-face { font-family: 'Gaegu'; src: url('/assets/fonts/gaegu-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Gaegu'; src: url('/assets/fonts/gaegu-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #111111;
  --paper: #ffffff;
  --good: #15803d;
  --dump: #c8261b;
  --yolk: #ffd23f;
  --belly: #fff1b8;
  --sky: #8fd3f4;
  --beak: #f39a1e;
  --leaf: #7cc66b;
  --gray: #4a4a4a;
  --hand: 'Gaegu', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --wob1: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wob2: 15px 225px 15px 255px / 255px 15px 225px 15px;
  --wob3: 225px 25px 205px 18px / 22px 205px 25px 225px;
  --pad: clamp(18px, 4vw, 72px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--hand); font-weight: 400; font-size: clamp(21px, 1.25vw + 12px, 30px); line-height: 1.3;
  overflow-x: clip;
}
img, canvas, svg { display: block; }
canvas, .pix, .pix img { image-rendering: pixelated; image-rendering: crisp-edges; }
a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--yolk); padding: 6px 14px; border: 3px solid var(--ink); z-index: 20; }
.skip:focus { left: 8px; }
.good { color: var(--good); }
.dump { color: var(--dump); }
:focus-visible { outline: 3px dashed var(--ink); outline-offset: 4px; }

/* ---------- hand-drawn buttons ---------- */
.doodle {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 4px 18px 6px; white-space: nowrap;
  font: 700 clamp(20px, 0.6vw + 15px, 28px)/1 var(--hand); color: var(--ink); text-decoration: none;
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--wob1);
  cursor: pointer; transition: transform .12s steps(2, end);
}
.doodle:nth-child(2n) { border-radius: var(--wob2); }
.doodle:nth-child(3n) { border-radius: var(--wob3); }
.doodle:hover, .doodle:focus-visible { transform: rotate(-3deg) scale(1.05); }
.doodle:nth-child(2n):hover, .doodle:nth-child(2n):focus-visible { transform: rotate(2.5deg) scale(1.05); }
.doodle:active { transform: rotate(0) scale(.97); }
.doodle.yolk { background: var(--yolk); }
.doodle.cool { background: var(--sky); }
.doodle.big { min-height: 64px; padding: 6px 30px 8px; font-size: clamp(26px, 1vw + 18px, 38px); }
.doodle.icon { padding: 4px 12px; min-width: 52px; }
.doodle[disabled], .doodle[aria-disabled="true"] { cursor: not-allowed; color: var(--gray); border-style: dashed; }
.doodle[disabled]:hover { transform: none; }

/* ---------- header ---------- */
.top {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(20px, 4vw, 80px);
  align-items: start; padding: clamp(22px, 3vw, 64px) var(--pad) 0; max-width: 2240px; margin: 0 auto;
}
.wordmark { margin: 0; line-height: 0; }
.wm { display: block; position: relative; width: min(100%, max(560px, 30vw)); aspect-ratio: 520 / 230; }
.wm svg, .boil svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tag { margin: 10px 0 0 6px; font-size: clamp(22px, 0.8vw + 15px, 32px); }
.lore-lead { margin: 6px 0 18px; font-size: clamp(25px, 1.3vw + 14px, 42px); line-height: 1.2; max-width: 30ch; }
.links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.links .doodle.icon svg, .links .doodle.icon img { width: 24px; height: 24px; }
.ca-line { margin: 12px 0 0; font-size: 21px; color: var(--gray); overflow-wrap: anywhere; }

/* line boil: three slightly different drawings swapped in steps, like an animated doodle */
.boil > svg { opacity: 0; animation: boil .42s steps(1, end) infinite; }
.boil > svg:nth-child(1) { animation-delay: 0s; }
.boil > svg:nth-child(2) { animation-delay: -.14s; }
.boil > svg:nth-child(3) { animation-delay: -.28s; }
@keyframes boil { 0% { opacity: 1; } 33.33% { opacity: 0; } 100% { opacity: 0; } }

/* ---------- section headlines ---------- */
.say { font-weight: 700; font-size: clamp(32px, 2.6vw + 14px, 76px); line-height: 1.08; margin: 0 auto; text-align: center; max-width: 22ch; overflow-wrap: normal; word-break: keep-all; hyphens: none; }
.big-say { font-size: clamp(54px, 5vw + 18px, 132px); max-width: none; }

/* ---------- hatch ---------- */
.hatch { padding: clamp(50px, 5vw, 110px) var(--pad) clamp(40px, 5vw, 90px); text-align: center; }
.stage { position: relative; width: min(92vw, 620px); aspect-ratio: 620 / 380; margin: clamp(70px, 9vw, 130px) auto 0; }
.nest-art { position: absolute; left: 0; right: 0; bottom: 0; height: 57%; }
.egg { position: absolute; left: 50%; bottom: 32%; width: 26%; aspect-ratio: 100 / 124; transform: translateX(-50%); }
.egg.shake { animation: shake .5s steps(6, end) 2; }
@keyframes shake { 0% { transform: translateX(-50%) rotate(0); } 25% { transform: translateX(-52%) rotate(-9deg); } 50% { transform: translateX(-48%) rotate(8deg); } 75% { transform: translateX(-51%) rotate(-5deg); } 100% { transform: translateX(-50%) rotate(0); } }
.baby { position: absolute; left: 50%; bottom: 27%; width: 54%; aspect-ratio: 1; transform: translateX(-50%); }
.baby[hidden], .egg[hidden] { display: none; }
.baby.pop { animation: pop .36s steps(3, end); }
@keyframes pop { 0% { transform: translateX(-50%) scale(.55) rotate(-8deg); } 100% { transform: translateX(-50%) scale(1) rotate(0); } }
.plate {
  position: absolute; right: 2%; bottom: 3%; margin: 0; padding: 2px 14px 4px; background: var(--belly);
  border: 3px solid var(--ink); border-radius: var(--wob2); font-weight: 700; font-size: clamp(20px, 1vw + 12px, 30px); transform: rotate(3deg); white-space: nowrap;
}
.hatch-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin-top: 22px; }
.picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 30px; max-width: 1160px; margin: 34px auto 0; text-align: left; }
.pick { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 52px; }
.pick-k { flex: 0 0 100%; font-weight: 700; font-size: 21px; }
.pick-v { flex: 1 1 0; min-width: 0; text-align: center; padding: 2px 6px; border-bottom: 3px solid var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nudge {
  flex: 0 0 auto; width: 44px; height: 44px; font: 700 30px/1 var(--hand); background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: var(--wob3); cursor: pointer; transition: transform .1s steps(2, end);
}
.nudge:hover { transform: rotate(-6deg) scale(1.08); }
.nudge:disabled { cursor: not-allowed; color: var(--gray); border-style: dashed; transform: none; }
.pick.name input {
  flex: 1 1 auto; min-width: 0; font: 400 inherit/1.2 var(--hand); font-size: inherit; color: var(--ink); background: var(--paper);
  border: 3px solid var(--ink); border-radius: var(--wob1); padding: 4px 14px;
}
.pick.name input::placeholder { color: var(--gray); }
.hatch-msg { margin: 24px auto 0; max-width: 40ch; min-height: 1.4em; }
.hatch-msg a { font-weight: 700; }
.mine { margin: 40px auto 0; max-width: 1160px; }
.mine-h { font-size: clamp(28px, 1.2vw + 18px, 44px); margin: 0 0 14px; }
.mine-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.mine-list li { width: 220px; padding: 10px 12px 14px; border: 3px solid var(--ink); border-radius: var(--wob2); }
.mine-list li:nth-child(2n) { border-radius: var(--wob1); }
.mine-list .mini { width: 120px; height: 120px; margin: 0 auto; }
.mine-list .mini img { width: 100%; height: 100%; }
.mine-list .nm { font-weight: 700; margin: 4px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mine-list .acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; font-size: 21px; }
.mine-list .acts a, .mine-list .acts button { font: 700 21px/1.3 var(--hand); color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- the flock ---------- */
.flock { position: relative; height: 290vh; }
.flock-pin { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; flex-direction: column; overflow: hidden; }
.flock-say { padding: clamp(18px, 2.4vw, 40px) var(--pad) 8px; text-align: center; }
.flock-say .say { max-width: none; }
.flock-status { margin: 8px auto 0; max-width: 52ch; }
.sky { flex: 1 1 auto; width: 100%; min-height: 0; }
.flock-hint { position: absolute; left: 0; right: 0; bottom: 12px; margin: 0; text-align: center; font-size: 21px; pointer-events: none; }
.flock-hint span { display: inline-block; max-width: 92%; background: var(--paper); padding: 0 10px; }

/* ---------- story ---------- */
.story { padding: clamp(70px, 8vw, 150px) var(--pad); text-align: center; }
.story-p { max-width: 36ch; margin: 22px auto 0; font-size: clamp(24px, 1vw + 16px, 38px); }
.panels { list-style: none; margin: clamp(40px, 5vw, 80px) auto 0; padding: 0; max-width: 1400px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(26px, 4vw, 70px) clamp(20px, 3vw, 60px); }
.panels li { opacity: 0; transform: translateY(26px) rotate(-2deg); transition: opacity .3s steps(3, end), transform .3s steps(3, end); }
.panels li:nth-child(2n) { transform: translateY(26px) rotate(2deg); }
.panels li.in { opacity: 1; transform: none; }
.panel-art { position: relative; width: 100%; aspect-ratio: 4 / 3; }
.panels p { margin: 10px auto 0; max-width: 22ch; }
.story-cta { margin: clamp(40px, 5vw, 80px) 0 0; }

/* ---------- episodes ---------- */
.episodes { padding: clamp(40px, 6vw, 110px) var(--pad) clamp(70px, 8vw, 140px); text-align: center; }
.ep-sub { margin: 4px 0 0; }
.player { margin: clamp(28px, 4vw, 60px) auto 0; max-width: 980px; }
.screen { border: 5px solid var(--ink); border-radius: 12px 6px 14px 8px / 8px 14px 6px 12px; padding: 0; overflow: hidden; background: var(--paper); transform: rotate(-.6deg); }
.screen img { width: 100%; height: auto; aspect-ratio: 1; }
.screen img.swap { animation: swap .3s steps(3, end); }
@keyframes swap { 0% { opacity: .2; } 100% { opacity: 1; } }
.ep-title { font-size: clamp(30px, 1.6vw + 18px, 56px); margin: 20px 0 4px; font-weight: 700; }
.ep-text { max-width: 44ch; margin: 0 auto; }
.thumbs { list-style: none; margin: 34px auto 0; padding: 0; max-width: 1240px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.thumbs button { width: 100%; background: var(--paper); border: 0; padding: 0; cursor: pointer; font: 400 21px/1.2 var(--hand); color: var(--ink); text-align: center; }
.thumbs img { width: 100%; height: auto; aspect-ratio: 1; border: 4px solid var(--ink); border-radius: var(--wob3); transition: transform .12s steps(2, end); }
.thumbs button:hover img { transform: rotate(-2.5deg) scale(1.03); }
.thumbs button[aria-current="true"] img { border-color: var(--good); border-width: 6px; }
.thumbs .tn { display: block; margin-top: 8px; }
.thumbs .tn b { color: var(--good); }

/* ---------- footer ---------- */
.foot { padding: clamp(50px, 6vw, 110px) var(--pad) 50px; text-align: center; border-top: 3px solid var(--ink); }
.foot-say { font-weight: 700; font-size: clamp(32px, 2.4vw + 16px, 80px); margin: 0; line-height: 1.1; }
.foot-small { font-size: 21px; margin: 14px auto 0; max-width: 60ch; }
.foot-small a { margin: 0 8px; font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 160%); z-index: 30;
  background: var(--yolk); border: 3px solid var(--ink); border-radius: var(--wob2); padding: 6px 20px 8px; font-weight: 700; max-width: 90vw; text-align: center;
  transition: transform .2s steps(3, end);
}
.toast:not(.on) { visibility: hidden; transition: transform .2s steps(3, end), visibility 0s .2s; }
.toast.on { transform: translate(-50%, 0); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .top { grid-template-columns: 1fr; }
  .wm { width: min(100%, 420px); }
  .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .panels { grid-template-columns: 1fr; max-width: 420px; }
  .pick-k { min-width: 4.6em; }
  .links { gap: 10px; }
  .doodle.big { padding: 6px 22px 8px; }
}
@media (min-width: 2000px) {
  .stage { width: 760px; }
  .lore-lead { font-size: 48px; }
  .player { max-width: 1180px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .boil > svg { animation: none; opacity: 0; }
  .boil > svg:first-child { opacity: 1; }
  .egg.shake, .baby.pop, .screen img.swap { animation: none; }
  .panels li { opacity: 1; transform: none; transition: none; }
  .doodle, .nudge, .thumbs img { transition: none; }
}
