/* ---------- Tokens ---------- */
:root {
  --bg: #0a0e0d;
  --bg-elev: #10161a;
  --surface: #121a1c;
  --surface-2: #172124;
  --border: #22302f;
  --border-strong: #2f4240;
  --text: #e6ede9;
  --text-muted: #9aaba5;
  --text-dim: #85968f;
  --accent: #4ade80;
  --accent-strong: #22c55e;
  --accent-soft: rgba(74, 222, 128, 0.12);
  --accent-ink: #052e16;
  --warn: #fbbf24;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 8px;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --max: 1120px;
  --gutter: 16px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f8f7;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --border: #dbe4e0;
  --border-strong: #c3d1cb;
  --text: #0f1a17;
  --text-muted: #44544e;
  --text-dim: #5b6b65;
  --accent: #15803d;
  --accent-strong: #166534;
  --accent-soft: rgba(21, 128, 61, 0.1);
  --accent-ink: #ffffff;
  --shadow: 0 20px 50px rgba(15, 26, 23, 0.1);
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  /* faint grid backdrop */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.25;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
  pointer-events: none;
}

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
strong { color: var(--text); font-weight: 600; }

.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
@media (min-width: 768px) { .container { padding: 0 32px; } }

.mono { font-family: var(--font-mono); }
.accent { color: var(--accent); }
.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }
.small { font-size: 0.9rem; color: var(--text-muted); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

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

/* ---------- Nav ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav { display: flex; align-items: center; gap: 16px; height: 64px; }

.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand .prompt { color: var(--accent); margin-right: 4px; }

.nav-links { display: flex; gap: 4px; margin-left: auto; }
.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

.nav-tools { display: flex; align-items: center; gap: 8px; }

.lang-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.lang-switch button {
  border: 0;
  background: none;
  color: var(--text-muted);
  font: 600 0.75rem var(--font-mono);
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--border-strong); }
.theme-btn .icon-moon { display: none; }
:root[data-theme="light"] .theme-btn .icon-sun { display: none; }
:root[data-theme="light"] .theme-btn .icon-moon { display: block; }

/* Mobile & tablet: section links become a tab bar under the top row.
   Each tab is a full-height (44px) segment and the tabs share the width,
   so neighbouring targets are well apart. The bar hides while scrolling down. */
@media (max-width: 820px) {
  html { scroll-padding-top: 112px; }
  .topbar { transition: transform 0.25s ease; }
  .topbar.is-hidden { transform: translateY(-100%); }
  .nav { flex-wrap: wrap; height: auto; row-gap: 0; padding-top: 10px; }
  .nav-tools { margin-left: auto; }
  .nav-links {
    order: 3;
    position: relative;
    flex: 0 0 calc(100% + 2 * var(--gutter));
    gap: 0;
    margin: 10px calc(-1 * var(--gutter)) 0;
    padding: 0 var(--gutter);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    border-top: 1px solid var(--border);
  }
  .nav-links.is-overflowing {
    mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 24px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter), #000 calc(100% - 24px), transparent);
  }
  .nav-links::-webkit-scrollbar { display: none; }
  .nav-links li { flex: 1 0 auto; scroll-snap-align: start; }
  .nav-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 7px;
    border-radius: 0;
    font-size: 0.875rem;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-links a.active { background: none; box-shadow: inset 0 -2px 0 var(--accent); }
  .nav-links a:active { background: var(--accent-soft); }
}

@media (max-width: 380px) {
  .brand .muted { display: none; }
}

/* ---------- Buttons ---------- */
.cta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: var(--border); padding-left: 14px; padding-right: 14px; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  align-items: center;
  padding-top: 88px;
  padding-bottom: 72px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 24px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.hero h1 { font-size: clamp(2.5rem, 6vw, 4.2rem); font-weight: 700; }
.caret { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

.role { margin-top: 14px; font-size: clamp(1.1rem, 2.2vw, 1.35rem); font-weight: 600; color: var(--text); }
.tagline { margin-top: 6px; color: var(--accent); font-size: 0.92rem; }
.lede { margin-top: 20px; max-width: 34em; color: var(--text-muted); font-size: 1.08rem; }
.interest { margin-top: 14px; font-size: 0.88rem; color: var(--text-muted); }

/* Terminal card */
.terminal {
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.term-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.term-bar span { width: 11px; height: 11px; border-radius: 50%; background: var(--border-strong); }
.term-bar span:nth-child(1) { background: #f87171; }
.term-bar span:nth-child(2) { background: #fbbf24; }
.term-bar span:nth-child(3) { background: #4ade80; }
.term-bar p { margin-left: 10px; font-size: 0.75rem; color: var(--text-muted); }

.term-body { padding: 18px 18px 22px; font-size: 0.84rem; line-height: 1.9; overflow-x: auto; }
.term-body p { padding-left: 1.4em; text-indent: -1.4em; }
.pass { color: var(--accent); font-weight: 700; }
.summary { margin-top: 8px; }
.cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.run-line { opacity: 0; animation: reveal 0.35s ease forwards; animation-delay: calc(var(--i) * 0.28s + 0.2s); }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; padding-top: 56px; gap: 40px; }
}
@media (max-width: 480px) {
  .term-body { font-size: 0.74rem; padding: 14px; }
}

/* ---------- Sections ---------- */
.section { padding-top: 72px; padding-bottom: 72px; border-top: 1px solid var(--border); }
.eyebrow { color: var(--accent); font-size: 0.82rem; margin-bottom: 10px; }
.section h2 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); margin-bottom: 36px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-strong); }
.card h3 { font-size: 1.08rem; margin: 6px 0 8px; }
.card p { color: var(--text-muted); font-size: 0.95rem; }

/* About */
.about-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px; align-items: start; }
.prose p { color: var(--text-muted); font-size: 1.05rem; }
.prose p + p { margin-top: 16px; }
.focus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.focus-grid .mono { font-size: 0.78rem; }
@media (max-width: 920px) { .about-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .focus-grid { grid-template-columns: 1fr; } }

/* Experience timeline */
.timeline { position: relative; }
.commit { display: grid; grid-template-columns: 150px 1fr; gap: 24px; position: relative; padding-bottom: 40px; }
.commit:last-child { padding-bottom: 0; }
.commit-meta { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding-top: 4px; font-size: 0.8rem; }
.hash { color: var(--warn); }
:root[data-theme="light"] .hash { color: #a16207; }
.ref {
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.72rem;
  white-space: nowrap;
}
.commit-body { position: relative; padding-left: 28px; border-left: 2px solid var(--border); }
.commit-body::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}
.commit-head h3 { font-size: 1.2rem; }
.at { color: var(--text-muted); font-weight: 500; }
.when { margin-top: 6px; font-size: 0.8rem; color: var(--text-dim); }
.bullets { margin-top: 16px; display: grid; gap: 10px; }
.bullets li { position: relative; padding-left: 20px; color: var(--text-muted); }
.bullets li::before { content: "+"; position: absolute; left: 0; color: var(--accent); font-family: var(--font-mono); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chips li {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font: 500 0.78rem var(--font-mono);
}

@media (max-width: 720px) {
  .commit { grid-template-columns: 1fr; gap: 8px; }
  .commit-meta { flex-direction: row; align-items: center; }
}

/* Work */
.work-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.case { display: flex; flex-direction: column; gap: 16px; padding: 26px; }
.case h3 { font-size: 1.25rem; margin: 10px 0 4px; }
.metric {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent) !important;
  font-size: 0.82rem !important;
  font-weight: 700;
}
.org { font-size: 0.78rem !important; color: var(--text-dim) !important; }
:root[data-theme="light"] .metric { color: var(--accent-strong) !important; }
.case dl { margin: 0; display: grid; gap: 4px; }
.case dt { font-size: 0.74rem; color: var(--accent); text-transform: lowercase; margin-top: 8px; }
.case dt::before { content: "› "; }
.case dd { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
@media (max-width: 820px) { .work-grid { grid-template-columns: 1fr; } }

.training { margin-top: 32px; }
.training > p { font-size: 0.85rem; margin-bottom: 12px; }
.training-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.training-list a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: border-color 0.15s;
}
.training-list a:hover { border-color: var(--accent); border-style: solid; }
.training-list .mono { font-weight: 700; font-size: 0.9rem; }
.training-list .dim { font-size: 0.8rem; }
@media (max-width: 720px) { .training-list { grid-template-columns: 1fr; } }

/* Built with AI */
.case-link { margin-top: auto; font-size: 0.82rem; color: var(--accent); text-decoration: none; }
.case-link:hover { text-decoration: underline; }
.ai-lede { margin: -16px 0 32px; max-width: 46em; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.ai-steps { display: grid; gap: 22px; counter-reset: none; }
.ai-steps li { padding-left: 16px; border-left: 2px solid var(--border); }
.ai-steps .mono { font-size: 0.78rem; }
.ai-steps h3 { font-size: 1.05rem; margin: 4px 0 6px; }
.ai-steps li > p:last-child { color: var(--text-muted); font-size: 0.95rem; }
.ai-report .term-body { line-height: 1.7; }
.ai-report .term-body p + p { margin-top: 6px; }
.ai-report .ai-commits { padding-top: 12px; margin-top: 14px; border-top: 1px dashed var(--border); line-height: 1.7; }
.ai-roles { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--border); }
.footer a { color: var(--text-muted); }
.footer a:hover { color: var(--accent); }
@media (max-width: 920px) { .ai-grid { grid-template-columns: 1fr; } }

/* Stack */
.stack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack-group { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stack-group.wide { grid-column: 1 / -1; }
.stack-group h3 { font-size: 0.82rem; font-weight: 700; color: var(--accent); letter-spacing: 0; }
.stack-group h3::before { content: '"'; color: var(--text-dim); }
.stack-group h3::after { content: '":'; color: var(--text-dim); }
.stack-group .chips { margin-top: 12px; }
@media (max-width: 920px) { .stack-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .stack-grid { grid-template-columns: 1fr; } }

/* Education */
.edu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.edu-grid .mono { font-size: 0.78rem; }
.edu-grid .small { margin-top: 10px; }
.lang-list { margin-top: 10px; display: grid; gap: 8px; }
.lang-list li { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.lang-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.lang-list .dim { font-size: 0.88rem; }
@media (max-width: 820px) { .edu-grid { grid-template-columns: 1fr; } }

/* Contact */
.contact { text-align: left; }
.contact h2 { margin-bottom: 12px; }
.contact .lede { margin-top: 0; }
.contact .btn-primary { word-break: break-all; }

/* Footer */
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 24px;
  padding-bottom: 40px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .run-line { opacity: 1; }
}
