/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #0d0a16;
  --bg-2: #140f22;
  --surface: #1a142b;
  --surface-2: #241b3a;
  --line: #322749;
  --text: #f0ebfa;
  --muted: #a69cbd;
  --accent: #b388ff;
  --accent-2: #ff6ad5;
  --accent-ink: #0d0a16;
  --danger: #ff5c7a;
  --radius: 14px;
  --radius-sm: 8px;
  --max: 1200px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f7f4fc;
  --bg-2: #efe9f8;
  --surface: #ffffff;
  --surface-2: #f2edfa;
  --line: #ded4ee;
  --text: #18122a;
  --muted: #655a7c;
  --accent: #6d28d9;
  --accent-2: #db2777;
  --accent-ink: #ffffff;
  color-scheme: light;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .4s var(--ease), color .4s var(--ease);
}
img, video, iframe { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--accent); color: var(--accent-ink); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.05; margin: 0; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.container { width: min(var(--max), 100% - 32px); margin-inline: auto; }
@media (min-width: 720px) { .container { width: min(var(--max), 100% - 64px); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ==========================================================================
   Page transitions
   router.js swaps only <main> between pages, wrapped in a View Transition:
   the nav stays put (its background crossfades), the active pill slides to
   the new link, and the content fades and lifts. Browsers without View
   Transitions (.no-vt) get a plain fade-out / fade-in of <main> instead.
   The @view-transition rule covers full page loads if the router falls back.
   ========================================================================== */
html { background: var(--bg); }
main:focus { outline: none; }
@view-transition { navigation: auto; }
.nav { view-transition-name: site-nav; }
.nav-links a.active { view-transition-name: nav-active; }
.cursor { view-transition-name: cursor-ring; }
.cursor-dot { view-transition-name: cursor-dot; }
/* Page content waits (max 1.5s) for the web fonts so text never shows in a fallback font
   and then jumps; once fonts are cached this resolves before the first paint. */
main, .footer { transition: opacity .25s ease; }
.fonts-pending main, .fonts-pending .footer { opacity: 0; transition: none; }
/* Solid backdrop behind the crossfading snapshots — otherwise the browser canvas (white) shows through mid-fade */
::view-transition { background: var(--bg); }
::view-transition-old(root) { animation: page-out .32s var(--ease) both; }
::view-transition-new(root) { animation: page-in .6s var(--ease) .08s both; }
::view-transition-group(nav-active) { animation-duration: .55s; animation-timing-function: var(--ease); }
::view-transition-group(site-nav) { animation-duration: .35s; }
::view-transition-group(cursor-ring), ::view-transition-group(cursor-dot) { animation: none; }
::view-transition-old(cursor-ring), ::view-transition-old(cursor-dot) { display: none; }
::view-transition-new(cursor-ring), ::view-transition-new(cursor-dot) { animation: none; }
@keyframes page-out { to { opacity: 0; transform: translateY(-28px) scale(.985); filter: blur(6px); } }
@keyframes page-in { from { opacity: 0; transform: translateY(36px); filter: blur(4px); } }

.no-vt main, .no-vt .footer { animation: page-in .6s var(--ease) both; }
.no-vt body.leaving main, .no-vt body.leaving .footer { animation: page-out .3s var(--ease) both; }

/* Reduced motion: keep a gentle crossfade, drop the movement and blur */
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root) { animation: fade-out .25s ease both; }
  ::view-transition-new(root) { animation: fade-in .35s ease both; }
  ::view-transition-group(nav-active) { animation-duration: .3s; }
  .no-vt main, .no-vt .footer { animation: fade-in .35s ease both; }
  .no-vt body.leaving main, .no-vt body.leaving .footer { animation: fade-out .25s ease both; }
}

/* Film-grain overlay for texture */
body::after {
  content: ""; position: fixed; inset: -50%; z-index: 999; pointer-events: none; opacity: .045;
  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 1s steps(4) infinite;
}
@keyframes grain { 0%{transform:translate(0,0)} 25%{transform:translate(-3%,2%)} 50%{transform:translate(2%,-3%)} 75%{transform:translate(-2%,-2%)} }

/* ==========================================================================
   Custom cursor (desktop only)
   ========================================================================== */
/* Top-most layer: above the terminal, lightbox, panels, toasts and loader, so it's never hidden */
.cursor, .cursor-dot { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 9999; border-radius: 50%; transform: translate(-50%, -50%); }
/* Contrast halo: every part of the cursor is drawn as accent colour sandwiched between thin
   strokes of the opposite tone, so it stays visible on any background, including accent-coloured
   buttons, selected chips, images and the dark console (the same trick as the system arrow's outline). */
:root { --cursor-halo: rgba(13, 10, 22, .85); }
:root[data-theme="light"] { --cursor-halo: rgba(255, 255, 255, .95); }
.cursor { width: 36px; height: 36px; border: 2px solid var(--accent); box-shadow: 0 0 0 1.5px var(--cursor-halo), inset 0 0 0 1.5px var(--cursor-halo); transition: width .25s var(--ease), height .25s var(--ease), background .25s; }
.cursor-dot { width: 6px; height: 6px; background: var(--accent); box-shadow: 0 0 0 1.5px var(--cursor-halo); }
.cursor.is-hover { width: 64px; height: 64px; background: color-mix(in srgb, var(--accent) 20%, transparent); }
/* Copy of the cursor in the terminal's (dark-mode) colours; main.js clips it to the part over the console */
.cursor.cursor-term, .cursor-dot.cursor-term { --cursor-halo: rgba(12, 9, 20, .9); z-index: 10000; visibility: hidden; view-transition-name: none; }
.cursor.cursor-term { border-color: #b388ff; }
.cursor.cursor-term.is-hover { background: rgba(179, 136, 255, .2); }
.cursor-dot.cursor-term { background: #b388ff; }
@media (hover: none), (pointer: coarse) { .cursor, .cursor-dot { display: none; } }
/* People who ask their system for more contrast (or use Windows high-contrast themes) keep the normal system cursor */
@media (prefers-contrast: more), (forced-colors: active) { .cursor, .cursor-dot { display: none; } }
@media (hover: hover) and (pointer: fine) { body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; } }

/* ==========================================================================
   Loader
   ========================================================================== */
.loader { position: fixed; inset: 0; z-index: 2000; background: var(--bg); display: grid; place-items: center; transition: opacity .5s, visibility .5s; }
.loader.done { opacity: 0; visibility: hidden; }
.loader-inner { font-family: var(--font-mono); font-size: 13px; color: var(--muted); width: min(320px, 80vw); }
.loader-bar { height: 3px; background: var(--line); margin-top: 12px; overflow: hidden; border-radius: 2px; }
.loader-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ==========================================================================
   Nav
   ========================================================================== */
.nav { position: fixed; inset: 0 0 auto; z-index: 100; transition: background .3s, backdrop-filter .3s, border-color .3s; border-bottom: 1px solid transparent; }
.nav.scrolled { background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(14px); border-color: var(--line); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.logo { font-family: var(--font-mono); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.logo-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 13px; transition: transform .4s var(--ease); }
.logo:hover .logo-mark { transform: rotate(-12deg) scale(1.08); }
.nav-links { display: flex; gap: 4px; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-links a { font-size: 14px; padding: 8px 14px; border-radius: 999px; color: var(--muted); transition: color .2s, background .2s; font-family: var(--font-mono); }
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--text); background: var(--surface-2); }
.nav-links a .idx { color: var(--accent); margin-right: 4px; font-size: 11px; }
.nav-tools { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); transition: border-color .2s, transform .2s; }
.icon-btn:hover { border-color: var(--accent); transform: rotate(15deg); }
.icon-btn svg { width: 17px; height: 17px; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: grid; }
  .nav-links { position: fixed; inset: 68px 0 auto; flex-direction: column; align-items: stretch; background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 16px 20px; transform: translateY(-120%); transition: transform .4s var(--ease); z-index: -1; }
  .nav-links.open { transform: none; }
  .nav-links a { display: block; font-size: 18px; padding: 12px 8px; }
}

/* ==========================================================================
   Buttons, tags, chips
   ========================================================================== */
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: 999px; font-weight: 600; font-size: 15px; border: 1px solid var(--line); transition: transform .25s var(--ease), background .25s, border-color .25s, color .25s; position: relative; overflow: hidden; }
.btn:hover { transform: translateY(-2px); border-color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { border-color: var(--accent); box-shadow: 0 10px 30px -10px var(--accent); }
.btn .arrow { transition: transform .25s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }
.tag { font-family: var(--font-mono); font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.eyebrow { font-family: var(--font-mono); font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; display: inline-flex; gap: 10px; align-items: center; }
.eyebrow::before { content: ""; width: 24px; height: 1px; background: currentColor; }

/* ==========================================================================
   Sections
   ========================================================================== */
main { display: block; }
.section { padding: clamp(72px, 12vw, 140px) 0; position: relative; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 48px; flex-wrap: wrap; }
.section-title { font-size: clamp(36px, 6vw, 72px); margin-top: 14px; }
.page-hero { padding: 160px 0 40px; }
.page-hero h1 { font-size: clamp(48px, 10vw, 128px); margin-top: 16px; }
.page-hero p { font-size: clamp(17px, 2vw, 20px); color: var(--muted); max-width: 640px; margin-top: 20px; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } body::after { animation: none; } html { scroll-behavior: auto; } }

/* ==========================================================================
   Home hero
   ========================================================================== */
.hero { min-height: 100svh; display: flex; align-items: center; position: relative; overflow: hidden; padding: 100px 0 60px; }
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-content { position: relative; z-index: 2; pointer-events: none; }
.hero-content a, .hero-content button { pointer-events: auto; }
.hero-status { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 13px; padding: 7px 14px 7px 10px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(6px); }
.pulse { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: #3dff8a; box-shadow: 0 0 0 0 #3dff8a; animation: pulse 2s infinite; }
.pulse.off { background: var(--danger); box-shadow: none; animation: none; }
/* Hidden for a moment while the live status (availabilityGist) loads, so the badge never flips colour in view */
.status-pending { visibility: hidden; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.hero h1 { font-size: clamp(52px, 11vw, 150px); margin: 26px 0 10px; font-weight: 700; }
.hero h1 .line { display: block; overflow: hidden; }
.hero h1 .line > span { display: inline-block; transform: translateY(110%); animation: rise 1s var(--ease) forwards; }
.hero h1 .line:nth-child(2) > span { animation-delay: .12s; }
/* Hero name: hover swaps it to your handle with a typewriter effect (pages.js) */
#hero-name { pointer-events: auto; white-space: nowrap; }
#hero-name .hn-caret { display: none; height: .85em; width: .08em; margin-left: .04em; vertical-align: -.02em; }
#hero-name.typing .hn-caret { display: inline-block; }
@keyframes rise { to { transform: none; } }
.glitch { position: relative; color: var(--accent); }
.glitch:hover::before, .glitch:hover::after { content: attr(data-text); position: absolute; inset: 0; }
.glitch:hover::before { color: var(--accent-2); animation: glitch 0.35s steps(2) infinite; clip-path: inset(0 0 55% 0); transform: translate(-3px, 0); }
.glitch:hover::after { color: #5ee7ff; animation: glitch 0.35s steps(2) infinite reverse; clip-path: inset(50% 0 0 0); transform: translate(3px, 0); }
@keyframes glitch { 0% { transform: translate(-3px, 1px); } 50% { transform: translate(3px, -1px); } 100% { transform: translate(-1px, 2px); } }
.hero-role { font-family: var(--font-mono); font-size: clamp(16px, 2.4vw, 22px); color: var(--muted); min-height: 1.6em; }
.hero-role .typed { color: var(--text); }
.caret { display: inline-block; width: .6em; height: 1.1em; background: var(--accent); vertical-align: -.15em; margin-left: 4px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero-tagline { max-width: 560px; font-size: clamp(17px, 2vw, 20px); color: var(--muted); margin: 22px 0 36px; }
.hero-ctas { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-hint { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 2; font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.hero-hint .mouse { width: 22px; height: 34px; border: 1.5px solid var(--muted); border-radius: 12px; position: relative; }
.hero-hint .mouse::after { content: ""; position: absolute; left: 50%; top: 7px; width: 3px; height: 7px; background: var(--accent); border-radius: 2px; transform: translateX(-50%); animation: scroll 1.6s infinite; }
@keyframes scroll { 0% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 10px); } }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text); }
.hud { position: absolute; z-index: 2; top: 92px; right: 32px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-align: right; line-height: 1.8; pointer-events: none; }
.hud b { color: var(--text); font-weight: 500; }
@media (max-width: 720px) { .hud { display: none; } }

/* Marquee */
.marquee { border-block: 1px solid var(--line); overflow: hidden; padding: 22px 0; background: var(--bg-2); }
.marquee-track { display: flex; gap: 48px; width: max-content; animation: marquee 40s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-item { font-family: var(--font-display); font-size: clamp(22px, 3vw, 34px); font-weight: 600; white-space: nowrap; display: flex; align-items: center; gap: 48px; color: var(--muted); }
.marquee-item::after { content: "✦"; color: var(--accent); font-size: .6em; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 32px 24px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat-value { font-family: var(--font-display); font-size: clamp(40px, 5vw, 64px); font-weight: 700; line-height: 1; }
.stat-value .suffix { color: var(--accent); }
.stat-label { color: var(--muted); font-family: var(--font-mono); font-size: 13px; margin-top: 10px; }
@media (max-width: 720px) { .stats { grid-template-columns: 1fr 1fr; } .stat:nth-child(2) { border-right: 0; } .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }

/* ==========================================================================
   Project cards
   ========================================================================== */
.grid { display: grid; gap: 24px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.card { position: relative; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; transition: border-color .3s, transform .5s var(--ease); transform-style: preserve-3d; will-change: transform; display: flex; flex-direction: column; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.card-media { aspect-ratio: 16/10; position: relative; overflow: hidden; background: var(--surface-2); }
.card-media img, .card-media video, .card-media canvas { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--ease), opacity .4s; }
.card:hover .card-media img, .card:hover .card-media canvas { transform: scale(1.06); }
.card-media video { position: absolute; inset: 0; opacity: 0; }
.card:hover .card-media video { opacity: 1; }
.card-badge { position: absolute; top: 14px; left: 14px; z-index: 2; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(8px); border: 1px solid color-mix(in srgb, var(--text) 15%, transparent); }
.card-body { padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card h3 { font-size: 24px; }
.card-year { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.card p { color: var(--muted); font-size: 15px; margin: 0; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.card-arrow { position: absolute; top: 14px; right: 14px; z-index: 2; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; transform: scale(0) rotate(-45deg); transition: transform .4s var(--ease); }
.card:hover .card-arrow { transform: scale(1) rotate(0); }
.card-glare { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--text) 10%, transparent), transparent 50%); opacity: 0; transition: opacity .3s; z-index: 3; }
.card:hover .card-glare { opacity: 1; }

/* Featured layout on home: first card large */
.featured-grid { display: grid; gap: 24px; grid-template-columns: repeat(2, 1fr); }
.featured-grid .card:first-child { grid-column: span 2; }
.featured-grid .card:first-child .card-media { aspect-ratio: 21/9; }
.featured-grid .card:first-child h3 { font-size: clamp(28px, 4vw, 44px); }
@media (max-width: 760px) { .featured-grid { grid-template-columns: 1fr; } .featured-grid .card:first-child { grid-column: auto; } .featured-grid .card:first-child .card-media { aspect-ratio: 16/10; } }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 36px; align-items: center; }
.filter { font-family: var(--font-mono); font-size: 13px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); transition: all .2s; }
.filter:hover { color: var(--text); border-color: var(--text); }
.filter.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.filter .count { opacity: .55; margin-left: 4px; }
.filter.zero:not(.active) { opacity: .4; }
.search { margin-left: auto; position: relative; }
.search input { font: inherit; font-family: var(--font-mono); font-size: 13px; background: var(--surface); border: 1px solid var(--line); color: var(--text); padding: 9px 16px; border-radius: 999px; width: 220px; outline: none; transition: border-color .2s; }
.search input:focus { border-color: var(--accent); }
@media (max-width: 640px) { .search { margin-left: 0; width: 100%; } .search input { width: 100%; } }
.card.hide { display: none; }
.empty { text-align: center; padding: 80px 0; color: var(--muted); font-family: var(--font-mono); }
/* Year & tag filter panel (Work page) — separate from the category filters above it */
.more-filters { display: inline-flex; align-items: center; gap: 6px; }
.more-filters::before { content: "⚙"; font-size: 12px; }
.more-filters[aria-expanded="true"], .more-filters.has-active { border-color: var(--accent); color: var(--text); }
.more-filters.has-active .count { opacity: 1; background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.adv-filters { display: grid; gap: 16px; margin: -16px 0 36px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.adv-filters[hidden] { display: none; }
.adv-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.adv-label { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); min-width: 52px; padding-top: 8px; }
.adv-select { font: inherit; font-family: var(--font-mono); font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; outline: none; cursor: pointer; }
.adv-select:focus { border-color: var(--accent); }
.adv-tags { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.tag-chip { font-family: var(--font-mono); font-size: 12px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); transition: all .2s; }
.tag-chip:hover { color: var(--text); border-color: var(--text); }
.tag-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag-chip .count { opacity: .55; margin-left: 5px; }
.adv-foot { align-items: center; }
.adv-foot .adv-label { padding-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg-btn { font-family: var(--font-mono); font-size: 12px; padding: 5px 12px; border-radius: 999px; color: var(--muted); transition: all .2s; }
.seg-btn.active { background: var(--text); color: var(--bg); }
.adv-clear { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.adv-clear:hover { color: var(--accent); }
@media (max-width: 640px) { .adv-label { min-width: 100%; padding-top: 0; } .adv-clear { margin-left: 0; } }

/* ==========================================================================
   Project detail
   ========================================================================== */
.project-hero { padding: 140px 0 40px; }
.back { font-family: var(--font-mono); font-size: 13px; color: var(--muted); display: inline-flex; gap: 8px; align-items: center; transition: color .2s, gap .2s; }
.back:hover { color: var(--accent); gap: 12px; }
.project-hero h1 { font-size: clamp(48px, 9vw, 120px); margin: 24px 0 18px; }
.project-hero .summary { font-size: clamp(18px, 2.2vw, 24px); color: var(--muted); max-width: 820px; }
.meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 40px; }
.meta div { background: var(--bg); padding: 18px 20px; }
.meta dt { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.meta dd { margin: 6px 0 0; font-weight: 500; }
@media (max-width: 720px) { .meta { grid-template-columns: 1fr 1fr; } }
.project-cover { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); aspect-ratio: 16/9; background: var(--surface); position: relative; }
.project-cover img, .project-cover canvas, .project-cover iframe, .project-cover video { width: 100%; height: 100%; object-fit: cover; border: 0; }
/* Video switcher (projects with more than one video) */
.video-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; margin-top: 16px; }
.video-tab { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); transition: border-color .2s, transform .25s var(--ease); }
.video-tab:hover { border-color: var(--text); transform: translateY(-2px); }
.video-tab.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.video-tab .thumb { position: relative; display: block; aspect-ratio: 16/9; background: var(--surface-2); }
.video-tab .thumb img, .video-tab .thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.video-tab .thumb::after { content: "▶"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 18px; background: rgba(0,0,0,.3); transition: background .2s; }
.video-tab:hover .thumb::after { background: rgba(0,0,0,.15); }
.video-tab.active .thumb::after { content: "● Now playing"; font-family: var(--font-mono); font-size: 12px; background: color-mix(in srgb, var(--accent) 35%, rgba(0,0,0,.45)); }
.video-tab-text { display: block; padding: 10px 12px 12px; font-size: 14px; font-weight: 500; line-height: 1.35; }
.video-tab-text small { display: block; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 2px; font-weight: 400; }
.project-layout { display: grid; grid-template-columns: 1fr 320px; gap: 64px; margin-top: 72px; align-items: start; }
@media (max-width: 900px) { .project-layout { grid-template-columns: 1fr; gap: 40px; } }
.prose h2 { font-size: clamp(26px, 3vw, 34px); margin: 0 0 16px; }
.prose section + section { margin-top: 48px; }
.prose p { color: color-mix(in srgb, var(--text) 82%, var(--muted)); font-size: 17px; line-height: 1.75; }
.prose code { font-family: var(--font-mono); font-size: .88em; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.aside { position: sticky; top: 100px; display: flex; flex-direction: column; gap: 28px; }
.aside h4 { font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 12px; font-weight: 500; }
.links-list { display: flex; flex-direction: column; gap: 8px; }
.links-list a { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius-sm); transition: all .2s; font-weight: 500; }
.links-list a:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.links-list a:first-child { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.highlights { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.highlights li { display: flex; gap: 10px; font-size: 15px; }
.highlights li::before { content: "▸"; color: var(--accent); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-top: 72px; }
.gallery button { aspect-ratio: 4/3; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); position: relative; padding: 0; }
.gallery img, .gallery canvas { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.gallery button:hover img, .gallery button:hover canvas { transform: scale(1.06); }
.next-project { display: block; border-top: 1px solid var(--line); margin-top: 100px; padding: 72px 0; text-align: center; transition: background .3s; }
.next-project:hover { background: var(--bg-2); }
.next-project .label { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.next-project h2 { font-size: clamp(40px, 8vw, 100px); margin-top: 12px; transition: color .3s; }
.next-project:hover h2 { color: var(--accent); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 1500; background: rgba(5,5,8,.92); display: none; place-items: center; padding: 24px; }
.lightbox.open { display: grid; }
.lightbox img, .lightbox canvas { max-height: 85vh; max-width: 92vw; border-radius: var(--radius-sm); }
.lightbox-close, .lightbox-nav { position: absolute; color: #fff; font-family: var(--font-mono); width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.2); display: grid; place-items: center; }
.lightbox-close { top: 20px; right: 20px; }
.lightbox-nav.prev { left: 20px; top: 50%; }
.lightbox-nav.next { right: 20px; top: 50%; }

/* ==========================================================================
   About
   ========================================================================== */
.about-grid { display: grid; grid-template-columns: 380px 1fr; gap: 72px; align-items: start; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; gap: 40px; } }
.portrait { aspect-ratio: 4/5; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); position: relative; background: var(--surface); }
.portrait img, .portrait canvas { width: 100%; height: 100%; object-fit: cover; }
.portrait-caption { position: absolute; left: 14px; bottom: 14px; right: 14px; font-family: var(--font-mono); font-size: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--bg) 75%, transparent); backdrop-filter: blur(8px); display: flex; justify-content: space-between; }
.about-intro { font-family: var(--font-display); font-size: clamp(24px, 3vw, 36px); line-height: 1.25; letter-spacing: -.01em; margin-bottom: 28px; }
.about-text p { color: var(--muted); font-size: 17px; line-height: 1.75; }
.fun-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 32px; }
.fun-facts div { background: var(--bg); padding: 16px 18px; }
.fun-facts dt { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.fun-facts dd { margin: 4px 0 0; font-weight: 500; }
.now-box { border: 1px dashed var(--accent); border-radius: var(--radius); padding: 22px 24px; margin-top: 32px; }
.now-box h3 { font-family: var(--font-mono); font-size: 13px; color: var(--accent); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 12px; }
.now-box ul { margin: 0; padding-left: 18px; color: var(--muted); }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 20px; }
.skill-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; background: var(--surface); transition: border-color .3s, transform .3s var(--ease); }
.skill-group:hover { border-color: var(--accent); transform: translateY(-4px); }
.skill-group h3 { font-size: 20px; margin-bottom: 16px; display: flex; justify-content: space-between; }
.skill-group h3 span { font-family: var(--font-mono); font-size: 12px; color: var(--muted); font-weight: 400; }
.skill-group .tags .tag { color: var(--text); }
.timeline { position: relative; padding-left: 32px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 44px; display: grid; grid-template-columns: 180px 1fr; gap: 24px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: -32px; top: 6px; width: 13px; height: 13px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.tl-when { font-family: var(--font-mono); font-size: 13px; color: var(--muted); padding-top: 2px; }
.tl-item h3 { font-size: 22px; }
.tl-where { color: var(--accent); font-size: 15px; margin: 4px 0 8px; }
.tl-item p { color: var(--muted); margin: 0; }
@media (max-width: 640px) { .tl-item { grid-template-columns: 1fr; gap: 4px; } }

/* ==========================================================================
   Contact / CTA
   ========================================================================== */
.cta { text-align: center; padding: clamp(80px, 14vw, 160px) 0; position: relative; overflow: hidden; }
.cta h2 { font-size: clamp(44px, 9vw, 120px); margin: 18px 0 32px; }
.cta h2 a { display: inline-block; transition: color .3s; border-bottom: 3px solid var(--accent); }
.cta h2 a:hover { color: var(--accent); }
.contact-wrap { display: grid; gap: 24px; padding: 32px 0 140px; }
.email-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: clamp(28px, 5vw, 56px); position: relative; overflow: hidden; }
.email-card::before { content: ""; position: absolute; inset: auto -20% -60% auto; width: 60%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); pointer-events: none; }
.contact-huge { position: relative; display: flex; align-items: baseline; gap: .3em; font-family: var(--font-display); font-weight: 700; letter-spacing: -.03em; font-size: clamp(22px, 4.4vw, 60px); line-height: 1.05; margin: 18px 0 32px; white-space: nowrap; transition: color .3s; }
.contact-huge .arrow { font-size: .6em; color: var(--accent); transition: transform .3s var(--ease); }
.contact-huge:hover { color: var(--accent); }
.contact-huge:hover .arrow { transform: translate(4px, -4px); }
.email-actions { position: relative; display: flex; gap: 12px; flex-wrap: wrap; }
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 24px; }
.info-card { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; background: var(--bg); transition: border-color .3s, transform .3s var(--ease); }
.info-card .label { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.info-card .value { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; }
.info-link:hover { border-color: var(--accent); transform: translateY(-3px); }
.info-link:hover .value { color: var(--accent); }
.social-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; margin-top: 20px; }
.social-card { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 20px 22px; border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .3s, background .3s, transform .3s var(--ease); }
.social-card strong { display: block; font-size: 18px; font-weight: 600; }
.social-card small { display: block; font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.social-card-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); transition: background .3s, border-color .3s; }
.social-card-icon .social-icon { width: 20px; height: 20px; color: var(--text); }
.social-card-text { flex: 1; min-width: 0; }
.social-card:hover .social-card-icon { background: var(--accent); border-color: var(--accent); }
.social-card:hover .social-card-icon .social-icon { color: var(--accent-ink); }
.social-card .arrow { color: var(--muted); transition: transform .3s var(--ease), color .3s; }
.social-card:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); transform: translateY(-3px); }
.social-card:hover .arrow { color: var(--accent); transform: translate(3px, -3px); }

/* ==========================================================================
   Footer
   ========================================================================== */
.footer { border-top: 1px solid var(--line); padding: 40px 0; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: center; }
.footer a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 10px; flex-wrap: wrap; }
.social-btn { display: inline-flex; align-items: center; gap: 9px; padding: 9px 14px 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; transition: border-color .25s, background .25s, transform .25s var(--ease), color .25s; }
.social-icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--muted); transition: color .25s, transform .25s var(--ease); }
.social-arrow { font-size: 11px; color: var(--muted); transition: transform .25s var(--ease), color .25s; }
.footer .social-btn:hover, .social-btn:focus-visible { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); transform: translateY(-2px); }
.social-btn:hover .social-icon, .social-btn:focus-visible .social-icon { color: var(--accent); transform: scale(1.1); }
.social-btn:hover .social-arrow, .social-btn:focus-visible .social-arrow { color: var(--accent); transform: translate(2px, -2px); }
.social-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ==========================================================================
   Terminal easter egg
   ========================================================================== */
.terminal { position: fixed; z-index: 1200; left: 50%; bottom: 24px; width: min(720px, calc(100% - 32px)); height: min(440px, 70vh); transform: translate(-50%, 120%); transition: transform .45s var(--ease); background: #0c0914; color: #e6dcff; border: 1px solid #322749; border-radius: 12px; box-shadow: 0 40px 80px -20px rgba(0,0,0,.7); display: flex; flex-direction: column; font-family: var(--font-mono); font-size: 13.5px; overflow: hidden; }
.terminal.open { transform: translate(-50%, 0); }
.term-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #161026; border-bottom: 1px solid #322749; color: #9a8fb5; font-size: 12px; }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; display: block; }
.term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: 8px; flex: 1; }
.term-bar button { color: #9a8fb5; }
.term-out { flex: 1; overflow-y: auto; padding: 14px 16px; white-space: pre-wrap; line-height: 1.55; }
.term-out .c { color: #b388ff; } .term-out .d { color: #7d7396; } .term-out .e { color: #ff6b8a; } .term-out a { color: #7cc4ff; text-decoration: underline; }
.term-in { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid #221a35; }
.term-in span { color: #b388ff; }
.term-in input { flex: 1; background: none; border: 0; outline: none; color: inherit; font: inherit; }

/* Achievement toast */
.toasts { position: fixed; z-index: 1300; top: 84px; right: 20px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 18px 12px 14px; box-shadow: 0 20px 40px -12px rgba(0,0,0,.5); animation: toast-in .5s var(--ease), toast-out .4s var(--ease) 3.6s forwards; max-width: 320px; }
.toast-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.toast small { display: block; font-family: var(--font-mono); font-size: 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; }
.toast strong { font-size: 14px; display: block; }
.toast span.desc { font-size: 12px; color: var(--muted); }
@keyframes toast-in { from { transform: translateX(120%); opacity: 0; } }
@keyframes toast-out { to { transform: translateX(120%); opacity: 0; } }
.ach-btn { position: relative; }
.ach-btn .badge { position: absolute; top: -4px; right: -4px; font-size: 10px; font-family: var(--font-mono); background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 5px; min-width: 16px; line-height: 16px; text-align: center; }
.ach-panel { position: fixed; z-index: 1250; top: 76px; right: 20px; width: min(340px, calc(100% - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.6); display: none; }
.ach-panel.open { display: block; }
.ach-panel h4 { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; display: flex; justify-content: space-between; font-weight: 500; }
.ach { display: flex; gap: 12px; align-items: center; padding: 8px 0; }
.ach .ico { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-2); filter: grayscale(1); opacity: .5; }
.ach.got .ico { background: var(--accent); color: var(--accent-ink); filter: none; opacity: 1; }
.ach b { font-size: 14px; display: block; font-weight: 600; }
.ach span { font-size: 12px; color: var(--muted); }
.ach:not(.got) b { color: var(--muted); }
.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .5s var(--ease); }

/* 404 */
.notfound { min-height: 100svh; display: grid; place-items: center; text-align: center; }
.notfound h1 { font-size: clamp(100px, 25vw, 280px); color: var(--accent); }
