:root {
  --bg: #e6e6e4;        /* whitish grey */
  --surface: #eeeeec;
  --ink: #0a0a0a;
  --muted: #5c5c5a;
  --line: #c9c9c6;
  --ink-rgb: 10, 10, 10;        /* used by the canvas background */
  --glow: rgba(255,255,255,.55);
  --glow2: rgba(255,255,255,.35);
  --grain-op: .07; --grain-blend: multiply;
  color-scheme: light;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --pad: clamp(20px, 5vw, 64px);
}
:root[data-theme="dark"] {
  --bg: #0e0e0e;
  --surface: #171717;
  --ink: #e6e6e4;               /* whitish grey text */
  --muted: #9a9a97;
  --line: #2b2b2b;
  --ink-rgb: 230, 230, 228;
  --glow: rgba(255,255,255,.07);
  --glow2: rgba(255,255,255,.04);
  --grain-op: .06; --grain-blend: screen;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
}
#bg { position: fixed; inset: 0; z-index: -2; pointer-events: none; }
/* soft light pool that follows the cursor, plus film grain */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(520px circle at var(--mx, 50%) var(--my, 20%), var(--glow), transparent 70%),
    radial-gradient(900px circle at 85% -10%, var(--glow2), transparent 60%);
}
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: var(--grain-op); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* hero skills */
.hero-skills { margin-top: 32px; max-width: 60ch; }
.mini { font-family: var(--mono); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px; }
.hero-skills .chips span { background: color-mix(in srgb, var(--surface) 80%, transparent); transition: .2s; }
.hero-skills .chips span:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
a { color: inherit; text-decoration: none; }
main, footer { max-width: 1100px; margin: 0 auto; padding-inline: var(--pad); }
section { padding-block: clamp(56px, 9vw, 112px); border-top: 1px solid var(--line); }

/* Nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: transparent; border-bottom: 1px solid transparent;
  transition: background-color .3s, border-color .3s, backdrop-filter .3s;
}
.nav-inner { max-width: 1100px; margin: 0 auto; padding: 20px var(--pad); display: flex; justify-content: space-between; align-items: center; transition: padding .3s; }
/* once the page scrolls, the bar frosts over the content beneath it */
.nav.scrolled { background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom-color: var(--line); }
.nav.scrolled .nav-inner { padding-block: 12px; }
.nav .logo { font-weight: 600; letter-spacing: -0.02em; }
.nav nav { display: flex; gap: 28px; font-size: 14px; color: var(--muted); }
.nav nav a { position: relative; padding-block: 4px; transition: color .2s; }
.nav nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .25s; }
.nav nav a:hover { color: var(--ink); }
.nav nav a:hover::after { transform: scaleX(1); }
.nav .logo { font-family: var(--mono); font-size: 15px; }

/* Hero */
.hero { border-top: 0; padding-top: clamp(64px, 12vw, 150px); }
.status {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); padding: 6px 14px; border-radius: 99px; margin-bottom: 32px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
h1 { font-size: clamp(36px, 7vw, 76px); line-height: 1.05; letter-spacing: -0.035em; font-weight: 600; max-width: 14ch; max-width: 18ch; }
h1 em { font-style: normal; color: var(--muted); }
.lead { margin-top: 28px; max-width: 52ch; font-size: clamp(16px, 2vw, 19px); color: var(--muted); }
.cta { margin-top: 40px; display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 12px 22px; border: 1px solid var(--ink);
  border-radius: 99px; font-size: 14px; font-weight: 500; transition: .2s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: transparent; color: var(--ink); }

.label { font-family: var(--mono); font-weight: 500; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 40px; }

/* Now */
.now-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; }
.now-grid h3 { font-size: 14px; margin-bottom: 6px; }
.now-grid p { color: var(--muted); font-size: 15px; }

/* Now timeline: swipeable row, highlighted dot in the middle; details expand inside the section */
.tl { --wf: 240px; margin-top: 44px; position: relative; }
.tl-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.tl-head .mini { margin: 0; }
.tl-nav { display: flex; gap: 8px; }
.tl-nav button { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: none; color: var(--ink); cursor: pointer; font-size: 14px; transition: .2s; }
.tl-nav button:hover:not(:disabled) { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tl-nav button:disabled { opacity: .3; cursor: default; }
.tl-nav button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.tl-scroll {
  --half: 0px; --fl: 0px; --fr: 0px;
  overflow-x: auto; overflow-y: hidden; padding: 12px 0 8px; overscroll-behavior-x: contain;
  scrollbar-width: none; -ms-overflow-style: none;                         /* scrollbar hidden: swipe or use the arrows */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
          mask-image: linear-gradient(90deg, transparent 0, #000 var(--fl), #000 calc(100% - var(--fr)), transparent 100%);
}
.tl-scroll::-webkit-scrollbar { display: none; }
.tl-track { list-style: none; display: flex; width: max-content; }

/* empty space either side so any dot can reach the middle */
.tl-pad, .tl-future { position: relative; flex: none; width: max(0px, calc(var(--half) - var(--wf) / 2)); }
/* the future: the line carries on, dashed and fading out, with no dots */
.tl-future::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 1px;
  background: repeating-linear-gradient(90deg, var(--muted) 0 6px, transparent 6px 12px);
  -webkit-mask-image: linear-gradient(90deg, #000, transparent); mask-image: linear-gradient(90deg, #000, transparent); }

.tl-item { position: relative; flex: none; width: var(--wf); }
.tl-item::before { content: ""; position: absolute; top: 6px; left: 50%; width: 100%; height: 1px; background: var(--line); }   /* this dot → next dot */
.tl-item.last::before { width: 50%; }

.tl-btn { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; padding: 0 12px; background: none; border: 0; color: inherit; font: inherit; text-align: center; cursor: pointer; }
.tl-btn:focus-visible { outline: none; }
.tl-btn:focus-visible .tl-label { outline: 2px solid var(--ink); outline-offset: 6px; border-radius: 6px; }
.tl-dot { position: relative; z-index: 1; width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--bg); transition: transform .22s cubic-bezier(.2,.7,.2,1), background-color .22s; }
.tl-item.current .tl-dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid var(--ink); animation: ring 2.2s ease-out infinite; }
@keyframes ring { from { transform: scale(.55); opacity: .6; } to { transform: scale(1.35); opacity: 0; } }
.tl-label { display: block; }
.tl-title { display: block; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; color: var(--muted); transition: color .2s; }
.tl-when { display: block; margin-top: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tl-item:hover .tl-dot { transform: scale(1.2); }
.tl-item:hover .tl-title, .tl-item.sel .tl-title { color: var(--ink); }
.tl-item.sel .tl-dot { background: var(--ink); transform: scale(1.35); }

/* details: grid-rows 0fr → 1fr gives a smooth height animation; the content then rises in, staggered.
   Nothing in the timeline row moves while this happens. */
.tl-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s cubic-bezier(.2,.8,.2,1); }
.tl.open .tl-detail { grid-template-rows: 1fr; }
.tl-clip { min-height: 0; overflow: hidden; }
.tl-card {
  position: relative; margin-top: 16px; padding: clamp(20px, 3vw, 30px);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); border-radius: 16px;
  display: grid; gap: 18px 36px; opacity: 0; transform: translateY(-8px);
  transition: opacity .3s ease, transform .45s cubic-bezier(.2,.8,.2,1);
}
.tl.open .tl-card { opacity: 1; transform: none; }
.tl-card::before { content: ""; position: absolute; top: -7px; left: var(--ax, 50%); width: 12px; height: 12px; background: var(--surface); border-top: 1px solid var(--line); border-left: 1px solid var(--line); transform: translateX(-50%) rotate(45deg); }
@media (min-width: 820px) { .tl-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); } }
.tl-card h4 { font-size: clamp(18px, 2vw, 21px); letter-spacing: -0.015em; }
.tl-sub { margin-top: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.tl-sum { margin-top: 12px; font-size: 15px; line-height: 1.55; }
.tl-card ul { margin-left: 18px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.tl-card li + li { margin-top: 8px; }
.rise { animation: rise .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 50ms + 120ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .tl { --wf: 200px; } }

/* Projects */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.project {
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px; display: flex; flex-direction: column; gap: 14px;
  transition: transform .25s, background .25s, color .25s, border-color .25s;
}
.project:hover { transform: translateY(-4px); background: var(--ink); color: var(--bg); border-color: var(--ink); }
.project:hover p, .project:hover .p-status, .project:hover .num { color: color-mix(in srgb, var(--bg) 68%, var(--ink)); }
.project:hover .chips span { border-color: color-mix(in srgb, var(--bg) 30%, var(--ink)); color: color-mix(in srgb, var(--bg) 82%, var(--ink)); }
.p-top { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.project h3 { font-size: 22px; letter-spacing: -0.02em; }
.project p { color: var(--muted); font-size: 15px; flex: 1; }
.p-links { display: flex; gap: 18px; font-size: 14px; font-weight: 500; }
.p-links a:hover { text-decoration: underline; text-underline-offset: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { font-family: var(--mono); font-size: 12.5px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 99px; }
.chips.small span { font-size: 11.5px; padding: 3px 10px; }

.empty-state { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 16px; padding: clamp(32px, 6vw, 56px); text-align: center; background: color-mix(in srgb, var(--surface) 50%, transparent); }
.empty-state p { font-size: clamp(18px, 2.1vw, 22px); letter-spacing: -0.01em; }
.empty-state span { display: block; margin-top: 6px; font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Resume */
.resume-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; color: var(--muted); margin-bottom: 24px; }
.sub { font-family: var(--mono); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; margin: 48px 0 20px; }
.entry { display: grid; grid-template-columns: 170px 1fr; gap: 24px; padding: 22px 0; border-top: 1px solid var(--line); }
.when { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 3px; }
.entry h4 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.entry ul { margin: 10px 0 0 18px; color: var(--muted); font-size: 15px; }
.entry li + li { margin-top: 4px; }

/* Contact */
.big { font-size: clamp(30px, 6vw, 60px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 600; }
.big a { border-bottom: 2px solid var(--ink); }
.big a:hover { color: var(--muted); border-color: var(--muted); }
.links { margin-top: 32px; display: flex; gap: 24px; font-size: 15px; }
.links a:hover { text-decoration: underline; text-underline-offset: 4px; }

footer { padding-block: 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; font-family: var(--mono); }

/* Reveal animation */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .dot, .tl-item.current .tl-dot::after { animation: none; }
  .tl-dot, .tl-detail, .tl-card { transition: none !important; }
  .rise { animation: none; }
}

@media (max-width: 640px) {
  .entry { grid-template-columns: 1fr; gap: 6px; }
  .nav nav { gap: 18px; }
}

[hidden] { display: none !important; }

/* theme toggle */
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--ink); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-items: center; transition: .2s; }
.theme-toggle:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.theme-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.nav-right { display: flex; align-items: center; gap: 24px; }
body, .project, footer { transition: background-color .3s, color .3s, border-color .3s; }
