/* Bitwright Studios — "Dusk at the Slipway"
   Crisp modern layout, pixel details: stepped corners, hard shadows,
   dithered fills, step-timed motion. */

@font-face { font-family: "Pixelify Sans"; src: url("/assets/fonts/pixelify-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Silkscreen"; src: url("/assets/fonts/silkscreen.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("/assets/fonts/atkinson-hyperlegible-next.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/assets/fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #f4ecdc;          /* sailcloth */
  --surface: #e9dec6;     /* driftwood */
  --surface-2: #e3d5ba;
  --ink: #1e2a33;         /* tarred ink */
  --muted: #4f5f67;       /* bilge */
  --accent: #e8a33d;      /* lantern */
  --accent-ink: #1e2a33;
  --hot: #c8452f;         /* signal red */
  --link: #22686e;        /* harbor teal (darkened for contrast) */
  --labs: #2a747b;
  --on-hot: #fff8ec;
  --on-labs: #fff8ec;
  --line: #1e2a33;
  --shadow: #1e2a33;
  --dither-a: #f4ecdc;
  --dither-b: #e3d5ba;
  --night: #141a2e;
  --px: 4px;              /* one "pixel" of UI chrome */
  --font-pixel: "Pixelify Sans", ui-monospace, monospace;
  --font-tiny: "Silkscreen", ui-monospace, monospace;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121c26; --surface: #1d2b38; --surface-2: #243545; --ink: #ede3cf;
    --muted: #8ea0a8; --accent: #f2b24c; --accent-ink: #121c26; --hot: #e2634a;
    --link: #5cb5b8; --labs: #5cb5b8; --line: #ede3cf; --shadow: #070b10;
    --dither-a: #121c26; --dither-b: #1d2b38; --on-hot: #121c26; --on-labs: #10202b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121c26; --surface: #1d2b38; --surface-2: #243545; --ink: #ede3cf;
  --muted: #8ea0a8; --accent: #f2b24c; --accent-ink: #121c26; --hot: #e2634a;
  --link: #5cb5b8; --labs: #5cb5b8; --line: #ede3cf; --shadow: #070b10;
  --dither-a: #121c26; --dither-b: #1d2b38; --on-hot: #121c26; --on-labs: #10202b; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--font-body);
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--link); text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 2px no-repeat; transition: background-size .3s steps(5); }
a:hover { background-size: 100% 2px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; box-shadow: 0 0 0 6px var(--accent); }
main:focus { outline: none; }
main p a, main li a, main dd a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; background: none; }
main p a:hover, main li a:hover { color: var(--hot); }
section[id] { scroll-margin-top: 5rem; }

h1, h2, h3 { text-wrap: balance; font-family: var(--font-pixel); font-weight: 600; line-height: 1.1; margin: 0 0 .5em; letter-spacing: .01em; }
h1 { font-size: clamp(2.6rem, 7vw, 4.75rem); }
h2 { font-size: clamp(1.9rem, 4.2vw, 2.75rem); }
h3 { font-size: 1.45rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
.lede { font-size: 1.2rem; color: var(--muted); max-width: 38rem; }

.wrap { width: min(72rem, 100% - 2rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 99; }
.skip:focus { left: 1rem; }

/* ---------- tiny labels (cargo tags) */
.tag {
  display: inline-block;
  font: 400 .72rem/1 var(--font-tiny);
  text-transform: uppercase; letter-spacing: .06em;
  padding: .45em .8em .4em 1.1em;
  background: var(--accent); color: var(--accent-ink);
  clip-path: polygon(8px 0, 100% 0, 100% 100%, 8px 100%, 0 50%);
}
.tag.teal { background: var(--labs); color: var(--on-labs); }
.eyebrow.on-dark { color: #9fd6d2; }
.eyebrow { font: 400 .8rem/1 var(--font-tiny); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-bottom: 1rem; display: flex; align-items: center; gap: .6rem; }
.eyebrow::before { content: ""; flex: none; width: 12px; height: 12px; background: var(--accent); box-shadow: 4px 4px 0 var(--hot); }

/* ---------- buttons */
.btn {
  --s: 4px;
  display: inline-flex; align-items: center; gap: .6rem;
  font: 600 1.05rem/1 var(--font-pixel); text-transform: uppercase; letter-spacing: .04em;
  padding: .95rem 1.4rem; color: var(--accent-ink); background: var(--accent);
  border: 3px solid var(--line);
  box-shadow: var(--s) var(--s) 0 var(--shadow), inset 0 -4px 0 rgba(0, 0, 0, .14);
  position: relative; overflow: hidden;
  transition: transform .12s steps(2), box-shadow .12s steps(2), background-color .12s steps(2);
  cursor: pointer;
}
.btn:hover { background-color: var(--hot); color: var(--on-hot); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow), inset 0 4px 0 rgba(0, 0, 0, .14); }
.btn.ghost { background-color: transparent; color: var(--ink); }
.btn.ghost:hover {
  color: var(--ink);
  background-color: transparent;
  background-image: conic-gradient(var(--surface-2) 25%, transparent 0 50%, var(--surface-2) 0 75%, transparent 0);
  background-size: 4px 4px; background-position: 0 0;
}
.btn .arrow { width: 14px; height: 14px; }
.btn:hover .arrow { animation: nudge .5s steps(2) infinite; }
@keyframes nudge { 50% { transform: translateX(3px); } }

/* ---------- nav */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-bottom: 3px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 4.25rem; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .7rem; color: var(--ink); font: 600 1.35rem/1 var(--font-pixel); background: none; }
.brand img { width: 36px; height: 36px; image-rendering: pixelated; }
.brand small { display: block; text-transform: uppercase; font: 400 .62rem/1 var(--font-tiny); letter-spacing: .14em; color: var(--muted); margin-top: .25rem; }
.nav-links { display: flex; align-items: center; gap: 1.4rem; list-style: none; margin: 0; padding: 0; }
.nav-links a { color: var(--ink); font: 400 .8rem/1 var(--font-tiny); text-transform: uppercase; letter-spacing: .08em; padding: .4rem 0; }
.nav-links a[aria-current="page"] { background-size: 100% 3px; background-image: linear-gradient(var(--accent), var(--accent)); }
.theme-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--surface); border: 3px solid var(--line); box-shadow: 3px 3px 0 var(--shadow); cursor: pointer; color: var(--ink);
}
.theme-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
@media (max-width: 380px) {
  .brand > span { display: none; }
}
@media (max-width: 640px) {
  .nav-links { gap: .9rem; }
  .nav-links .hide-sm { display: none; }
  .brand small { display: none; }
}

/* ---------- hero */
.hero { position: relative; padding: clamp(2.5rem, 6vw, 5rem) 0 clamp(3rem, 6vw, 5rem); overflow: hidden; }
.hero::before { /* dithered bayer backdrop fading to the bottom */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: conic-gradient(var(--dither-b) 25%, transparent 0 50%, var(--dither-b) 0 75%, transparent 0);
  background-size: 8px 8px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 10%, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 10%, #000 100%);
}
.hero-grid { display: grid; grid-template-columns: 1fr; gap: clamp(2rem, 4vw, 3.5rem); align-items: center; }
@media (min-width: 960px) {
  .hero-grid { grid-template-columns: 1fr auto; }
  .hero-grid .frame img { width: 480px; } /* whole-number scale (6x) keeps pixels square */
}
@media (min-width: 1160px) { .hero-grid .frame img { width: 640px; } /* 8x */ }
@media (max-width: 959px) { .hero-grid .frame { order: -1; margin-bottom: 1rem; } }
.hero h1 { line-height: 1.02; text-shadow: 4px 4px 0 var(--surface-2); }
.hero h1 .hl { color: var(--hot); }
.hero .lede { color: var(--ink); opacity: .85; font-size: 1.25rem; }
.hero .actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }

.frame { /* pixel picture frame around the shipyard */
  position: relative; background: var(--night); padding: 8px;
  border: 3px solid var(--line); box-shadow: 8px 8px 0 var(--shadow);
}
.frame img { width: 100%; height: auto; image-rendering: pixelated; aspect-ratio: 16 / 9; }
.game-frame { display: block; background-image: none; }
.game-frame img { aspect-ratio: auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.5rem; }
.hero-grid .frame { margin-bottom: 1.25rem; }
.frame .cap { box-shadow: 3px 3px 0 var(--shadow);
  position: absolute; left: 14px; bottom: -14px; font: 400 .7rem/1 var(--font-tiny);
  text-transform: uppercase; letter-spacing: .1em; padding: .5em .8em; background: var(--accent); color: var(--accent-ink); border: 3px solid var(--line);
}
.frame .live { position: absolute; right: 14px; bottom: -14px; display: flex; gap: .5rem; align-items: center; font: 400 .7rem/1 var(--font-tiny); color: #ede3cf; letter-spacing: .1em; padding: .5em .8em; background: var(--night); border: 3px solid var(--line); }
@media (max-width: 520px) { .frame .live { display: none; } }
.frame .live i { width: 8px; height: 8px; background: var(--hot); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- divider: rope */
.rope {
  height: 12px; margin: 0;
  background:
    linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 8px) 0 4px / 8px 4px repeat-x,
    linear-gradient(90deg, transparent 0 4px, var(--muted) 4px 8px) 0 0 / 8px 4px repeat-x,
    linear-gradient(90deg, transparent 0 4px, var(--muted) 4px 8px) 0 8px / 8px 4px repeat-x;
  opacity: .55; border: 0;
}

/* ---------- sections */
section { padding: clamp(3.5rem, 8vw, 6rem) 0; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem 2rem; margin-bottom: 2.5rem; }
.section-head p { max-width: 34rem; color: var(--muted); margin: 0; }
.alt { position: relative; background-color: var(--surface); }
.alt::before, .alt::after { /* dithered edge: the page colour dissolves into the band */
  content: ""; position: absolute; left: 0; right: 0; height: 16px; pointer-events: none;
  background: conic-gradient(var(--bg) 25%, transparent 0 50%, var(--bg) 0 75%, transparent 0) 0 0 / 16px 16px;
}
.alt::before { top: 0; }
.alt::after { bottom: 0; transform: scaleY(-1); }

/* ---------- cards */
.grid { display: grid; gap: 1.75rem; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); }
.card {
  position: relative; background: var(--bg); padding: 1.75rem 1.6rem 1.6rem;
  border: 3px solid var(--line); box-shadow: 6px 6px 0 var(--shadow);
  transition: transform .15s steps(2), box-shadow .15s steps(2);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--shadow); }
.card::before, .card::after { /* rivets */
  content: ""; position: absolute; left: 8px; right: 8px; top: 8px; height: 4px;
  background:
    linear-gradient(var(--muted), var(--muted)) 0 0 / 4px 4px no-repeat,
    linear-gradient(var(--muted), var(--muted)) 100% 0 / 4px 4px no-repeat;
}
.card::after { top: auto; bottom: 8px; }
.card .tag { margin-bottom: .9rem; }
.card h3 { margin-top: .9rem; }
.card p:last-child { margin-bottom: 0; }
.card .icon { width: 60px; height: 60px; padding: 6px; box-sizing: content-box; background: var(--surface); border: 3px solid var(--line); }
.card { --c: var(--accent); background-image: linear-gradient(var(--c), var(--c)); background-size: 100% 6px; background-repeat: no-repeat; }
.card:nth-child(3n+2) { --c: var(--hot); }
.card:nth-child(3n+3) { --c: var(--labs); }

/* ---------- the slipway (first game) */
.slip > *, .hero-grid > * { min-width: 0; }
.slip { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 900px) { .slip { grid-template-columns: 1fr 1fr; } }
.blueprint {
  position: relative; aspect-ratio: 4 / 3; border: 3px solid var(--line); box-shadow: 8px 8px 0 var(--shadow);
  background-color: #1b3a52;
  background-image:
    linear-gradient(rgba(159, 214, 210, .18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(159, 214, 210, .18) 1px, transparent 1px);
  background-size: 16px 16px;
  display: grid; place-items: center; overflow: hidden;
}
.blueprint .plan { position: absolute; inset: 14% 8% 10%; width: 84%; height: 76%; color: rgba(159, 214, 210, .55); }
.blueprint .q { font: 600 18px/1 var(--font-pixel); fill: #ede3cf; animation: bob 2s steps(2) infinite; }
@keyframes bob { 50% { transform: translateY(-2px); } }
.blueprint .stamp {
  position: absolute; right: 1rem; bottom: 1rem; transform: rotate(-6deg);
  font: 400 .8rem/1 var(--font-tiny); color: var(--accent); border: 3px solid var(--accent); padding: .5em .7em; letter-spacing: .1em;
}
.blueprint .corner { position: absolute; left: 1rem; top: 1rem; font: 400 .7rem/1.6 var(--font-mono); color: rgba(237, 227, 207, .65); }
.facts { padding: 0; margin: 1.5rem 0 2rem; display: grid; gap: .6rem; }
.facts > div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 1rem; padding-bottom: .6rem; border-bottom: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent); }
.facts dd { margin: 0; }
.facts dt { font: 400 .75rem/1.9 var(--font-tiny); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* progress bar made of blocks */
.blocks { display: flex; flex-wrap: wrap; gap: 3px; padding-top: .35rem; }
.blocks i { width: 13px; height: 13px; background: var(--surface-2); border: 2px solid var(--line); }
.blocks i.on { background: var(--accent); }

/* ---------- log entries */
.log { display: grid; gap: 1.25rem; position: relative; padding-left: 1.75rem; }
.log::before { content: ""; position: absolute; left: 4px; top: 0; bottom: 0; width: 4px; background: repeating-linear-gradient(var(--muted) 0 4px, transparent 4px 8px); opacity: .6; }
.entry { position: relative; }
.entry::before { content: ""; position: absolute; left: calc(-1.75rem - 2px); top: 1.55rem; width: 12px; height: 12px; background: var(--hot); border: 3px solid var(--line); }
.entry:hover { transform: translateX(4px); }
.entry {
  display: grid; grid-template-columns: auto 1fr; gap: .25rem 1.5rem; padding: 1.25rem 1.5rem;
  background: var(--bg); border: 3px solid var(--line); box-shadow: 5px 5px 0 var(--shadow);
}
.entry time { font: 400 .72rem/2 var(--font-tiny); letter-spacing: .08em; color: var(--hot); grid-row: span 2; min-width: 6.5rem; }
.entry h3 { font-size: 1.2rem; margin: 0; }
.entry p { margin: 0; color: var(--muted); }
@media (max-width: 560px) { .entry { grid-template-columns: 1fr; } .entry time { grid-row: auto; } }

/* ---------- about */
.about { display: grid; gap: 2.5rem; align-items: start; }
@media (min-width: 860px) { .about { grid-template-columns: 220px 1fr; } }
.portrait { width: 220px; max-width: 60%; border: 3px solid var(--line); box-shadow: 6px 6px 0 var(--shadow), 14px 14px 0 var(--accent); background: var(--night); image-rendering: pixelated; }

/* ---------- labs strip */
.labs-strip {
  position: relative; padding: 3.25rem 2.5rem 2.5rem; color: #ede3cf;
  background-color: #17303f;
  background-image:
    linear-gradient(rgba(92, 181, 184, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 181, 184, .16) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 3px solid var(--line); box-shadow: 8px 8px 0 var(--shadow);
  display: grid; gap: 1.5rem; align-items: center;
}
@media (min-width: 820px) { .labs-strip { grid-template-columns: 1fr auto; } }
.labs-strip::before { /* bunting */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 8px;
  background: repeating-linear-gradient(90deg, #f2b24c 0 16px, #17303f 16px 24px, #e2634a 24px 40px, #17303f 40px 48px);
}
.labs-strip h2 { color: #ede3cf; }
.labs-strip p { color: #b9c7cc; margin: 0; max-width: 40rem; }
.labs-strip .btn { --line: #ede3cf; background-color: #5cb5b8; color: #10202b; }
.labs-strip .btn:hover { background-color: var(--accent); color: #10202b; }

/* ---------- footer */
.footer { background: var(--night); color: #ede3cf; border-top: 4px solid var(--accent); padding: 3rem 0 3.5rem; margin-top: 4rem; font-size: .95rem; position: relative; }
.footer .brand, .footer a { color: #ede3cf; }
.footer nav a { font: 400 .75rem/1 var(--font-tiny); text-transform: uppercase; letter-spacing: .1em; }
.footer .brand small { color: #8ea0a8; }
.footer :focus-visible { outline-color: #ede3cf; }
.footer::before { /* waves */
  content: ""; position: absolute; left: 0; right: 0; top: -15px; height: 12px;
  background:
    linear-gradient(90deg, transparent 0 8px, var(--accent) 8px 16px, transparent 16px 32px) 0 0 / 32px 4px repeat-x,
    linear-gradient(90deg, var(--accent) 0 8px, transparent 8px 16px, var(--accent) 16px 24px, transparent 24px 32px) 0 4px / 32px 4px repeat-x;
  opacity: .8; animation: tide 2.4s steps(4) infinite;
}
@keyframes tide { to { background-position: 32px 0, 32px 4px; } }
.footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem; align-items: center; }
.footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer small { color: #8ea0a8; }

/* ---------- labs page theme shift */
.labs-page { --accent: #5cb5b8; --accent-ink: #10202b; }
.labs-page .hero::before {
  background-image:
    linear-gradient(rgba(47, 127, 134, .2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 127, 134, .2) 1px, transparent 1px);
  background-image:
    linear-gradient(color-mix(in srgb, var(--labs) 22%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--labs) 22%, transparent) 1px, transparent 1px);
  background-size: 24px 24px;
}
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding-top: 3.25rem; }
.steps li::before {
  content: counter(s, decimal-leading-zero); position: absolute; top: 0; left: 0;
  font: 600 1.4rem/1 var(--font-pixel); width: 2.6rem; height: 2.6rem; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); border: 3px solid var(--line); box-shadow: 3px 3px 0 var(--shadow);
}
.steps li::after { content: ""; position: absolute; top: 1.2rem; left: 3.2rem; right: -1rem; height: 4px; background: repeating-linear-gradient(90deg, var(--muted) 0 6px, transparent 6px 12px); opacity: .5; }
.steps li:last-child::after { display: none; }
@media (max-width: 1000px) { .steps li::after { display: none; } }
.steps h3 { font-size: 1.25rem; margin-bottom: .3rem; }
.steps p { color: var(--muted); margin: 0; }
.term {
  min-width: 0; max-width: 100%;
  background: #0d1520; color: #cfe3e0; font: .9rem/1.7 var(--font-mono); padding: 1.25rem 1.5rem;
  border: 3px solid var(--line); box-shadow: 8px 8px 0 var(--shadow); white-space: pre-wrap;
}
@media (max-width: 480px) { .term { font-size: .78rem; padding: 1rem; } }
.term .k { color: #f2b24c; } .term .c { color: #6f8790; } .term .t { color: #5cb5b8; }
.checks { list-style: none; padding: 0; margin: 1rem 0 0; }
.checks li { position: relative; padding-left: 1.6rem; margin-bottom: .45rem; }
.checks li::before { content: ""; position: absolute; left: 0; top: .5em; width: 10px; height: 10px; background: var(--accent); box-shadow: 2px 2px 0 var(--shadow); }

/* ---------- prose (privacy) */
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.6rem; margin-top: 2.5rem; }
.prose h2 span { font: 400 .8rem/1 var(--font-mono); color: var(--muted); margin-right: .6rem; vertical-align: middle; }
.prose ul { padding-left: 1.2rem; }
.summary { padding: 1.5rem 1.75rem; background: var(--surface); border: 3px solid var(--line); box-shadow: 6px 6px 0 var(--shadow); margin: 2rem 0; }
.summary h2 { margin-top: 0; font-size: 1.3rem; }

/* ---------- reveal on scroll (stepped) */
/* blocks wipe up in pixel stairs, siblings one after another */
.js .reveal {
  opacity: 0; transform: translateY(24px); clip-path: inset(-40px -40px 100% -40px);
  transition: clip-path .55s steps(6), transform .55s steps(6), opacity .15s steps(2);
  transition-delay: calc(var(--i, 0) * 110ms);
}
.js .reveal.in { opacity: 1; transform: none; clip-path: inset(-40px); }
@media print { .reveal { opacity: 1 !important; transform: none !important; clip-path: none !important; } .motes, .nav, .voyage { display: none; } }

/* ---------- floating sawdust motes */
.motes { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.motes i { position: absolute; width: 4px; height: 4px; background: var(--accent); opacity: .35; animation: drift linear infinite; }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-110vh); } }
main, .footer { position: relative; z-index: 1; }


.h1-sm { font-size: clamp(2.2rem, 5vw, 3.2rem); }

/* ---------- 404 */
.lost { min-height: 60vh; display: grid; align-items: center; }
.lost-art { width: 128px; height: 128px; margin-bottom: 2rem; border: 3px solid var(--line); box-shadow: 6px 6px 0 var(--shadow); animation: bob 2s steps(2) infinite; }
.lost .actions { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }

@media (forced-colors: active) {
  .blocks i.on { background: Highlight; }
}

/* =====================================================================
   Motion. Everything moves in steps, like sprites on a grid.
   ===================================================================== */

/* page intro: the title builds word by word, the hero follows */
.js main h1.built .w { display: inline-block; animation: word-in .5s steps(5) both; animation-delay: calc(140ms + var(--i) * 85ms); }
@keyframes word-in {
  from { clip-path: inset(0 0 100% 0); transform: translateY(.45em); }
  to { clip-path: inset(-20% -10% -20% -10%); transform: none; }
}
.js .intro { animation: rise .5s steps(5) both; animation-delay: var(--d, 0ms); }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.js .boot { animation: boot .8s steps(8) both .2s; }
@keyframes boot { /* old screen switching on */
  0% { clip-path: inset(50% 0 50% 0); filter: brightness(1.8) saturate(0); }
  35% { clip-path: inset(48% 0 48% 0); filter: brightness(1.8) saturate(0); }
  100% { clip-path: inset(-24px); filter: none; }
}

/* moving between pages: old page lifts away, new page wipes up in stairs */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
.nav { view-transition-name: site-nav; }
::view-transition-old(root) { animation: vt-out .25s steps(3) both; }
::view-transition-new(root) { animation: vt-in .5s steps(7) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-16px); } }
@keyframes vt-in { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0); } }

/* theme switch: the new palette grows out of the button */
html.theme-vt .nav { view-transition-name: none; }
html.theme-vt::view-transition-old(root) { animation: none; }
html.theme-vt::view-transition-new(root) { animation: theme-in .65s steps(9) both; }
@keyframes theme-in {
  from { clip-path: circle(0 at var(--tx) var(--ty)); }
  to { clip-path: circle(var(--tr) at var(--tx) var(--ty)); }
}

/* header: a boat sails along the bottom edge as you scroll */
.voyage { position: absolute; left: 0; right: 0; bottom: -3px; height: 3px; pointer-events: none; }
.voyage .trail { position: absolute; left: 0; top: 0; height: 3px; width: calc(var(--p, 0) * 100%); background: var(--accent); }
.voyage .boat { position: absolute; bottom: 2px; left: calc(var(--p, 0) * (100% - 16px)); width: 16px; height: 14px; animation: bob 1.2s steps(2) infinite; }
.nav { transition: box-shadow .2s steps(2); }
.nav.scrolled { box-shadow: 0 6px 0 color-mix(in srgb, var(--shadow) 14%, transparent); }

/* hover details */
.btn::after { /* a glint sweeps across */
  content: ""; position: absolute; top: -20%; bottom: -20%; left: -40px; width: 10px;
  background: rgba(255, 255, 255, .45); box-shadow: 8px 0 0 rgba(255, 255, 255, .2);
  transform: skewX(-20deg); opacity: 0; pointer-events: none;
}
.btn:hover::after { animation: glint .55s steps(7); }
@keyframes glint { from { opacity: 1; left: -40px; } to { opacity: 1; left: calc(100% + 20px); } }
.card:hover .icon { animation: hop .5s steps(2); }
@keyframes hop { 50% { transform: translateY(-6px); } }
.brand:hover img { animation: bob .6s steps(2) infinite; }
.entry { transition: transform .15s steps(2); }

/* click sparks */
.spark { position: fixed; z-index: 100; width: 4px; height: 4px; margin: -2px 0 0 -2px; background: var(--c); pointer-events: none; animation: spark .45s steps(5) forwards; }
@keyframes spark { 70% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

/* code blocks type in line by line */
.term .ln { display: block; }
.js .term .ln { clip-path: inset(0 100% 0 0); }
.js .boot .ln, .js .term.seen .ln { animation: type .35s steps(10) both; animation-delay: calc(700ms + var(--i) * 140ms); }
.js .term.seen .ln { animation-delay: calc(250ms + var(--i) * 110ms); }
@keyframes type { to { clip-path: inset(0 -1ch 0 0); } }
.term .hop { animation: hl 7s step-end infinite; animation-delay: calc(var(--s) * 1s); padding: 0 2px; margin: 0 -2px; }
@keyframes hl { 0% { background: rgba(242, 178, 76, .28); } 14.28%, 100% { background: transparent; } }
.term .ln:first-child { color: #8ea0a8; }

/* progress blocks light up one by one */
.seen .blocks i.on { animation: light .2s steps(1) both; }
.seen .blocks i.on:nth-child(1) { animation-delay: .7s; }
.seen .blocks i.on:nth-child(2) { animation-delay: .9s; }
.seen .blocks i:not(.on):nth-child(3) { animation: blink 1s steps(1) infinite 1.1s; }
@keyframes light { from { background: var(--surface-2); } to { background: var(--accent); } }

/* labs steps: numbers pop in turn, connectors march */
.seen.steps li::before { animation: pop .4s steps(3) both; }
.seen.steps li:nth-child(2)::before { animation-delay: .15s; }
.seen.steps li:nth-child(3)::before { animation-delay: .3s; }
.seen.steps li:nth-child(4)::before { animation-delay: .45s; }
@keyframes pop { 0% { transform: scale(0); } 66% { transform: scale(1.2); } 100% { transform: scale(1); } }
.steps li::after { animation: march 1s steps(2) infinite; }
@keyframes march { to { background-position: 12px 0; } }

/* blueprint: a scan line passes over the drawing */
.blueprint::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: rgba(159, 214, 210, .45); box-shadow: 0 0 0 1px rgba(159, 214, 210, .12);
  animation: scan 4s steps(24) infinite;
}
@keyframes scan { from { top: 0; } to { top: calc(100% - 2px); } }

/* portrait gives a little wave now and then */
.portrait { animation: nod 6s steps(1) infinite; }
@keyframes nod { 0%, 92% { transform: none; } 94% { transform: translateY(-4px); } 96% { transform: none; } 98% { transform: translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .js .reveal { opacity: 1; transform: none; clip-path: none; }
  .js .term .ln { clip-path: none; }
  .motes, .voyage { display: none; }
}

/* code windows get a pixel title bar */
.term::before {
  content: ""; display: block; height: 14px; margin: -1.25rem -1.5rem 1rem; border-bottom: 3px solid #2a3a48;
  background:
    linear-gradient(#e2634a, #e2634a) 12px 4px / 6px 6px no-repeat,
    linear-gradient(#f2b24c, #f2b24c) 24px 4px / 6px 6px no-repeat,
    linear-gradient(#5cb5b8, #5cb5b8) 36px 4px / 6px 6px no-repeat,
    #17303f;
}
@media (max-width: 480px) { .term::before { margin: -1rem -1rem .8rem; } }

/* log: sticky heading on the left, timeline on the right */
@media (min-width: 900px) {
  .split { display: grid; grid-template-columns: 18rem 1fr; gap: 3rem; align-items: start; }
  .split > .section-head { display: block; position: sticky; top: 6.5rem; margin: 0; }
  .split > .section-head p { margin-top: 1rem; }
}
