:root {
  --bg: #070b16;
  --bg-2: #0c1222;
  --surface: #0f1729;
  --surface-2: #131d35;
  --border: #1c2a4a;
  --text: #cbd5e8;
  --text-dim: #7e8cab;
  --heading: #f1f5ff;
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --cyan: #22d3ee;
  --glow: rgba(59, 130, 246, 0.35);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }
.mono { font-family: var(--mono); }
.grad {
  background: linear-gradient(90deg, var(--blue-light), var(--cyan));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.container { width: min(1100px, 100% - 3rem); margin-inline: auto; }
::selection { background: var(--blue); color: #fff; }

/* Background */
.bg-grid {
  position: fixed; inset: 0; z-index: -2;
  background-image:
    linear-gradient(rgba(96,165,250,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(96,165,250,.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, #000 30%, transparent 100%);
}
.bg-glow {
  position: fixed; z-index: -1; pointer-events: none;
  width: 600px; height: 600px; border-radius: 50%;
  left: var(--mx, 70%); top: var(--my, 20%);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--glow), transparent 65%);
  opacity: .5; filter: blur(40px);
  transition: left .6s ease-out, top .6s ease-out;
}

/* Nav */
.nav {
  position: fixed; top: 0; inset-inline: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem clamp(1.25rem, 4vw, 3rem);
  transition: background .3s, backdrop-filter .3s, border-color .3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(7, 11, 22, .8);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}
.logo { display: inline-flex; line-height: 0; }
.logo-mark { width: 40px; height: 40px; display: block; transition: transform .2s, filter .2s; }
.logo:hover .logo-mark { transform: translateY(-1px); filter: drop-shadow(0 0 10px var(--glow)); }
.nav-links { display: flex; align-items: center; gap: 1.75rem; font-size: .92rem; }
.nav-links a:not(.btn) { color: var(--text-dim); transition: color .2s; }
.nav-links a:not(.btn):hover { color: var(--blue-light); }
.idx { color: var(--blue-light); font-size: .8em; }
.nav-toggle { display: none; background: none; border: 0; width: 40px; height: 40px; cursor: pointer; position: relative; }
.nav-toggle span { position: absolute; left: 9px; right: 9px; height: 2px; background: var(--heading); transition: transform .25s, top .25s; }
.nav-toggle span:first-child { top: 15px; }
.nav-toggle span:last-child { top: 23px; }
.nav-toggle[aria-expanded="true"] span:first-child { top: 19px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { top: 19px; transform: rotate(-45deg); }

/* Buttons */
.btn {
  display: inline-block; padding: .8rem 1.6rem; border-radius: 10px;
  background: linear-gradient(135deg, #2f6fe8, #1d4ed8);
  color: #fff; font-weight: 600; font-size: .95rem;
  border: 1px solid transparent;
  box-shadow: 0 0 0 0 var(--glow);
  transition: transform .2s, box-shadow .25s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--glow); }
.btn-sm { padding: .5rem 1rem; font-size: .85rem; }
.btn-lg { padding: 1.1rem 2.4rem; font-size: 1.05rem; }
.btn-ghost { background: transparent; color: var(--blue-light); border-color: var(--blue); }
.btn-ghost:hover { background: rgba(59,130,246,.1); }

/* Hero */
.hero {
  min-height: 100vh; padding-top: 7rem; padding-bottom: 4rem;
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 3rem; align-items: center;
}
.eyebrow { color: var(--blue-light); font-size: .95rem; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.8rem); line-height: 1.05; color: var(--heading); font-weight: 800; letter-spacing: -.03em; }
.cursor { color: var(--blue-light); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero h2 { font-size: clamp(1.4rem, 3.4vw, 2.2rem); color: var(--text-dim); font-weight: 600; margin-top: .6rem; min-height: 1.3em; }
#typed::after { content: "|"; color: var(--cyan); -webkit-text-fill-color: var(--cyan); animation: blink .8s steps(1) infinite; margin-left: 2px; }
.lead { max-width: 560px; margin-top: 1.5rem; color: var(--text-dim); font-size: 1.05rem; }
.cta { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.socials { display: flex; gap: 1.1rem; margin-top: 2.2rem; }
.socials a { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); transition: .2s; }
.socials svg { width: 20px; height: 20px; fill: var(--text-dim); transition: fill .2s; }
.socials a:hover { border-color: var(--blue); transform: translateY(-3px); box-shadow: 0 6px 20px var(--glow); }
.socials a:hover svg { fill: var(--blue-light); }

/* Code window */
.window {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 60px -10px var(--glow);
  overflow: hidden;
  transform: perspective(1200px) rotateY(-6deg) rotateX(3deg);
  transition: transform .5s;
}
.window:hover { transform: perspective(1200px) rotateY(0) rotateX(0); }
.window-bar { display: flex; align-items: center; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); background: rgba(0,0,0,.2); }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.window-title { margin-left: .6rem; font-size: .78rem; color: var(--text-dim); }
.code { margin: 0; padding: 1.4rem 1.5rem; font-size: clamp(.72rem, 1.5vw, .88rem); line-height: 1.8; overflow-x: auto; color: var(--text); }
.code .k { color: #c084fc; } .code .v { color: var(--blue-light); }
.code .a { color: #7dd3fc; } .code .s { color: #86efac; }
.code .n { color: #fbbf24; } .code .p { color: var(--cyan); }

/* Sections */
.section { padding: 6rem 0; }
.section-title {
  display: flex; align-items: center; gap: .75rem;
  font-size: clamp(1.5rem, 3.5vw, 2rem); color: var(--heading); font-weight: 700; margin-bottom: 2.5rem;
}
.section-title::after { content: ""; flex: 1; max-width: 300px; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }

.about-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 3rem; align-items: center; }
.about-text p + p { margin-top: 1rem; }
.about-text em { color: var(--blue-light); font-style: normal; }
.stats { display: grid; gap: 1rem; }
.stats li { display: flex; align-items: center; gap: 1.1rem; padding: 1.2rem 1.6rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat-num { font-family: var(--mono); font-size: 2.4rem; font-weight: 700; line-height: 1; color: var(--blue-light); flex: 0 0 3.6rem; }
.stat-num::after { content: "+"; }
.stat-label { color: var(--text-dim); font-size: 1.05rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.6rem; transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card:hover { transform: translateY(-6px); border-color: var(--blue); box-shadow: 0 16px 40px -12px var(--glow); }
.skills-grid, .projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.4rem; }
.projects-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .projects-grid { grid-template-columns: 1fr; } }
.card h3.mono { color: var(--cyan); font-size: .95rem; margin-bottom: 1rem; font-weight: 500; }
.tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li { padding: .3rem .8rem; border-radius: 999px; background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.25); color: var(--blue-light); font-size: .85rem; }
.tags.small li { padding: 0; background: none; border: 0; font-size: .78rem; color: var(--text-dim); }

.project { display: flex; flex-direction: column; gap: .8rem; }
.project-top { display: flex; justify-content: space-between; align-items: center; }
.folder { width: 38px; height: 38px; fill: none; stroke: var(--blue-light); stroke-width: 1.5; stroke-linejoin: round; }
.project-links { display: flex; gap: 1rem; font-size: .85rem; font-family: var(--mono); }
.project-links a { color: var(--text-dim); transition: color .2s; }
.project-links a:hover { color: var(--blue-light); }
.project h3 { font-size: 1.25rem; color: var(--heading); }
.project p { color: var(--text-dim); font-size: .95rem; flex: 1; }
.project .tags { margin-top: .4rem; gap: 1rem; }

.timeline { position: relative; padding-left: 2rem; border-left: 1px solid var(--border); display: grid; gap: 2.4rem; max-width: 760px; }
.timeline > li { position: relative; }
.timeline > li::before { content: ""; position: absolute; left: calc(-2rem - 6px); top: .55rem; width: 11px; height: 11px; border-radius: 50%; background: var(--bg); border: 2px solid var(--blue-light); box-shadow: 0 0 12px var(--glow); }
.when { color: var(--cyan); font-size: .82rem; }
.timeline h3 { color: var(--heading); font-size: 1.15rem; margin: .25rem 0 .4rem; }
.timeline p { color: var(--text-dim); }

.contact { text-align: center; padding-bottom: 8rem; }
.contact .lead { margin-inline: auto; }
.contact-title { font-size: clamp(2rem, 5vw, 3.2rem); color: var(--heading); font-weight: 800; letter-spacing: -.02em; margin: .5rem 0; }
.contact .btn { margin-top: 2.2rem; }

.footer { text-align: center; padding: 2rem 1rem; border-top: 1px solid var(--border); color: var(--text-dim); font-size: .8rem; }

/* Scroll reveal */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s ease; transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }

/* Responsive */
@media (max-width: 860px) {
  .hero, .about-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 6rem; min-height: auto; }
  .window { transform: none; }
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed; top: 0; right: 0; height: 100vh; width: min(300px, 80vw);
    flex-direction: column; justify-content: center; gap: 2rem; font-size: 1.1rem;
    background: var(--bg-2); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform .3s;
  }
  .nav-links.open { transform: none; }
  .nav-toggle { z-index: 60; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

.bullets { display: grid; gap: .5rem; margin-top: .6rem; }
.bullets li { position: relative; padding-left: 1.4rem; color: var(--text-dim); font-size: .95rem; }
.bullets li::before { content: "▹"; position: absolute; left: 0; color: var(--blue-light); }

.section-note { max-width: 640px; margin: -1.4rem 0 2rem; color: var(--text-dim); font-size: .95rem; }

.stat-num.no-plus::after { content: none; }
.stat-num.no-plus { font-size: 2.8rem; }

.timeline .org { color: var(--blue-light); font-weight: 500; font-size: .95rem; margin: -.1rem 0 .6rem; }
.timeline .tags { margin-top: .8rem; gap: .5rem 1rem; }

/* 404 page */
.nf-page { min-height: 100vh; display: flex; flex-direction: column; }
.notfound { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; align-items: center; padding-top: 6rem; padding-bottom: 2rem; }
.code-404 { font-size: clamp(5rem, 16vw, 9rem); line-height: 1; font-weight: 800; letter-spacing: -.04em; color: var(--heading); }
.notfound h2 { font-size: clamp(1.1rem, 2.1vw, 1.5rem); color: var(--heading); margin-top: .5rem; }
.nf-window { width: auto; min-width: 0; max-width: 100%; text-align: left; }
.nf-window .code { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; }
@media (max-width: 860px) {
  .notfound { grid-template-columns: 1fr; text-align: center; gap: 2rem; }
  .notfound .lead { margin-inline: auto; }
  .notfound .cta { justify-content: center; }
}

/* 404 brick breaker easter egg */
button.dot { border: 0; padding: 0; cursor: default; transition: filter .2s; }
.nf-window .dot:hover { filter: brightness(1.25); }
.nf-window .dot.g { cursor: pointer; animation: dotPulse 30s ease-out 12s infinite; }
@keyframes dotPulse {
  0% { box-shadow: 0 0 0 0 rgba(40, 200, 64, .55); }
  3% { box-shadow: 0 0 0 9px rgba(40, 200, 64, 0); }
  100% { box-shadow: 0 0 0 9px rgba(40, 200, 64, 0); }
}
.notfound.playing .nf-window .dot { cursor: pointer; animation: none; }
.nf-right { min-width: 0; }
.nf-game canvas { display: block; width: 100%; aspect-ratio: 8 / 5; touch-action: none; }
.notfound.playing { grid-template-columns: 1fr; }
.notfound.playing .nf-text { display: none; }
.notfound.playing .nf-window { transform: none; width: min(860px, 100%); margin-inline: auto; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
@media (prefers-reduced-motion: reduce) { .nf-window .dot.g { animation: none; } }
.nf-game canvas:focus { outline: none; }

/* Respect the hidden attribute even on elements that set their own display (e.g. .btn) */
[hidden] { display: none !important; }

/* No-JavaScript fallback for the obfuscated email */
.nojs-mail { margin-top: 1.4rem; color: var(--text-dim); font-size: .9rem; }

/* Resources page */
.res-page { padding-top: 7rem; padding-bottom: 3rem; }
.res-hero { padding: 2rem 0 1rem; }
.res-hero h1 { font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.05; color: var(--heading); font-weight: 800; letter-spacing: -.03em; }
.res-section { padding: 2.5rem 0; }
.cert-card { padding: 1.8rem; display: grid; gap: 1.1rem; }
.cert-card:hover { transform: none; }
.cert-card p { color: var(--text); }
.cert-card strong { color: var(--heading); font-weight: 600; }
.inline-link { color: var(--blue-light); border-bottom: 1px solid rgba(96, 165, 250, .4); transition: border-color .2s; }
.inline-link:hover { border-color: var(--blue-light); }
.steps { display: grid; gap: .6rem; counter-reset: step; padding-left: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 2.2rem; color: var(--text-dim); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: .1rem; width: 1.5rem; height: 1.5rem; display: grid; place-items: center; font-family: var(--mono); font-size: .75rem; color: var(--blue-light); border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.res-links { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; margin-top: .2rem; }
.res-links a { color: var(--blue-light); font-size: .92rem; font-weight: 500; }
.res-links a:hover { color: var(--cyan); }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.res-window { transform: none; min-width: 0; }
.res-window:hover { transform: none; }
.res-window .code { font-size: clamp(.68rem, 1.4vw, .8rem); line-height: 1.7; }
.code .c { color: #8190ad; }
.mini-title { color: var(--cyan); font-size: .95rem; font-weight: 500; margin: .4rem 0 -.2rem; }
.cert-card :not(pre) > code { font-family: var(--mono); font-size: .85em; color: var(--blue-light); background: rgba(59, 130, 246, .1); padding: .1em .4em; border-radius: 5px; }
.cert-card .bullets li { color: var(--text-dim); }
.cert-card .bullets strong { color: var(--text); }
.note-small { color: var(--text-dim); font-size: .9rem; }
.disclosure { display: grid; gap: 1.1rem; margin-top: 2rem; padding: 1.2rem 1.5rem; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-dim); font-size: .9rem; }
.disclosure .mono { color: var(--cyan); font-size: .85rem; margin-bottom: .3rem; }
.nav-links a[aria-current="page"] { color: var(--blue-light); }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.thanks { padding: 1.8rem; border-left: 3px solid var(--blue-light); display: grid; gap: .9rem; }
.thanks:hover { transform: none; }
.thanks p { color: var(--text); font-size: 1.05rem; }
.thanks .thanks-sign { color: var(--cyan); font-size: .9rem; }

/* Simple always-visible header links (404 page) */
.nav-simple { display: flex; gap: 1.5rem; font-size: .92rem; }
.nav-simple a { color: var(--heading); font-weight: 600; transition: color .2s; }
.nav-simple a:hover { color: var(--blue-light); }
.res-section { scroll-margin-top: 80px; }

/* Header: main pages stand out, in-page quick jumps stay quiet */
.nav-links { gap: 1.4rem; }
.nav-links a.nav-main { color: var(--heading); font-weight: 600; font-size: 1rem; padding-bottom: 2px; border-bottom: 2px solid transparent; }
.nav-links a.nav-main:hover { color: var(--blue-light); }
.nav-links a.nav-main[aria-current="page"] { color: var(--blue-light); border-bottom-color: var(--blue-light); }
.nav-links a.nav-jump { font-family: var(--mono); font-size: .78rem; color: var(--text-dim); }
.nav-sep { width: 1px; height: 1.1rem; background: var(--border); }
@media (max-width: 860px) {
  .nav-links a.nav-main { font-size: 1.3rem; }
  .nav-links a.nav-jump { font-size: .9rem; }
  .nav-sep { width: 3rem; height: 1px; margin: -.4rem 0; }
}

/* Accessibility */
a:focus-visible, button:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 3px; border-radius: 6px; }
.skip-link { position: fixed; top: .75rem; left: .75rem; z-index: 200; padding: .6rem 1rem; border-radius: 8px; background: var(--blue); color: #fff; font-weight: 600; transform: translateY(-200%); transition: transform .2s; }
.skip-link:focus { transform: none; }
@media (max-width: 860px) {
  /* closed mobile menu must not be reachable by keyboard */
  .nav-links { visibility: hidden; transition: transform .3s, visibility 0s linear .3s; }
  .nav-links.open { visibility: visible; transition: transform .3s; }
}

/* 404 header matches the other pages: main links bold, Contact as a button */
.nav-simple { align-items: center; gap: 1.4rem; }
.nav-simple a.nav-main { color: var(--heading); font-weight: 600; font-size: 1rem; padding-bottom: 2px; border-bottom: 2px solid transparent; }
.nav-simple a.nav-main:hover { color: var(--blue-light); }
@media (max-width: 480px) { .nav-simple { gap: 1rem; } .nav-simple a.nav-main { font-size: .95rem; } }

/* Spilled ice cream + fallen cookie (404) */
.nf-art { margin: 2rem 0 0; width: min(340px, 100%); }
.nf-art svg { display: block; width: 100%; height: auto; }
.nf-art figcaption { margin-top: .4rem; color: var(--text-dim); font-size: .78rem; }
@media (max-width: 860px) { .nf-art { margin-inline: auto; } }

.footer-legal { margin-top: .35rem; font-size: .72rem; opacity: .85; }
