/* ==========================================================================
   Portfolio stylesheet
   Order: tokens → base → layout → components → utilities
   Breakpoints (mobile-first): 576, 768, 992, 1200px
   ========================================================================== */

/* ---------- 1. Tokens ---------------------------------------------------- */

:root {
  color-scheme: light;

  /* Palette: navy/slate neutrals + one accent (teal).
     To switch to blue, change --primary / --primary-contrast here and in
     the dark theme below. All text pairs are checked at ≥ 4.5:1. */
  --primary: #0f766e;            /* 5.2:1 on --background */
  --primary-hover: #115e59;
  --primary-contrast: #ffffff;   /* text on --primary buttons */
  --primary-soft: #ccfbf1;
  --secondary: #1e3a5f;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;              /* 7.2:1 on --background */
  --border: #e2e8f0;
  --focus: #0f766e;
  --danger: #b91c1c;             /* 6.5:1 on --surface */
  --success: #15803d;            /* 5.0:1 on --surface */

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  --fs-3xl: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
  --lh-tight: 1.2;
  --lh-base: 1.6;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.06);
  --shadow-md: 0 4px 12px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / 0.12);

  /* Layout */
  --container: 1140px;
  --gutter: 1rem;
  --header-height: 64px;
  --transition: 180ms ease;
}

[data-theme="dark"] {
  color-scheme: dark;
  --primary: #2dd4bf;            /* 10:1 on --background */
  --primary-hover: #5eead4;
  --primary-contrast: #0b1220;
  --primary-soft: #134e4a;
  --secondary: #93c5fd;
  --background: #0b1220;
  --surface: #131c2e;
  --surface-alt: #1a2438;
  --text: #e2e8f0;
  --muted: #94a3b8;              /* 7.3:1 on --background */
  --border: #26324a;
  --focus: #2dd4bf;
  --danger: #f87171;
  --success: #4ade80;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.5);
}

/* No-JS fallback: follow the OS setting when no theme has been set. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-contrast: #0b1220;
    --primary-soft: #134e4a;
    --secondary: #93c5fd;
    --background: #0b1220;
    --surface: #131c2e;
    --surface-alt: #1a2438;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #26324a;
    --focus: #2dd4bf;
  --danger: #f87171;
  --success: #4ade80;
  }
}

@media (min-width: 768px) {
  :root { --gutter: 1.5rem; --header-height: 72px; }
}

/* ---------- 2. Base ------------------------------------------------------ */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--background);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--space-4);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: var(--fs-3xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--primary);
  text-underline-offset: 0.2em;
  transition: color var(--transition);
}
a:hover { color: var(--primary-hover); }

img, svg { display: block; max-width: 100%; height: auto; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

ul[role="list"], ol[role="list"] { list-style: none; margin: 0; padding: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--primary-soft); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. Layout ---------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--space-8); }
.section:nth-of-type(odd) { background: var(--surface-alt); }
@media (min-width: 992px) {
  .section { padding-block: var(--space-9); }
}

.section-header { max-width: 680px; margin-bottom: var(--space-6); }
.section-header > :last-child { margin-bottom: 0; }
.section-eyebrow {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
}
.section-lead { font-size: var(--fs-lg); color: var(--muted); }

.card-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: 1fr;
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 768px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .card-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 4. Components ------------------------------------------------ */

/* Header + navigation
   Full nav shows at ≥ 1200px; below that it collapses behind the menu button.
   Without JS the nav wraps under the header so every link stays reachable. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-height: var(--header-height);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Theme toggle: shows the moon in light mode, the sun in dark mode. JS only. */
.theme-toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  transition: border-color var(--transition), color var(--transition);
}
.js .theme-toggle { display: grid; }
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.nav-toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
}
.js .nav-toggle { display: grid; }
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  transition: transform var(--transition), background-color var(--transition);
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before,
.nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: translateY(-6px) rotate(-45deg); }

/* No-JS: links wrap in a row under the brand. */
.primary-nav { width: 100%; padding-bottom: var(--space-3); }
.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-list a {
  display: block;
  padding: var(--space-2) 0;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}
.nav-list a:hover,
.nav-list a[aria-current] { color: var(--primary); }
.nav-list a[aria-current] { font-weight: 600; }

/* JS, below 1200px: dropdown panel under the header. */
@media (max-width: 1199.98px) {
  .js .primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: auto;
    padding: var(--space-2) var(--gutter) var(--space-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .js .primary-nav.is-open { display: block; }
  .js .nav-list { flex-direction: column; gap: 0; }
  .js .nav-list a {
    padding: var(--space-3) 0;
    font-size: var(--fs-base);
    border-bottom: 1px solid var(--border);
  }
  .js .nav-list li:last-child a { border-bottom: 0; }
}

/* ≥ 1200px: inline nav, menu button hidden. */
@media (min-width: 1200px) {
  .header-inner { flex-wrap: nowrap; }
  .primary-nav { order: 1; width: auto; padding: 0; margin-left: auto; }
  .header-actions { order: 2; }
  .nav-list { flex-wrap: nowrap; gap: var(--space-5); }
  .js .nav-toggle { display: none; }
}

/* Buttons */
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-5); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.tag {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--muted);
}

/* Cards */
.card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.card h3 { font-size: var(--fs-lg); margin-bottom: var(--space-2); }
.card p { color: var(--muted); }
.card p:last-child { margin-bottom: 0; }

.icon-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary);
}
.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.expertise-card { transition: border-color var(--transition), transform var(--transition); }
.expertise-card:hover { border-color: var(--primary); transform: translateY(-2px); }

/* Hero */
.hero {
  padding-block: var(--space-8);
  background:
    radial-gradient(circle at 85% 20%, var(--primary-soft), transparent 45%),
    var(--background);
}
.hero-grid { display: grid; gap: var(--space-7); align-items: center; }
.hero h1 { margin-bottom: var(--space-4); }
.text-accent { color: var(--primary); }
.hero-lead { max-width: 560px; margin-bottom: var(--space-6); font-size: var(--fs-lg); color: var(--muted); }
.hero-visual { display: none; }
@media (min-width: 992px) {
  .hero { padding-block: var(--space-9); }
  .hero-grid { grid-template-columns: 1.15fr 1fr; }
  .hero-visual { display: block; }
}
.hero-svg { width: 100%; filter: drop-shadow(var(--shadow-lg)); }
.hv-panel { fill: var(--surface); stroke: var(--border); }
.hv-bar-top { fill: var(--surface-alt); }
.hv-dot { fill: var(--border); }
.hv-card { fill: var(--background); stroke: var(--border); }
.hv-line { fill: var(--border); }
.hv-line-strong { fill: var(--muted); opacity: 0.5; }
.hv-accent { fill: var(--primary); }
.hv-accent-soft { fill: var(--primary); opacity: 0.45; }
.hv-ring { fill: none; stroke: var(--border); stroke-width: 10; }
.hv-ring-accent { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; }

/* About */
.about-grid { display: grid; gap: var(--space-6); align-items: start; }
.about-copy p { max-width: 640px; font-size: var(--fs-lg); }
@media (min-width: 992px) {
  .about-grid { grid-template-columns: 1.6fr 1fr; gap: var(--space-8); }
}
.about-card {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.avatar {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  margin-bottom: var(--space-5);
  overflow: hidden;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: var(--fs-xl);
  font-weight: 700;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.fact-list { display: grid; gap: var(--space-4); margin: 0; }
.fact-list dt {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.fact-list dd { margin: 0; font-weight: 500; }

/* Experience timeline */
.timeline {
  position: relative;
  display: grid;
  gap: var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--space-6);
}
.timeline::before {
  content: "";
  position: absolute;
  top: var(--space-2);
  bottom: var(--space-2);
  left: 7px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; }
.timeline-item::before {
  content: "";
  position: absolute;
  top: 1.6rem;
  left: calc(-1 * var(--space-6) + 1px);
  width: 14px;
  height: 14px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  background: var(--surface);
}
.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.timeline-date { font-weight: 600; color: var(--primary); }
.timeline-item ul { margin: var(--space-3) 0 0; padding-left: var(--space-5); color: var(--muted); }
.timeline-item li + li { margin-top: var(--space-1); }

/* Skills */
.skill-groups { display: grid; gap: var(--space-5); }
@media (min-width: 768px) {
  .skill-groups { grid-template-columns: repeat(2, 1fr); }
}
.skill-group h3 { margin-bottom: var(--space-4); }

/* Achievements */
.achievement-card { border-top: 4px solid var(--primary); }
.achievement-kicker {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Certifications */
.cert-card { display: flex; flex-direction: column; gap: var(--space-1); }
.cert-card h3 { margin-bottom: 0; }
.cert-meta { font-size: var(--fs-sm); color: var(--muted); }
.cert-link { margin-top: var(--space-3); font-size: var(--fs-sm); font-weight: 600; }

/* Contact: details beside the form from 992px; stacked above it below. */
.contact-grid { display: grid; gap: var(--space-6); align-items: start; }
.contact-list {
  display: grid;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 576px) {
  .contact-list { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .contact-grid { grid-template-columns: 1fr 1.6fr; }
  .contact-list { grid-template-columns: 1fr; }
}
.contact-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: 100%;
  color: var(--text);
  text-decoration: none;
}
a.contact-item { transition: border-color var(--transition); }
a.contact-item:hover { border-color: var(--primary); color: var(--text); }
.contact-item .icon-badge { margin-bottom: 0; }
.contact-label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.contact-value { display: block; font-weight: 600; overflow-wrap: anywhere; }

/* Contact form */
.contact-form { display: none; }
.js .contact-form { display: grid; gap: var(--space-4); }
.form-row { display: grid; gap: var(--space-4); }
@media (min-width: 576px) {
  .form-row { grid-template-columns: 1fr 1fr; }
}
.form-field { display: grid; gap: var(--space-2); }
.form-field label { font-size: var(--fs-sm); font-weight: 600; }
.optional { font-weight: 400; color: var(--muted); }
.form-field input,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-field textarea { resize: vertical; min-height: 140px; }
.form-field input:focus-visible,
.form-field textarea:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { margin: 0; font-size: var(--fs-sm); color: var(--danger); }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
}
.form-actions .btn:disabled { opacity: 0.6; cursor: progress; }
.form-status { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.form-status[data-state="success"] { color: var(--success); }
.form-status[data-state="error"] { color: var(--danger); }

/* Reveal on scroll. The class is only added by JS (and skipped under
   reduced motion), so nothing is ever hidden without JS. */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms ease, transform 500ms ease;
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-visible { opacity: 1; transform: none; }
@media print {
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* 404 page */
.not-found {
  display: grid;
  align-items: center;
  min-height: calc(100vh - var(--header-height));
  padding-block: var(--space-8);
}

/* Footer */
.site-footer {
  padding-block: var(--space-7) var(--space-5);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.footer-tagline { margin: var(--space-3) 0 0; }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--primary); }
.footer-legal { margin: 0; padding-top: var(--space-5); border-top: 1px solid var(--border); }

/* Projects: filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}
.filter-button {
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}
.filter-button:hover { border-color: var(--primary); color: var(--primary); }
.filter-button[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}
.filter-count { margin-left: var(--space-1); opacity: 0.75; }

/* Projects: cards */
.project-grid {
  display: grid;
  gap: var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 768px) {
  .project-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
  .project-grid { grid-template-columns: repeat(3, 1fr); }
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.project-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.project-cover {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.project-cover img,
.project-cover svg { width: 100%; height: 100%; object-fit: cover; }
.project-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
}
.project-content h3 { margin: 0; }
.project-subtitle { margin: calc(-1 * var(--space-2)) 0 0; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.project-content .tag-list { margin-top: auto; padding-top: var(--space-2); }
.project-open { align-self: flex-start; margin-top: var(--space-2); }

.project-badge {
  align-self: flex-start;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--primary-contrast);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .project-card.is-featured {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
  }
  .project-card.is-featured .project-cover {
    aspect-ratio: auto;
    min-height: 100%;
    border-bottom: 0;
    border-right: 1px solid var(--border);
  }
  .project-card.is-featured .project-content { padding: var(--space-6); }
  .project-card.is-featured h3 { font-size: var(--fs-2xl); }
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.chip {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary);
}
.chip + .chip::before { content: "·"; margin-right: var(--space-2); color: var(--muted); }

.project-empty {
  padding: var(--space-6);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Fallback illustration (used until real images exist) */
.fallback-art .fa-bg { fill: var(--surface-alt); }
.fallback-art .fa-grid { stroke: var(--border); stroke-width: 1; }
.fallback-art .fa-node { fill: var(--surface); stroke: var(--border); stroke-width: 2; }
.fallback-art .fa-link { stroke: var(--border); stroke-width: 2; stroke-dasharray: 4 4; fill: none; }
.fallback-art .fa-hub { fill: var(--primary-soft); stroke: var(--primary); stroke-width: 2; }
.fallback-art .fa-icon { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Case-study modal (native <dialog>) */
html.modal-open { overflow: hidden; }

.modal {
  width: min(880px, 100% - 2 * var(--space-4));
  max-height: min(90vh, 100% - 2 * var(--space-4));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.modal[open] { display: flex; }
.modal::backdrop { background: rgb(2 6 23 / 0.65); }
@media (max-width: 575.98px) {
  .modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border: 0;
    border-radius: 0;
  }
}

.modal-inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: var(--space-2) 0 var(--space-1); }
.modal-subtitle { margin: 0; color: var(--muted); }
.modal-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
}
.modal-close:hover { border-color: var(--primary); color: var(--primary); }
.modal-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5);
}
@media (min-width: 768px) {
  .modal-header, .modal-body { padding: var(--space-6); }
}
.modal-summary { font-size: var(--fs-lg); }
.modal-section { margin-top: var(--space-6); }
.modal-section h3 {
  margin-bottom: var(--space-3);
  font-size: var(--fs-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
}
.modal-section p, .modal-section ul { margin: 0; }
.modal-section ul:not(.tag-list) { padding-left: var(--space-5); }
.modal-section li + li { margin-top: var(--space-1); }

.gallery-main {
  margin: 0 0 var(--space-5);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
}
.gallery-main img,
.gallery-main svg { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; }
.gallery-main figcaption {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.gallery-thumbs {
  display: flex;
  gap: var(--space-2);
  margin: calc(-1 * var(--space-3)) 0 var(--space-5);
  overflow-x: auto;
  list-style: none;
  padding: 0;
}
.gallery-thumb {
  flex: none;
  width: 96px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.gallery-thumb img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery-thumb[aria-current="true"] { border-color: var(--primary); }

/* ---------- 5. Utilities ------------------------------------------------- */

.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;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); color: var(--primary-contrast); }

.muted { color: var(--muted); }
[hidden] { display: none !important; }
