@import url("/assets/fonts.css");

/* Cold paper, one warm thing. Orange belongs only to the playful voice:
   the ice cream, the oranges, the socks, the goldfish, the asides. */
:root {
  --paper: #f1f1f4;
  --paper-deep: #e6e6ec;
  --ink: #26252d;
  --ink-soft: #8a8898;
  --ink-faint: #c3c2cc;
  --warm: #f07a2a;
  --warm-ink: #c85a14;
  --measure: 34rem;
  --stage: 60rem;
  --serif: "Source Serif 4", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --hand: "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", var(--serif);
  --display: "Playfair Display", "Songti SC", "STSong", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16161b;
    --paper-deep: #1e1e25;
    --ink: #dcdbe3;
    --ink-soft: #8f8d9d;
    --ink-faint: #45434f;
    --warm: #ff8a3d;
    --warm-ink: #ff9b57;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16161b; --paper-deep: #1e1e25; --ink: #dcdbe3; --ink-soft: #8f8d9d;
  --ink-faint: #45434f; --warm: #ff8a3d; --warm-ink: #ff9b57; color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/2 var(--serif);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-underline-offset: 0.3em; text-decoration-thickness: 1px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 1.5px dashed var(--warm-ink); outline-offset: 4px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 10; background: var(--paper); padding: 4px 8px; }

/* ---------- header ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 18px clamp(16px, 4vw, 40px);
  font-size: 0.8125rem; letter-spacing: 0.12em;
  background: linear-gradient(var(--paper) 55%, transparent);
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.mark { font-size: 1.05rem; letter-spacing: 0.3em; }
.top nav { display: flex; gap: 20px; align-items: baseline; }
.top nav a, .top nav button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-soft); text-decoration: none; letter-spacing: 0.12em; }
.top nav a:hover, .top nav button:hover { color: var(--ink); }

/* ---------- stations ---------- */
main { padding: 0 16px; }
.station { position: relative; max-width: var(--stage); margin: 0 auto; padding: 18vh 0 6vh; }
.prose { position: relative; max-width: var(--measure); margin: 0 auto; }
.prose p { margin: 0 0 1.35em; }
.stage-wrap { position: relative; margin: 8vh auto; max-width: 48rem; }
.stage { display: block; width: 100%; height: auto; overflow: visible; }

.ink { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.ink .faint, .ink.faint { stroke: var(--ink-faint); }
.ink text { fill: var(--ink); stroke: none; font: 13px var(--hand); letter-spacing: 0.1em; }
.ink text.tiny { font: 9px var(--serif); letter-spacing: 0.2em; fill: var(--ink-soft); }
.warm-fill { fill: var(--warm); stroke: var(--warm); }
.warm-stroke { stroke: var(--warm) !important; }

/* lines draw themselves when a station comes into view */
.js .stage .draw { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 1.8s cubic-bezier(.6,.05,.3,1) calc(var(--i, 0) * 45ms); }
.js .seen .stage .draw { stroke-dashoffset: 0; }
.js .stage .warm-fill { opacity: 0; transition: opacity .8s ease 1.2s; }
.js .seen .stage .warm-fill { opacity: 1; }

/* ---------- cover ---------- */
/* The title hangs beside the door like a name plate; both stand on one ground line. */
.cover {
  min-height: 100vh; min-height: 100svh;
  display: grid; grid-template-columns: auto auto; grid-template-rows: 1fr auto auto auto;
  grid-template-areas: ". ." "door text" "ground ground" "hint hint";
  justify-content: center; column-gap: clamp(40px, 7vw, 112px);
  padding: 12vh 0 7vh;
}
.cover-door { grid-area: door; height: min(50vh, 420px); width: auto; align-self: end; }
.cover-text { grid-area: text; align-self: end; padding-bottom: clamp(24px, 6vh, 64px); }
/* Each line steps closer to the door, as if drawn toward it. */
.cover h1 { font: 400 clamp(2rem, 4.4vw, 3.6rem)/1.4 var(--display); letter-spacing: 0.06em; margin: 0; }
.cover h1 span { display: block; white-space: nowrap; }
.cover h1 span:nth-child(1) { padding-left: 3.4em; }
.cover h1 span:nth-child(2) { padding-left: 1.7em; }
.js .cover h1 span { opacity: 0; translate: 0.6em 0; transition: opacity 1.2s ease, translate 1.6s cubic-bezier(.2,.7,.2,1); }
.js .cover h1 span:nth-child(2) { transition-delay: .35s; }
.js .cover h1 span:nth-child(3) { transition-delay: .7s; }
.js .seen h1 span { opacity: 1; translate: 0 0; }
/* the signature sits lower right, where a Chinese letter is signed */
.byline { text-align: right; margin: 1.6em 0 0; color: var(--ink-soft); font-size: 0.8125rem; letter-spacing: 0.2em; }
.ground { grid-area: ground; height: 1.3px; background: var(--ink); margin: 0 -8vw; transform-origin: left; }
.js .ground { transform: scaleX(0); transition: transform 1.6s cubic-bezier(.6,.05,.3,1); }
.js .seen .ground { transform: none; }
.hint { grid-area: hint; justify-self: center; display: flex; align-items: center; gap: 12px; margin: 6vh 0 0; color: var(--ink-soft); font: 0.95rem var(--hand); }
.hint .arrow { width: 14px; height: 32px; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(6px); } }
.cover-door .warm-fill { animation: glow 4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .55; } }

/* ---------- the second voice ---------- */
.aside {
  font: 1.15rem/1.6 var(--hand);
  color: var(--warm-ink);
  letter-spacing: 0.06em;
  transform: rotate(-2.5deg);
  transform-origin: left center;
}
.aside.echo { margin: -0.4em 0 1.6em 1.2em; font-size: 1.05rem; }
.aside.echo::before { content: "—— "; opacity: .6; }
.aside.inline { margin: 1.6em 0 1.8em -0.4em; font-size: 1.3rem; }
.aside.big { font-size: clamp(1.35rem, 2.6vw, 1.75rem); line-height: 1.7; margin: 2em 0 2.4em; transform: rotate(-1.5deg); }
@media (min-width: 1080px) {
  .aside.echo { position: absolute; width: 12rem; margin: 0; transform: translateY(-5.2em) rotate(-3deg); }
  .aside.echo::before { content: none; }
  .aside.echo[data-side="right"] { left: calc(100% + 3.5rem); }
  .aside.echo[data-side="left"] { right: calc(100% + 3.5rem); text-align: right; transform: translateY(-5.2em) rotate(2.5deg); transform-origin: right center; }
}

.chapter { max-width: var(--measure); margin: 0 auto 2.2em; font: 400 1.6rem/1.5 var(--display); letter-spacing: 0.08em; }
.chapter .num { display: block; font: italic 400 0.85rem var(--display); color: var(--ink-soft); letter-spacing: 0.2em; margin-bottom: 0.4em; }
.said { font-size: 1.45rem; line-height: 1.8; margin: 1.6em 0 1.4em !important; }
.why { font: 400 clamp(2rem, 5vw, 3.2rem)/1.4 var(--display); margin: 1.2em 0 1em !important; }

/* ---------- photos ---------- */
.photo { margin: 2.6em 0; }
.photo img { display: block; width: 100%; height: auto; background: var(--paper-deep); }
.photo.narrow { width: 62%; }
.tilt-r { transform: rotate(0.8deg); }
.tilt-l { transform: rotate(-1deg); margin-left: auto; }
.photo.final { max-width: 40rem; margin: 10vh auto 0; }
.photo figcaption { display: flex; align-items: center; gap: 10px; margin-top: 12px; font: 1rem var(--hand); color: var(--warm-ink); }
.photo figcaption svg { width: 64px; }

/* ---------- ice cream ---------- */
.cone { cursor: pointer; outline: none; }
.cone .drip { transform-box: fill-box; transform-origin: top; transform: scaleY(0.15); transition: transform 2.6s cubic-bezier(.3,.7,.3,1); }
.cone .d2 { transition-delay: .3s; }
.cone:hover .drip, .cone:focus .drip, .cone.melting .drip { transform: scaleY(2.4); }
.cone:focus-visible { outline: none; }
.cone:focus-visible > path:first-child { stroke-dasharray: 3 3; stroke: var(--ink); }

/* ---------- door ---------- */
.door-leaf { fill: var(--paper); stroke: var(--ink); }
#door-handle { cursor: grab; }
.pebbles circle, .pebbles ellipse { stroke: var(--ink-soft); stroke-width: 1; }
.welcome { opacity: 0; transition: opacity .6s ease; }
.opened .welcome { opacity: 1; transition-delay: .8s; }
.shoes path { fill: var(--ink); stroke: var(--ink); transition: transform 1s ease, opacity 1s ease; }
.pull {
  position: absolute; left: 50%; bottom: -3.2em; transform: translateX(-50%);
  background: none; border: 0; border-bottom: 1px solid currentColor; padding: 2px 0; cursor: pointer;
  font: 1rem var(--hand); letter-spacing: 0.12em; color: var(--ink);
}
.pull[hidden] { display: none; }
.js .gated { display: none; }
.js .gated.open { display: block; animation: rise .9s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.detours { display: flex; gap: 28px; margin: 0.4em 0 1.6em; }
.detour { display: grid; justify-items: start; gap: 4px; background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink-soft); font: 0.95rem var(--hand); }
.detour svg { width: 90px; height: 60px; transition: transform .4s ease; }
.detour:hover svg, .detour[aria-expanded="true"] svg { transform: translateY(-3px) rotate(-3deg); }
.detour[aria-expanded="true"] { color: var(--warm-ink); }
.detour-note { border-left: 1px solid var(--ink-faint); padding-left: 1.2em; margin: 0 0 1.6em; color: var(--ink-soft); font-size: 0.97rem; }
.detour-note:not([hidden]) { animation: rise .6s ease both; }

.choice { display: flex; gap: 14px; flex-wrap: wrap; margin: 2.4em 0 1em; }
.choice button {
  background: none; border: 1px solid var(--ink); border-radius: 999px; padding: 0.35em 1.3em; cursor: pointer;
  font: 1rem var(--hand); letter-spacing: 0.12em; transition: background .3s, color .3s;
}
.choice button:hover { background: var(--ink); color: var(--paper); }
.choice[data-done] button { opacity: .35; pointer-events: none; }
.choice[data-done] button[aria-pressed="true"] { opacity: 1; background: var(--ink); color: var(--paper); }

/* ---------- phone ---------- */
.phone-wrap { max-width: 46rem; }
.phone-fill { fill: var(--paper); }
.keypad rect { fill: none; stroke: var(--ink-soft); stroke-width: 1; }
.cord { stroke-width: 1.1; }
.hold {
  display: block; margin: 1.6em auto 0; background: none; border: 1px solid var(--ink); border-radius: 999px;
  padding: 0.45em 1.4em; cursor: pointer; font: 1rem var(--hand); letter-spacing: 0.12em;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.listening .hold { background: var(--ink); color: var(--paper); }
.line-voice {
  min-height: 3.4em; max-width: 34rem; margin: 1.4em auto 0; text-align: center;
  font-size: 1.05rem; line-height: 1.7; letter-spacing: 0.05em; color: var(--ink-soft);
}
.line-voice .blur { filter: blur(2.6px); opacity: .7; }
.line-voice .heard { color: var(--warm-ink); font-family: var(--hand); font-size: 1.2em; filter: none; }
.line-voice .heard small { font-size: .7em; margin-left: 2px; }
.line-voice .gone { opacity: 0; transition: opacity 1.2s ease; }
.orange { fill: var(--warm); stroke: none; }

/* ---------- piano ---------- */
.piano-keys rect { fill: var(--paper); stroke: var(--ink); stroke-width: 1; cursor: pointer; transition: fill .15s; }
.piano-keys rect.black { fill: var(--ink); }
.piano-keys rect.down { fill: var(--warm); }
.sea { animation: sea 7s ease-in-out infinite; }
@keyframes sea { 50% { transform: translateX(10px); } }
.stage-note { text-align: center; color: var(--ink-soft); font: 0.95rem var(--hand); letter-spacing: 0.1em; }

/* ---------- window ---------- */
.zoom-track { height: 220vh; position: relative; }
.zoom-sticky { position: sticky; top: 0; height: 100vh; display: grid; place-items: center; overflow: hidden; }
.zoom { max-width: 60rem; overflow: hidden !important; }
#zoom-world * { vector-effect: non-scaling-stroke; }
.fishy { fill: var(--warm); stroke: var(--warm-ink); stroke-width: .8; }
.water { stroke: var(--ink-soft); }
.reveal-line { position: absolute; bottom: 12vh; left: 0; right: 0; text-align: center; font: 1.3rem var(--hand); color: var(--warm-ink); opacity: 0; transition: opacity .8s ease; margin: 0; }
.reveal-line.show { opacity: 1; }

.wall { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 52rem !important; gap: clamp(12px, 3vw, 40px); max-width: var(--stage); margin: 10vh auto; padding: clamp(20px, 4vw, 48px); border: 1px solid var(--ink-faint); }
.pane { aspect-ratio: 3 / 4; overflow: hidden; border: 1.3px solid var(--ink); outline: 6px solid var(--paper); outline-offset: -8px; position: relative; }
.pane::after { content: ""; position: absolute; inset: 0; background: linear-gradient(var(--ink), var(--ink)) 50% 0 / 1.3px 100% no-repeat, linear-gradient(var(--ink), var(--ink)) 0 50% / 100% 1.3px no-repeat; opacity: .8; pointer-events: none; transition: opacity .5s; }
.pane img { width: 120%; height: 120%; object-fit: cover; transform: translate(calc(-8% + var(--x, 0) * 8%), calc(-8% + var(--y, 0) * 8%)); filter: grayscale(.85) contrast(.9); opacity: .7; transition: filter .6s, opacity .6s; }
.pane:hover img, .pane.looking img { filter: none; opacity: 1; }
.pane:hover::after, .pane.looking::after { opacity: .15; }

/* ---------- sound ---------- */
.waves path { stroke: var(--warm); opacity: 0; animation: wave 2.4s ease-out infinite; }
.waves path:nth-child(2) { animation-delay: .4s; }
.waves path:nth-child(3) { animation-delay: .8s; }
@keyframes wave { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
.speaker { cursor: pointer; outline: none; }
.speaker .hit { fill: transparent; stroke: none; }
.speaker:hover path, .speaker:focus-visible path { stroke-width: 2; }
.speaker:focus-visible .hit { stroke: var(--warm-ink); stroke-dasharray: 3 4; }
.clip { max-width: 22rem; margin: 3em auto 0; }
.clip video { width: 100%; display: block; background: #000; }

/* ---------- collection ---------- */
.collection { list-style: none; padding: 0; margin: 4em auto; max-width: 48rem; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.collection li { display: grid; justify-items: center; gap: 8px; text-align: center; font: 0.85rem/1.4 var(--hand); color: var(--ink-soft); opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .6s; transition-delay: calc(var(--i) * 140ms); }
.seen .collection li, .collection.seen li { opacity: 1; transform: none; }
.collection svg { width: 60px; height: 50px; }

/* the breeze: everything written by hand sways once */
.breeze .aside, .breeze .collection svg, .breeze .photo, .breeze .walker { animation: sway 3.2s ease-in-out 1; }
@keyframes sway { 30% { translate: 5px 0; rotate: .8deg; } 65% { translate: -3px 0; rotate: -.5deg; } }

.end { max-width: var(--measure); margin: 12vh auto 16vh; padding: 0 16px; color: var(--ink-soft); font-size: 0.875rem; }

/* ---------- walker ---------- */
.walker { position: fixed; left: clamp(10px, 3vw, 36px); bottom: 20px; width: 34px; z-index: 4; pointer-events: none; transition: opacity .6s; }
.walker svg { width: 100%; height: auto; overflow: visible; }
.walker .leg, .walker .arm { transform-box: view-box; transform-origin: 20px 42px; }
.walker .arm { transform-origin: 20px 24px; }
.walker .foot { fill: var(--ink); }
.walker.socks .foot { fill: var(--warm); stroke: var(--warm); }
.walker.walking .l1, .walker.walking .a2 { animation: stride .5s ease-in-out infinite alternate; }
.walker.walking .l2, .walker.walking .a1 { animation: stride .5s ease-in-out infinite alternate-reverse; }
.walker.walking svg { animation: bob .25s ease-in-out infinite alternate; }
@keyframes stride { from { rotate: -16deg; } to { rotate: 16deg; } }
@keyframes bob { to { translate: 0 -1.5px; } }
.walker.back svg { transform: scaleX(-1); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  body { font-size: 1rem; }
  .cover { grid-template-columns: 1fr; grid-template-rows: 1fr auto auto auto auto; grid-template-areas: "." "door" "ground" "text" "hint"; justify-items: center; }
  .cover-door { height: min(38vh, 300px); }
  .cover-text { padding: 5vh 0 0; }
  .ground { margin: 0 -16px; justify-self: stretch; }
  .station { padding-top: 12vh; }
  .wall { grid-template-columns: repeat(2, 1fr); }
  .collection { grid-template-columns: repeat(3, 1fr); row-gap: 24px; }
  .walker { width: 18px; left: 3px; bottom: 8px; }
  .photo.narrow { width: 80%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  .zoom-track { height: auto; }
  .zoom-sticky { position: static; height: auto; }
}
.cushion { fill: var(--paper); }
