/* =========================================================
   Thivyan Jeyamohan — Portfolio
   Black & champagne-gold luxury theme (dark default, ivory light)
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #0a0a0b;
  --bg-alt: #0f0f11;
  --surface: #141416;
  --surface-2: #1a1a1d;
  --text: #f2ede4;
  --muted: #a39d92;
  --faint: #6d685f;
  --hair: rgba(201, 169, 110, .18);
  --hair-strong: rgba(201, 169, 110, .38);
  --gold: #c9a96e;
  --gold-light: #e8d3a3;
  --gold-deep: #9c7c45;
  --gold-grad: linear-gradient(120deg, #f1dfb2 0%, #c9a96e 45%, #a8854c 70%, #e8d3a3 100%);
  --on-gold: #17130b;
  --glow: rgba(201, 169, 110, .12);
  --glow-strong: rgba(201, 169, 110, .22);
  --shadow: 0 30px 80px rgba(0, 0, 0, .55);
  --font-display: "Cormorant Garamond", "Times New Roman", serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --intro: 1.15s; /* hero animations start after the preloader */

  /* Code editor (always dark) */
  --ed-bg: #111113;
  --ed-bar: #0b0b0c;
  --ed-side: #0e0e10;
  --ed-line: rgba(255, 255, 255, .06);
  --ed-text: #d9d2c5;
  --ed-gutter: #4c4840;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f7f3ec;
  --bg-alt: #efe9de;
  --surface: #fbf8f3;
  --surface-2: #f3ede2;
  --text: #16130e;
  --muted: #615a4e;
  --faint: #938b7d;
  --hair: rgba(140, 108, 52, .22);
  --hair-strong: rgba(140, 108, 52, .45);
  --gold: #9c7a3e;
  --gold-light: #b8955a;
  --gold-deep: #7a5d2b;
  --gold-grad: linear-gradient(120deg, #b8955a 0%, #8f6d33 50%, #b08a4c 100%);
  --on-gold: #fffaf0;
  --glow: rgba(176, 138, 76, .14);
  --glow-strong: rgba(176, 138, 76, .2);
  --shadow: 0 30px 70px rgba(60, 45, 20, .18);
  color-scheme: light;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 300 16px/1.75 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .4s, color .4s;
}
::selection { background: var(--gold); color: var(--on-gold); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.05; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: clamp(2.4rem, 5vw, 3.8rem); margin-bottom: 1rem; }
h2 em, .pull em, .tagline em { font-style: italic; color: var(--gold-light); }
:root[data-theme="light"] h2 em, :root[data-theme="light"] .pull em, :root[data-theme="light"] .tagline em { color: var(--gold); }
h3 { font-size: 1.5rem; }
p { margin: 0 0 1.1rem; }
strong { font-weight: 600; color: var(--text); }
a { color: var(--gold); text-decoration: none; }
button { font: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.fill { fill: currentColor; stroke: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.wrap { width: min(1200px, 100% - 32px); margin-inline: auto; position: relative; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--on-gold); padding: 8px 14px; z-index: 300; }
.skip:focus { left: 8px; }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ---------- Ambient layers ---------- */
.grain {
  position: fixed; inset: 0; z-index: 100; 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");
}
:root[data-theme="light"] .grain { opacity: .035; }

.scroll-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 120;
  background: var(--gold-grad); transform-origin: left; transform: scaleX(var(--p, 0));
}

.cursor-glow, .cursor-ring { position: fixed; left: 0; top: 0; pointer-events: none; opacity: 0; transition: opacity .4s; }
.cursor-glow {
  z-index: 90; width: 520px; height: 520px; margin: -260px 0 0 -260px; border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 62%);
}
.cursor-ring {
  z-index: 130; width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 50%;
  border: 1px solid var(--gold); transition: opacity .3s, width .3s var(--ease), height .3s var(--ease), margin .3s var(--ease), background .3s;
}
.cursor-ring.hover { width: 64px; height: 64px; margin: -32px 0 0 -32px; background: var(--glow); }
body.has-cursor .cursor-glow, body.has-cursor .cursor-ring { opacity: 1; }

/* Preloader — fully CSS-timed so it never blocks the page */
.preloader {
  position: fixed; inset: 0; z-index: 400; display: grid; place-items: center;
  background: var(--bg); pointer-events: none;
  animation: preOut .7s var(--ease) .9s forwards;
}
.preloader svg { position: absolute; width: 120px; height: 120px; transform: rotate(-90deg); }
.preloader circle { fill: none; stroke: var(--gold); stroke-width: 1; stroke-dasharray: 340; stroke-dashoffset: 340; animation: draw 1s var(--ease) forwards; }
.preloader span { font: italic 500 2rem var(--font-display); color: var(--gold-light); opacity: 0; animation: fadeIn .6s .2s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes preOut { to { opacity: 0; visibility: hidden; transform: scale(1.04); } }

/* Floating orbs */
.orb { position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; z-index: -1; }
.orb-1 { width: 520px; height: 520px; right: -120px; top: -80px; background: radial-gradient(circle, rgba(201, 169, 110, .22), transparent 65%); animation: drift 18s ease-in-out infinite alternate; }
.orb-2 { width: 420px; height: 420px; left: -160px; bottom: 60px; background: radial-gradient(circle, rgba(156, 124, 69, .16), transparent 65%); animation: drift 22s ease-in-out infinite alternate-reverse; }
.orb-3 { width: 760px; height: 760px; left: 50%; top: 50%; margin: -380px 0 0 -380px; background: radial-gradient(circle, rgba(201, 169, 110, .16), transparent 62%); animation: breathe 8s ease-in-out infinite; }
@keyframes drift { to { transform: translate(-60px, 50px) scale(1.1); } }
@keyframes breathe { 50% { transform: scale(1.15); opacity: .7; } }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 110;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .4s, transform .5s var(--ease);
}
.nav.scrolled { border-bottom-color: var(--hair); }
.nav.hidden { transform: translateY(-100%); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 76px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--text); }
.monogram {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--hair-strong);
  font: italic 500 1.15rem var(--font-display); color: var(--gold-light);
  transition: transform .6s var(--ease), background .3s;
}
.brand:hover .monogram { transform: rotate(360deg); background: var(--glow); }
:root[data-theme="light"] .monogram { color: var(--gold); }
.monogram.small { width: 34px; height: 34px; font-size: .95rem; }
.brand-name { font: 500 .78rem var(--font-body); letter-spacing: .28em; text-transform: uppercase; }
.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-links a {
  position: relative; color: var(--muted); padding: 8px 11px;
  font-size: .76rem; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  transition: color .25s;
}
.nav-links a::after {
  content: ""; position: absolute; left: 11px; right: 11px; bottom: 2px; height: 1px;
  background: var(--gold); transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a:hover::after, .nav-links a.active::after { transform: scaleX(1); }
.nav-links .nav-cta { color: var(--gold); border: 1px solid var(--hair-strong); padding: 9px 18px; margin-left: 10px; border-radius: 999px; }
.nav-links .nav-cta::after { display: none; }
.nav-links .nav-cta:hover { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.nav-actions { display: flex; gap: 8px; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--hair); background: transparent; color: var(--text); cursor: pointer;
  transition: border-color .25s, color .25s, transform .5s var(--ease);
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }
#themeToggle:hover { transform: rotate(40deg); }
.i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; }
:root[data-theme="light"] .i-moon { display: none; }
.menu-btn { display: none; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 15px 28px; border-radius: 999px;
  font: 500 .78rem var(--font-body); letter-spacing: .16em; text-transform: uppercase;
  border: 1px solid transparent; transition: transform .35s var(--ease), box-shadow .3s, background .3s, color .3s, border-color .3s;
}
.btn-gold { background: var(--gold-grad); background-size: 200% 100%; color: var(--on-gold); box-shadow: 0 10px 30px var(--glow); }
.btn-gold::before {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg); animation: shine 4.5s ease-in-out 2.5s infinite;
}
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }
.btn-gold:hover { background-position: 100% 0; box-shadow: 0 14px 40px rgba(201, 169, 110, .32); }
.btn-gold svg { transition: transform .3s var(--ease); }
.btn-gold:hover svg { transform: translateX(4px); }
.btn-line { border-color: var(--hair-strong); color: var(--text); }
.btn-line:hover { border-color: var(--gold); color: var(--gold); }

/* ---------- Hero ---------- */
.hero { position: relative; isolation: isolate; padding: clamp(40px, 6vw, 80px) 0 0; overflow: hidden; }
.particles { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: 1fr 1.02fr; gap: 64px; align-items: center; }
.hero-grid > * { min-width: 0; }
.eyebrow {
  display: flex; align-items: center; gap: 14px; margin-bottom: 26px; min-height: 1.6em;
  font-size: .74rem; font-weight: 500; letter-spacing: .28em; text-transform: uppercase; color: var(--gold);
}
.eyebrow .line { width: 44px; height: 1px; background: var(--gold); flex-shrink: 0; }
.caret { width: 1px; height: 1.2em; background: var(--gold); margin-left: -8px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
h1 { font-weight: 400; line-height: .95; margin-bottom: 26px; }
.h1-top, .h1-bottom { display: block; font-size: clamp(3.3rem, 7.4vw, 6.4rem); white-space: nowrap; }
.h1-bottom { font-style: italic; padding-left: clamp(0px, 3vw, 52px); }
.ch { display: inline-block; opacity: 0; transform: translateY(60%) rotate(6deg); filter: blur(8px); animation: chUp 1s var(--ease) forwards; animation-delay: calc(var(--intro) + var(--i) * 45ms); }
@keyframes chUp { to { opacity: 1; transform: none; filter: none; } }
.gold { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-style: normal; }
.tagline { font: italic 400 clamp(1.3rem, 2.1vw, 1.65rem)/1.3 var(--font-display); color: var(--text); margin-bottom: 16px; }
.lede { color: var(--muted); max-width: 52ch; font-size: 1.02rem; }
.hero-ctas { display: flex; flex-wrap: wrap; gap: 14px; margin: 32px 0 28px; }
.hero-ctas.center { justify-content: center; margin-bottom: 0; }
.availability { display: inline-flex; align-items: center; gap: 12px; font-size: .84rem; color: var(--muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #6fcf97; box-shadow: 0 0 0 0 rgba(111, 207, 151, .6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70%, 100% { box-shadow: 0 0 0 10px rgba(111, 207, 151, 0); } }

.hero-copy > * { animation: rise 1.1s var(--ease) both; }
.hero-copy > :nth-child(1) { animation-delay: var(--intro); }
.hero-copy > :nth-child(2) { animation: none; }
.hero-copy > :nth-child(3) { animation-delay: calc(var(--intro) + .45s); }
.hero-copy > :nth-child(4) { animation-delay: calc(var(--intro) + .55s); }
.hero-copy > :nth-child(5) { animation-delay: calc(var(--intro) + .65s); }
.hero-copy > :nth-child(6) { animation-delay: calc(var(--intro) + .75s); }
.stage { animation: stageIn 1.4s var(--ease) calc(var(--intro) + .2s) both; }
@keyframes rise { from { opacity: 0; transform: translateY(30px); } }
@keyframes stageIn { from { opacity: 0; transform: perspective(1200px) rotateY(-14deg) translateX(40px); } }

/* Stage */
.stage { position: relative; padding: 84px 28px 40px 0; }
.editor {
  position: relative; border-radius: 14px; overflow: hidden;
  background: var(--ed-bg); border: 1px solid rgba(201, 169, 110, .22);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .4), 0 0 80px rgba(201, 169, 110, .08);
  transform: perspective(1400px) rotateY(-6deg) rotateX(2deg);
  transition: transform .8s var(--ease);
}
.stage:hover .editor { transform: perspective(1400px) rotateY(0) rotateX(0); }
.editor::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--ang, 0deg), transparent 0 70%, rgba(232, 211, 163, .9) 80%, transparent 90%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: spinBorder 6s linear infinite;
}
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes spinBorder { to { --ang: 360deg; } }
.editor-bar, .ide-bar { display: flex; align-items: center; gap: 4px; padding: 0 14px; height: 40px; background: var(--ed-bar); border-bottom: 1px solid var(--ed-line); }
.dots { display: flex; gap: 7px; margin-right: 12px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #3a3630; }
.dots i:nth-child(1) { background: #e0685d; }
.dots i:nth-child(2) { background: #e3b04b; }
.dots i:nth-child(3) { background: #62c073; }
.editor-tab { display: inline-flex; align-items: center; gap: 7px; height: 100%; padding: 0 14px; font: 400 .72rem var(--font-mono); color: #7d776c; white-space: nowrap; }
.editor-tab.active { color: var(--ed-text); background: var(--ed-bg); box-shadow: inset 0 -1px 0 var(--gold); }
b.al, b.js { font: 600 .58rem var(--font-mono); padding: 2px 4px; border-radius: 3px; }
b.al { color: #0b0b0c; background: #c9a96e; }
b.js { color: #e3b04b; }
.editor-body { display: flex; padding: 16px 0 18px; }
.gutter { padding: 0 14px 0 16px; text-align: right; font: 400 .76rem/1.75 var(--font-mono); color: var(--ed-gutter); user-select: none; white-space: pre; }
.code { position: relative; margin: 0; flex: 1; min-width: 0; padding-right: 18px; font: 400 .76rem/1.75 var(--font-mono); color: var(--ed-text); overflow-x: auto; scrollbar-width: none; }
.code::-webkit-scrollbar { display: none; }
.code code { display: block; white-space: pre; font: inherit; }
.code .ghost { visibility: hidden; }
.code .live { position: absolute; inset: 0 18px 0 0; }
.type-caret { display: inline-block; width: 7px; height: 1.15em; vertical-align: -.2em; background: var(--gold); animation: blink 1s steps(1) infinite; }
.editor-status { display: flex; gap: 18px; align-items: center; padding: 0 14px; height: 28px; background: #a8854c; color: #17130b; font: 500 .66rem var(--font-mono); }
.editor-status .st-live { margin-left: auto; }

/* Syntax tokens */
.tk-k { color: #e3c98f; }
.tk-t { color: #8ec5ff; }
.tk-s { color: #a8d5a2; }
.tk-q { color: #f0b49a; }
.tk-n { color: #c7a8ff; }
.tk-f { color: #f6e7c1; }
.tk-p { color: #8fd3c9; }
.tk-c { color: #6b6658; font-style: italic; }

/* Avatar (small portrait) */
.avatar {
  position: absolute; top: -6px; right: -6px; z-index: 3; margin: 0;
  width: 180px; height: 180px; border-radius: 50%;
  animation: bob 6s ease-in-out infinite;
}
.avatar img {
  position: relative; z-index: 1; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 28%;
  border: 4px solid var(--bg); background: #e9e6e0; box-shadow: var(--shadow);
}
.avatar-ring {
  position: absolute; inset: -7px; border-radius: 50%;
  background: conic-gradient(from 0deg, #f1dfb2, #a8854c, transparent 40%, #c9a96e 60%, #f1dfb2);
  animation: spin 7s linear infinite;
}
.avatar::after {
  content: ""; position: absolute; inset: -18px; border-radius: 50%; border: 1px dashed var(--hair-strong);
  animation: spin 30s linear infinite reverse;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bob { 50% { transform: translateY(-10px); } }

.badge {
  position: absolute; z-index: 4; display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--hair-strong); box-shadow: var(--shadow);
}
.badge-honours { left: -36px; bottom: 8px; padding: 12px 18px 12px 16px; border-radius: 14px; animation: bob 7s ease-in-out -2s infinite; }
.badge-big { font: italic 500 2.3rem/1 var(--font-display); color: var(--gold-light); }
:root[data-theme="light"] .badge-big { color: var(--gold); }
.badge-big sup { font-size: .45em; }
.badge-small { font-size: .7rem; line-height: 1.45; color: var(--muted); letter-spacing: .04em; }

.toast {
  position: absolute; z-index: 4; right: 0; bottom: 64px;
  display: flex; align-items: center; gap: 12px; padding: 12px 18px 12px 12px;
  background: #121a14; border: 1px solid rgba(98, 192, 115, .35); border-radius: 12px; color: #d7eadb;
  font-size: .74rem; line-height: 1.35; box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(16px) scale(.96); transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast strong { color: #fff; font-weight: 600; }
.toast em { font: normal 400 .68rem var(--font-mono); color: #8fbf98; }
.toast-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #62c073; color: #0b0b0c; font-weight: 700; }

/* Marquee */
.marquee {
  margin-top: clamp(56px, 8vw, 96px); border-block: 1px solid var(--hair);
  overflow: hidden; padding: 18px 0; display: grid; gap: 10px;
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track { display: flex; gap: 40px; width: max-content; animation: marquee 42s linear infinite; align-items: center; }
.marquee-track.reverse { animation-direction: reverse; animation-duration: 36s; }
.marquee span { font: italic 400 1.5rem var(--font-display); color: var(--muted); white-space: nowrap; }
.marquee .outline span { font: 500 1.6rem var(--font-display); font-style: normal; color: transparent; -webkit-text-stroke: 1px var(--hair-strong); letter-spacing: .04em; text-transform: uppercase; }
.marquee i { font-style: normal; color: var(--gold); font-size: .8rem; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */
.section { padding: clamp(80px, 11vw, 140px) 0; position: relative; }
.section-alt { background: var(--bg-alt); }
.section-head { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.section-head.center { justify-content: center; }
.numeral { font: italic 500 1.05rem var(--font-display); color: var(--gold); min-width: 24px; }
.label {
  margin: 0; display: flex; align-items: center; gap: 16px;
  font-size: .72rem; font-weight: 500; letter-spacing: .32em; text-transform: uppercase; color: var(--muted);
}
.label::before { content: ""; width: 44px; height: 1px; background: var(--hair-strong); transform-origin: left; transform: scaleX(0); transition: transform 1s var(--ease) .2s; }
.section-head.in .label::before { transform: scaleX(1); }
.title-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; flex-wrap: wrap; margin-bottom: 48px; }
.title-row h2 { margin: 0; }
.section-sub { color: var(--muted); max-width: 44ch; margin: 0; }

/* About */
.about-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 80px; align-items: start; }
.about-grid > * { min-width: 0; }
.pull {
  margin: 0; font: 400 clamp(1.9rem, 3.4vw, 2.8rem)/1.2 var(--font-display); color: var(--text);
  position: relative; padding-left: 28px;
}
.pull::before { content: ""; position: absolute; left: 0; top: 0; width: 1px; height: 100%; background: var(--gold); transform-origin: top; transform: scaleY(0); transition: transform 1.4s var(--ease) .3s; }
.pull.in::before { transform: scaleY(1); }
.prose p { color: var(--muted); }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 80px;
  border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair);
}
.stat { padding: 34px 24px; display: flex; flex-direction: column; gap: 6px; transition: background .4s; }
.stat:hover { background: linear-gradient(180deg, var(--glow), transparent); }
.stat + .stat { border-left: 1px solid var(--hair); }
.stat-num { font: 400 3.4rem/1 var(--font-display); color: var(--gold-light); }
:root[data-theme="light"] .stat-num { color: var(--gold); }
.stat-num sup { font-size: .45em; }
.stat-label { font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

/* Tags */
.legend { display: flex; gap: 10px; margin: 0; }
.tag { display: inline-block; font-size: .66rem; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.tag-gold { background: var(--gold-grad); color: var(--on-gold); }
.tag-line { border: 1px solid var(--hair-strong); color: var(--gold); }

/* Expertise rows */
.skill-rows { border-top: 1px solid var(--hair); }
.skill-row {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 60px 1.1fr 1.6fr auto; gap: 28px; align-items: center;
  padding: 30px 8px; border-bottom: 1px solid var(--hair);
  transition: padding .5s var(--ease);
}
.skill-row::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, var(--glow-strong), transparent 75%);
  transform: scaleX(0); transform-origin: left; transition: transform .6s var(--ease);
}
.skill-row:hover { padding-left: 22px; }
.skill-row:hover::before { transform: scaleX(1); }
.skill-idx { font: italic 500 1.05rem var(--font-display); color: var(--gold); }
.skill-row h3 { font-size: clamp(1.35rem, 2.2vw, 1.75rem); transition: color .3s; }
.skill-row:hover h3 { color: var(--gold-light); }
:root[data-theme="light"] .skill-row:hover h3 { color: var(--gold); }
.skill-row p { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- IDE / Craft ---------- */
.ide {
  border-radius: 14px; overflow: hidden; background: var(--ed-bg);
  border: 1px solid rgba(201, 169, 110, .22); box-shadow: 0 40px 100px rgba(0, 0, 0, .45);
}
.ide-title { margin: 0 auto; transform: translateX(-30px); font: 400 .72rem var(--font-mono); color: #7d776c; }
.ide-main { display: grid; grid-template-columns: 290px 1fr; min-height: 560px; }
.ide-tree .tree-file { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ide-side { background: var(--ed-side); border-right: 1px solid var(--ed-line); padding: 14px 0; }
.ide-side-title { margin: 0 0 8px; padding: 0 18px; font: 500 .64rem var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: #6d675c; }
.ide-tree li { font: 400 .74rem/1 var(--font-mono); }
.tree-folder { padding: 8px 18px; color: #b9b1a3; font-weight: 500; }
.tree-folder.sub { padding-left: 30px; }
.tree-file {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 18px 8px 46px;
  background: none; border: 0; color: #9d968a; font: 400 .74rem/1 var(--font-mono); text-align: left; cursor: pointer;
  border-left: 2px solid transparent; transition: background .2s, color .2s;
}
li.tree-file { padding-left: 30px; }
.tree-file.muted { color: #6d675c; cursor: default; }
button.tree-file:hover { background: rgba(255, 255, 255, .03); color: var(--ed-text); }
button.tree-file.active { background: rgba(201, 169, 110, .1); color: #f2ede4; border-left-color: var(--gold); }
.ide-editor { display: flex; flex-direction: column; min-width: 0; }
.ide-tabs { display: flex; background: var(--ed-bar); border-bottom: 1px solid var(--ed-line); overflow-x: auto; scrollbar-width: none; }
.ide-tab {
  position: relative; padding: 12px 20px; background: none; border: 0; border-right: 1px solid var(--ed-line);
  color: #7d776c; font: 400 .74rem var(--font-mono); cursor: pointer; white-space: nowrap; transition: color .2s, background .2s;
}
.ide-tab:hover { color: var(--ed-text); }
.ide-tab.active { color: #f2ede4; background: var(--ed-bg); }
.ide-tab.active::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--gold-grad); }
.ide-code { display: flex; flex: 1; padding: 18px 0; min-height: 380px; }
.ide-code .gutter, .ide-code .code { font-size: .8rem; }
.ide-code .ln { display: block; opacity: 0; transform: translateX(-8px); animation: lnIn .45s var(--ease) forwards; animation-delay: calc(var(--i) * 28ms); }
@keyframes lnIn { to { opacity: 1; transform: none; } }
.ide-term { border-top: 1px solid var(--ed-line); background: #0c0c0d; }
.term-head { display: flex; gap: 22px; padding: 9px 18px; font: 500 .62rem var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: #5f5a50; border-bottom: 1px solid var(--ed-line); }
.term-head .active { color: #d9d2c5; box-shadow: 0 9px 0 -8px var(--gold); }
.term-head b { display: inline-grid; place-items: center; min-width: 16px; height: 16px; margin-left: 4px; border-radius: 8px; background: #2a2722; color: #a39d92; font-size: .58rem; }
.term-body { padding: 12px 18px 14px; min-height: 118px; font: 400 .74rem/1.75 var(--font-mono); color: #a39d92; }
.term-body .t-line { display: block; animation: lnIn .3s var(--ease) forwards; opacity: 0; }
.term-body .t-cmd::before { content: "❯ "; color: var(--gold); }
.term-body .t-ok { color: #7fd08f; }
.term-body .t-dim { color: #5f5a50; }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; perspective: 1200px; }
.project, .edu { --mx: 50%; --my: 50%; }
.project {
  position: relative; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--hair); border-radius: 6px; padding: 0 30px 30px;
  transition: transform .6s var(--ease), border-color .4s, box-shadow .5s, opacity 1s var(--ease);
  overflow: hidden; transform-style: preserve-3d;
}
.project::before {
  content: ""; position: absolute; left: 0; top: 0; height: 2px; width: 100%; z-index: 2;
  background: var(--gold-grad); transform: scaleX(0); transform-origin: left; transition: transform .7s var(--ease);
}
.project::after, .edu::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(380px circle at var(--mx) var(--my), var(--glow-strong), transparent 45%);
}
.project:hover, .edu:hover { border-color: var(--hair-strong); box-shadow: var(--shadow); }
.project:hover::before { transform: scaleX(1); }
.project:hover::after, .edu:hover::after { opacity: 1; }
.viz {
  margin: 0 -30px 26px; padding: 22px 20px 12px; color: var(--gold);
  background: linear-gradient(180deg, var(--glow), transparent); border-bottom: 1px solid var(--hair);
}
.viz svg { width: 100%; height: auto; display: block; overflow: visible; stroke-width: 1.4; }
.viz-label { font: 400 8.5px var(--font-mono); fill: var(--faint); stroke: none; letter-spacing: .06em; }
/* stock bars */
.viz-stock .axis { stroke: var(--hair-strong); }
.viz-stock .reorder-label { fill: #e0685d; opacity: .8; }
.viz-stock .reorder { stroke: #e0685d; stroke-dasharray: 4 4; opacity: .7; animation: dash 1.6s linear infinite; }
.viz-stock .bar { fill: currentColor; stroke: none; opacity: .85; transform-box: fill-box; transform-origin: bottom; transform: scaleY(0); }
.viz-stock .bar.low { fill: #e0685d; }
.project.in .viz-stock .bar { animation: barUp 1s var(--ease) forwards, barBreath 4s ease-in-out 1.6s infinite; animation-delay: calc(.3s + var(--d)), calc(1.6s + var(--d)); }
.viz-stock .alert { fill: #e0685d; stroke: #e0685d; stroke-width: 0; transform-box: fill-box; transform-origin: center; animation: ping 1.8s ease-out infinite; }
@keyframes barUp { to { transform: scaleY(1); } }
@keyframes barBreath { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.88); } }
@keyframes ping { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(3.2); opacity: 0; } }
@keyframes dash { to { stroke-dashoffset: -16; } }
/* approval flow */
.viz-flow .flow-line { stroke: var(--hair-strong); }
.viz-flow .flow-run { stroke: currentColor; stroke-width: 2; stroke-dasharray: 180; stroke-dashoffset: 180; }
.viz-flow .node circle { fill: var(--surface); stroke: var(--hair-strong); transition: fill .3s; }
.viz-flow .tick { stroke: var(--on-gold); stroke-width: 2.2; stroke-dasharray: 20; stroke-dashoffset: 20; }
.project.in .viz-flow .flow-run { animation: flowRun 4.5s var(--ease) infinite; }
.project.in .viz-flow .n1 circle { animation: nodeOn 4.5s infinite; }
.project.in .viz-flow .n2 circle { animation: nodeOn 4.5s infinite .9s; }
.project.in .viz-flow .n3 circle { animation: nodeOn 4.5s infinite 1.8s; }
.project.in .viz-flow .n1 .tick { animation: tickOn 4.5s infinite; }
.project.in .viz-flow .n2 .tick { animation: tickOn 4.5s infinite .9s; }
.project.in .viz-flow .n3 .tick { animation: tickOn 4.5s infinite 1.8s; }
@keyframes flowRun { 0% { stroke-dashoffset: 180; } 45%, 85% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes nodeOn { 0%, 5% { fill: var(--surface); stroke: var(--hair-strong); } 12%, 70% { fill: var(--gold); stroke: var(--gold); } 85%, 100% { fill: var(--surface); stroke: var(--hair-strong); } }
@keyframes tickOn { 0%, 8% { stroke-dashoffset: 20; } 16%, 70% { stroke-dashoffset: 0; } 85%, 100% { stroke-dashoffset: 20; } }
/* sales line */
.viz-sales .grid { stroke: var(--hair); stroke-dasharray: 2 4; }
.viz-sales .line { stroke: currentColor; stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; }
.viz-sales .area { stroke: none; opacity: 0; }
.viz-sales .end-dot { fill: currentColor; stroke: none; opacity: 0; }
.viz-sales .end-pulse { fill: none; stroke: currentColor; transform-box: fill-box; transform-origin: center; opacity: 0; }
.project.in .viz-sales .line { animation: drawLine 2s var(--ease) .3s forwards; }
.project.in .viz-sales .area { animation: fadeIn 1.2s ease 1.4s forwards; }
.project.in .viz-sales .end-dot { animation: fadeIn .4s ease 2.1s forwards; }
.project.in .viz-sales .end-pulse { animation: ping 2s ease-out 2.2s infinite; }
@keyframes drawLine { to { stroke-dashoffset: 0; } }

.project-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.project-num { font: italic 400 3.4rem/.8 var(--font-display); color: transparent; -webkit-text-stroke: 1px var(--gold); transition: color .4s; }
.project:hover .project-num { color: var(--glow-strong); }
.status { font-size: .66rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); border: 1px solid var(--hair-strong); padding: 5px 12px; border-radius: 999px; }
.project h3 { font-size: 1.7rem; margin-bottom: 14px; }
.project > p { color: var(--muted); font-size: .94rem; }
.feature-list { margin: 6px 0 26px; flex: 1; }
.feature-list li { position: relative; padding-left: 22px; font-size: .9rem; margin-bottom: 8px; color: var(--text); }
.feature-list li::before { content: "✦"; position: absolute; left: 0; top: .15em; font-size: .6rem; color: var(--gold); }
.tech { margin: 0; padding-top: 18px; border-top: 1px solid var(--hair); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }

/* ---------- Timeline ---------- */
.timeline { margin-top: 56px; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--hair);
}
.tl-item { position: relative; display: grid; grid-template-columns: 260px 1fr; gap: 48px; padding: 44px 0; border-bottom: 1px solid var(--hair); }
.tl-item::after {
  content: ""; position: absolute; left: 0; bottom: -1px; height: 1px; width: 100%;
  background: var(--gold-grad); transform: scaleX(0); transform-origin: left; transition: transform 1.4s var(--ease) .3s;
}
.tl-item.in::after { transform: scaleX(1); }
.tl-meta { display: flex; flex-direction: column; gap: 4px; }
.tl-date { font: italic 500 1.2rem var(--font-display); color: var(--gold-light); }
:root[data-theme="light"] .tl-date { color: var(--gold); }
.tl-place { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.tl-body h3 { font-size: 2rem; }
.tl-org { color: var(--gold); font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; margin: 8px 0 18px; }
.tl-body ul { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 32px; }
.tl-body li { position: relative; padding-left: 22px; color: var(--muted); font-size: .95rem; }
.tl-body li::before { content: ""; position: absolute; left: 0; top: .8em; width: 10px; height: 1px; background: var(--gold); }

/* ---------- Education ---------- */
.edu-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 24px; margin-top: 56px; perspective: 1200px; }
.edu {
  position: relative; overflow: hidden;
  border: 1px solid var(--hair); border-radius: 6px; padding: 36px 30px; background: var(--surface);
  transition: border-color .4s, transform .6s var(--ease), box-shadow .5s, opacity 1s var(--ease);
}
.edu-feature { background: radial-gradient(120% 120% at 0% 0%, var(--glow), transparent 60%), var(--surface); border-color: var(--hair-strong); }
.edu-badge { display: inline-block; font-size: .64rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; padding: 6px 12px; border-radius: 999px; background: var(--gold-grad); color: var(--on-gold); margin-bottom: 22px; }
.edu-badge.muted { background: none; border: 1px solid var(--hair-strong); color: var(--gold); }
.edu h3 { font-size: 1.55rem; margin-bottom: 12px; }
.edu-feature h3 { font-size: 1.9rem; }
.edu-org { color: var(--muted); font-size: .92rem; margin-bottom: 6px; }
.edu-date { font: italic 500 1.2rem var(--font-display); color: var(--gold); margin: 0; }
.progress { height: 1px; background: var(--hair-strong); margin-top: 22px; position: relative; overflow: hidden; }
.progress span { position: absolute; left: 0; top: -.5px; height: 2px; width: 35%; background: var(--gold-grad); animation: grow 3s ease-in-out infinite alternate; }
@keyframes grow { from { width: 22%; } to { width: 48%; } }

/* ---------- Contact ---------- */
.contact { text-align: center; overflow: hidden; isolation: isolate; border-top: 1px solid var(--hair); }
.contact-inner { max-width: 820px; }
.contact-title { font-size: clamp(2.8rem, 7vw, 5.4rem); font-weight: 400; margin-bottom: 26px; }
.contact-inner > p { color: var(--muted); font-size: 1.05rem; max-width: 56ch; margin-inline: auto; }

/* ---------- Footer ---------- */
.footer { padding: 34px 0; border-top: 1px solid var(--hair); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; color: var(--faint); font-size: .8rem; letter-spacing: .06em; }
.footer p { margin: 0; }
.footer a { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; }

/* ---------- Reveal ---------- */
.reveal { opacity: 0; transform: translateY(32px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
h2.reveal { clip-path: inset(0 0 100% 0); transform: translateY(24px); transition: clip-path 1.1s var(--ease), transform 1.1s var(--ease), opacity .6s; }
h2.reveal.in { clip-path: inset(0 0 -20% 0); transform: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal, h2.reveal { opacity: 1; transform: none; clip-path: none; }
  .preloader { display: none; }
  .ch { opacity: 1; transform: none; filter: none; }
  .viz-stock .bar { transform: none; }
  .viz-sales .line { stroke-dashoffset: 0; }
  .viz-sales .area, .viz-sales .end-dot { opacity: 1; }
  .ide-code .ln, .term-body .t-line { opacity: 1; transform: none; }
  .toast { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1120px) {
  .nav-links a { padding: 8px 8px; letter-spacing: .1em; }
  .nav-links a::after { left: 8px; right: 8px; }
  .projects { grid-template-columns: 1fr 1fr; }
  .edu-grid { grid-template-columns: 1fr 1fr; }
  .edu-feature { grid-column: 1 / -1; }
}
@media (max-width: 1000px) {
  .menu-btn { display: grid; }
  .nav-links {
    position: absolute; top: 76px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--bg); border-bottom: 1px solid var(--hair);
    padding: 12px 16px 24px; display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 16px 4px; border-bottom: 1px solid var(--hair); }
  .nav-links a::after { display: none; }
  .nav-links .nav-cta { margin: 16px 0 0; text-align: center; padding: 14px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .stage { max-width: 640px; width: 100%; justify-self: center; }
  .about-grid { grid-template-columns: 1fr; gap: 40px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--hair); }
  .skill-row { grid-template-columns: 44px 1fr auto; gap: 8px 20px; }
  .skill-row p { grid-column: 2 / 4; }
  .skill-row .tag { grid-row: 1; grid-column: 3; }
  .tl-item { grid-template-columns: 1fr; gap: 16px; }
  .ide-main { grid-template-columns: 1fr; }
  .ide-side { display: none; }
}
@media (max-width: 640px) {
  .brand-name { display: none; }
  .h1-top, .h1-bottom { font-size: clamp(2.9rem, 15vw, 4rem); }
  .projects, .edu-grid { grid-template-columns: 1fr; }
  .tl-body ul { grid-template-columns: 1fr; }
  .stage { padding: 72px 0 28px; }
  .editor { transform: none; }
  .editor-tab:not(.active) { display: none; }
  .gutter { padding: 0 10px 0 10px; }
  .code, .gutter { font-size: .64rem; }
  .ide-code .gutter, .ide-code .code { font-size: .68rem; }
  .avatar { width: 128px; height: 128px; top: -4px; right: 8px; }
  .badge-honours { left: -6px; bottom: -8px; padding: 9px 14px; }
  .badge-big { font-size: 1.8rem; }
  .toast { right: 4px; bottom: -6px; }
  .stat { padding: 26px 14px; }
  .stat-num { font-size: 2.6rem; }
  .skill-row:hover { padding-left: 8px; }
  .project { padding: 0 22px 26px; }
  .viz { margin: 0 -22px 22px; }
  .ide-title { display: none; }
  .ide-code { min-height: 340px; }
  .footer-inner { flex-direction: column; text-align: center; }
  .title-row { margin-bottom: 36px; }
  .cursor-glow, .cursor-ring { display: none; }
}
