/* DM Sans, self-hosted like the CV page (fonts/dm-sans, OFL) */
@font-face { font-family: "DM Sans"; src: url("fonts/dm-sans/DM-Sans-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("fonts/dm-sans/DM-Sans-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }

:root {
    --bg: #0b0b0b;
    --card: #111;
    --ink: #ececec;
    --text: #a9a9a9;
    --mute: #666;
    --line: rgba(255, 255, 255, .26);
    --line-soft: rgba(255, 255, 255, .11);
    --top: #1c1c1c;
    --left: #151515;
    --right: #101010;
    --accent: #ff6500;
    --nav: 64px;
    --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-padding-top: var(--nav); scroll-behavior: smooth; }
/* Mouse, trackpad and keyboard snap one chapter at a time (native, so trackpad momentum works).
   Touch screens scroll freely. --nav is set from the real nav height in home.js so snaps land exactly. */
@media (pointer: fine) {
    html { scroll-snap-type: y mandatory; }
    .hero, .chapter { scroll-snap-align: start; }
    .chapter { scroll-snap-stop: always; }
    .footer { scroll-snap-align: end; }
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration: none; }
a:hover { color: var(--accent); }

.nav {
    position: sticky; top: 0; z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    max-width: 1080px; margin: 0 auto; padding: 18px 24px;
    font-family: var(--mono); font-size: 13px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(8px);
}
.nav-right { display: flex; gap: 18px; align-items: center; }
.btn { border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }
.btn:hover { border-color: var(--accent); }

.eyebrow {
    font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
    text-transform: uppercase; color: var(--mute); margin-bottom: 14px;
}

.hero {
    max-width: 1080px; margin: 0 auto; padding: 8vh 24px 0;
    min-height: calc(100svh - var(--nav)); display: flex; flex-direction: column;
}
.hero h1 {
    color: var(--ink); font-weight: 500; letter-spacing: -.03em;
    font-size: clamp(44px, 8vw, 96px); line-height: 1; margin-bottom: 28px;
}
.lead { max-width: 620px; font-size: clamp(17px, 2vw, 20px); }
.links { display: flex; gap: 22px; margin-top: 28px; font-family: var(--mono); font-size: 13px; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 56px; align-items: center; }
.portrait {
    position: relative; aspect-ratio: 4 / 5; max-width: 400px; justify-self: end; width: 100%;
    border: 1px solid var(--line-soft); border-radius: 18px; overflow: hidden; background: var(--card);
}
.portrait img {
    display: block; width: 100%; height: 100%; object-fit: cover;
    filter: grayscale(1) contrast(1.08) brightness(.9);
    transition: filter .6s ease;
}
.portrait:hover img { filter: none; }
.portrait::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .45), transparent 22%);
}
.portrait .lbl { z-index: 1; color: rgba(255, 255, 255, .75); }
.scroll-hint { margin-top: auto; padding-bottom: 32px; font-family: var(--mono); font-size: 12px; color: var(--mute); letter-spacing: .14em; text-transform: uppercase; }

main { max-width: 1080px; margin: 0 auto; padding: 0 24px; }
/* Keep text clear of the chapter ticks on the right when the window is narrower than the content */
@media (max-width: 1200px) and (min-width: 761px) { main, .hero, .footer { padding-right: 64px; } }

.chapter {
    display: grid; grid-template-columns: 1.15fr 1fr; gap: 56px; align-items: center;
    min-height: calc(100svh - var(--nav)); padding: 32px 0;
}
.reveal .chapter { opacity: 0; transform: translateY(40px); transition: opacity .9s ease, transform .9s ease; }
.reveal .chapter.in { opacity: 1; transform: none; }
.chapter:nth-child(even) .fig { order: 2; }

.fig {
    position: relative; aspect-ratio: 1 / .92;
    background: var(--card); border: 1px solid var(--line-soft); border-radius: 18px; overflow: hidden;
}
.fig canvas { position: absolute; inset: 44px 0; width: 100%; height: calc(100% - 88px); cursor: grab; touch-action: pan-y; }
.fig svg { position: absolute; inset: 44px 0; width: 100%; height: calc(100% - 88px); cursor: pointer; }
.fig svg * { vector-effect: non-scaling-stroke; }
.lbl { position: absolute; font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--mute); text-transform: uppercase; }
.tl { top: 18px; left: 22px; text-transform: none; }
.tr { top: 18px; right: 22px; }
.bl { bottom: 16px; left: 22px; }
.br { bottom: 16px; right: 22px; text-transform: none; }

.story h2 { color: var(--ink); font-weight: 500; letter-spacing: -.02em; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; margin-bottom: 20px; }
.story p + p { margin-top: 14px; }

.footer {
    max-width: 1080px; margin: 10vh auto 0; padding: 40px 24px 56px;
    border-top: 1px solid var(--line-soft);
    display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap; font-size: 14px;
}
.muted { color: var(--mute); margin-top: 6px; }
.imprint { color: var(--mute); font-size: 13px; }
.imprint strong { color: var(--text); font-weight: 500; }

/* Chapter tracker. Class "rail", because generic names like "tracker" can be hidden by ad-block cosmetic filters. */
.count { font-family: var(--mono); font-size: 12px; color: var(--mute); letter-spacing: .08em; }
.count b { color: var(--ink); font-weight: 400; }
.rail {
    position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 20;
    display: flex; flex-direction: column; gap: 6px;
}
.rail a {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 4px 0;
    font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--mute);
}
.rail a::after { content: ""; width: 14px; height: 1px; background: var(--mute); transition: width .3s, background .3s; }
.rail .name { opacity: 0; transform: translateX(6px); transition: opacity .3s, transform .3s; white-space: nowrap; }
.rail a:hover .name { opacity: 1; transform: none; }
.rail a.active { color: var(--ink); }
.rail a.active::after { width: 30px; background: var(--accent); }
@media (min-width: 1400px) { .rail a.active .name { opacity: 1; transform: none; } }

/* Isometric objects */
.led { animation: led 1.6s steps(1) infinite; }
@keyframes led { 50% { opacity: .25; } }
.rack.busy .led { animation-duration: .18s !important; }
.eyes { animation: eyes 4.5s infinite; }
@keyframes eyes { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.pulse { animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .3; } }
.scan { animation: scan 4s ease-in-out infinite alternate; }
@keyframes scan { from { transform: translateY(-40px); } to { transform: translateY(40px); } }
.prop { animation: spin .2s linear infinite; transform-origin: 0 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.shutter.go { animation: press .25s ease-out; }
@keyframes press { 40% { transform: translateY(1.5px); } }
.aperture.go { animation: stop-down .35s ease-out; }
@keyframes stop-down { 40% { transform: scale(.35); } }
.flash.go { animation: flash .7s ease-out; }
@keyframes flash { 0% { opacity: .9; transform: scale(.3); } 25% { opacity: .8; } 100% { opacity: 0; transform: scale(1.3); } }
.swing { animation: swing 1.4s ease-out; }
@keyframes swing { 15% { transform: rotate(5deg); } 40% { transform: rotate(-3.5deg); } 65% { transform: rotate(2deg); } 85% { transform: rotate(-1deg); } }

@media (max-width: 760px) {
    .reveal .chapter { transform: none; transition: opacity .6s ease; }
    .rail { right: 6px; gap: 2px; }
    .rail .name { display: none; }
    .rail a::after { width: 8px; }
    .rail a.active::after { width: 16px; }
    .count .name { display: none; }
    .chapter { grid-template-columns: 1fr; gap: 20px; padding: 48px 0; min-height: 0; }
    .fig { aspect-ratio: 4 / 3; }
    .story h2 { margin-bottom: 12px; }
    .chapter:nth-child(even) .fig { order: 0; }
    .hero { padding-top: 4vh; }
    .hero-grid { grid-template-columns: 1fr; gap: 36px; }
    .portrait { justify-self: start; max-width: 320px; }
    .scroll-hint { margin-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal .chapter { opacity: 1; transform: none; transition: none; }
    .scan, .prop, .swing, .go, .led, .eyes, .pulse { animation: none !important; }
}

/* Portrait placeholder when no headshot yet */
.portrait-placeholder {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    background:
        linear-gradient(135deg, #161616 0%, #0e0e0e 50%, #1a1a1a 100%);
    color: var(--mute);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.7;
}
.portrait-placeholder span { position: relative; z-index: 1; opacity: .85; }
.story strong { color: var(--ink); font-weight: 500; }

/* v5: simple lists inside chapter copy (pilot terms) */
.story ul { margin-top: 14px; padding-left: 20px; }
.story li + li { margin-top: 6px; }
.story li::marker { color: var(--accent); }
.story .also { margin-top: 18px; font-size: 15px; color: var(--mute); }
.lead + .also { max-width: 620px; }
.story ul + p { margin-top: 14px; }
