: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: #38bdf8;
    --accent-left: #1d8fc2;
    --accent-right: #146a91;
    --nav: 64px;
    --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
}

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

html { scroll-padding-top: var(--nav); scroll-behavior: smooth; }

@media (pointer: fine) {
    html.snap { scroll-snap-type: y mandatory; }
    .snap .hero, .snap .chapter { scroll-snap-align: start; }
    .snap .chapter { scroll-snap-stop: always; }
    .snap .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; transition: color .2s; }
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; flex-wrap: wrap; 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%);
}
.scroll-hint { margin-top: auto; padding: 32px 0; font-family: var(--mono); font-size: 12px; color: var(--mute); }

.lbl {
    position: absolute; font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
    text-transform: uppercase; color: var(--mute); pointer-events: none;
}
.portrait .lbl { z-index: 1; color: rgba(255, 255, 255, .75); }
.lbl.tl { top: 14px; left: 16px; }
.lbl.tr { top: 14px; right: 16px; }
.lbl.bl { bottom: 14px; left: 16px; }
.lbl.br { bottom: 14px; right: 16px; color: var(--accent); }

.chapter {
    max-width: 1080px; margin: 0 auto; padding: 48px 24px;
    min-height: calc(100svh - var(--nav));
    display: grid; grid-template-columns: 1fr 1fr; gap: 64px; align-items: center;
}
.chapter:nth-child(even) .fig { order: 2; }

.fig {
    position: relative; aspect-ratio: 1; width: 100%;
    border: 1px solid var(--line-soft); border-radius: 18px; background: var(--card);
    cursor: pointer; user-select: none; overflow: hidden;
}
.fig svg { position: absolute; inset: 0; width: 100%; height: 100%; padding: 44px 24px; overflow: visible; }
.fig:hover { border-color: var(--line); }

.story h2 {
    color: var(--ink); font-weight: 500; letter-spacing: -.02em;
    font-size: clamp(28px, 3.4vw, 40px); line-height: 1.15; margin-bottom: 20px;
}
.story p + p { margin-top: 14px; }
.story .more { display: inline-block; margin-top: 24px; font-family: var(--mono); font-size: 13px; }

.f { stroke: var(--line); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.f.top { fill: var(--top); }
.f.left { fill: var(--left); }
.f.right { fill: var(--right); }
.f.acc.top { fill: var(--accent); }
.f.acc.left { fill: var(--accent-left); }
.f.acc.right { fill: var(--accent-right); }
.f.glow { fill: #0d1b22; }
.f.dim { stroke: var(--line-soft); }
.ink { fill: var(--ink); }
.accent { fill: var(--accent); }
.mute { fill: var(--mute); }
.notch { fill: var(--bg); }
.slot { fill: #070707; stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.shadow { fill: #000; }
.app-icon { transition: opacity .2s; }
.app-icon:hover { opacity: .7; }

.footer {
    max-width: 1080px; margin: 0 auto; padding: 96px 24px 48px;
    display: flex; justify-content: space-between; gap: 32px; flex-wrap: wrap;
    border-top: 1px solid var(--line-soft);
}
.footer p { margin-top: 6px; }
.muted { color: var(--mute); font-size: 14px; }

/* projects list */
.page { max-width: 1080px; margin: 0 auto; padding: 48px 24px 96px; }
.page h1 {
    color: var(--ink); font-weight: 500; letter-spacing: -.03em;
    font-size: clamp(40px, 6vw, 72px); line-height: 1; margin-bottom: 20px;
}
.tabs { display: flex; gap: 10px; margin: 32px 0; font-family: var(--mono); font-size: 13px; }
.tabs button {
    background: none; color: var(--text); font: inherit; cursor: pointer;
    border: 1px solid var(--line-soft); border-radius: 6px; padding: 6px 12px;
}
.tabs button:hover { border-color: var(--line); color: var(--ink); }
.tabs button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
    position: relative; display: flex; flex-direction: column; gap: 14px;
    border: 1px solid var(--line-soft); border-radius: 14px; background: var(--card);
    padding: 20px; color: var(--text); transition: border-color .2s, transform .2s;
}
.card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.card img { width: 56px; height: 56px; border-radius: 14px; object-fit: cover; background: var(--top); }
.card.wide img { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 8px; }
.card h3 { color: var(--ink); font-weight: 600; font-size: 17px; line-height: 1.3; }
.card p { font-size: 14px; line-height: 1.5; }
.card .meta { margin-top: auto; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }

/* project detail */
.back { font-family: var(--mono); font-size: 13px; }
.detail-head { display: flex; gap: 20px; align-items: center; margin: 40px 0 16px; }
.detail-head img { width: 80px; height: 80px; border-radius: 20px; object-fit: cover; flex: none; }
.detail-head h1 { margin: 0; }
.detail-tagline { font-size: clamp(17px, 2vw, 20px); max-width: 680px; }
.screens {
    display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 40px -24px; padding: 0 24px 12px; scrollbar-color: var(--line) transparent;
}
.screens img {
    height: min(560px, 70svh); width: auto; flex: none; scroll-snap-align: start;
    border-radius: 14px; border: 1px solid var(--line-soft); background: var(--card);
}
.screens.wide img { height: min(420px, 50svh); }
.detail-body { display: grid; grid-template-columns: 2fr 1fr; gap: 56px; }
.detail-body .desc { white-space: pre-line; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span {
    font-family: var(--mono); font-size: 12px; color: var(--ink);
    border: 1px solid var(--line-soft); border-radius: 6px; padding: 3px 8px;
}
.side > div + div { margin-top: 32px; }
/* sketchfab viewer */
.back + .eyebrow { margin-top: 40px; }
.viewer { margin: 40px 0; }
.viewer .picks { margin: 14px 0 0; flex-wrap: wrap; }
.stage {
    position: relative; aspect-ratio: 16 / 9; overflow: hidden;
    border: 1px solid var(--line-soft); border-radius: 14px; background: var(--card);
}
.stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.poster { all: unset; position: absolute; inset: 0; display: grid; place-items: center; cursor: pointer; }
.poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: brightness(.55); transition: filter .3s; }
.poster:hover img { filter: brightness(.75); }
.screens .clip {
    position: relative; flex: none; height: min(560px, 70svh); aspect-ratio: 9 / 16; overflow: hidden;
    scroll-snap-align: start; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--card);
}
button.clip { all: unset; display: grid; place-items: center; cursor: pointer; }
.screens .clip img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; object-fit: cover; filter: brightness(.7); transition: filter .3s; }
.clip:hover img { filter: brightness(.9); }
.poster span, .clip span {
    position: relative; margin: 16px; text-align: center; font-family: var(--mono); font-size: 13px; color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; background: color-mix(in srgb, var(--bg) 70%, transparent);
}
.poster:hover span, .poster:focus-visible span, .clip:hover span, .clip:focus-visible span { border-color: var(--accent); color: var(--accent); }
.grid.models { margin-top: 32px; }
button.card { font: inherit; text-align: left; cursor: pointer; }
.viewer-dialog {
    width: min(1100px, calc(100vw - 32px)); max-width: none; margin: auto; padding: 16px;
    border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--text);
}
.viewer-dialog::backdrop { background: rgba(0, 0, 0, .75); }
.viewer-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.viewer-head h2 { color: var(--ink); font-size: 17px; font-weight: 600; }
.viewer-head .btn { background: none; color: var(--ink); font-family: var(--mono); font-size: 13px; cursor: pointer; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 72px; font-family: var(--mono); font-size: 13px; }

@media (max-width: 820px) {
    .hero-grid, .chapter, .detail-body { grid-template-columns: 1fr; gap: 32px; }
    .portrait { justify-self: start; max-width: 320px; }
    .chapter { min-height: auto; padding: 56px 16px; }
    .chapter:nth-child(even) .fig { order: 0; }
    .fig .lbl.br { bottom: 34px; }
    .hero, .page, .footer, .nav { padding-left: 16px; padding-right: 16px; }
    .screens { margin: 32px -16px; padding: 0 16px 12px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; animation: none !important; }
}
.beam { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.open { cursor: alias; }

/* each chapter recolours its figure and links */
[data-tone="farm"] { --accent: #10b981; --accent-left: #0c8f64; --accent-right: #086b4b; }
[data-tone="studio"] { --accent: #a45bff; --accent-left: #7f3fd6; --accent-right: #5f2ea3; }
[data-tone="games"] { --accent: #f5792a; --accent-left: #c45e1f; --accent-right: #934617; }
.chapter .more:hover, .story a:hover { color: var(--accent); }

.f.soil.top { fill: #231e19; }
.f.soil.left { fill: #1a1612; }
.f.soil.right { fill: #13110e; }
.win { fill: #0a0a0a; }
.win.lit { fill: var(--accent); opacity: .8; }
.street { stroke: #0c0c0c; stroke-width: 7; stroke-linecap: round; }
.road { fill: #0d0d0d; }
.lane { stroke: var(--mute); stroke-width: 1; stroke-dasharray: 6 5; }
.door { fill: #0a0a0a; stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.eye { fill: var(--bg); }
.coin { fill: var(--accent); stroke: rgba(255, 255, 255, .35); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ring { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.bob { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }

.email-reveal { font-family: var(--mono); }
.email-reveal.locked { color: var(--mute); border-bottom: 1px dashed var(--line); }
.email-reveal.locked:hover { color: var(--accent); border-color: var(--accent); }
.email-reveal.decrypting { color: var(--ink); cursor: progress; }
.email-reveal .glyph { color: var(--accent); text-shadow: 0 0 8px var(--accent); }
.email-reveal.revealed { animation: reveal-flash .7s ease-out; }
@keyframes reveal-flash {
    0% { color: var(--accent); text-shadow: 0 0 14px var(--accent); }
    100% { text-shadow: none; }
}
