:root {
  color-scheme: light dark;
  --bg: #f7f6f3;
  --bg-elevated: #ffffff;
  --header-bg: #f7f6f3f2;
  --text: #1c1917;
  --muted: #57534e;
  --accent: #1d4ed8;
  --accent-bg: #1d4ed8;
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --accent-soft: #eff6ff;
  --badge-border: #dbeafe;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --max: 960px;
}

/* An explicit light choice must also pin the UA colour scheme, or scrollbars and
   form controls stay dark on a dark system. */
:root[data-theme="light"] {
  color-scheme: light;
}

/* Dark palette. It applies when the visitor's system asks for it — unless they
   picked light with the header toggle — and whenever they pick dark outright.
   The two blocks are identical on purpose; keep them in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1c1917;
    --bg-elevated: #262220;
    --header-bg: #1c1917f2;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --accent: #93c5fd;
    --accent-bg: #2563eb;
    --accent-hover: #1d4ed8;
    --on-accent: #ffffff;
    --accent-soft: #1e293b;
    --badge-border: #334155;
    --border: #3a3532;
    --border-strong: #57534e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1917;
  --bg-elevated: #262220;
  --header-bg: #1c1917f2;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --accent: #93c5fd;
  --accent-bg: #2563eb;
  --accent-hover: #1d4ed8;
  --on-accent: #ffffff;
  --accent-soft: #1e293b;
  --badge-border: #334155;
  --border: #3a3532;
  --border-strong: #57534e;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 6px 10px;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  flex: 1;
  justify-content: center;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.88rem;
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--text);
}

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

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elevated);
  color: var(--muted);
  cursor: pointer;
}

.theme-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* No display here: it would outrank the .icon-* rules below and show both icons. */
.theme-btn svg {
  width: 16px;
  height: 16px;
}

/* The icon shows the theme the button switches to, following the same three
   cases as the palette above. */
.icon-sun {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }

  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="light"] .icon-moon {
  display: block;
}

:root[data-theme="light"] .icon-sun {
  display: none;
}

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-elevated);
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  cursor: pointer;
}

.lang-btn[aria-pressed="true"] {
  background: var(--text);
  color: var(--bg);
}

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.hero {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 32px;
  align-items: start;
  padding: 40px 0 28px;
}

.hero-photo {
  width: 140px;
  height: 140px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
  overflow: hidden;
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0 0 14px;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  font-size: 1.02rem;
  margin: 0 0 24px;
  max-width: 640px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-bg);
  color: var(--on-accent);
}

.btn-primary:hover {
  text-decoration: none;
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover,
.btn-small:hover {
  text-decoration: none;
  border-color: var(--border-strong);
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.section h2 {
  margin: 0 0 22px;
  font-size: 1.28rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.metric-card,
.card,
.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.metric-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.metric-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.cards {
  display: grid;
  gap: 14px;
}

.card h3,
.project-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.card-meta {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0 0 10px;
}

.card p,
.project-card p {
  margin: 0;
}

.card ul,
.about-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.card li + li,
.about-list li + li {
  margin-top: 6px;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--badge-border);
}

.tech-tags {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 10px 0 0 !important;
}

.project-links {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.skill-grid > div {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.skill-grid h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.skill-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.about-list {
  margin-top: 16px;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--border);
}

.timeline li {
  position: relative;
  padding: 0 0 28px 22px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.tl-date {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.timeline h3 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.timeline p {
  margin: 0;
  color: var(--muted);
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.contact-list li + li {
  margin-top: 8px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .nav {
    flex-wrap: wrap;
  }

  .nav-links {
    order: 3;
    justify-content: flex-start;
    width: 100%;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 24px;
  }

  .hero-photo {
    width: 96px;
    height: 96px;
  }
}

/* Projects: one column on a phone, two once there is room. */
.section-lead {
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 62ch;
}

.project-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 760px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}

.project-card .project-links { margin-top: auto; padding-top: 4px; }

/* Standalone 404 page. */
.notfound {
  max-width: 520px;
  margin: 0 auto;
  padding: 96px 20px;
  text-align: center;
}

.notfound h1 {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  margin: 0 0 12px;
}

.notfound .lead {
  margin-left: auto;
  margin-right: auto;
}

/* Print / save-as-PDF: drop the chrome and keep the cards off page breaks. */
@media print {
  :root {
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --text: #000000;
    --muted: #333333;
    --accent: #000000;
    --border: #cccccc;
  }

  .site-header,
  .nav-controls,
  .hero-actions,
  .project-links,
  .site-footer {
    display: none;
  }

  body {
    line-height: 1.45;
    font-size: 10.5pt;
  }

  main {
    max-width: none;
    padding: 0;
  }

  .section {
    padding: 14px 0;
  }

  .hero {
    padding: 0 0 14px;
  }

  .metric-card,
  .card,
  .project-card,
  .skill-grid > div,
  .timeline li {
    break-inside: avoid;
  }

  a {
    color: #000000;
    text-decoration: none;
  }
}
