/* ---------- Theme tokens ---------- */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --radius: 10px;
  --max: 1120px;
}

[data-theme="dark"] {
  --bg: #0a0e13;
  --bg-2: #0f151c;
  --panel: #121a23;
  --panel-2: #17212c;
  --line: #223040;
  --text: #e6edf3;
  --muted: #8b9bab;
  --dim: #5d6d7d;
  --grid: rgba(120, 160, 200, 0.06);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --bg-2: #eef2f6;
  --panel: #ffffff;
  --panel-2: #f3f6f9;
  --line: #d6dee6;
  --text: #0f1720;
  --muted: #4b5a68;
  --dim: #7a8794;
  --grid: rgba(20, 40, 60, 0.05);
  --shadow: 0 8px 24px rgba(15, 30, 50, 0.08);
  color-scheme: light;
}

/* Accent colours: a brighter tone for dark mode, a deeper one for light mode so text stays readable. */
[data-accent="cyan"]    { --acc: #22d3ee; --acc-l: #0e7490; }
[data-accent="green"]   { --acc: #4ade80; --acc-l: #15803d; }
[data-accent="amber"]   { --acc: #fbbf24; --acc-l: #b45309; }
[data-accent="magenta"] { --acc: #e879f9; --acc-l: #a21caf; }
[data-accent="red"]     { --acc: #f87171; --acc-l: #b91c1c; }
[data-theme="light"] { --a: var(--acc-l); }
[data-theme="dark"]  { --a: var(--acc); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }

body {
  margin: 0;
  font: 16px/1.65 var(--font);
  color: var(--text);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  transition: background-color .25s, color .25s;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--a); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: .85em; letter-spacing: .01em; }
.dim { color: var(--dim); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--a); color: #000; padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--a); outline-offset: 3px; border-radius: 4px; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 14px max(20px, calc((100vw - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--mono); font-weight: 600; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 7px;
  border: 1px solid var(--a); color: var(--a); font-size: 13px;
}
.nav nav { display: flex; gap: 22px; margin-left: auto; }
.nav nav a { color: var(--muted); font-size: 15px; }
.nav nav a:hover { color: var(--text); text-decoration: none; }

.theme { display: flex; align-items: center; gap: 12px; }
.theme-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 6px 10px; border-radius: 8px; cursor: pointer; font: 12px var(--mono);
}
.theme-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; display: none; }
.theme-btn svg .fill { fill: currentColor; stroke: none; }
.theme-btn[data-mode="dark"] .i-dark,
.theme-btn[data-mode="light"] .i-light,
.theme-btn[data-mode="auto"] .i-auto { display: block; }
.swatches { display: flex; gap: 6px; }
.swatches button {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--line);
}
.swatches button[data-accent="cyan"]    { background: #22d3ee; }
.swatches button[data-accent="green"]   { background: #4ade80; }
.swatches button[data-accent="amber"]   { background: #fbbf24; }
.swatches button[data-accent="magenta"] { background: #e879f9; }
.swatches button[data-accent="red"]     { background: #f87171; }
.swatches button[aria-pressed="true"] { border-color: var(--bg); box-shadow: 0 0 0 2px var(--text); }

/* ---------- Hero ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center;
  padding: 72px 0 56px;
}
.kicker { font-family: var(--mono); font-size: 13px; color: var(--muted); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--a); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 25%, transparent); }
h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 1.05; margin: 0 0 18px; letter-spacing: -.02em; }
.lede { font-size: 1.15rem; color: var(--muted); margin: 0 0 28px; max-width: 34em; }
.hl { color: var(--text); border-bottom: 2px solid var(--a); }
.stats { list-style: none; padding: 0; margin: 0 0 30px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stats li { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 12px 14px; }
.stats b { display: block; font: 700 1.5rem var(--mono); color: var(--a); }
.stats li > span { font-size: 13px; color: var(--muted); line-height: 1.4; display: block; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; padding: 10px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 15px; font-weight: 500;
  transition: border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--a); text-decoration: none; transform: translateY(-1px); }
.btn.primary { background: var(--a); border-color: var(--a); color: var(--bg); }
[data-theme="light"] .btn.primary { color: #fff; }

.hero-fig { margin: 0; }
.frame { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: #e9ecef; padding: 10px; box-shadow: var(--shadow); }
.frame img { border-radius: 6px; }
.corner { position: absolute; width: 14px; height: 14px; border: 2px solid var(--a); }
.corner.tl { top: -6px; left: -6px; border-right: 0; border-bottom: 0; }
.corner.tr { top: -6px; right: -6px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: -6px; left: -6px; border-right: 0; border-top: 0; }
.corner.br { bottom: -6px; right: -6px; border-left: 0; border-top: 0; }
.hero-fig figcaption { margin-top: 12px; font-size: 14px; color: var(--muted); }
.hero-fig figcaption .mono { color: var(--a); margin-right: 6px; }

/* ---------- Sections ---------- */
.section { padding: 56px 0; border-top: 1px solid var(--line); }
.section-head { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: baseline; margin-bottom: 32px; }
.section-head .num { font: 600 14px var(--mono); color: var(--a); }
.section-head h2 { margin: 0; font-size: 1.9rem; letter-spacing: -.01em; }
.section-head p { grid-column: 2; margin: 6px 0 0; color: var(--muted); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 118px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.project { display: grid; grid-template-columns: 100px 1fr; gap: 36px; margin-bottom: 28px; position: relative; }
.project::before {
  content: ""; position: absolute; left: 113px; top: 22px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--a);
}
.project.featured::before { background: var(--a); }
.when { padding-top: 14px; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.when .mono { color: var(--text); font-weight: 600; }
.tag-sm { font: 11px var(--mono); color: var(--dim); }
.tag-sm.live { color: var(--a); }
.tag-sm.live::before { content: "● "; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 24px; transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: color-mix(in srgb, var(--a) 45%, var(--line)); box-shadow: var(--shadow); }
.featured .card { border-color: color-mix(in srgb, var(--a) 35%, var(--line)); }
.card h3 { margin: 0; font-size: 1.3rem; letter-spacing: -.01em; }
.role { margin: 4px 0 12px; font: 13px var(--mono); color: var(--a); }
.card > p { margin: 0 0 12px; color: var(--muted); }
.badge {
  display: inline-block; margin-bottom: 10px; padding: 3px 10px; border-radius: 99px;
  font: 600 12px var(--mono); color: var(--a); background: color-mix(in srgb, var(--a) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--a) 40%, transparent);
}
.facts { margin: 0 0 16px; padding-left: 0; list-style: none; }
.facts li { position: relative; padding-left: 20px; margin: 4px 0; font-size: 15px; }
.facts li::before { content: "›"; position: absolute; left: 4px; color: var(--a); font-weight: 700; }

.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 16px; }
.shot {
  grid-column: span 1; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: #fff; cursor: zoom-in; height: 200px;
}
.shot.wide { grid-column: span 2; }
.shot img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.shot.wide img { object-fit: contain; }
.shot:hover img { transform: scale(1.03); }

.media-slot {
  display: grid; place-items: center; height: 160px; margin: 0 0 16px; border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--a) 50%, var(--line));
  background: repeating-linear-gradient(135deg, transparent 0 12px, color-mix(in srgb, var(--a) 6%, transparent) 12px 24px);
  color: var(--muted);
}
.sub { border-left: 2px solid var(--a); padding: 4px 0 4px 16px; margin: 0 0 16px; }
.sub h4 { margin: 0 0 6px; font-size: 1rem; }
.sub p { margin: 0; color: var(--muted); font-size: 15px; }

.tags { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { font: 12px var(--mono); padding: 3px 9px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }

/* ---------- Experience ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.panel-title { font: 600 13px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--a); margin: 0 0 14px; }
.panel-title:not(:first-child) { margin-top: 26px; }
.xp { list-style: none; margin: 0; padding: 0; }
.xp li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.xp li:last-child { border-bottom: 0; }
.xp-head { display: flex; justify-content: space-between; gap: 12px; }
.xp-head .mono { color: var(--dim); white-space: nowrap; }
.org { margin: 2px 0 4px; color: var(--muted); font-size: 14px; }
.xp p:not(.org) { margin: 4px 0 0; font-size: 15px; color: var(--muted); }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.skills > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.skills h3 { margin: 0 0 6px; font: 600 13px var(--mono); color: var(--a); text-transform: uppercase; letter-spacing: .06em; }
.skills p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- Contact / footer ---------- */
.contact { padding-bottom: 72px; }
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 20px max(20px, calc((100vw - var(--max)) / 2)); border-top: 1px solid var(--line); color: var(--muted);
}

/* ---------- Lightbox ---------- */
.lightbox { border: 0; padding: 0; background: transparent; max-width: 94vw; max-height: 92vh; }
.lightbox::backdrop { background: rgba(5, 8, 12, .85); backdrop-filter: blur(4px); }
.lightbox img { max-width: 94vw; max-height: 84vh; border-radius: 8px; background: #fff; }
.lb-cap { color: #cfd8e1; text-align: center; font-size: 14px; margin: 10px 0 0; }
.lb-close {
  position: fixed; top: 16px; right: 20px; width: 40px; height: 40px; border-radius: 50%;
  background: #1b2530; color: #fff; border: 1px solid #2c3a48; font-size: 24px; cursor: pointer; line-height: 1;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 44px; }
  .grid-2, .skills { grid-template-columns: 1fr; }
  .skills { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .nav { flex-wrap: wrap; gap: 10px 16px; }
  .nav nav { order: 3; width: 100%; margin: 0; gap: 18px; overflow-x: auto; }
  .theme { margin-left: auto; }
  .stats { grid-template-columns: 1fr; }
  .timeline::before { left: 6px; }
  .project { grid-template-columns: 1fr; gap: 8px; padding-left: 26px; }
  .project::before { left: 1px; top: 6px; }
  .when { flex-direction: row; align-items: center; justify-content: flex-start; padding-top: 0; text-align: left; gap: 10px; }
  .gallery { grid-template-columns: 1fr 1fr; }
  .shot.wide { grid-column: span 2; }
  .skills { grid-template-columns: 1fr; }
  .card, .panel { padding: 18px; }
}

/* =====================================================================
   v2: motion layer
   ===================================================================== */

/* Hero: full-bleed with the interactive arm behind the text */
.hero { position: relative; grid-template-columns: 1fr; min-height: calc(100vh - 64px); padding: 80px 0 90px; align-content: center; }
.hero-text { position: relative; z-index: 2; max-width: 640px; pointer-events: none; }
.hero-text a, .hero-text button { pointer-events: auto; }
.arm-canvas { position: absolute; inset: 0 calc(50% - 50vw); width: 100vw; height: 100%; z-index: 1; cursor: crosshair; touch-action: pan-y; }
.arm-hint { position: absolute; right: 0; bottom: 34px; z-index: 2; color: var(--dim); font-size: 12px; margin: 0; }

.lede { min-height: 4.2em; }
.rotator { color: var(--a); font-family: var(--mono); font-weight: 600; }
.caret { display: inline-block; width: .55em; height: 1.05em; margin-left: 2px; vertical-align: -0.15em; background: var(--a); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Glitch on the name, triggered on hover */
.glitch { position: relative; pointer-events: auto; }
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; inset: 0; opacity: 0; pointer-events: none;
}
.glitch:hover::before { opacity: .8; color: var(--a); animation: glitch 0.35s steps(2) 2; clip-path: inset(10% 0 55% 0); transform: translate(-3px, 0); }
.glitch:hover::after  { opacity: .8; color: #ff3d7f; animation: glitch 0.35s steps(2) reverse 2; clip-path: inset(60% 0 8% 0); transform: translate(3px, 0); }
@keyframes glitch { 0% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 100% { transform: translate(0, 0); } }

.stats li { backdrop-filter: blur(6px); background: color-mix(in srgb, var(--panel) 80%, transparent); }

.scroll-cue { position: absolute; left: 50%; bottom: 22px; z-index: 2; width: 24px; height: 38px; margin-left: -12px; border: 2px solid var(--line); border-radius: 14px; }
.scroll-cue span { position: absolute; left: 50%; top: 7px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--a); animation: cue 1.6s ease-in-out infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }

/* Scroll progress + cursor glow */
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 60; background: var(--a); transform-origin: 0 50%; transform: scaleX(0); }
.cursor-glow {
  position: fixed; left: 0; top: 0; width: 520px; height: 520px; margin: -260px 0 0 -260px; z-index: 0; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--a) 13%, transparent), transparent 65%);
  transform: translate(var(--gx, -999px), var(--gy, -999px)); transition: opacity .3s;
}
[data-theme="light"] .cursor-glow { opacity: .7; }
main, .nav, .foot { position: relative; z-index: 1; }
.nav { z-index: 50; }

/* Skills marquee */
.marquee { position: relative; z-index: 1; overflow: hidden; border-block: 1px solid var(--line); background: var(--bg-2); padding: 14px 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.marquee-track { display: flex; gap: 42px; width: max-content; animation: marquee 38s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee span { font: 600 14px var(--mono); color: var(--muted); white-space: nowrap; }
.marquee span::before { content: "◆"; color: var(--a); margin-right: 14px; font-size: 9px; vertical-align: 2px; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 28px; }
.chip { font: 13px var(--mono); padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; transition: all .2s; }
.chip:hover { color: var(--text); border-color: var(--a); }
.chip[aria-pressed="true"] { background: var(--a); border-color: var(--a); color: var(--bg); }
[data-theme="light"] .chip[aria-pressed="true"] { color: #fff; }
.project { transition: opacity .35s, transform .35s, max-height .45s, margin .45s; }
.project.hidden { opacity: 0; transform: scale(.97); max-height: 0; margin: 0; overflow: hidden; pointer-events: none; }

/* Timeline fills in as you scroll */
.timeline::after { content: ""; position: absolute; left: 118px; top: 8px; width: 1px; height: var(--fill, 0%); background: var(--a); box-shadow: 0 0 8px var(--a); }
.project::before { transition: background .3s, box-shadow .3s; }
.project.lit::before { background: var(--a); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a) 25%, transparent); }

/* Scroll reveal */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.js .reveal.in { opacity: 1; transform: none; }

/* 3D tilt + spotlight on cards */
.tilt { transform-style: preserve-3d; will-change: transform; position: relative; }
.card.tilt, .panel.tilt, .skills .tilt { transition: transform .25s ease-out, border-color .2s, box-shadow .2s; }
.tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .25s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--a) 12%, transparent), transparent 45%);
}
.tilt:hover::after { opacity: 1; }

@media (max-width: 720px) {
  .hero { min-height: auto; padding: 36px 0 70px; }
  .arm-canvas { opacity: .45; }
  .arm-hint { display: none; }
  .timeline::after { left: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
  .marquee-track, .caret { animation: none; }
}

/* =====================================================================
   v3: editorial layer (grain, big type, index, hatching, invert band)
   ===================================================================== */

/* Film grain over everything */
body::before {
  content: ""; position: fixed; inset: -50%; z-index: 70; pointer-events: none; opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
[data-theme="light"] body::before { opacity: .07; }
@keyframes grain { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-3%,2%); } 40% { transform: translate(2%,-3%); } 60% { transform: translate(-2%,-1%); } 80% { transform: translate(3%,3%); } }

/* Big uppercase headline */
h1.big { font-size: clamp(3rem, 8.5vw, 7.2rem); line-height: .9; text-transform: uppercase; letter-spacing: -.035em; font-weight: 800; margin-bottom: 26px; }
h1.big span { display: block; }
h1.big span:last-child { -webkit-text-stroke: 1.5px var(--text); color: transparent; }
.hero-text { max-width: 760px; }

/* Hatched dividers */
.hatch {
  height: 18px; margin: 0 calc(50% - 50vw); border-block: 1px solid var(--line);
  background: repeating-linear-gradient(-45deg, var(--line) 0 1px, transparent 1px 9px);
}
.hatch + .section, .section + .hatch { border-top: 0; }

/* Mono "# label" headings */
.section-head h2 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); letter-spacing: -.02em; }
.about .section-head h2 { font: 600 14px var(--mono); color: var(--muted); letter-spacing: .1em; text-transform: uppercase; }

/* Scroll-lit statement */
.statement { font-size: clamp(1.5rem, 3.2vw, 2.5rem); line-height: 1.3; font-weight: 600; letter-spacing: -.015em; margin: 0; max-width: 28em; }
.statement .w { color: var(--dim); opacity: .45; transition: color .25s, opacity .25s; }
.statement .w.on { color: var(--text); opacity: 1; }
.statement .w.key.on { color: var(--a); }

/* Bracket corners on cards */
.bk { position: absolute; width: 12px; height: 12px; border: 1.5px solid var(--a); opacity: .7; pointer-events: none; }
.bk.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: var(--radius); }
.bk.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: var(--radius); }

/* Work: sticky numbered index + cards */
.work-layout { display: grid; grid-template-columns: 260px 1fr; gap: 48px; align-items: start; }
.index { position: sticky; top: 96px; }
.index ol { list-style: none; margin: 0; padding: 0; counter-reset: idx; }
.index li { counter-increment: idx; }
.index a {
  display: grid; grid-template-columns: 30px 1fr; gap: 6px; padding: 7px 0; color: var(--dim);
  font-size: 15px; line-height: 1.3; font-weight: 600; transition: color .25s, transform .25s;
}
.index a::before { content: counter(idx, decimal-leading-zero); font: 12px var(--mono); padding-top: 2px; }
.index a:hover { color: var(--muted); text-decoration: none; }
.index li.active a { color: var(--text); transform: translateX(6px); }
.index li.active a::before { color: var(--a); }
.index li.gone { display: none; }
.index-count { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--dim); }

.work-layout .timeline::before, .work-layout .timeline::after { display: none; }
.work-layout .project { grid-template-columns: 1fr; gap: 8px; padding-left: 0; }
.work-layout .project::before { display: none; }
.work-layout .when { flex-direction: row; align-items: center; justify-content: flex-start; padding-top: 0; text-align: left; gap: 10px; }

/* Inverted band (theme tokens swapped) */
.invert {
  margin: 0 calc(50% - 50vw); padding-inline: max(20px, calc((100vw - var(--max)) / 2 + 20px));
  --bg: #f4f2ee; --bg-2: #ebe8e2; --panel: #ffffff; --panel-2: #f3f1ec; --line: #d9d4cb;
  --text: #0d1117; --muted: #4b5563; --dim: #8a8f98; --a: var(--acc-l); --shadow: 0 8px 24px rgba(0,0,0,.08);
  background: var(--bg); color: var(--text); border-top: 0;
}
[data-theme="light"] .invert {
  --bg: #0b0f14; --bg-2: #10161d; --panel: #121a23; --panel-2: #17212c; --line: #243241;
  --text: #e6edf3; --muted: #8b9bab; --dim: #5d6d7d; --a: var(--acc); --shadow: 0 10px 30px rgba(0,0,0,.45);
}
.invert .xp-head b { color: var(--text); }

@media (max-width: 960px) {
  .work-layout { grid-template-columns: 1fr; }
  .index { display: none; }
}
@media (max-width: 720px) {
  h1.big { font-size: clamp(2.6rem, 13vw, 4rem); }
  .statement { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
  body::before { animation: none; }
  .statement .w { opacity: 1; color: var(--text); }
}

/* v3 fixes */
html, body { overflow-x: clip; }
h1.big { font-size: clamp(2.6rem, 6.6vw, 6.2rem); }
h1.big span { white-space: nowrap; }

/* v3.1: portrait, video, coursework */
.about-grid { display: grid; grid-template-columns: 240px 1fr; gap: 44px; align-items: center; }
.portrait { margin: 0; position: relative; }
.portrait img { border-radius: var(--radius); border: 1px solid var(--line); filter: grayscale(.25) contrast(1.05); transition: filter .4s; }
.portrait:hover img { filter: none; }
.portrait figcaption { margin-top: 8px; color: var(--dim); font-size: 11px; }
.gallery.media { grid-template-columns: 1.15fr 1fr 1fr; align-items: stretch; }
.shot.tall { height: 300px; }
.clip { margin: 0; position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #000; height: 300px; }
.clip video { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip figcaption { position: absolute; left: 8px; bottom: 8px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; }
.modules { border-top: 1px solid var(--line); padding: 10px 0; }
.modules summary { cursor: pointer; color: var(--text); font-size: 13px; list-style: none; }
.modules summary::before { content: "+ "; color: var(--a); }
.modules[open] summary::before { content: "− "; }
.modules p { margin: 8px 0 2px; color: var(--muted); font-size: 14px; line-height: 1.6; }
@media (max-width: 720px) {
  .about-grid { grid-template-columns: 1fr; gap: 24px; }
  .portrait { max-width: 200px; }
  .gallery.media { grid-template-columns: 1fr 1fr; }
  .gallery.media .clip { grid-column: span 2; height: 360px; }
  .shot.tall { height: 220px; }
}

/* v3.2: SO-101 gallery */
.gallery.so101 { grid-template-columns: repeat(4, 1fr); }
.gallery.so101 .clip.wide2 { grid-column: span 2; height: 260px; }
.gallery.so101 .shot.wide { height: 260px; }
.gallery.so101 .shot.wide img { object-fit: cover; }
.gallery.so101 .shot:not(.wide) img { object-position: center 30%; }
@media (max-width: 720px) {
  .gallery.so101 { grid-template-columns: 1fr 1fr; }
  .gallery.so101 .clip.wide2, .gallery.so101 .shot.wide { grid-column: span 2; height: 220px; }
}
.gallery.so101 .shot.fit { background: #0b1533; }
.gallery.so101 .shot.fit img { object-fit: contain; }

/* v3.3: tracker + gesture videos */
.clip.wide2 { grid-column: span 2; }
.clip.portrait-clip { grid-row: span 2; height: 410px; }
.gallery:has(.portrait-clip) { grid-template-columns: repeat(3, 1fr); grid-auto-flow: dense; }
.gallery:has(.portrait-clip) .shot.wide:last-child { grid-column: span 3; }
.gallery:has(.presentation) .shot, .clip.presentation { height: 260px; }
.clip.presentation video { object-fit: contain; background: #000; }
@media (max-width: 720px) {
  .gallery:has(.portrait-clip) { grid-template-columns: 1fr 1fr; }
  .gallery:has(.portrait-clip) .shot.wide:last-child { grid-column: span 2; }
  .clip.portrait-clip { height: 420px; }
  .clip.presentation { grid-column: span 2; height: 200px; }
}
.glitch::before, .glitch::after { white-space: nowrap; height: 1em; overflow: hidden; }
.clip.presentation figcaption { top: 8px; bottom: auto; }

/* v3.4: MIHAI fades in after RARES-STEFAN */
h1.big span:last-child { opacity: 0; filter: blur(8px); transform: translateY(10px); animation: mihaiIn 1.4s cubic-bezier(.2,.7,.2,1) 0.9s forwards; }
@keyframes mihaiIn { to { opacity: 1; filter: blur(0); transform: none; } }
@media (prefers-reduced-motion: reduce) { h1.big span:last-child { animation: none; opacity: 1; filter: none; transform: none; } }

/* v3.5: MIHAI hidden until you hover over the name, then fades in (accent colour) */
h1.big span:last-child {
  animation: none; color: var(--a); -webkit-text-stroke: 0;
  opacity: 0; filter: blur(10px); transform: translateX(-14px);
  transition: opacity .6s ease, filter .6s ease, transform .6s cubic-bezier(.2,.7,.2,1);
}
h1.big:hover span:last-child { opacity: 1; filter: blur(0); transform: none; }
@media (hover: none) { h1.big span:last-child { opacity: .9; filter: none; transform: none; } }
@media (prefers-reduced-motion: reduce) { h1.big span:last-child { transition: opacity .2s; } }
.gallery:has(.presentation) .clip.portrait-clip { height: auto; min-height: 400px; }
@media (max-width: 720px) {
  .gallery:has(.presentation) .shot.wide:last-child { grid-column: span 1; height: auto; }
  .gallery:has(.presentation) .clip.portrait-clip { min-height: 0; height: 380px; grid-row: span 1; }
}
@media (max-width: 720px) {
  .gallery:has(.presentation) { grid-template-columns: 1fr; }
  .gallery:has(.presentation) > * { grid-column: auto !important; }
}
.gallery:has(.presentation) .shot.wide:last-child { grid-column: span 2; }
@media (max-width: 720px) { .gallery:has(.presentation) .shot.wide:last-child { grid-column: auto; height: 220px; } }
