/* ── Design tokens ──────────────────────────────────────────────────────────
   The palette is written twice on purpose: light-dark() would be shorter but
   an unsupported browser would drop every colour instead of degrading. */

:root {
  --bg:      #ffffff;
  --surface: #f6f8fa;
  --border:  #d1d9e0;
  --text:    #1f2328;
  --muted:   #59636e;
  --accent:  #0f7b5f;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --maxw:   960px;
  --radius: 10px;
  --sp:     0.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:      #0b0f14;
    --surface: #121821;
    --border:  #1f2a37;
    --text:    #e6edf3;
    --muted:   #8b98a5;
    --accent:  #4dd4ac;
  }
}

html[data-theme="light"] {
  --bg:      #ffffff;
  --surface: #f6f8fa;
  --border:  #d1d9e0;
  --text:    #1f2328;
  --muted:   #59636e;
  --accent:  #0f7b5f;
}

html[data-theme="dark"] {
  --bg:      #0b0f14;
  --surface: #121821;
  --border:  #1f2a37;
  --text:    #e6edf3;
  --muted:   #8b98a5;
  --accent:  #4dd4ac;
}

/* ── Base ─────────────────────────────────────────────────────────────────── */

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

html { -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;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
h1, h2, h3 { line-height: 1.25; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); }
h3 { font-size: 1.0625rem; }
ul { padding-left: 1.1rem; }

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

img { max-width: 100%; height: auto; }

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

/* ── Layout ───────────────────────────────────────────────────────────────── */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: calc(var(--sp) * 5);
}

main > section { padding-block: calc(var(--sp) * 14); }
main > section + section { border-top: 1px solid var(--border); }

/* ── Skip link ────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10;
  padding: calc(var(--sp) * 2) calc(var(--sp) * 3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.skip-link:focus { left: calc(var(--sp) * 3); top: calc(var(--sp) * 3); }

/* ── Header ───────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--border);
}

@supports (backdrop-filter: blur(8px)) {
  .site-header { backdrop-filter: blur(8px); }
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--sp) * 3);
  padding-block: calc(var(--sp) * 3);
}

.site-header__brand {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--sp) * 4);
  font-size: 0.9375rem;
}

.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover, .site-nav a:focus-visible { color: var(--text); }

.site-header__controls { display: flex; gap: calc(var(--sp) * 2); }

.btn-toggle {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(var(--sp) * 1.5) calc(var(--sp) * 3);
  cursor: pointer;
}
.btn-toggle:hover { border-color: var(--accent); }

/* ── Footer ───────────────────────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding-block: calc(var(--sp) * 8);
  font-size: 0.875rem;
  color: var(--muted);
}

.site-footer__inner { display: grid; gap: calc(var(--sp) * 3); }
.site-footer__links { display: flex; gap: calc(var(--sp) * 3); }
.site-footer__meta { display: flex; flex-wrap: wrap; gap: calc(var(--sp) * 2) calc(var(--sp) * 4); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.hero {
  display: grid;
  gap: calc(var(--sp) * 6);
  padding-block: calc(var(--sp) * 16);
}

.hero__avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  overflow: hidden;
}

/* The avatar is painted as a background layer rather than an <img>, so a
   missing file draws nothing at all — no broken-image icon — and the monogram
   underneath simply stays visible. No JavaScript involved.
   avatar.png ships as a 1x1 fully transparent placeholder so this URL always
   resolves: an unresolved url() here logs a 404 in the browser console on the
   front page, and nginx would cache that 404. Replace the file, keep the name. */
.hero__avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/assets/img/avatar.png") center / cover no-repeat;
}

.hero__monogram {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent);
}

.hero__body { display: grid; gap: calc(var(--sp) * 4); justify-items: start; }

.hero__tagline { max-width: 46ch; color: var(--muted); font-size: 1.125rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: calc(var(--sp) * 3); }

.cta {
  display: inline-block;
  padding: calc(var(--sp) * 2) calc(var(--sp) * 5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
}

.cta:hover { border-color: var(--accent); color: var(--accent); }

/* ── Highlights (skills, projects) ────────────────────────────────────────── */

.skills-grid,
.project-grid { display: grid; gap: calc(var(--sp) * 4); }

.skill-card,
.project-card {
  display: grid;
  gap: calc(var(--sp) * 2);
  padding: calc(var(--sp) * 5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.skill-card p,
.project-card p { color: var(--muted); font-size: 0.9375rem; }

.project-card__tech {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--sp) * 2);
  padding: 0;
  list-style: none;
}

.project-card__tech li {
  padding-inline: calc(var(--sp) * 2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.project-card__link { font-size: 0.875rem; font-weight: 600; }
.project-card__link--private { color: var(--muted); font-weight: 400; }

/* ── Contact ──────────────────────────────────────────────────────────────── */

.contact-list { display: grid; gap: calc(var(--sp) * 4); font-size: 0.9375rem; }

.contact-list dt {
  margin-bottom: calc(var(--sp) * 1);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.contact-list dd { margin: 0; }

/* ── Sub-pages ────────────────────────────────────────────────────────────── */

.page { padding-block: calc(var(--sp) * 12); }
.page__back { margin-bottom: calc(var(--sp) * 5); font-size: 0.875rem; }
.page__back a { color: var(--muted); }
.page__list { display: grid; gap: calc(var(--sp) * 3); color: var(--muted); }

/* ── Rhythm inside sections ───────────────────────────────────────────────── */

main > section > h1 + p,
main > section > h2 + p,
main > section > h2 + div,
main > section > p + p,
main > section > p + div,
main > section > p + ul,
main > section > p + dl,
main > section > p + h2 { margin-top: calc(var(--sp) * 5); }

main > section > ul + p { margin-top: calc(var(--sp) * 8); }

/* ── Wider screens ────────────────────────────────────────────────────────── */

@media (min-width: 640px) {
  .hero { grid-template-columns: auto 1fr; align-items: start; padding-block: calc(var(--sp) * 20); }
  .skills-grid, .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-list { grid-template-columns: max-content 1fr; gap: calc(var(--sp) * 3) calc(var(--sp) * 5); align-items: baseline; }
  .contact-list dt { margin-bottom: 0; font-size: 0.9375rem; letter-spacing: 0; text-transform: none; }
}

@media (min-width: 960px) {
  .skills-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ── Motion ───────────────────────────────────────────────────────────────── */

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