:root {
  --bg: #f8fafc;
  --bg-elev: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #6366f1;
  --accent-2: #06b6d4;
  --accent-soft: rgba(99, 102, 241, 0.1);
  --shadow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --bg-elev: #121a2e; --text: #e2e8f0; --muted: #94a3b8;
    --border: #1e293b; --accent: #818cf8; --accent-2: #22d3ee;
    --accent-soft: rgba(129, 140, 248, 0.12); --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --bg-elev: #121a2e; --text: #e2e8f0; --muted: #94a3b8;
  --border: #1e293b; --accent: #818cf8; --accent-2: #22d3ee;
  --accent-soft: rgba(129, 140, 248, 0.12); --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}
body::before {
  content: ""; position: fixed; inset: -20% -10% auto auto; width: 60vmax; height: 60vmax;
  background: radial-gradient(circle, var(--accent-soft), transparent 60%);
  pointer-events: none; z-index: -1;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.container { width: min(1100px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* Nav */
.nav { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom: 1px solid transparent; transition: border-color .3s; }
.nav.scrolled { border-bottom-color: var(--border); }
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.logo { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.logo .mono { color: var(--accent); }
.nav-links { display: flex; gap: 28px; font-size: .92rem; font-weight: 500; }
.nav-links a { color: var(--muted); position: relative; transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); }
.nav-links a::after { content: ""; position: absolute; left: 0; bottom: -4px; height: 2px; width: 0; background: var(--accent); transition: width .25s; }
.nav-links a:hover::after, .nav-links a.active::after { width: 100%; }
.nav-actions { display: flex; gap: 8px; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); cursor: pointer; transition: transform .2s, border-color .2s; }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.moon { display: none; }
:root[data-theme="dark"] .sun { display: none; }
:root[data-theme="dark"] .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun { display: none; }
  :root:not([data-theme="light"]) .moon { display: block; }
}
.menu-btn { display: none; }

/* Hero */
.hero { min-height: calc(100vh - 68px); display: flex; flex-direction: column; justify-content: center; padding: 60px 0 80px; }
.eyebrow { color: var(--accent); font-size: .95rem; margin-bottom: 14px; }
.hero h1 { font-size: clamp(2.6rem, 8vw, 5rem); line-height: 1.05; letter-spacing: -.04em; font-weight: 800; }
.hero-role { font-size: clamp(1.6rem, 5vw, 3.2rem); line-height: 1.15; letter-spacing: -.03em; font-weight: 700; margin-top: 8px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; min-height: 1.2em; }
.caret { display: inline-block; width: 3px; height: .9em; background: var(--accent-2); margin-left: 4px; vertical-align: -0.08em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero-tag { max-width: 560px; color: var(--muted); font-size: 1.1rem; margin-top: 22px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.hero-cta.center { justify-content: center; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 40px; color: var(--muted); font-size: .85rem; }
.hero-meta span { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34,197,94,.18); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 10px; font-weight: 600; font-size: .95rem; border: 1px solid var(--border); background: var(--bg-elev); transition: transform .2s, box-shadow .2s, border-color .2s; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Sections */
.section { padding: 90px 0; }
.section-title { font-size: clamp(1.6rem, 3.5vw, 2.1rem); letter-spacing: -.03em; margin-bottom: 40px; display: flex; align-items: center; gap: 12px; }
.section-title .mono { color: var(--accent); font-size: .7em; font-weight: 500; }
.section-title::after { content: ""; flex: 1; max-width: 300px; height: 1px; background: var(--border); margin-left: 12px; }
.sub-title { font-size: 1.2rem; margin: 50px 0 18px; }

.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 48px; align-items: start; }
#aboutText p { color: var(--muted); margin-bottom: 16px; font-size: 1.05rem; }
.code-card { background: #0f172a; color: #e2e8f0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid #1e293b; }
.code-bar { display: flex; align-items: center; gap: 6px; padding: 12px 14px; background: #111a2f; border-bottom: 1px solid #1e293b; }
.code-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ef4444; }
.code-bar i:nth-child(2) { background: #eab308; } .code-bar i:nth-child(3) { background: #22c55e; }
.code-bar span { margin-left: 10px; font-size: .78rem; color: #94a3b8; }
.code-card pre { padding: 20px; font-size: .84rem; line-height: 1.7; overflow-x: auto; }
.k { color: #c084fc; } .s { color: #86efac; } .p { color: #7dd3fc; } .c { color: #64748b; }

.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; transition: transform .25s, border-color .25s, box-shadow .25s; }
.card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.card h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin-bottom: 14px; font-family: "JetBrains Mono", monospace; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: .82rem; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-weight: 500; }

.timeline { position: relative; padding-left: 28px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding-bottom: 36px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -36px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.tl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; }
.tl-head h3 { font-size: 1.15rem; }
.tl-head h3 span { color: var(--accent); }
.tl-period { color: var(--muted); font-size: .85rem; }
.timeline ul { margin-top: 10px; }
.tl-meta { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.timeline .tech { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .75rem; color: var(--accent); }
.earlier { margin-top: 28px; padding: 14px 18px; border-left: 3px solid var(--border); color: var(--muted); font-size: .95rem; }
.chip.verified { display: inline-flex; align-items: center; gap: 4px; }
.chip.verified svg { color: #22c55e; }
.timeline ul li { padding: 0 0 6px 20px; color: var(--muted); }
.timeline ul li::before { content: "▹"; left: 0; top: 0; width: auto; height: auto; border: 0; background: none; color: var(--accent); border-radius: 0; }
.edu { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; }
.edu p { color: var(--muted); }

.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px; }
.project { display: flex; flex-direction: column; }
.project-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; color: var(--accent); }
.project-links { display: flex; gap: 12px; }
.project-links a { color: var(--muted); transition: color .2s; }
.project-links a:hover { color: var(--accent); }
.project h3 { font-size: 1.2rem; margin-bottom: 10px; text-transform: none; letter-spacing: -.01em; color: var(--text); font-family: inherit; font-weight: 700; }
.project p.desc { color: var(--muted); flex: 1; }
.project .org { font-size: .75rem; color: var(--accent); margin-bottom: 4px; }
.project .tech { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 18px; font-size: .78rem; color: var(--muted); }

.contact { text-align: center; max-width: 640px; }
.contact-title { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -.03em; margin-bottom: 16px; }
.contact > p { color: var(--muted); font-size: 1.05rem; }
.socials { display: flex; justify-content: center; gap: 12px; margin-top: 36px; }
.socials a { width: 44px; height: 44px; }

.footer { text-align: center; padding: 30px 0 40px; color: var(--muted); font-size: .8rem; }

/* ---------- Spring motion ----------
   --spring / --spring-dur are generated in main.js from real spring physics
   (stiffness, damping, mass) and expressed as a CSS linear() easing curve.
   The fallbacks below are used if JS hasn't run or linear() is unsupported. */
:root {
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --spring-dur: 1800ms;
  --fade: 1100ms;
  --fade-ease: cubic-bezier(.45, 0, .25, 1);
  --dist: 110px;
  --hero-stagger: 220ms;
  --letter-stagger: 65ms;
  --spring-bouncy: cubic-bezier(.34, 1.8, .64, 1);
  --spring-bouncy-dur: 700ms;
}

/* Hero intro (plays on load) */
.js .intro, .js .hero-name .char {
  opacity: 0;
  translate: 0 40px;
  filter: blur(10px);
}
.loaded .intro, .loaded .hero-name .char {
  opacity: 1;
  translate: 0 0;
  filter: blur(0);
  transition:
    opacity var(--fade) var(--fade-ease),
    filter var(--fade) var(--fade-ease),
    translate var(--spring-dur) var(--spring);
  transition-delay: calc(var(--i, 0) * var(--hero-stagger) + 200ms);
}
.hero-name { display: inline; }
.hero-name .word { display: inline-block; white-space: nowrap; }
.hero-name .char { display: inline-block; translate: 0 0.6em; }
.js .hero-name .char { translate: 0 0.6em; }
.loaded .hero-name .char {
  transition-delay: calc(300ms + var(--c) * var(--letter-stagger));
  translate: 0 0;
}

/* Scroll reveals: direction is set with data-reveal="up|left|right|scale" */
.js .reveal {
  opacity: 0;
  transition:
    opacity var(--fade) var(--fade-ease),
    translate var(--spring-dur) var(--spring),
    scale var(--spring-dur) var(--spring),
    transform var(--spring-bouncy-dur) var(--spring-bouncy),
    box-shadow .3s, border-color .3s;
  transition-delay: var(--delay, 0ms), var(--delay, 0ms), var(--delay, 0ms), 0ms, 0ms, 0ms;
}
.js .reveal[data-reveal="up"]    { translate: 0 var(--dist); }
.js .reveal[data-reveal="left"]  { translate: calc(var(--dist) * -1) 0; }
.js .reveal[data-reveal="right"] { translate: var(--dist) 0; }
.js .reveal[data-reveal="scale"] { translate: 0 calc(var(--dist) * .5); scale: .8; }
.js .reveal.in { opacity: 1; translate: 0 0; scale: 1; }

/* Springy hover (uses transform, so it stacks on top of the reveal's translate) */
.btn, .icon-btn {
  transition: transform var(--spring-bouncy-dur) var(--spring-bouncy), box-shadow .3s, border-color .3s;
}
.card { transition: transform var(--spring-bouncy-dur) var(--spring-bouncy), box-shadow .3s, border-color .3s; }
.btn:active, .icon-btn:active { transform: scale(.94); }
.chip { transition: transform var(--spring-bouncy-dur) var(--spring-bouncy), background .2s; }
.chip:hover { transform: translateY(-2px) scale(1.06); }
.timeline li::before { transition: scale var(--spring-bouncy-dur) var(--spring-bouncy); }
.timeline > li.in::before { scale: 1; }
.js .timeline > li:not(.in)::before { scale: 0; }

/* Mobile */
@media (max-width: 760px) {
  .menu-btn { display: grid; }
  .nav-links { position: fixed; top: 68px; left: 0; right: 0; flex-direction: column; gap: 0; background: var(--bg-elev); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; transform: translateY(-120%); visibility: hidden; transition: transform .3s, visibility 0s .3s; z-index: -1; }
  .nav-links.open { transform: none; visibility: visible; transition: transform .3s, visibility 0s; }
  .nav-links a { display: block; padding: 12px 4px; font-size: 1rem; }
  .nav-links a::after { display: none; }
  .nav-links a.active { color: var(--accent); }
  .about-grid { grid-template-columns: 1fr; }
  .section { padding: 64px 0; }
  .projects-grid { grid-template-columns: 1fr; }
  .section-title::after { display: none; }
}
.skills-note { color: var(--muted); font-size: .85rem; margin: -24px 0 22px; display: flex; align-items: center; gap: 6px; }
