/* Edgar. Day and night are two paintings of the same road. */

:root {
  --paper: #f5f0e4;
  --paper-2: #ebe3d1;
  --ink: #1b1714;
  --ink-2: #574d43;
  --rule: #cfc4ad;
  --red: #c42c37;
  --on-red: #fffaf2;
  --rope: #8b6b45;
  --skin: #e2bd8f;
  --focus: #1d4fb8;
  --sky: #bfe3f1;
  --name-ink: #1b1714;
  --pp: clamp(8px, 1.5vw, 22px);
  --bg-wide: url("/assets/media/bg/day-wide.a7dcb5afaf.webp");
  --bg-tall: url("/assets/media/bg/day-tall.ac8c6b28d1.webp");
  --mascot-light: none;
  --m-white: #fdfdfc;
  --m-shade: #c9c9c8;
  --m-skin: #ddb98c;
  --sleepy: 0;
  --lid: 0;
  --lash: 0;
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1160px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14172b; --paper-2: #1d2140; --ink: #f3ecdd; --ink-2: #b9b6c4; --rule: #373c63;
    --red: #e2505a; --on-red: #1a080a; --rope: #a98a62; --focus: #9db9ff; --sky: #14183a; --name-ink: #fbf3e2;
    --bg-wide: url("/assets/media/bg/night-wide.61da21510c.webp"); --bg-tall: url("/assets/media/bg/night-tall.bbf302ff97.webp");
    --mascot-light: brightness(.82) saturate(.88); --m-white: #cfcfce; --m-shade: #a5a5a3; --m-skin: #b3966f; --sleepy: .42; --lid: 1; --lash: 1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14172b; --paper-2: #1d2140; --ink: #f3ecdd; --ink-2: #b9b6c4; --rule: #373c63;
  --red: #e2505a; --on-red: #1a080a; --rope: #a98a62; --focus: #9db9ff; --sky: #14183a; --name-ink: #fbf3e2;
  --bg-wide: url("/assets/media/bg/night-wide.61da21510c.webp"); --bg-tall: url("/assets/media/bg/night-tall.bbf302ff97.webp");
  --mascot-light: brightness(.82) saturate(.88); --m-white: #cfcfce; --m-shade: #a5a5a3; --m-skin: #b3966f; --sleepy: .42; --lid: 1; --lash: 1;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 400 1.0625rem/1.6 var(--font); overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
h1, h2 { margin: 0; line-height: 1.1; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.4rem); }
p { margin: 0 0 1em; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -80px; z-index: 50; background: var(--ink); color: var(--paper); padding: 12px 16px; font-weight: 700; }
.skip:focus { top: calc(env(safe-area-inset-top) + 10px); }
.wrap { max-width: var(--max); margin-inline: auto; padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right)); }
.lede { color: var(--ink-2); margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 22px;
  font: 700 1rem/1.2 var(--font); text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--paper); border: 2px solid #1b1714; border-radius: 999px;
}
.btn:hover { background: var(--paper-2); }
.btn--red { background: var(--red); color: var(--on-red); }
.btn--red:hover { background: var(--red); filter: brightness(1.08); }
.btn[hidden] { display: none; }

/* bar */
.bar { display: flex; align-items: center; gap: 8px; max-width: var(--max); margin: 0 auto; padding: calc(10px + env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left)); }
.bar__nav { display: flex; gap: clamp(2px, 1vw, 14px); margin-inline: auto 4px; }
.bar__nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; font-weight: 600; text-decoration: none; }
.bar__nav a:hover { text-decoration: underline; }
.home .bar { position: absolute; inset: 0 0 auto; z-index: 5; }
.bar__mark svg { width: 104px; height: auto; }
.bar__mark { display: inline-flex; align-items: center; min-height: 44px; }
.home .bar__mark { display: none; }
.eyes { display: grid; place-items: center; min-height: 44px; min-width: 60px; padding: 0; border: 0; background: none; cursor: pointer; }
.eye__ball { fill: #fffdf8; }
.eye__rim { fill: none; stroke: #1b1714; stroke-width: 2.4; }
.eye__pupil { fill: #1b1714; transition: transform .3s; }
.eyes:hover .eye__pupil { transform: translate(-5px, -2px); }
.eye__lid { fill: var(--skin); transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(var(--lid)); transition: transform .28s; }
.eye__lash { fill: none; stroke: #1b1714; stroke-width: 2.2; stroke-linecap: round; opacity: var(--lash); }

/* scene */
.scene { position: relative; isolation: isolate; overflow: hidden; display: grid; justify-items: center; align-content: start; height: 100svh; min-height: 600px; max-height: 1200px; background: var(--sky); }
.scene__bg { position: absolute; inset: 0; z-index: -3; background: var(--bg-wide) 46% 100% / cover no-repeat; }
.scene__cover { position: absolute; inset: 0; z-index: 0; display: none; background: var(--paper); }
.scene__words { position: relative; z-index: 2; display: grid; justify-items: center; text-align: center; padding: clamp(64px, 9svh, 108px) 16px 0; }
.name { width: min(78vw, 46svh, 500px); }
.name svg { width: 100%; height: auto; overflow: visible; }
.name path, .bar__mark path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.name__ink path { stroke: var(--name-ink); stroke-width: 50; }
.name__fill path { stroke: #d3323d; stroke-width: 27; }
.scene__line { margin: 4px 0 16px; font-weight: 700; text-shadow: 0 0 10px var(--sky), 0 0 4px var(--sky); font-size: clamp(1.1rem, 1rem + .6vw, 1.35rem); }
.scene__go { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0; }
/* mascot: two layers of the original drawing plus live eyes, posed every frame by mascot.js */
.mascot { position: absolute; z-index: 1; bottom: -1px; left: 50%; height: min(50%, 600px); aspect-ratio: 349 / 576; translate: -50% 0; padding: 0; border: 0; background: none; cursor: default; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.mascot[data-over] { cursor: grab; }
.mascot[data-grab] { cursor: grabbing; }
.mascot__move, .mascot__head { position: absolute; inset: 0; display: block; will-change: transform; }
.mascot__move { transform-origin: 62% 100%; }
.mascot__head { transform-origin: 33% 40%; }
.mascot__layer { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; pointer-events: none; }
img.mascot__layer { filter: var(--mascot-light); }
.m-white { fill: var(--m-white); }
.m-shade { fill: var(--m-shade); }
.m-pupil { fill: #0c0b0a; transform-box: fill-box; transform-origin: center; }
.m-glint { fill: var(--m-white); }
.m-line, .m-edge { fill: none; stroke: #0c0b0a; stroke-width: 3; stroke-linecap: round; }
.m-skin { fill: var(--m-skin); }
.m-lid { transform: translateY(calc((var(--sleepy) - 1) * 88px)); }
.m-lid--r { transform: translateY(calc((var(--sleepy) - 1) * 46px)); }

/* clothesline */
.watch { overflow-x: clip; padding-block: clamp(48px, 8vw, 88px) clamp(40px, 6vw, 72px); }
.line { list-style: none; margin: 18px 0 30px; max-width: var(--max); margin-inline: auto; padding: 0 calc(var(--gutter) - var(--pp)); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 40px; }
.peg { position: relative; padding: 34px var(--pp) 0; }
/* one taut rope per row (each item draws it edge to edge, clipped by .watch) and one wooden peg */
.peg::before { content: ""; position: absolute; left: -100vw; right: -100vw; top: 17px; height: 3px; background: var(--rope); }
.peg::after { content: ""; position: absolute; left: 50%; top: 10px; width: 13px; height: 38px; translate: -50% 0; background: #d9b37c; border: 2px solid #1b1714; border-radius: 3px 3px 5px 5px; box-shadow: inset 0 -13px 0 #c49a60; z-index: 1; pointer-events: none; }
.peg__card { display: block; text-decoration: none; transform-origin: 50% -14px; }
.peg__card img { width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border: 2px solid #1b1714; background: var(--paper-2); margin-bottom: 10px; }
.peg__card strong { display: block; font-size: 1.06rem; line-height: 1.25; }
.peg__card:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.peg__meta { display: block; color: var(--ink-2); font-size: .9rem; line-height: 1.4; margin-top: 2px; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .peg__card:hover { animation: sway .9s ease-in-out; }
}
@keyframes sway { 0%, 100% { transform: none; } 25% { transform: rotate(2.2deg); } 60% { transform: rotate(-1.5deg); } 82% { transform: rotate(.6deg); } }
.more { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; }

.about { border-top: 1px solid var(--rule); }
.about__in { display: grid; grid-template-columns: 1fr 2fr; gap: 20px 40px; padding-block: clamp(44px, 7vw, 80px); }
.about p { max-width: 58ch; }
.about p:last-child { margin: 0; }
.foot { border-top: 1px solid var(--rule); padding: 22px max(var(--gutter), env(safe-area-inset-right)) calc(26px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 32px; max-width: var(--max); margin: 0 auto; color: var(--ink-2); font-size: .92rem; }
.foot p { margin: 0; }
.foot a { display: inline-flex; align-items: center; min-height: 44px; margin-right: 16px; }

/* player */
.screen { width: min(430px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 2px solid #1b1714; border-radius: 10px; background: var(--paper); color: var(--ink); overflow: hidden; }
.screen::backdrop { background: rgb(10 10 18 / .78); }
.screen__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; }
.screen__head h2 { font-size: 1.15rem; letter-spacing: -.01em; }
.screen__head p { margin: 0; font-size: .88rem; color: var(--ink-2); }
.screen__close { flex: none; width: 44px; height: 44px; display: grid; place-items: center; color: inherit; background: none; border: 0; cursor: pointer; }
.screen__close path { stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; fill: none; }
.screen__stage { position: relative; aspect-ratio: 9 / 16; width: 100%; max-height: calc(100dvh - 160px); min-height: 220px; overflow: hidden; background: #0d0b09; }
.screen__poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.34); }
.screen__stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; }
.screen__stage.is-live iframe { opacity: 1; }
.screen__stage.is-live .load { display: none; }
.screen__foot { margin: 0; padding: 2px 16px; font-weight: 600; }
.screen__foot a { display: inline-flex; align-items: center; min-height: 44px; }
.load { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 20px; text-align: center; color: #f6efe2; }
.load__msg { margin: 0; max-width: 30ch; }
.load__go { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.load .f { fill: #e2bd8f; stroke: #f6efe2; stroke-width: 1.6; visibility: hidden; }
.load .w { fill: #fffdf8; stroke: #1b1714; }
.load .p { fill: #1b1714; stroke: none; }
.load .f1 { animation: f1 .5s steps(1, end) infinite; }
.load .f2 { animation: f2 .5s steps(1, end) infinite; }
.load .f3 { animation: f3 .5s steps(1, end) infinite; }
@keyframes f1 { 0% { visibility: visible; } 25%, 100% { visibility: hidden; } }
@keyframes f2 { 0% { visibility: hidden; } 25% { visibility: visible; } 50% { visibility: hidden; } 75%, 100% { visibility: visible; } }
@keyframes f3 { 0% { visibility: hidden; } 50% { visibility: visible; } 75%, 100% { visibility: hidden; } }
.load.is-failed .f { animation: none; }
.load.is-failed .f3 { visibility: visible; }

/* docs, 404 */
.doc { max-width: 720px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) var(--gutter) 64px; }
.doc h1 { font-size: clamp(2.2rem, 1.8rem + 2vw, 3.2rem); margin-bottom: .4em; }
.doc h2 { font-size: 1.4rem; margin: 1.8em 0 .5em; scroll-margin-top: 16px; }
.doc li { margin-bottom: .5em; }
.doc ul { padding-left: 1.15em; }
.doc .scene__go { justify-content: flex-start; margin-top: 24px; }
.doc code { font-size: .92em; background: var(--paper-2); padding: 1px 5px; border-radius: 4px; }
.doc kbd { font: 600 .88em var(--font); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 6px; }
.toc { display: flex; flex-wrap: wrap; gap: 0 18px; border-block: 1px solid var(--rule); padding: 6px 0; margin: 20px 0; }
.toc a { display: inline-flex; align-items: center; min-height: 40px; }

/* theme change: night comes down from the sky, day comes up from the ground */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* boot: blank paper, the character pops up, the name is inked, then the background is painted in */
[data-boot] .scene__cover { display: block; animation: paint .5s cubic-bezier(.65, 0, .3, 1) 1.5s both; }
[data-boot] .mascot { transform-origin: 50% 100%; animation: popup 1.02s .08s both; }
[data-boot] .name path { stroke-dasharray: 1 2; animation: ink .26s cubic-bezier(.4, 0, .4, 1) both; }
[data-boot] .name .l1 { animation-delay: .72s; }
[data-boot] .name .l2 { animation-delay: .86s; }
[data-boot] .name .l3 { animation-delay: 1s; }
[data-boot] .name .l4 { animation-delay: 1.14s; }
[data-boot] .name .l5 { animation-delay: 1.28s; animation-duration: .18s; }
[data-boot] .bar, [data-boot] .scene__line, [data-boot] .scene__go { animation: show .25s ease-out 1.85s both; }
@keyframes paint { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 0 0 100%); visibility: hidden; } }
@keyframes ink { from { stroke-dashoffset: 1.02; visibility: hidden; } 1% { visibility: visible; } to { stroke-dashoffset: 0; visibility: visible; } }
@keyframes show { from { opacity: 0; } to { opacity: 1; } }
/* peek over the edge, sink back to wind up, spring into place */
@keyframes popup {
  0% { transform: translateY(100%) scale(1); animation-timing-function: cubic-bezier(.2, .9, .3, 1); }
  22% { transform: translateY(64%) scale(1); animation-timing-function: linear; }
  50% { transform: translateY(63%) scale(1); animation-timing-function: cubic-bezier(.5, 0, .7, .6); }
  64% { transform: translateY(84%) scale(1.03, .97); animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
  82% { transform: translateY(0) scale(.955, 1.07); animation-timing-function: ease-in-out; }
  91% { transform: translateY(0) scale(1.022, .972); animation-timing-function: ease-in-out; }
  100% { transform: translateY(0) scale(1); }
}

@media (max-width: 900px) {
  .line { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 30px; }
}
@media (max-aspect-ratio: 1 / 1) {
  .scene__bg { background-image: var(--bg-tall); background-position: 42% 100%; }
  .mascot { height: auto; width: min(58vw, 33svh); left: 48%; }
}
@media (max-width: 640px) {
  .bar { padding-inline: 8px; }
  .about__in { grid-template-columns: 1fr; gap: 10px; }
  .scene__words { padding-top: 74px; }
}
/* short, wide windows (phones on their side): words left, character right */
@media (max-height: 560px) and (min-aspect-ratio: 1 / 1) {
  .scene { min-height: 320px; justify-items: start; }
  .scene__words { justify-items: start; text-align: left; padding: 56px 0 0; margin-left: 35vw; }
  .scene__line { margin-bottom: 10px; }
  .scene .btn { padding-inline: 16px; min-height: 44px; }
  .scene__go { justify-content: flex-start; }
  .name { width: min(34vw, 56svh, 300px); }
  .mascot { left: 80%; height: 78%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .load .f3 { visibility: visible; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
