/* =====================================================================
   main.css — reset, tokens, themes, type systems, layout shell
   ===================================================================== */

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

body, h1, h2, h3, h4, p, figure, dl, dd, ol, ul { margin: 0; }

ol, ul { list-style: none; padding: 0; }

img, svg { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  /* White page, warm neutrals over it */
  --bg:          #ffffff;
  --surface:     #e8e6e0;
  --surface-2:   #dcd9d1;
  --fg:          #14140f;
  --fg-muted:    #6c6960;
  --fg-faint:    #94918a;
  --line:        #dedbd4;
  --line-strong: #c9c5bc;
  --rule:        #1c1c17;

  --ink-bg:      #14140f;   /* inverted surfaces: buttons */
  --ink-fg:      #f6f5f1;
  --ink-faint:   #86847c;

  --focus:       #14140f;

  /* Type */
  --font-display: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body:    "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display-weight: 700;
  --display-tracking: -0.033em;
  --display-leading: 0.98;
  --display-scale: 1;
  --weight-strong: 600;   /* headings, stat figures */
  --weight-mid: 500;      /* the intro statement */

  /* Scale */
  --fs-display:   clamp(2.75rem, 6.6vw, 5.25rem);
  --fs-statement: clamp(1.375rem, 2.15vw, 1.9rem);
  --fs-stat:      clamp(1.75rem, 2.6vw, 2.25rem);
  --fs-title:     clamp(1.125rem, 1.55vw, 1.375rem);
  --fs-head:      0.9375rem;
  --fs-body:      0.875rem;
  --fs-small:     0.8125rem;
  --fs-label:     0.6875rem;

  /* Space */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  2rem;
  --space-lg:  clamp(3rem, 6vw, 5rem);
  --space-xl:  clamp(4rem, 9vw, 7.5rem);

  --container: 1120px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --radius: 3px;
}

/* ---------- Dark theme ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:          #131311;
    --surface:     #201f1c;
    --surface-2:   #2b2a26;
    --fg:          #f3f2ed;
    --fg-muted:    #9c9a92;
    --fg-faint:    #77746d;
    --line:        #2c2b27;
    --line-strong: #3b3a35;
    --rule:        #4a4842;
    --ink-bg:      #f3f2ed;
    --ink-fg:      #131311;
    --ink-faint:   #77746d;
    --focus:       #f3f2ed;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:          #131311;
  --surface:     #201f1c;
  --surface-2:   #2b2a26;
  --fg:          #f3f2ed;
  --fg-muted:    #9c9a92;
  --fg-faint:    #77746d;
  --line:        #2c2b27;
  --line-strong: #3b3a35;
  --rule:        #4a4842;
  --ink-bg:      #f3f2ed;
  --ink-fg:      #131311;
  --ink-faint:   #77746d;
  --focus:       #f3f2ed;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--fg); color: var(--bg); }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Utilities ---------- */
.label {
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink-bg);
  color: var(--ink-fg);
  font-size: var(--fs-small);
  border-radius: var(--radius);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; }

/* ---------- Header ---------- */
.site-header__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding: 1.15rem var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--font-display);
  font-size: var(--fs-head);
  font-weight: var(--weight-strong);
  letter-spacing: -0.015em;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(1.25rem, 3vw, 2.5rem);
}

.nav__list {
  display: flex;
  gap: clamp(1rem, 2.2vw, 1.75rem);
  font-size: var(--fs-body);
}

.nav__list a {
  color: var(--fg-muted);
  padding-block: 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav__list a:hover { color: var(--fg); }

.nav__list a[aria-current="page"] {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.nav__actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  font-size: var(--fs-small);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  transition: border-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--fg-muted); }

.theme-toggle__swatch {
  width: 9px;
  height: 9px;
  background: var(--fg);
}

/* ---------- Nav toggle (mobile) ---------- */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 0.5rem;
  margin-right: -0.5rem;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--fg);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(3.25px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child  { transform: translateY(-3.25px) rotate(-45deg); }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: var(--space-xl);
  padding-bottom: var(--space-xl);
}

.site-footer__inner {
  padding-top: var(--space-md);
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.footer-col__title {
  font-family: var(--font-display);
  font-size: var(--fs-body);
  font-weight: var(--weight-strong);
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.footer-col p {
  color: var(--fg-muted);
  font-size: var(--fs-small);
  max-width: 30ch;
}

.footer-col .btn { margin-top: 0.9rem; }

/* ---------- Generic page header (about/work/contact) ---------- */
.page-header {
  padding-block: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-md);
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1.05;
}

/* When the section below brings its own rule, the header does not need one. */
.page-header--flush {
  border-bottom: 0;
  margin-bottom: 0;
}

.content { padding-block: var(--space-sm) var(--space-lg); }
.content p { color: var(--fg-muted); max-width: 62ch; }

/* ---------- Responsive shell ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: flex; }

  .site-header__inner { position: relative; flex-wrap: wrap; }

  .nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    padding-block: var(--space-sm) 0.25rem;
  }

  .nav.is-open { display: flex; }

  .nav__list { flex-direction: column; gap: 0.6rem; font-size: 1rem; }

  .nav__actions { width: 100%; }

  .site-footer__inner { grid-template-columns: 1fr; gap: var(--space-md); }
  .footer-col p { max-width: 46ch; }
}

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