/* One family (DM Sans, variable). Weights used: 200 thin, 300 light, 700 bold. Self-hosted. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url('/fonts/dm-sans-latin.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-display: swap;
  font-weight: 100 1000;
  src: url('/fonts/dm-sans-latin-ext.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
    U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens (contrast checked for WCAG AA in both themes) ---------- */
:root {
  --bg: #ffffff;
  --text: #121212;
  --muted: #55554f;        /* 7:1 on --bg */
  --line: rgb(18 18 18 / 0.22);
  --surface: #f5f5f4;
  --code: #1d4ed8;         /* "code" accent: blue in light (6.7:1 on --bg), green in dark */
  --draft: #8a4b00;

  --font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* System monospace: no extra download. */
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Cascadia Code', 'JetBrains Mono', Menlo, Consolas, monospace;
  --thin: 200;
  --light: 300;
  --bold: 700;

  --text-base: clamp(0.9375rem, 0.92rem + 0.1vw, 1rem);
  --text-small: 0.8125rem;
  --text-lede: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  --text-display: clamp(1.75rem, 1.1rem + 1.7vw, 2.625rem);
  --text-work: clamp(1.5rem, 1.05rem + 1.2vw, 2.125rem);
  --text-h1: clamp(2.5rem, 1.6rem + 3.5vw, 4.5rem);

  --measure: 38rem;
  --page: 64rem;
  --edge: clamp(1.5rem, 8vw, 9rem);
  --radius: 6px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000000;
    --text: #f2f2ef;
    --muted: #a6a6a0;
    --line: rgb(242 242 239 / 0.28);
    --surface: #141414;
    --code: #6fe3a4;
    --draft: #f0b36a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #000000;
  --text: #f2f2ef;
  --muted: #a6a6a0;
  --line: rgb(242 242 239 / 0.28);
  --surface: #141414;
  --code: #6fe3a4;
  --draft: #f0b36a;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: var(--light) var(--text-base) / 1.6 var(--font);
  transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: var(--thin); }
strong, b { font-weight: var(--bold); }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: text-decoration-color 0.2s;
}
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip { position: absolute; left: -9999px; z-index: 10; }
.skip:focus { left: var(--edge); top: 0.5rem; background: var(--bg); padding: 0.25rem 0.5rem; }

.label {
  font-size: 0.75rem;
  font-weight: var(--bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 1rem;
  line-height: 1.4;
}

.badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: var(--bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--draft);
  border: 1px solid currentColor;
  border-radius: 99px;
  padding: 0.05em 0.6em;
  vertical-align: middle;
  line-height: 1.5;
}

/* ---------- Home: full screen, four corners ---------- */
.home {
  min-height: 100dvh;
  padding: clamp(2rem, 7vh, 5rem) var(--edge);
  display: grid;
  grid-template-columns: minmax(24rem, 1fr) auto;
  grid-template-rows: auto auto 1fr auto;
  /* Top: the bike alone in the top-right corner (it is also the theme switch), then the text with contact chips.
     Bottom: work on the left, ask your AI in the bottom-right corner. */
  grid-template-areas:
    'contact scene'
    'intro   intro'
    '.     .'
    'work  ask';
  overflow-x: clip;
  gap: 1rem clamp(2.5rem, 7vw, 9rem);
}
.home__intro { grid-area: intro; align-self: start; margin-top: clamp(1rem, 4vh, 3rem); }
.home__scene { grid-area: scene; align-self: start; justify-self: end; }
.intro-hi { display: inline; font: inherit; letter-spacing: inherit; color: var(--text); }
.home__contact { grid-area: contact; align-self: end; padding-bottom: 0.1em; } /* sits on the bike's road */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem clamp(1.5rem, 3vw, 2.5rem); }
.chips a {
  font-size: 0.875rem;
  line-height: 1.3;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.chips a:hover, .chips a:focus-visible { color: var(--text); }
.home__ask { grid-area: ask; align-self: end; justify-self: end; text-align: right; font-size: 0.875rem; }
.home__ask .mcp { justify-content: flex-end; }
.home__ask .mcp__url { white-space: nowrap; overflow-wrap: normal; }
.home__ask .howto { text-align: left; }

/* Panels of the ask block (how to connect, conversation) open above it, over the empty space, without moving the layout */
@media (min-width: 761px) {
  .home__ask { position: relative; }
  .home__ask .demo,
  .home__ask .howto {
    position: absolute; right: 0; bottom: calc(100% + 1rem);
    width: min(30rem, 70vw); max-width: none; margin: 0;
    background: var(--bg); padding: 1rem 1.25rem;
    border: 1px solid var(--line); border-radius: var(--radius); z-index: 2;
  }
}

/* "// see a conversation" and the transcript it opens */
.mcp__more { margin: 0.35rem 0 0; }
.link-code {
  appearance: none; border: 0; background: none; padding: 0; cursor: pointer;
  font-family: var(--mono); font-size: 0.8125rem; font-weight: var(--thin); color: var(--muted);
  transition: color 0.2s;
}
.link-code:hover, .link-code[aria-expanded='true'] { color: var(--code); }
.demo {
  margin-top: 0.9rem; max-width: 30rem; text-align: left;
  font-family: var(--mono); font-size: 0.75rem; font-weight: var(--thin); line-height: 1.55;
  color: var(--muted);
}
.demo p { margin: 0 0 0.45rem; }
.demo__note { color: var(--muted); opacity: 0.8; }
.demo__user { color: var(--text); }
.demo__tool { color: var(--code); padding-left: 1ch; }
.demo__ai { font-family: var(--font); font-size: 0.875rem; font-weight: var(--light); color: var(--text); margin-top: 0.6rem; }
@media (prefers-reduced-motion: no-preference) {
  .demo:not([hidden]) { animation: enter 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
}

/* Case hint: on hover the company line turns into a code comment with the key numbers */
.work__meta { position: relative; }
.work__company, .work__hint { transition: opacity 0.25s; }
.work__hint {
  position: absolute; right: 1.5rem; top: 50%; transform: translateY(-50%);
  opacity: 0; pointer-events: none; font-family: var(--mono); font-weight: var(--thin); text-transform: none;
  letter-spacing: -0.02em; font-size: 0.75rem; color: var(--code); white-space: nowrap;
}
.work__item:hover .work__company, .work__item:focus-visible .work__company { opacity: 0; }
.work__item:hover .work__hint, .work__item:focus-visible .work__hint { opacity: 1; }
.work__hint-slash { display: none; }
@media (hover: none) {
  .work__company { opacity: 0; }
  .work__hint { opacity: 1; }
}
/* Phones: the comment goes under the title, one part per line */
@media (max-width: 760px) {
  .work .work__item { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 0.5rem; }
  .work .work__title { grid-column: 1; grid-row: 1; }
  .work .work__meta { display: contents; }
  .work .work__meta::after { display: none; }
  .work .work__item::after { content: '→'; grid-column: 2; grid-row: 1; font-weight: var(--light); color: var(--text); }
  .work__company { display: none; }
  .work .work__hint { position: static; transform: none; opacity: 1; grid-column: 1 / -1; grid-row: 2; white-space: normal; line-height: 1.5; }
  .work__hint-part { display: block; }
  .work__hint-dot { display: none; }
  .work__hint-slash { display: inline; }
}
.home__work { grid-area: work; align-self: end; width: 100%; max-width: 34rem; }

.hello {
  font-size: var(--text-lede);
  font-weight: var(--light);
  color: var(--muted);
  margin-bottom: 0.75rem;
}
.lede {
  font-size: clamp(2.25rem, 1.2rem + 2.2vw, 3.5rem);
  font-weight: var(--thin);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin-bottom: 1rem;
  text-wrap: balance;
}
.positioning {
  font-size: 0.6875rem;
  font-weight: var(--bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.intro-text {
  font-size: clamp(1.25rem, 0.7rem + 1.05vw, 1.875rem);
  font-weight: var(--thin);
  color: var(--muted);
  line-height: 1.5;
  letter-spacing: -0.01em;
  max-width: none;
  margin-bottom: 0;
}
.aside {
  color: var(--code);
  font-family: var(--mono);
  font-weight: var(--thin);
  font-size: clamp(1rem, 0.7rem + 0.75vw, 1.5rem);
  line-height: 1.4;
  letter-spacing: -0.02em;
  margin-bottom: clamp(2rem, 5vh, 3.5rem);
}
.intro-text .code {
  font-family: var(--mono);
  font-size: 0.9em;
  font-weight: var(--thin);
  letter-spacing: -0.03em;
  color: var(--code);
}
.caret { margin-left: 0.05em; }
/* Wide screens: the "whole loop" line sits on its own line */
@media (min-width: 761px) {
  .intro-text .code { display: block; }
  .intro-text .code + br { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .caret { animation: blink 1.1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
}

.contact-list { list-style: none; margin: 0; padding: 0; line-height: 2.1; }

.home .label { font-size: 0.6875rem; letter-spacing: 0.1em; margin-bottom: 1.25rem; }
.home__ask p:not(.label):not(.fineprint) { line-height: 1.7; }
.fineprint { margin-top: 1.5rem; font-size: 0.6875rem; color: var(--muted); }

/* MCP address: green mono line + copy icon */
.mcp { display: flex; align-items: center; gap: 0.35rem; margin: 0; }
.mcp__url { font-family: var(--mono); font-size: 0.875rem; color: var(--code); overflow-wrap: anywhere; user-select: all; }
.mcp__copy {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: var(--muted); padding: 0.4rem; margin: -0.1rem 0; line-height: 0; border-radius: 4px;
  transition: color 0.2s;
}
.mcp__copy:hover { color: var(--text); }
.icon { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.icon--check, .is-copied .icon--copy { display: none; }
.is-copied .icon--check { display: block; color: var(--code); }
.howto { margin-top: 0.75rem; font-size: 0.8125rem; color: var(--muted); max-width: 24rem; }
.howto ol { margin: 0; padding-left: 1.1rem; line-height: 1.6; }
.howto li { margin-bottom: 0.35rem; }
.howto strong { color: var(--text); font-weight: var(--bold); }
.mcp__help[aria-expanded='true'] { color: var(--text); }
@media (prefers-reduced-motion: no-preference) {
  .howto:not([hidden]) { animation: enter 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ASCII scene (home: cyclist, pages: runner), green "code" colour, no frame.
   Sun/moon top right is the theme switch; the actor runs in place while the road scrolls under it. */
.frame {
  --frame-size: 0.8125rem;
  --road-speed: 0.8s;
  position: relative;
  display: inline-grid;
  grid-template-columns: 24ch;
  font-family: var(--mono);
  font-size: var(--frame-size);
  line-height: 1.15;
  color: var(--code);
}
.frame .pre { display: block; margin: 0; white-space: pre; }
.frame--toggle {
  appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer;
  font-family: var(--mono); text-align: left; transition: opacity 0.2s;
}
.frame--toggle:hover { opacity: 0.75; }
.frame--toggle .frame__sky { padding: 0.15em 0; }
.frame__sky {
  justify-self: end;
  appearance: none; border: 0; background: none; padding: 0.15em 0; cursor: pointer;
  font: inherit; line-height: inherit; color: inherit; transition: opacity 0.2s;
}
.frame__sky:hover { opacity: 0.7; }
.frame .sky--moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .frame .sky--sun { display: none; }
  :root:not([data-theme='light']) .frame .sky--moon { display: block; }
}
:root[data-theme='dark'] .frame .sky--sun { display: none; }
:root[data-theme='dark'] .frame .sky--moon { display: block; }
.frame .frame__actor { justify-self: start; margin-left: 5ch; margin-top: 0.3em; transition: transform 0.14s ease-in-out; }
.frame .frame__actor.is-up { transform: translateY(-0.18em); }
.frame__home { justify-self: start; text-decoration: none; color: inherit; }
.frame__home .frame__actor { margin-left: 5ch; }
.frame__road { display: block; overflow: hidden; opacity: 0.7; margin-top: 0.15em; }
.frame--run { --road-speed: 1.1s; }
@media (prefers-reduced-motion: no-preference) {
  .is-moving .frame__road .pre { animation: road var(--road-speed) linear infinite; }
  @keyframes road { to { transform: translateX(-8ch); } }
  /* A soft, continuous float on the bike so it doesn't feel frozen between frames */
  .is-moving.frame--bike .frame__actor { animation: float 0.9s ease-in-out infinite alternate; }
  @keyframes float { to { transform: translateY(-0.12em); } }
}
.top .frame { --frame-size: 0.75rem; }
.frame--mini { grid-template-columns: auto; }
.top { align-items: flex-end; }
.top__back { font-size: var(--text-small); text-decoration: none; color: var(--muted); padding-bottom: 0.1rem; transition: color 0.2s; }
.top__back:hover { color: var(--text); }

.work { list-style: none; margin: 0; padding: 0; }
.work li { border-bottom: 1px solid var(--line); }
.work__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 1rem;
  padding-block: 1.1rem 0.9rem;
  text-decoration: none;
}
.work__title {
  font-size: var(--text-work);
  font-weight: var(--thin);
  letter-spacing: -0.03em;
  line-height: 1.05;
  white-space: nowrap;
  transition: font-weight 0.35s ease, letter-spacing 0.35s ease;
}
.work__meta {
  font-size: 0.6875rem;
  font-weight: var(--bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.work__meta::after {
  content: '→';
  font-weight: var(--light);
  font-size: 1rem;
  letter-spacing: 0;
  color: var(--text);
  transition: transform 0.25s;
}
.work__item:hover .work__title,
.work__item:focus-visible .work__title { font-weight: var(--light); letter-spacing: -0.035em; }
.work__item:hover .work__meta::after,
.work__item:focus-visible .work__meta::after { transform: translateX(0.3rem); }

/* ---------- Home entrance: elements drift in one after another ---------- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes enter { from { opacity: 0; transform: translateY(0.6rem); } }
  .is-home .hello,
  .is-home .lede,
  .is-home .positioning,
  .is-home .intro-text,
  .is-home .home__contact,
  .is-home .home__scene .frame,
  .is-home .home__work .label,
  .is-home .work li,
  .is-home .home__ask {
    animation: enter 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .is-home .positioning { animation-delay: 0.35s; }
  .is-home .home__scene .frame { animation-delay: 0.1s; animation-duration: 1.6s; }
  .is-home .home__contact { animation-delay: 0.3s; }
  .is-home .intro-text { animation-delay: 0.5s; }
  .is-home .home__work .label { animation-delay: 0.8s; }
  .is-home .work li:nth-child(1) { animation-delay: 0.9s; }
  .is-home .work li:nth-child(2) { animation-delay: 1s; }
  .is-home .work li:nth-child(3) { animation-delay: 1.1s; }
  .is-home .work li:nth-child(n + 4) { animation-delay: 1.2s; }
  .is-home .home__ask { animation-delay: 1.3s; }
}

/* ---------- Inner pages (case, CV) ---------- */
.is-page .top,
.is-page main,
.is-page .foot {
  max-width: calc(var(--page) + 2 * var(--edge));
  margin-inline: auto;
  padding-inline: var(--edge);
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2rem;
  font-size: var(--text-small);
}
.is-page main { padding-block: clamp(4rem, 12vh, 8rem) 4rem; }

.case__head { margin-bottom: 3rem; }
.case__head h1 { font-size: var(--text-h1); letter-spacing: -0.03em; margin-bottom: 1.25rem; text-wrap: balance; }
.case__summary { font-size: var(--text-lede); line-height: 1.4; margin-bottom: 2rem; }

.facts { display: grid; gap: 0.4rem; margin: 0; font-size: 0.9375rem; }
.facts div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; }
.facts dt { color: var(--muted); font-weight: var(--bold); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 0.2em; }
.facts dd { margin: 0; }

.metrics {
  list-style: none;
  margin: 0 0 3.5rem;
  padding: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1.5rem;
  border-block: 1px solid var(--line);
}
.metrics li { display: flex; flex-direction: column; gap: 0.35rem; }
.metrics__value { font-size: var(--text-h1); font-weight: var(--thin); line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.metrics__label { font-size: var(--text-small); color: var(--muted); line-height: 1.35; }

/* A case with no open sections reads as one narrow column; chapter cases keep the full width */
.prose--cv, .is-page main > .case:not(:has(.case__section)):not(.case--chapters) { max-width: 44rem; }
.case__head { max-width: none; }
.case__summary { max-width: none; }
.case__head .facts { max-width: 44rem; }
.case__section {
  display: grid;
  grid-template-columns: minmax(9rem, 1fr) minmax(0, 3fr);
  gap: 0 clamp(1.5rem, 4vw, 4rem);
  margin-bottom: 3rem;
}
.case__section .prose { max-width: 42rem; }
.case__more .prose { max-width: 42rem; margin-left: auto; margin-right: 0; }
.case__section h2,
.case__more h2 {
  font-size: 0.75rem;
  font-weight: var(--bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  line-height: 1.4;
}
.case__section h2 { margin-bottom: 0.9rem; padding-top: 0.25rem; }

.case__more { border-top: 1px solid var(--line); padding-block: 1rem; }
.case__more:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: 2.75rem; }
.case__more summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.case__more summary::-webkit-details-marker { display: none; }
.case__more summary::after { content: '+'; color: var(--muted); }
.case__more[open] summary::after { content: '−'; }
.case__more .prose { margin-top: 0.9rem; }

/* Images and loops: full case width, caption as a code comment */
.case__media { margin: 0 0 3.5rem; }
.case__media--narrow { max-width: 36rem; }

/* 3D runner: same box as the video it replaces */
.runner__stage { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: var(--line); }
.runner.is-3d .runner__stage { background: none; }
.runner__stage video { width: 100%; height: 100%; border-radius: 0; }
.runner__canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.runner__canvas:active { cursor: grabbing; }
.runner__bar { margin-top: 0.75rem; font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.runner__kms { display: flex; gap: 1.25rem; margin-bottom: 0.4rem; }
.runner__km {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.runner__km[aria-pressed='true'] { color: var(--text); text-decoration: underline; text-underline-offset: 0.3em; }
.runner__km:hover { color: var(--text); }
.runner__stats { margin: 0; line-height: 1.6; }
.runner__vo, .runner__note { color: var(--code); }.case__media img,
.case__media video,
.media-slot {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 10px;
  background: var(--line);
}
.media-slot {
  display: grid;
  place-items: center;
  background: none;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
  padding: 1.5rem;
  text-align: center;
}
.case__media figcaption {
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--code);
}

.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 1em; }
.prose li { margin-bottom: 0.5rem; }
.prose li::marker { color: var(--muted); }
.prose--cv h1 { font-size: var(--text-h1); letter-spacing: -0.03em; margin-bottom: 1rem; }
.prose--cv h2 { font-size: 0.75rem; font-weight: var(--bold); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 3rem 0 1rem; }
.prose--cv h3 { font-size: var(--text-base); font-weight: var(--bold); margin: 1.75rem 0 0.25rem; line-height: 1.4; }

.case__nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  margin-top: 3rem;
  border-top: 1px solid var(--line);
}
.foot { padding-block: 2rem 3rem; font-size: 0.75rem; color: var(--muted); }

/* ---------- Short laptop screens: tighter vertical rhythm, still no scroll ---------- */
@media (min-width: 761px) and (max-height: 820px) {
  .home { padding-block: clamp(1.5rem, 4vh, 2.5rem); gap: 0.75rem clamp(2.5rem, 7vw, 9rem); }
  .intro-text { font-size: clamp(1.125rem, 0.6rem + 1.15vw, 1.75rem); }
  .lede { font-size: clamp(2rem, 1.1rem + 2.2vw, 3.25rem); }
  .aside { margin-bottom: 1.75rem; }
  .intro-text { margin-bottom: 0; }
  .home .label { margin-bottom: 0.9rem; }
  .work__item { padding-block: 0.6rem 0.5rem; }
  .work__title { font-size: clamp(1.375rem, 1rem + 0.9vw, 1.75rem); }
  .fineprint { margin-top: 1rem; }
}

/* ---------- Small screens: one column, page may scroll ---------- */
@media (max-width: 760px) {
  .home {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: 'scene' 'contact' 'intro' 'work' 'ask';
    grid-template-rows: auto;
    gap: 3.5rem;
    padding-top: 1.5rem;
  }
  .home__contact { margin-top: -2.5rem; } /* close to the scene above it */
  .home__intro { margin-top: -1rem; }
  .home__ask { justify-self: stretch; margin-top: 0; }
  .home__ask { text-align: left; }
  .home__scene { grid-area: scene; justify-self: start; }
  .home__ask .mcp { justify-content: flex-start; }
  .home__ask .mcp__url { white-space: normal; overflow-wrap: anywhere; }
  .home__work { align-self: start; margin-top: 0; }
  .case__section { grid-template-columns: minmax(0, 1fr); }
  .contact-list { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; line-height: 1.6; }
  .home__work { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- /stats (private) ---------- */
.muted { color: var(--muted); }
.stats { max-width: 64rem; margin: 0 auto; padding: clamp(1.5rem, 5vw, 4rem) clamp(1rem, 4vw, 3rem); font-size: 0.875rem; }
.stats section { margin-block: 2.5rem; }
.stats__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; margin: 2rem 0; }
.kpis div { border-top: 1px solid var(--line); padding-top: 0.75rem; }
.kpis dt { color: var(--muted); font-size: 0.75rem; }
.kpis dd { margin: 0.25rem 0 0; font-size: 2rem; font-weight: var(--thin); font-variant-numeric: tabular-nums; }
.stats__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); column-gap: 3rem; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 10rem) 1fr 2.5rem; align-items: center; gap: 0.75rem; padding-block: 0.3rem; }
.bars__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { height: 2px; background: var(--line); }
.bars__fill { display: block; height: 100%; background: var(--text); }
.bars__n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.note { border-top: 1px solid var(--line); padding-block: 0.9rem; }
.note__meta { margin: 0; color: var(--muted); font-size: 0.75rem; }
.note__msg { margin: 0.4rem 0 0; white-space: pre-wrap; }
.log { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.log th { text-align: left; font-weight: var(--bold); color: var(--muted); }
.log th, .log td { padding: 0.4rem 0.6rem 0.4rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.log code { color: var(--code); word-break: break-word; }
@media (max-width: 760px) { .log th:nth-child(4), .log td:nth-child(4) { display: none; } }
.runner__hint { margin-left: auto; opacity: 0.7; }

/* ---------- Chapters: one product told as a series of steps ----------
   The chapter list on the left, content on the right; the list stays in view and lights up the chapter you're reading. */
.case__book {
  display: grid;
  grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
}
.case__flow { min-width: 0; }
.case__flow > .prose { max-width: 42rem; margin-bottom: 3.5rem; }
.case__toc { position: sticky; top: 2rem; order: -1; }
.chapters__label {
  font-size: 0.75rem; font-weight: var(--bold); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 1rem;
}
.chapters ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.chapters a {
  display: grid; grid-template-columns: 2ch 1fr; gap: 0.75rem;
  font-size: var(--text-small); line-height: 1.35;
  text-decoration: none; color: var(--muted); transition: color 0.25s;
}
.chapters a:hover { color: var(--text); }
.chapters a[aria-current='true'] { color: var(--text); }
.chapters a[aria-current='true'] .chapters__n { opacity: 1; }
.chapters__n, .chapter__n { font-family: var(--mono); color: var(--code); font-weight: var(--thin); }
.chapters__n { opacity: 0.5; transition: opacity 0.25s; }
.chapter { border-top: 1px solid var(--line); padding-top: 2.5rem; margin-bottom: 3.5rem; scroll-margin-top: 2rem; }
.chapter__title {
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.25rem);
  font-weight: var(--thin);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 1.25rem;
  text-wrap: balance;
}
.chapter__title .chapter__n { display: block; font-size: 0.8125rem; letter-spacing: 0; margin-bottom: 0.6rem; }
.chapter .prose { max-width: 42rem; }
.chapter .prose p strong:first-child { color: var(--text); }
/* Fixed chapter bar: small screens only */
.chapter-bar { display: none; }
@media (max-width: 900px) {
  .chapter-bar {
    display: block;
    position: fixed; inset: 0 0 auto 0; z-index: 10;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    transform: translateY(-100%);
    transition: transform 0.25s ease;
  }
  .chapter-bar.is-visible { transform: none; }
  .chapter-bar__toggle {
    display: flex; align-items: baseline; gap: 0.75rem; width: 100%;
    padding: 0.85rem var(--edge);
    background: none; border: 0; color: var(--text); text-align: left; cursor: pointer;
    font: inherit; font-size: var(--text-small);
  }
  .chapter-bar__n { font-family: var(--mono); color: var(--code); flex: none; }
  .chapter-bar__t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chapter-bar__caret { color: var(--muted); transition: transform 0.2s; }
  .chapter-bar__toggle[aria-expanded='true'] .chapter-bar__caret { transform: rotate(180deg); }
  .chapter-bar__list {
    list-style: none; margin: 0; padding: 0.25rem var(--edge) 1rem;
    display: grid; gap: 0.15rem; max-height: 70vh; overflow-y: auto;
  }
  .chapter-bar__list[hidden] { display: none; }
  .chapter-bar__list a {
    display: grid; grid-template-columns: 2ch 1fr; gap: 0.75rem; padding: 0.5rem 0;
    font-size: var(--text-small); color: var(--muted); text-decoration: none;
  }
  .chapter-bar__list a[aria-current='true'] { color: var(--text); }
  .chapter { scroll-margin-top: 3.5rem; }
}
@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  .chapter-bar { transition: none; }
}
@media (max-width: 900px) {
  /* Narrow: the list goes back on top of the chapters, not sticky */
  .case__book { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .case__toc { position: static; order: -1; margin-bottom: 3rem; }
}

/* ---------- Layered case images: base + floating parts ---------- */
.layered__box { position: relative; width: 100%; border-radius: 10px; overflow: hidden; background: #0a0a0a; }
.layered__base { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0 !important; background: none !important; }
.case__media .layered__float { position: absolute; display: block; height: auto; background: none; border-radius: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .layered .layered__float { opacity: 0; transform: translateY(8%) scale(0.97); }
  .layered.is-in .layered__float {
    opacity: 1; transform: none;
    transition: opacity 0.7s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
    transition-delay: calc(var(--i) * 0.18s + 0.1s);
    animation: drift 6s ease-in-out calc(var(--i) * 0.6s + 1.4s) infinite alternate;
  }
  @keyframes drift { from { translate: 0 0; } to { translate: 0 -1.2%; } }
}

/* ---------- Real UI, as it is ---------- */
/* Same height for every screen; long screens show their top. Scrolls sideways on small screens. */
.ui-gallery__row {
  display: flex; gap: clamp(0.75rem, 2vw, 1.5rem); justify-content: center; align-items: flex-start;
  overflow-x: auto; scrollbar-width: none;
}
.case__media .ui-gallery__row img {
  flex: none; height: clamp(16rem, 34vw, 28rem); width: auto;
  aspect-ratio: 409 / 868; object-fit: cover; object-position: top;
  border-radius: 0; background: none;
}
@media (max-width: 760px) { .ui-gallery__row { justify-content: flex-start; } }
