/* George Orfanakis — home page.
   Idea: "the long way", told as a film. A 3D landscape of contour lines (film.js) sits behind
   the page; scrolling flies the camera along the course, and every chapter of the story is a
   stretch of it. After the film the landscape fades into a flat contour map for the rest:
   results, work, university, smart home, finish.
   Project pages may have their own world (see emg.css); the typefaces are shared. */

@layer base, layout, components, sections, responsive, print;

@font-face {
  font-family: "Commissioner";
  src: url("../fonts/commissioner-var.woff2") format("woff2");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens: "first light" (light) and "night" (dark) ----------
   The page runs from night to first light: the hardest hours of the stories happen in the dark,
   in the cold and in open water. Ice blue is the course; warm dawn appears only at the finish.
   --g-* colour the 3D landscape (film.js reads them). data-accent swaps the course colour. */

:root {
  color-scheme: light;
  --paper: #eef1f4;
  --paper-2: #e2e7ed;
  --card: #f8fafb;
  --glass: rgba(248, 250, 251, 0.8);
  --line: rgba(12, 19, 32, 0.12);
  --line-strong: rgba(12, 19, 32, 0.26);
  --contour: rgba(60, 90, 130, 0.16);
  --ink: #0c1320;
  --ink-2: #344052;
  --ink-3: #556174;
  --route: #0a7cc1;          /* the course line, dots, fills */
  --route-text: #075e94;     /* text-safe on paper and cards */
  --route-soft: rgba(10, 124, 193, 0.12);
  --route-btn: #7cccf5;      /* button fill, dark text on it */
  --on-route: #06121e;
  --finish-bg: #0c1320;
  --finish-ink: #eef1f4;
  --finish-accent: #8fd6ff;
  --trail: #0f7a6b;          /* sea green, text-safe */
  --scrim: rgba(238, 241, 244, 0.9);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 20px 44px -28px rgba(12, 30, 60, 0.35);
  --g-sky-top: #b9cde0;
  --g-sky-horizon: #eef1f4;
  --g-ground: #e9eef3;
  --g-minor: #c6d2de;
  --g-major: #8ea6bf;
  --g-water: #c2d9e9;
  --g-water-line: #7eaed0;
  --g-route: var(--route);
  --g-dawn: #ffc89e;
  --g-star: #ffffff;
  --g-stars: 0;
  --g-additive: 0;
  --g-ahead: 0.35;
  --radius: 18px;
  --radius-lg: 26px;
  --gutter: clamp(16px, 5vw, 96px);
  --wrap: 1200px;
  --font-display: "Commissioner", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Commissioner", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #060912;
    --paper-2: #0e1420;
    --card: #0d131e;
    --glass: rgba(10, 15, 24, 0.78);
    --line: rgba(220, 232, 245, 0.12);
    --line-strong: rgba(220, 232, 245, 0.26);
    --contour: rgba(120, 160, 210, 0.12);
    --ink: #e8eef5;
    --ink-2: #b8c3d1;
    --ink-3: #8a96a8;
    --route: #7fd0ff;
    --route-text: #8fd6ff;
    --route-soft: rgba(127, 208, 255, 0.14);
    --route-btn: #8fd6ff;
    --on-route: #04121c;
    --finish-bg: #f6e3d0;
    --finish-ink: #0c1320;
    --finish-accent: #94400e;
    --trail: #6fd6c0;
    --scrim: rgba(6, 9, 18, 0.86);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 44px -28px rgba(0, 0, 0, 0.9);
    --g-sky-top: #02040a;
    --g-sky-horizon: #0c1526;
    --g-ground: #08101c;
    --g-minor: #17304a;
    --g-major: #2c5a84;
    --g-water: #04182b;
    --g-water-line: #2c78a8;
    --g-dawn: #ff9d6b;
    --g-star: #dfe9ff;
    --g-stars: 1;
    --g-additive: 1;
    --g-ahead: 0.28;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #060912;
  --paper-2: #0e1420;
  --card: #0d131e;
  --glass: rgba(10, 15, 24, 0.78);
  --line: rgba(220, 232, 245, 0.12);
  --line-strong: rgba(220, 232, 245, 0.26);
  --contour: rgba(120, 160, 210, 0.12);
  --ink: #e8eef5;
  --ink-2: #b8c3d1;
  --ink-3: #8a96a8;
  --route: #7fd0ff;
  --route-text: #8fd6ff;
  --route-soft: rgba(127, 208, 255, 0.14);
  --route-btn: #8fd6ff;
  --on-route: #04121c;
  --finish-bg: #f6e3d0;
  --finish-ink: #0c1320;
  --finish-accent: #94400e;
  --trail: #6fd6c0;
  --scrim: rgba(6, 9, 18, 0.86);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 44px -28px rgba(0, 0, 0, 0.9);
  --g-sky-top: #02040a;
  --g-sky-horizon: #0c1526;
  --g-ground: #08101c;
  --g-minor: #17304a;
  --g-major: #2c5a84;
  --g-water: #04182b;
  --g-water-line: #2c78a8;
  --g-dawn: #ff9d6b;
  --g-star: #dfe9ff;
  --g-stars: 1;
  --g-additive: 1;
  --g-ahead: 0.28;
}

/* Other course colours to compare: add ?accent=volt or ?accent=ember to the address. */
:root[data-accent="volt"] { --route: #6a8f00; --route-text: #4b6500; --route-soft: rgba(106, 143, 0, 0.12); --route-btn: #c8f03a; --on-route: #0c1320; --finish-accent: #d4ff3f; }
:root[data-accent="ember"] { --route: #e2550b; --route-text: #ad3f08; --route-soft: rgba(226, 85, 11, 0.1); --route-btn: #f06a1d; --on-route: #15171b; --finish-accent: #ff7a2e; }
@media (prefers-color-scheme: dark) {
  :root[data-accent="volt"]:not([data-theme="light"]) { --route: #d4ff3f; --route-text: #d4ff3f; --route-soft: rgba(212, 255, 63, 0.12); --route-btn: #d4ff3f; --on-route: #121a00; --finish-accent: #4b6500; }
  :root[data-accent="ember"]:not([data-theme="light"]) { --route: #ff7a2e; --route-text: #ff9a5c; --route-soft: rgba(255, 122, 46, 0.12); --route-btn: #ff7a2e; --on-route: #1a0b02; --finish-accent: #ad3f08; }
}
:root[data-theme="dark"][data-accent="volt"] { --route: #d4ff3f; --route-text: #d4ff3f; --route-soft: rgba(212, 255, 63, 0.12); --route-btn: #d4ff3f; --on-route: #121a00; --finish-accent: #4b6500; }
:root[data-theme="dark"][data-accent="ember"] { --route: #ff7a2e; --route-text: #ff9a5c; --route-soft: rgba(255, 122, 46, 0.12); --route-btn: #ff7a2e; --on-route: #1a0b02; --finish-accent: #ad3f08; }

/* ---------- base ---------- */

@layer base {
  *, *::before, *::after { box-sizing: border-box; }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
  }

  body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
    overflow-x: hidden;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
  }

  /* The contour map: a seamless tile used as a mask, coloured by --contour. */
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-color: var(--contour);
    -webkit-mask: url("../img/home/topo.svg") 0 0 / 900px 900px repeat;
    mask: url("../img/home/topo.svg") 0 0 / 900px 900px repeat;
  }

  img, svg { display: block; max-width: 100%; }
  img { height: auto; }
  figure { margin: 0; }
  p { margin: 0; }

  a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  a:hover { color: var(--route-text); }

  :focus-visible {
    outline: 3px solid var(--route);
    outline-offset: 3px;
    border-radius: 6px;
  }

  h1, h2, h3, h4 {
    font-family: var(--font-display);
    line-height: 1.1;
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.015em;
  }

  .mono {
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.02em;
    line-height: 1.5;
  }

  .skip {
    position: absolute;
    left: 12px; top: 12px;
    z-index: 100;
    padding: 12px 18px;
    background: var(--ink);
    color: var(--paper);
    border-radius: 999px;
    text-decoration: none;
    clip-path: inset(50%);
  }
  .skip:focus { clip-path: none; color: var(--paper); }

  .sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
}

/* ---------- layout ---------- */

@layer layout {
  .wrap {
    width: min(var(--wrap), calc(100% - 2 * var(--gutter)));
    margin-inline: auto;
  }

  section { padding-block: 132px 0; }

  .km {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--route-text);
    font-weight: 600;
  }
  /* a checkpoint flag */
  .km::before {
    content: "";
    width: 12px; height: 12px;
    border: 2px solid var(--route);
    background: var(--paper);
    border-radius: 3px;
    transform: rotate(45deg);
  }

  .section-head { margin-bottom: 44px; max-width: 820px; }
  .section-head h2 {
    margin-top: 14px;
    font-size: clamp(2.3rem, 1.2rem + 3.4vw, 4.2rem);
    font-weight: 780;
    letter-spacing: -0.03em;
    line-height: 1;
  }
  .lede { margin-top: 18px; font-size: 19px; color: var(--ink-2); max-width: 680px; }
}

/* ---------- components ---------- */

@layer components {
  /* header */
  .site-header {
    position: sticky;
    top: 12px;
    z-index: 50;
    padding-inline: var(--gutter);
    margin-top: 12px;
  }
  .site-header .bar {
    width: min(var(--wrap), 100%);
    margin-inline: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 60px;
    padding: 8px 8px 8px 18px;
    border-radius: 999px;
    background: var(--glass);
    border: 1px solid var(--line);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: var(--shadow);
  }
  .brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    text-decoration: none;
    font-weight: 700;
    white-space: nowrap;
  }
  .brand svg { width: 34px; height: 34px; }
  .brand .brand-tile { stroke: rgba(255, 255, 255, 0.16); stroke-width: 1; }
  .brand .brand-line { stroke: var(--route-btn); }
  .brand:hover { color: var(--ink); }
  .site-header nav { margin-left: auto; min-width: 0; }
  .nav { display: flex; gap: 2px; list-style: none; padding: 0; margin: 0; }
  .nav a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 15px;
    white-space: nowrap;
    color: var(--ink-2);
  }
  .nav a:hover { background: var(--paper-2); color: var(--ink); }

  .icon-btn {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 48px; height: 48px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    cursor: pointer;
  }
  .icon-btn:hover { border-color: var(--line-strong); }
  .icon-btn svg { width: 20px; height: 20px; }
  .icon-btn .i-sun, .icon-btn .i-moon, .icon-btn .i-auto { display: none; }
  .icon-btn[data-mode="light"] .i-sun,
  .icon-btn[data-mode="dark"] .i-moon,
  .icon-btn[data-mode="auto"] .i-auto { display: block; }

  /* buttons */
  .cta { display: flex; flex-wrap: wrap; gap: 12px; }
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 0 24px;
    border-radius: 999px;
    font-weight: 650;
    text-decoration: none;
    border: 1px solid transparent;
    transition: transform 0.2s var(--ease);
  }
  .btn svg { width: 18px; height: 18px; }
  .btn:hover { transform: translateY(-1px); }
  .btn-primary { background: var(--route-btn); color: var(--on-route); }
  .btn-primary:hover { color: var(--on-route); }
  .btn-ghost { border-color: var(--line-strong); background: var(--card); }
  .btn-ghost:hover { color: var(--ink); border-color: var(--ink-3); }

  /* chips */
  .chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
  .chip {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--card);
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-2);
  }

  /* cards */
  .card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--card);
    box-shadow: var(--shadow);
  }
  .card .meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .card .meta .yr { color: var(--route-text); font-weight: 600; }
  .card h3 { font-size: clamp(1.6rem, 1.3rem + 0.8vw, 2rem); letter-spacing: -0.02em; }
  .card h3 a { text-decoration: none; }
  .card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
  .card .context { color: var(--ink-3); font-size: 15px; margin-top: -8px; }
  .card .desc { color: var(--ink-2); }
  .card .foot { margin-top: auto; padding-top: 6px; font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }
  .card .foot .go { color: var(--route-text); font-weight: 600; }
  .card:has(h3 a):hover { border-color: var(--line-strong); }

  .prose p + p { margin-top: 18px; }
  .prose { color: var(--ink-2); font-size: 18px; }
  .prose strong { color: var(--ink); }
  ul.plain { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--ink-2); }
  .crumbs { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }
  .section-title { font-size: clamp(2rem, 1.3rem + 2.4vw, 3.2rem); margin: 12px 0 24px; letter-spacing: -0.025em; }

}

/* ---------- sections ---------- */

@layer sections {
  /* ---------- the film ---------- */
  .film-stage {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    display: none;
  }
  .film-live .film-stage { display: block; }
  .film-stage canvas { display: block; width: 100%; height: 100%; }
  /* reading side: text sits on the left, the landscape stays clear on the right */
  /* the reading shade behind the text is drawn inside the canvas (film.js), dithered so it does not band;
     --g-shade-dir: 0 = from the left (desktop), 1 = from the bottom (phones and tablets) */
  .film-pins { position: absolute; inset: 0; overflow: hidden; }
  .pin {
    position: absolute;
    left: 0; top: 0;
    padding: 5px 11px;
    border-radius: 999px;
    font: 600 11.5px/1.3 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    background: var(--glass);
    border: 1px solid var(--line-strong);
    opacity: 0;
    will-change: transform, opacity;
  }
  .pin.is-current { color: var(--on-route); background: var(--route-btn); border-color: transparent; }

  .site-header, main, .site-footer { position: relative; z-index: 1; }

  /* hero: the title over the landscape seen from above */
  .hero {
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding-block: 120px 96px;
  }
  .hero-inner {
    transform: translate3d(0, calc(var(--hero, 0) * -14vh), 0) scale(calc(1 - var(--hero, 0) * 0.06));
    opacity: calc(1 - var(--hero, 0) * 1.4);
    transform-origin: 0 50%;
  }
  .kicker { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.1em; font-size: 12.5px; }
  .kicker b { color: var(--route-text); font-weight: 600; }
  .name {
    margin-top: 22px;
    font-size: clamp(3.4rem, 1rem + 11vw, 12.5rem);
    line-height: 0.86;
    letter-spacing: -0.05em;
    font-weight: 800;
  }
  .name span { display: block; white-space: nowrap; }
  .name .dot { display: inline; color: var(--route); }
  .greek {
    margin-top: 22px;
    font-family: var(--font-mono);
    font-size: clamp(15px, 0.7rem + 0.5vw, 19px);
    color: var(--ink-3);
  }
  .tagline { margin-top: 28px; font-size: clamp(20px, 1rem + 0.6vw, 25px); line-height: 1.45; color: var(--ink-2); max-width: 620px; }
  .tagline strong { color: var(--ink); font-weight: 650; }
  .splits { list-style: none; margin: 36px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 168px)); gap: 10px; }
  .splits li { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .splits b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
  .splits span { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); letter-spacing: 0.03em; }
  .cue {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 44px;
    min-height: 48px;
    font-family: var(--font-mono);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--ink-2);
  }
  .cue::before {
    content: "";
    width: 2px; height: 40px;
    background: linear-gradient(var(--route), transparent);
    animation: cue 2.2s var(--ease) infinite;
    transform-origin: top;
  }
  @keyframes cue { 0% { transform: scaleY(0); } 60% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }

  /* chapter heads and chapters */
  .film-head { padding-block: 20vh 10vh; }
  .film-head h2, .film-outro h2 {
    margin-top: 14px;
    font-size: clamp(2.6rem, 1rem + 5.4vw, 6.4rem);
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 0.95;
  }
  .film-head .lede { max-width: 560px; }
  .film-outro .lede { max-width: 560px; margin-top: 18px; }
  .film-outro .ch-said { max-width: 620px; }
  .film-outro .cta { margin-top: 34px; }
  .chapter { position: relative; min-height: 150vh; }
  .chapter .ch {
    position: sticky;
    top: 18vh;
    max-width: 560px;
    margin-left: max(var(--gutter), calc((100% - var(--wrap)) / 2));
    padding-bottom: 6vh;
  }
  .ch-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
  }
  .ch-meta .n { color: var(--route-text); font-weight: 700; }
  .ch-meta .n::after { content: ""; display: inline-block; width: 28px; height: 1px; margin-left: 12px; vertical-align: middle; background: var(--line-strong); }
  .ch-meta .dnf { padding: 2px 8px; border-radius: 6px; border: 1px dashed var(--route); color: var(--route-text); font-weight: 700; }
  .ch-title {
    margin-top: 14px;
    font-size: clamp(2.2rem, 1.1rem + 3.2vw, 4.4rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 0.98;
  }
  .ch-text { margin-top: 20px; font-size: 18px; color: var(--ink-2); }
  .ch-text + .ch-text { margin-top: 12px; }
  .ch-said {
    margin: 24px 0 0;
    padding-left: 18px;
    border-left: 3px solid var(--route);
    font-size: clamp(19px, 1rem + 0.5vw, 23px);
    line-height: 1.4;
    font-weight: 600;
    color: var(--ink);
  }
  .ch-said p { margin: 0; }
  .ch-said cite { display: block; margin-top: 8px; font: 500 12px/1.4 var(--font-mono); font-style: normal; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
  .ch-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; padding: 0; list-style: none; }
  .ch-stats li { padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .ch-stats b { display: block; font-size: 19px; font-weight: 750; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
  .ch-stats span { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }
  /* the big year rides through the frame like a title card */
  .ch-year {
    position: sticky;
    top: 0;
    display: block;
    height: 0;
    overflow: visible;
    pointer-events: none;
  }
  .ch-year span {
    position: absolute;
    right: var(--gutter);
    top: 30vh;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(5rem, 2rem + 13vw, 15rem);
    line-height: 1;
    letter-spacing: -0.06em;
    color: transparent;
    -webkit-text-stroke: 1.5px color-mix(in srgb, var(--route) 60%, transparent);
    transform: translate3d(0, calc((0.5 - var(--cp, 0.5)) * 36vh), 0) scale(calc(0.92 + var(--cv, 0) * 0.08));
    opacity: calc(var(--cv, 0) * 0.9);
  }
  /* reveal: the lines of a chapter arrive one after another */
  .film-live .chapter .ch > * { opacity: 0; transform: translate3d(0, 26px, 0); transition: opacity 0.8s var(--ease), transform 0.8s var(--ease); }
  .film-live .chapter.is-in .ch > * { opacity: 1; transform: none; }
  .film-live .chapter.is-in .ch > :nth-child(2) { transition-delay: 0.08s; }
  .film-live .chapter.is-in .ch > :nth-child(3) { transition-delay: 0.16s; }
  .film-live .chapter.is-in .ch > :nth-child(4) { transition-delay: 0.24s; }
  .film-live .chapter.is-in .ch > :nth-child(5) { transition-delay: 0.32s; }
  .film-live .chapter.is-in .ch > :nth-child(6) { transition-delay: 0.4s; }

  /* the outro: the camera rises and the whole course appears at first light */
  .film-outro { min-height: 190vh; padding-block: 30vh 40vh; }
  .film-outro .inner { position: sticky; top: 16vh; }

  /* chapter progress, fixed at the bottom while the film runs */
  .hud {
    position: fixed;
    left: 50%;
    bottom: 14px;
    z-index: 60;
    width: min(620px, calc(100% - 24px));
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    min-height: 44px;
    padding: 6px 18px;
    border-radius: 999px;
    background: var(--glass);
    border: 1px solid var(--line);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: var(--shadow);
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink-2);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 24px);
    transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  }
  .hud.is-on { opacity: 1; transform: translate(-50%, 0); }
  .no-js .hud { display: none; }
  .hud b { color: var(--route-text); font-weight: 700; font-variant-numeric: tabular-nums; }
  .hud .h-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud .h-ticks { display: none; }
  @media (min-width: 640px) {
    .hud { grid-template-columns: auto minmax(0, 1fr) auto; }
    .hud .h-ticks { display: flex; gap: 4px; }
    .hud .h-ticks i { width: 10px; height: 4px; border-radius: 2px; background: var(--line-strong); }
    .hud .h-ticks i.on { background: var(--route); }
  }

  /* still version (no WebGL, reduced motion, no JavaScript): the story reads as a column */
  .film-static .chapter, .no-js .chapter { min-height: 0; padding-block: 64px 0; display: block; }
  .film-static .chapter .ch, .no-js .chapter .ch { position: static; }
  .film-static .ch-year, .no-js .ch-year { display: none; }
  .film-static .film-head, .no-js .film-head { padding-block: 132px 0; }
  .film-static .film-outro, .no-js .film-outro { min-height: 0; padding-block: 120px 0; }
  .film-static .film-outro .inner, .no-js .film-outro .inner { position: static; }
  .film-static .hud { display: none; }

  /* results sheet */
  .results { list-style: none; margin: 0; padding: 0; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--card); overflow: hidden; }
  .result {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 260px;
    gap: 6px 28px;
    padding: 18px 26px;
    align-items: center;
  }
  .result + .result { border-top: 1px solid var(--line); }
  .result .date { font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }
  .result h3 { font-size: 18px; letter-spacing: -0.01em; }
  .result .detail { color: var(--ink-2); font-size: 15px; margin-top: 2px; }
  .result .dist { display: grid; gap: 6px; justify-items: end; }
  .result .dist svg { width: 100%; height: 12px; }
  .result .dist .track { fill: var(--line); }
  .result .dist .ticks { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
  .result .dist .fill { fill: var(--route); }
  .result .dist .fill.cool { fill: var(--trail); }
  .result .stat { font-family: var(--font-mono); font-size: 13.5px; font-weight: 700; color: var(--ink); }
  .result.dnf .stat { color: var(--route-text); }
  .result.dnf .dist .fill { fill: none; stroke: var(--route); stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
  .scale-note { margin-top: 12px; font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }

  /* cards and tiles rise into place as they arrive; cards lean towards the pointer */
  .js .rise { opacity: 0; transform: translate3d(0, 34px, 0); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
  .js .rise.is-in { opacity: 1; transform: none; }
  .js .rise.is-in.tilting { transition: opacity 0.9s var(--ease), transform 0.25s ease-out; }

  /* projects */
  .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
  .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tools {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--card);
  }
  .tools > div { padding: 22px 26px; }
  .tools > div + div { border-left: 1px solid var(--line); }
  .tools h3 { font-size: 18px; margin: 4px 0 6px; }
  .tools p { color: var(--ink-2); font-size: 15px; }
  .tools .mono { color: var(--ink-3); }

  .mindset { margin-top: 110px; }
  .mindset .quote {
    font-family: var(--font-display);
    font-size: clamp(2rem, 1rem + 3.4vw, 4rem);
    font-weight: 780;
    letter-spacing: -0.035em;
    line-height: 1.02;
    max-width: 15ch;
  }
  .mindset .quote em { font-style: normal; color: var(--route-text); }
  .mindset .who { margin-top: 14px; font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }
  .principles { margin-top: 40px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; list-style: none; padding: 0; }
  .principles li { padding: 24px; border-radius: var(--radius-lg); background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--route); }
  .principles .n { font-family: var(--font-mono); font-size: 12px; color: var(--route-text); font-weight: 700; }
  .principles h3 { font-size: 21px; margin: 8px 0 8px; }
  .principles p { color: var(--ink-2); font-size: 15.5px; }

  /* university: the EMG card is a portal into that project's own world */
  .portal {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 28px;
    padding: 0;
    overflow: hidden;
    color: #f2ece2;
    background-color: #141210;
    background-image:
      linear-gradient(rgba(255, 90, 71, 0.1) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 90, 71, 0.1) 1px, transparent 1px),
      linear-gradient(rgba(255, 90, 71, 0.045) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 90, 71, 0.045) 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
    border-color: rgba(242, 236, 226, 0.14);
  }
  .portal .body { display: flex; flex-direction: column; gap: 14px; padding: 32px; }
  .portal .meta, .portal .context, .portal .foot { color: #b4aa9d; }
  .portal .meta .yr, .portal .foot .go { color: #ff7a68; }
  .portal .desc { color: #d8d0c4; }
  .portal .chip { background: rgba(242, 236, 226, 0.06); border-color: rgba(242, 236, 226, 0.16); color: #d8d0c4; }
  .portal h3 a:hover { color: #ff7a68; }
  .portal .wave { width: 100%; height: 64px; }
  .portal .wave .raw { fill: none; stroke: #6b655e; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
  .portal .wave .rest { fill: none; stroke: #7ea2ff; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
  .portal .wave .hot { fill: none; stroke: #ff4a3a; stroke-width: 2.2; vector-effect: non-scaling-stroke; }
  .portal .shots { display: flex; gap: 14px; align-items: flex-end; justify-content: center; padding: 32px 32px 0; }
  .portal .shots img { width: 46%; max-width: 200px; border-radius: 22px 22px 0 0; border: 1px solid rgba(242, 236, 226, 0.16); border-bottom: 0; }
  .portal .shots img + img { margin-bottom: 24px; }

  .terms { margin-top: 20px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; list-style: none; padding: 0; }
  .term { padding: 22px 24px; border-radius: var(--radius-lg); border: 1px dashed var(--line-strong); }
  .term .when { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
  .term h3 { font-size: 19px; margin-top: 6px; }
  .term ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
  .term li { color: var(--ink-2); font-size: 15.5px; }
  .term li strong, .term li a { color: var(--ink); font-weight: 600; }

  /* smart home */
  .home-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
  .home-grid li { padding: 22px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--card); }
  .home-grid svg { width: 30px; height: 30px; color: var(--route); }
  .home-grid h3 { font-size: 18px; margin: 14px 0 6px; }
  .home-grid p { color: var(--ink-2); font-size: 15px; }
  .home-note { margin-top: 18px; font-family: var(--font-mono); font-size: 13px; color: var(--ink-3); }

  /* finish */
  .finish {
    position: relative;
    overflow: hidden;
    padding: clamp(40px, 6vw, 80px);
    border-radius: 36px;
    background: var(--finish-bg);
    color: var(--finish-ink);
  }
  .finish .km { color: var(--finish-accent); font-size: 13px; opacity: 1; }
  .finish .km::before { background: var(--finish-bg); border-color: var(--finish-accent); }
  .finish h2 { margin: 14px 0 16px; font-size: clamp(2.8rem, 1.4rem + 5vw, 6rem); font-weight: 800; letter-spacing: -0.045em; line-height: 0.95; }
  .finish p { max-width: 560px; opacity: 0.85; font-size: 18px; }
  .finish .cta { margin-top: 28px; }
  .finish .btn-ghost { background: transparent; color: var(--finish-ink); border-color: color-mix(in srgb, var(--finish-ink) 40%, transparent); }
  .finish .btn-ghost:hover { color: var(--finish-ink); }
  /* chequered finish line */
  .finish::after {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 48px;
    background-image: conic-gradient(var(--finish-ink) 25%, transparent 0 50%, var(--finish-ink) 0 75%, transparent 0);
    background-size: 24px 24px;
    opacity: 0.12;
  }

  .site-footer { margin-top: 80px; padding: 28px 0 96px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-3); }
  .site-footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; justify-content: space-between; }
  .site-footer a { color: var(--ink-2); }

  /* plain pages (notices, 404) */
  .plain-page { padding-block: 120px 40px; }
  .off-course { font-size: clamp(3rem, 1rem + 8vw, 8rem); font-weight: 800; letter-spacing: -0.05em; line-height: 0.9; margin: 18px 0 18px; }
}

/* ---------- responsive ---------- */

@layer responsive {
  @media (min-width: 1800px) {
    body { font-size: 18px; }
    :root { --wrap: 1320px; }
  }

  @media (max-width: 1100px) {
    .principles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .result { grid-template-columns: 100px minmax(0, 1fr); }
    .result .dist { grid-column: 2; justify-items: start; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  }

  @media (max-width: 900px) {
    .portal { grid-template-columns: minmax(0, 1fr); }
    .splits { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 420px; }
    /* phones and tablets: text at the bottom of the frame, landscape above it */
    :root { --g-shade-dir: 1; }
    .chapter { display: flex; flex-direction: column; justify-content: flex-end; }
    /* bottom padding keeps the last line of stats above the chapter bar */
    .chapter .ch { top: auto; bottom: 0; margin-inline: var(--gutter); max-width: none; padding-bottom: 92px; }
    .ch-year span { top: 10vh; right: auto; left: var(--gutter); }
    .grid, .grid.three { grid-template-columns: minmax(0, 1fr); }
    .terms { grid-template-columns: minmax(0, 1fr); }
    .tools { grid-template-columns: minmax(0, 1fr); }
    .tools > div + div { border-left: 0; border-top: 1px solid var(--line); }
  }

  @media (max-width: 760px) {
    .site-header { position: relative; top: 0; margin-top: 0; padding-inline: 0; }
    .site-header .bar { border-radius: 0; border-width: 0 0 1px; flex-wrap: wrap; gap: 4px 8px; padding: 6px 12px; }
    .brand { margin-right: auto; }
    .site-header nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; }
    .nav a { padding: 0 9px; font-size: 14px; }
    html { scroll-padding-top: 16px; }
    section { padding-block: 96px 0; }
    .card, .portal .body { padding: 22px; }
    .result { grid-template-columns: minmax(0, 1fr); padding: 18px 22px; }
    .result .dist { grid-column: 1; }
    .ch-text { font-size: 16.5px; }
    .portal .shots { padding: 0 22px; }
  }

  @media (max-width: 560px) {
    body { font-size: 16px; }
    .principles, .home-grid { grid-template-columns: minmax(0, 1fr); }
    .splits b { font-size: 19px; }
    .hud { gap: 10px; padding: 6px 14px; }
    .finish { padding-right: 52px; }
    .finish::after { width: 24px; background-size: 12px 12px; }
  }

  @media (max-width: 380px) {
    .nav a { padding: 0 7px; }
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .cue::before { animation: none; }
    .btn, .hud, .js .rise { transition: none; }
    .js .rise { opacity: 1; transform: none; }
    .hero-inner { transform: none; opacity: 1; }
  }
}

@layer print {
  @media print {
    body::before, .film-stage, .hud, .site-header, .icon-btn { display: none; }
    .chapter { min-height: 0; }
    .chapter .ch { position: static; }
    .ch-year { display: none; }
    body { background: #fff; color: #000; }
    section { padding-block: 32px 0; }
  }
}
