/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { line-height: 1.55; -webkit-font-smoothing: antialiased; min-height: 100vh; }
img, picture, svg, video { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
ul[role="list"] { list-style: none; padding: 0; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }

/* ---------- Tokens (light theme) ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;

  --c-bg: #fafaf7;
  --c-surface: #ffffff;
  --c-surface-2: #f3f3ee;
  --c-text: #16181d;
  --c-text-muted: #555a66;
  --c-border: #d8d8d2;
  --c-accent: #1c5dff;
  --c-accent-contrast: #ffffff;
  --c-accent-soft: #e6edff;
  --c-success: #1f7a3f;
  --c-link: #0a47cc;
  --c-link-hover: #06329a;
  --c-focus: #1c5dff;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.08);

  --container-max: 1100px;
  --container-pad: clamp(16px, 4vw, 32px);

  --t-h1: clamp(2.2rem, 4.6vw, 3.4rem);
  --t-h2: clamp(1.6rem, 3.2vw, 2.2rem);
  --t-h3: clamp(1.2rem, 2.2vw, 1.4rem);
  --t-lead: clamp(1.05rem, 1.4vw, 1.2rem);
  --t-body: 1rem;
  --t-small: 0.875rem;
}

/* ---------- Tokens (dark theme) ---------- */
[data-theme="dark"] {
  --c-bg: #0e1117;
  --c-surface: #161a22;
  --c-surface-2: #1d222c;
  --c-text: #e6e8ee;
  --c-text-muted: #a3a9b5;
  --c-border: #2a303c;
  --c-accent: #6c9bff;
  --c-accent-contrast: #0b1020;
  --c-accent-soft: #1a2540;
  --c-success: #5fd28b;
  --c-link: #8fb3ff;
  --c-link-hover: #b8ceff;
  --c-focus: #8fb3ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* ---------- Base ---------- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--t-body);
}

h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -0.01em; font-weight: 700; }
h1 { font-size: var(--t-h1); letter-spacing: -0.02em; }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }
p { color: var(--c-text); }
small, .text-small { font-size: var(--t-small); color: var(--c-text-muted); }

a {
  color: var(--c-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--c-link-hover); }

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

.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  padding: 8px 12px;
  background: var(--c-accent);
  color: var(--c-accent-contrast);
  border-radius: var(--radius-sm);
  z-index: 1000;
}
.skip-link:focus { top: 8px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.container, main {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

main {
  padding-block: var(--space-7);
}

section {
  padding-block: var(--space-7);
  scroll-margin-top: 80px;
}

section + section { border-top: 1px solid var(--c-border); }

/* ---------- Site Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--c-bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--c-border);
}
.site-nav__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-3) var(--container-pad);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.site-nav__brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--c-text);
  margin-right: auto;
}
.site-nav__list {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
  flex-wrap: wrap;
}
.site-nav__list a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--c-text);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.site-nav__list a:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}
.theme-toggle {
  min-width: 44px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 120ms ease, border-color 120ms ease;
}
.theme-toggle:hover { background: var(--c-surface-2); }

/* ---------- Hero ---------- */
.hero {
  padding-block: var(--space-8) var(--space-7);
  border-top: none !important;
}
.hero__inner {
  display: flex;
  align-items: center;
  gap: var(--space-7);
}
.hero__content { flex: 1 1 0; min-width: 0; }
.hero__media   { flex: 0 0 auto; }
.hero__photo {
  width: clamp(220px, 26vw, 320px);
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
}
.hero__name {
  font-size: var(--t-h1);
  margin-bottom: var(--space-3);
}
.hero__role-stack {
  font-size: var(--t-h2);
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: var(--space-4);
}
.hero__role-stack span + span::before {
  content: " · ";
  color: var(--c-text-muted);
}
.hero__claim {
  font-size: var(--t-lead);
  color: var(--c-text-muted);
  margin-bottom: var(--space-5);
  max-width: 60ch;
}
.hero__tags {
  display: flex; flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.hero__badges {
  display: flex; flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: var(--t-small);
  text-decoration: none;
  color: var(--c-text);
}
.hero__badge strong { color: var(--c-accent); font-weight: 600; }
.hero__ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-5); }
.hero__links { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Tag chips ---------- */
.tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--c-accent-soft);
  color: var(--c-text);
  border-radius: 999px;
  font-size: var(--t-small);
}
[data-theme="dark"] .tag { color: var(--c-text); }

/* ---------- CTAs ---------- */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.cta--primary {
  background: var(--c-accent);
  color: var(--c-accent-contrast);
}
.cta--primary:hover { background: var(--c-link-hover); color: var(--c-accent-contrast); }
.cta--secondary {
  background: transparent;
  color: var(--c-text);
  border-color: var(--c-border);
}
.cta--secondary:hover { background: var(--c-surface-2); }

/* ---------- Section heading ---------- */
.section__eyebrow {
  font-size: var(--t-small);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--c-text-muted);
  margin-bottom: var(--space-2);
}
.section__heading {
  margin-bottom: var(--space-5);
}

/* ---------- About ---------- */
.about__lead {
  font-size: var(--t-lead);
  max-width: 65ch;
  margin-bottom: var(--space-5);
}
.about__focus {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.about__quote {
  font-size: var(--t-h3);
  font-style: italic;
  color: var(--c-text);
  border-left: 3px solid var(--c-accent);
  padding-left: var(--space-4);
  margin-block: var(--space-5);
}
.about__metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}
.about__metric {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

/* ---------- Portfolio teaser ---------- */
.portfolio-teaser__lead {
  font-size: var(--t-lead);
  max-width: 60ch;
  margin-bottom: var(--space-5);
}
.portfolio-teaser__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

/* ---------- Experience ---------- */
.experience__group { margin-bottom: var(--space-6); }
.experience__group h3 { margin-bottom: var(--space-4); color: var(--c-text-muted); font-size: var(--t-small); text-transform: uppercase; letter-spacing: 0.1em; }
.role {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.role__header {
  display: flex; flex-wrap: wrap;
  align-items: baseline; gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.role__title { font-weight: 700; font-size: 1.1rem; }
.role__org { color: var(--c-text-muted); }
.role__period { font-size: var(--t-small); color: var(--c-text-muted); margin-left: auto; }
.role__focus, .role__stack { padding-left: 1.2em; margin-block: var(--space-2); }
.role__focus li, .role__stack li { margin-block: 4px; }
.role__context { color: var(--c-text-muted); margin-top: var(--space-2); }

/* ---------- Skills ---------- */
.skills__group { margin-bottom: var(--space-5); }
.skills__group h3 { margin-bottom: var(--space-3); }
.skills__list { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; }

/* ---------- Languages / Qualifications / Education ---------- */
.dual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}
.list--clean { list-style: none; padding: 0; display: grid; gap: var(--space-3); }
.list--clean li { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: var(--space-3); }

/* ---------- Hobbies ---------- */
.hobbies__list { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; }

/* ---------- Contact ---------- */
.contact__lead { font-size: var(--t-lead); margin-bottom: var(--space-5); max-width: 60ch; }
.contact__meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.contact__meta dt { font-size: var(--t-small); color: var(--c-text-muted); margin-bottom: 4px; }
.contact__meta dd { font-weight: 600; }
.contact__links {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.contact__links a { min-height: 44px; min-width: 44px; padding: 10px 16px; }
.contact__ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.contact__quote {
  margin-top: var(--space-6);
  font-style: italic;
  color: var(--c-text-muted);
  border-left: 3px solid var(--c-border);
  padding-left: var(--space-4);
}

/* ---------- Project cards / list ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.project-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
  text-decoration: none;
  color: inherit;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--c-accent); }
.project-card__category { font-size: var(--t-small); color: var(--c-accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.project-card__title { font-size: 1.2rem; font-weight: 700; }
.project-card__summary { color: var(--c-text-muted); }
.project-card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }

.filter-chips {
  display: flex; flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  list-style: none; padding: 0;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-text);
  text-decoration: none;
  font-size: var(--t-small);
}
.filter-chip[aria-current="page"] {
  background: var(--c-accent);
  color: var(--c-accent-contrast);
  border-color: var(--c-accent);
}

.pagination {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-6);
  gap: var(--space-3);
}

.empty-state {
  background: var(--c-surface);
  border: 1px dashed var(--c-border);
  border-radius: var(--radius-md);
  padding: var(--space-7);
  text-align: center;
  color: var(--c-text-muted);
}

/* ---------- Project detail ---------- */
.project-detail__header { margin-bottom: var(--space-6); }
.project-detail__category { font-size: var(--t-small); color: var(--c-accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.project-detail__summary { font-size: var(--t-lead); color: var(--c-text-muted); margin-block: var(--space-3) var(--space-5); max-width: 65ch; }
.project-detail__section { margin-bottom: var(--space-6); }
.project-detail__section h2 { margin-bottom: var(--space-3); }
.project-detail__tech { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; padding: 0; }

.breadcrumb {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--t-small);
}
.breadcrumb li + li::before { content: "/"; color: var(--c-text-muted); margin-right: var(--space-2); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  margin-top: var(--space-8);
}
.site-footer__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--space-5) var(--container-pad);
  display: flex; justify-content: space-between; gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--t-small);
  color: var(--c-text-muted);
}

/* ---------- Reveal animation (CSS-only) ---------- */
@media (prefers-reduced-motion: no-preference) {
  section {
    animation: reveal 600ms ease both;
    animation-timeline: view();
    animation-range: entry 0% cover 30%;
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640px) {
  .site-nav__list a { padding: 10px 12px; }
  .hero { padding-block: var(--space-6) var(--space-5); }
  .hero__inner { flex-direction: column; align-items: flex-start; gap: var(--space-5); }
  .hero__photo { width: clamp(160px, 55vw, 220px); }
  .hero__role-stack { font-size: 1.4rem; }
  .role__period { margin-left: 0; }
}
