/* ---------- Fonts (self-hosted, Latin subset, SIL OFL — see fonts/LICENSE-*.txt) ---------- */
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url("fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-display: swap; src: url("fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

/* ---------- Theme tokens: dark is the default ---------- */
:root {
  color-scheme: dark;
  --bg: #0b1628;
  --bg-2: #0e1c33;
  --surface: #12233d;
  --raised: #1a3557;
  --border: #24406a;
  --fg: #e6edf6;
  --muted: #9fb0c6;
  --accent: #22d3ee;
  --accent-ink: #0b1628;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --glow: rgba(34, 211, 238, 0.35);
  --dot: rgba(159, 176, 198, 0.16);
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.7);

  --font-head: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 14px;
  --nav-h: 60px;
}

/* Light tokens: used when chosen via the toggle, or (without JS) when the system prefers light. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f8fc;
  --bg-2: #edf2f8;
  --surface: #ffffff;
  --raised: #e8eef6;
  --border: #d3dde9;
  --fg: #0f1f35;
  --muted: #4a5d78;
  --accent: #0e7490;
  --accent-ink: #ffffff;
  --accent-soft: rgba(14, 116, 144, 0.1);
  --glow: rgba(14, 116, 144, 0.28);
  --dot: rgba(15, 31, 53, 0.09);
  --shadow: 0 18px 40px -24px rgba(15, 31, 53, 0.35);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f5f8fc;
    --bg-2: #edf2f8;
    --surface: #ffffff;
    --raised: #e8eef6;
    --border: #d3dde9;
    --fg: #0f1f35;
    --muted: #4a5d78;
    --accent: #0e7490;
    --accent-ink: #ffffff;
    --accent-soft: rgba(14, 116, 144, 0.1);
    --glow: rgba(14, 116, 144, 0.28);
    --dot: rgba(15, 31, 53, 0.09);
    --shadow: 0 18px 40px -24px rgba(15, 31, 53, 0.35);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1rem/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; margin: 0; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 32px); }
.mono { font-family: var(--font-mono); }

.skip {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 14px; border-radius: 8px; font-weight: 600;
}
.skip:focus { top: 12px; }

/* ---------- Sticky nav ---------- */
.site-nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.nav-inner { display: flex; align-items: center; gap: 16px; min-height: var(--nav-h); }
.brand {
  font-family: var(--font-mono); font-weight: 500; font-size: 0.95rem; color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px; padding: 4px 9px; letter-spacing: 0.04em;
}
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; border-color: var(--accent); }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  position: relative; display: block; padding: 8px 12px;
  color: var(--muted); font-size: 0.9rem; font-weight: 600; border-radius: 8px;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-links a:hover { color: var(--fg); text-decoration: none; background: var(--accent-soft); }
.nav-links a.is-active { color: var(--fg); }
.nav-links a.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px;
  height: 2px; border-radius: 2px; background: var(--accent);
}

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: transparent; color: var(--fg); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: border-color 0.2s ease, background-color 0.2s ease;
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-toggle { display: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: block; }
:root[data-theme="light"] .theme-toggle .i-moon { display: none; }
.no-js .theme-toggle, .no-js .menu-toggle { display: none; }

@media (max-width: 767px) {
  .menu-toggle { display: inline-grid; margin-left: auto; }
  .nav-links {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px clamp(16px, 4vw, 32px) 16px;
    background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .nav-links.is-open { display: flex; }
  .nav-links a { padding: 12px; font-size: 1rem; }
  .nav-links a.is-active::after { left: 0; right: auto; top: 12px; bottom: 12px; width: 2px; height: auto; }
  /* Without JS: show the links as a scrollable row under the brand. */
  .no-js .nav-inner { flex-wrap: wrap; }
  .no-js .nav-links {
    display: flex; position: static; flex-direction: row; overflow-x: auto; width: 100%;
    padding: 0 0 8px; box-shadow: none; border: 0; background: transparent;
  }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(48px, 9vw, 104px) 0 clamp(40px, 6vw, 72px); isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 30% 35%, #000 40%, transparent 100%);
  mask-image: radial-gradient(ellipse 80% 70% at 30% 35%, #000 40%, transparent 100%);
}
.hero::after {
  content: ""; position: absolute; z-index: -1; width: 520px; height: 520px; right: -140px; top: -120px;
  background: radial-gradient(circle, var(--accent-soft), transparent 65%);
  pointer-events: none;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(32px, 6vw, 72px); align-items: center; }
.hero h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); letter-spacing: -0.03em; line-height: 1.02; }
.headline { font-family: var(--font-head); font-weight: 500; font-size: clamp(1.15rem, 2.4vw, 1.5rem); color: var(--fg); margin: 18px 0 10px; max-width: 32ch; }
.location { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.875rem; color: var(--muted); margin: 0 0 28px; }
.location svg { width: 16px; height: 16px; color: var(--accent); flex: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  font: 600 0.95rem/1 var(--font-body); color: var(--fg); background: var(--surface);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 8px 24px -12px var(--glow); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { box-shadow: 0 10px 28px -10px var(--glow); }
.btn-lg { min-height: 52px; padding: 14px 22px; font-size: 1rem; }
/* No-JS email fallback: readable text, not a fake button. */
.email-fallback { display: inline-flex; align-items: center; min-height: 44px; font-family: var(--font-mono); font-size: 0.875rem; color: var(--muted); }

.photo-frame { position: relative; width: clamp(200px, 26vw, 300px); }
.photo-frame img {
  width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
}
.photo-frame::before, .photo-frame::after {
  content: ""; position: absolute; width: 44px; height: 44px; border: 2px solid var(--accent); pointer-events: none;
}
.photo-frame::before { top: -10px; left: -10px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.photo-frame::after { bottom: -10px; right: -10px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }

@media (max-width: 767px) {
  .hero-grid { grid-template-columns: 1fr; }
  .photo-frame { order: -1; width: 168px; margin-left: 10px; }
}

/* ---------- Stats strip ---------- */
.stats { border-block: 1px solid var(--border); background: var(--bg-2); }
.stats ul { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stats li { padding: 26px 20px; border-left: 1px solid var(--border); }
.stats li:first-child { border-left: 0; padding-left: 0; }
.stat-value { display: block; font-family: var(--font-head); font-weight: 700; font-size: clamp(1.9rem, 3.4vw, 2.5rem); line-height: 1; color: var(--accent); }
.stat-label { display: block; margin-top: 8px; font-family: var(--font-mono); font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 1023px) {
  .stats ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats li { border-left: 0; border-bottom: 1px solid var(--border); padding-left: 0; }
  .stats li:nth-child(n + 4) { border-bottom: 0; }
}
@media (max-width: 599px) {
  .stats ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .stats li { padding: 20px 0; }
  .stats li:nth-child(n + 4) { border-bottom: 1px solid var(--border); }
  .stats li:last-child { grid-column: 1 / -1; border-bottom: 0; }
}

/* ---------- Sections ---------- */
main { counter-reset: section; }
.section { padding: clamp(56px, 9vw, 104px) 0 0; scroll-margin-top: var(--nav-h); }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 32px; }
.section-head h2 { font-size: clamp(1.6rem, 3.6vw, 2.2rem); letter-spacing: -0.02em; }
.section-head::before {
  counter-increment: section; content: "0" counter(section);
  font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent);
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--border); align-self: center; }

/* About */
.about-body { max-width: 72ch; font-size: 1.075rem; }
.note {
  display: flex; gap: 12px; max-width: 72ch; margin-top: 8px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0; color: var(--muted); font-size: 0.95rem;
}
.note svg { width: 18px; height: 18px; flex: none; margin-top: 3px; color: var(--accent); }
.note p { margin: 0; }

/* Experience timeline */
.timeline { position: relative; padding-left: 32px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--accent), var(--border) 30%); }
.job { position: relative; padding: 22px 24px; margin-bottom: 20px; border: 1px solid transparent; border-radius: var(--radius); transition: border-color 0.2s ease, background-color 0.2s ease; }
.job:hover { border-color: var(--border); background: var(--surface); }
.job::before {
  content: ""; position: absolute; left: -32px; top: 28px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg); border: 2px solid var(--border);
}
.job.current { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.job.current::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft), 0 0 18px var(--glow); }
.job-role { font-family: var(--font-mono); font-weight: 500; font-size: 1.05rem; letter-spacing: -0.01em; }
.job-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 8px 0 14px; font-family: var(--font-mono); font-size: 0.85rem; }
.job-company { color: var(--accent); }
.job-period { color: var(--muted); padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; }
.job.current .job-period { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.job ul li { position: relative; padding-left: 18px; margin-bottom: 8px; color: var(--muted); }
.job.current ul li { color: var(--fg); }
.job ul li::before { content: ""; position: absolute; left: 0; top: 0.8em; width: 8px; height: 2px; background: var(--accent); }
@media (max-width: 599px) {
  .timeline { padding-left: 24px; }
  .timeline::before { left: 5px; }
  .job { padding: 18px 16px; }
  .job::before { left: -24px; width: 14px; height: 14px; }
}

/* Project cards */
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.card:hover, .card:focus-within { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 0 0 1px var(--glow), 0 20px 40px -20px var(--glow); }
.card h3 { font-size: 1.25rem; margin: 20px 0 10px; letter-spacing: -0.01em; }
.card p { color: var(--muted); }
.diagram { padding: 14px 12px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--border); }
.diagram svg { width: 100%; height: auto; }
.dg-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.2; }
.dg-box.hl { fill: var(--accent-soft); stroke: var(--accent); }
.dg-t { fill: var(--fg); font: 600 12px var(--font-body); }
.dg-s { fill: var(--muted); font: 400 10.5px var(--font-mono); }
.dg-line { stroke: var(--muted); stroke-width: 1.3; fill: none; }
.dg-head { fill: var(--muted); }
.dg-bar { stroke: var(--border); stroke-width: 2; stroke-linecap: round; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.tag {
  font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.4;
  padding: 4px 9px; border-radius: 6px; color: var(--fg);
  background: var(--accent-soft); border: 1px solid transparent;
}
@media (max-width: 767px) { .projects { grid-template-columns: 1fr; } }

/* Skills */
.skills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.skill-group { padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.skill-group h3 { font-family: var(--font-mono); font-weight: 500; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.skill-group .tags { padding-top: 0; }
.skill-group .tag { background: transparent; border-color: var(--border); }
.skill-group.primary { grid-column: span 2; border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }
.skill-group.primary h3 { color: var(--accent); font-size: 0.85rem; }
.skill-group.primary .tag { background: var(--accent-soft); border-color: transparent; font-size: 0.8rem; }
@media (max-width: 1023px) { .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599px) { .skills { grid-template-columns: 1fr; } .skill-group.primary { grid-column: auto; } }

/* Education & certifications */
.edu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.edu ul { padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.edu li { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.edu li:last-child { border-bottom: 0; padding-bottom: 0; }
.edu li:first-child { padding-top: 0; }
.edu .period { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
@media (max-width: 767px) { .edu { grid-template-columns: 1fr; } }

/* Contact block */
.contact { padding: clamp(64px, 10vw, 120px) 0 0; scroll-margin-top: var(--nav-h); }
.contact-panel {
  position: relative; overflow: hidden; isolation: isolate;
  padding: clamp(32px, 6vw, 64px); border-radius: 20px;
  /* Always navy, in both themes, so the closing block reads as one strong panel. */
  background: #1a3557; border: 1px solid #24406a;
}
.contact-panel::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(circle at 85% 20%, rgba(34, 211, 238, 0.22), transparent 45%),
    radial-gradient(rgba(230, 237, 246, 0.08) 1.2px, transparent 1.2px) 0 0 / 22px 22px;
}
.contact-panel h2 { font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -0.03em; color: #e6edf6; margin-bottom: 28px; }
.contact-panel .btn { background: rgba(11, 22, 40, 0.35); border-color: rgba(230, 237, 246, 0.25); color: #e6edf6; }
.contact-panel .btn:hover { border-color: #22d3ee; }
.contact-panel .btn-primary { background: #22d3ee; border-color: #22d3ee; color: #0b1628; }
.contact-panel .email-fallback { color: #c3d0e0; }
.contact-panel :focus-visible { outline-color: #22d3ee; }

.site-footer { padding: 32px 0 40px; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }

/* ---------- Motion (progressive enhancement: only hidden once JS adds .js-reveal) ---------- */
.js-reveal .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js-reveal .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .card:hover, .card:focus-within, .btn:hover { transform: none; }
}
