/* Fonts: self-hosted, SIL Open Font License */
@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #f7f7f4;
  --bg-2: #efefe9;
  --surface: #ffffff;
  --text: #15171c;
  --muted: #586070;
  --border: #e0e1db;
  --accent: #2554e8;
  --accent-2: #0f9d74;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfd;
  --glow: rgba(37, 84, 232, 0.16);
  --term-bg: #12151c;
  --term-text: #d7dbe4;
  --shadow: 0 1px 2px rgba(20, 23, 28, 0.04), 0 8px 24px rgba(20, 23, 28, 0.06);
  --max: 68rem;
  --prose: 42rem;
  --f-head: "Space Grotesk", system-ui, sans-serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f14;
    --bg-2: #12151c;
    --surface: #161a22;
    --text: #e9ebf0;
    --muted: #9aa2b2;
    --border: #262b36;
    --accent: #7c9cff;
    --accent-2: #3ddc97;
    --accent-ink: #0b1020;
    --accent-soft: #1b2340;
    --glow: rgba(124, 156, 255, 0.18);
    --term-bg: #0a0c10;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f14;
  --bg-2: #12151c;
  --surface: #161a22;
  --text: #e9ebf0;
  --muted: #9aa2b2;
  --border: #262b36;
  --accent: #7c9cff;
  --accent-2: #3ddc97;
  --accent-ink: #0b1020;
  --accent-soft: #1b2340;
  --glow: rgba(124, 156, 255, 0.18);
  --term-bg: #0a0c10;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.7 var(--f-body);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--f-head); line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
p { margin: 0 0 1rem; }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 1rem; top: -3rem; z-index: 20;
  background: var(--accent); color: var(--accent-ink);
  padding: 0.5rem 0.9rem; border-radius: 6px;
}
.skip:focus { top: 1rem; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1rem; }
@media (min-width: 48rem) { .wrap { padding: 0 2rem; } }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 3.75rem; }
.brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-family: var(--f-head); font-weight: 700; color: var(--text); text-decoration: none;
}
.brand-mark {
  display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 0.85rem; letter-spacing: -0.03em;
}
.site-nav { display: flex; align-items: center; gap: 0.25rem 1.1rem; margin-left: auto; font-size: 0.9rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--text); }
.lang {
  font-family: var(--f-mono); font-size: 0.78rem; font-weight: 600;
  border: 1px solid var(--border); padding: 0.2rem 0.6rem; border-radius: 999px;
}
@media (max-width: 52rem) { .site-nav .opt { display: none; } }

/* ---------- Shared bits ---------- */
.label {
  font-family: var(--f-mono); font-size: 0.78rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent);
  margin: 0 0 0.75rem;
}
.label span { color: var(--muted); }
.meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.6rem; }
.lede { font-size: 1.15rem; color: var(--text); }
.eyebrow { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0; }
.chips li {
  font-family: var(--f-mono); font-size: 0.76rem; line-height: 1.5;
  background: var(--accent-soft); color: var(--text);
  border-radius: 6px; padding: 0.2rem 0.55rem;
}

.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-radius: 10px;
  font-weight: 600; font-size: 0.95rem; text-decoration: none;
  border: 1px solid var(--accent); transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 20px var(--glow); }
.btn-ghost { color: var(--text); border-color: var(--border); background: var(--surface); }
.btn svg { width: 1.05em; height: 1.05em; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.5rem; box-shadow: var(--shadow);
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: 4rem 0 3rem; isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: -4rem -50vw 0; z-index: -1;
  background:
    radial-gradient(40rem 22rem at 75% 20%, var(--glow), transparent 70%),
    radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 28%, transparent) 1px, transparent 0) 0 0 / 22px 22px;
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.hero-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 60rem) { .hero-grid { grid-template-columns: 1.25fr 1fr; gap: 3.5rem; } .hero { padding: 6rem 0 4rem; } }

.status {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--f-mono); font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 0.3rem 0.8rem; margin-bottom: 1.5rem;
}
.status .dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-2) 22%, transparent); }

.hero h1 { font-size: clamp(2.5rem, 7.5vw, 4.4rem); font-weight: 700; letter-spacing: -0.035em; margin-bottom: 1rem; }
.hero h1 .last { display: block; color: var(--muted); font-weight: 500; }
.role { font-family: var(--f-head); font-size: clamp(1.15rem, 2.6vw, 1.45rem); font-weight: 600; margin: 0 0 1.25rem; }
.role em { font-style: normal; color: var(--accent); }
.hero .lede { max-width: 36rem; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }

/* Terminal card */
.term {
  background: var(--term-bg); color: var(--term-text); border-radius: 14px;
  font: 0.84rem/1.75 var(--f-mono); box-shadow: 0 20px 60px var(--glow), var(--shadow);
  border: 1px solid #262b36; overflow: hidden;
}
.term-bar { display: flex; gap: 0.4rem; padding: 0.75rem 1rem; border-bottom: 1px solid #262b36; }
.term-bar i { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #3a404d; }
.term-bar i:first-child { background: #ff5f57; } .term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
.term pre { margin: 0; padding: 1rem 1.25rem 1.25rem; white-space: pre-wrap; font: inherit; }
.term .p { color: #3ddc97; }
.term .c { color: #7c9cff; }
.term .d { color: #7d8597; }

/* Stats */
.stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  margin-top: 3.5rem;
}
.stat { background: var(--surface); padding: 1.25rem 1rem; }
.stat b { display: block; font-family: var(--f-head); font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.1; letter-spacing: -0.03em; }
.stat span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; display: block; margin-top: 0.3rem; }

/* ---------- Sections ---------- */
.section { padding: 4.5rem 0; border-top: 1px solid var(--border); }
.section .wrap > h2 { font-size: clamp(1.75rem, 4vw, 2.4rem); margin-bottom: 2rem; }
.section-alt { background: var(--bg-2); }
.prose { max-width: var(--prose); }

.split { display: grid; gap: 2rem; }
@media (min-width: 56rem) { .split { grid-template-columns: 1.5fr 1fr; gap: 3rem; align-items: start; } }

.principles { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.principles li { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem; }
.principles b { display: block; font-family: var(--f-head); }
.principles span { color: var(--muted); font-size: 0.92rem; }
.principles .n { font-family: var(--f-mono); color: var(--accent); font-size: 0.8rem; padding-top: 0.15rem; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 0.45rem; top: 0.5rem; bottom: 0.5rem; width: 2px; background: var(--border); }
.timeline > li { position: relative; padding-left: 2.25rem; margin-bottom: 2.5rem; }
.timeline > li:last-child { margin-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: 0.4rem; width: 1rem; height: 1rem; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.timeline > li.past::before { border-color: var(--muted); }
.timeline h3 { font-size: 1.2rem; }
.timeline .org { color: var(--accent); }
.timeline .when { font-family: var(--f-mono); font-size: 0.8rem; color: var(--muted); margin: 0.3rem 0 0.75rem; }
.timeline ul { margin: 0; padding-left: 1.1rem; max-width: var(--prose); }
.timeline ul li { margin-bottom: 0.35rem; }
.timeline ul li::marker { color: var(--accent); }

/* Projects */
.grid-2 { display: grid; gap: 1.25rem; }
@media (min-width: 56rem) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.project { display: flex; flex-direction: column; gap: 0.9rem; transition: transform 0.2s, border-color 0.2s; position: relative; overflow: hidden; }
.project::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); opacity: 0; transition: opacity 0.2s; }
.project:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.project:hover::before { opacity: 1; }
.project .tag { font-family: var(--f-mono); font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.project h3 { font-size: 1.25rem; }
.project dl { margin: 0; display: grid; gap: 0.75rem; flex: 1; }
.project dt { font-family: var(--f-mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); }
.project dd { margin: 0.15rem 0 0; font-size: 0.95rem; }
.project .role-line { font-size: 0.88rem; color: var(--muted); margin: 0; }
.more { margin-top: 2rem; }
.more h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.more ul { margin: 0; padding-left: 1.1rem; color: var(--muted); }

/* Flow (AI tooling) */
.flow { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 1.25rem; counter-reset: step; }
@media (min-width: 56rem) { .flow { grid-template-columns: repeat(4, 1fr); } }
.flow li { counter-increment: step; position: relative; }
.flow li::before {
  content: "0" counter(step); display: grid; place-items: center;
  width: 2.6rem; height: 2.6rem; border-radius: 12px; margin-bottom: 1rem;
  font: 600 0.9rem var(--f-mono); color: var(--accent-ink); background: var(--accent);
  box-shadow: 0 6px 18px var(--glow);
}
@media (min-width: 56rem) {
  .flow li:not(:last-child)::after {
    content: ""; position: absolute; top: 1.3rem; left: 3.3rem; right: -0.6rem; height: 2px;
    background: linear-gradient(90deg, var(--accent), transparent);
  }
}
.flow h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.flow p { font-size: 0.93rem; color: var(--muted); margin: 0; }

/* Skills */
.skills { display: grid; gap: 1rem; }
@media (min-width: 40rem) { .skills { grid-template-columns: 1fr 1fr; } }
@media (min-width: 62rem) { .skills { grid-template-columns: repeat(3, 1fr); } }
.skills .card { padding: 1.25rem; box-shadow: none; }
.skills h3 { font-size: 0.95rem; margin-bottom: 0.8rem; }

/* Education */
.edu { display: grid; gap: 1rem; }
@media (min-width: 56rem) { .edu { grid-template-columns: 1.4fr 1fr; gap: 2rem; } }
.edu-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; }
.edu-list h3 { font-size: 1.05rem; }
.edu-list p { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }
.certs h3 { font-size: 0.95rem; margin-bottom: 0.8rem; }

/* Services */
.services { display: grid; gap: 1rem; }
@media (min-width: 40rem) { .services { grid-template-columns: 1fr 1fr; } }
@media (min-width: 62rem) { .services { grid-template-columns: repeat(3, 1fr); } }
.services .card { box-shadow: none; }
.services h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.services p { font-size: 0.93rem; color: var(--muted); margin: 0; }
.services .local { border-style: dashed; border-color: color-mix(in srgb, var(--accent-2) 55%, var(--border)); }
.services .local .label { color: var(--accent-2); margin-bottom: 0.5rem; }

/* Contact */
.cta {
  position: relative; overflow: hidden; border-radius: 22px; padding: 2.5rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent-2)));
  color: #fff;
}
@media (min-width: 48rem) { .cta { padding: 3.5rem; } }
.cta::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.18) 1px, transparent 0) 0 0 / 20px 20px;
  mask-image: linear-gradient(120deg, transparent 40%, #000);
  -webkit-mask-image: linear-gradient(120deg, transparent 40%, #000);
}
.cta > * { position: relative; z-index: 1; }
.cta .label { color: rgba(255, 255, 255, 0.8); }
.cta h2 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: 1rem; }
.cta p { color: rgba(255, 255, 255, 0.88); max-width: 34rem; }
.cta .mail { display: inline-block; font-family: var(--f-head); font-size: clamp(1.2rem, 4vw, 1.7rem); font-weight: 600; color: #fff; margin: 0.5rem 0 1.5rem; overflow-wrap: anywhere; }
.cta .btn { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.cta .btn-primary { background: #fff; color: #15171c; border-color: #fff; box-shadow: none; }

/* ---------- Footer ---------- */
.site-footer { padding: 2.5rem 0 3rem; color: var(--muted); font-size: 0.88rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }
.site-footer p { margin: 0; }

/* ---------- Long-form pages (gcalcli, 404, root) ---------- */
.doc { max-width: calc(var(--prose) + 4rem); padding-top: 3.5rem; padding-bottom: 3.5rem; }
.doc h1 { font-size: clamp(2rem, 6vw, 2.8rem); margin-bottom: 0.75rem; }
.doc h2 { margin: 2.5rem 0 0.75rem; font-size: 1.35rem; }
.doc section { padding-top: 0; }
.doc ul { padding-left: 1.2rem; }
.doc li { margin-bottom: 0.4rem; }
.doc code { font-family: var(--f-mono); background: var(--accent-soft); padding: 0.05rem 0.35rem; border-radius: 4px; font-size: 0.85em; overflow-wrap: anywhere; }
.note { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 1rem 1.2rem; }
.contact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; }
hr.lang-split { border: 0; border-top: 1px solid var(--border); margin: 3rem 0; }
.spaced { margin-top: 1.25rem; }
.cta .actions { margin-top: 0; }

/* Theme switch */
.theme-toggle {
  display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 1rem; height: 1rem; display: none; }
:root:not([data-theme-pref]) .theme-toggle .i-auto,
[data-theme-pref="auto"] .theme-toggle .i-auto,
[data-theme-pref="light"] .theme-toggle .i-light,
[data-theme-pref="dark"] .theme-toggle .i-dark { display: block; }
