/* Reset, layout primitives, nav, theme toggle, footer. */

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

* { margin: 0; }

html {
  scroll-behavior: smooth;
  /* Sticky header must not cover the section you just jumped to. */
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  /* The one place we guard the whole page against sideways scroll. */
  overflow-x: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  text-wrap: balance;
}

p { text-wrap: pretty; }

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

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

/* ---------- Layout primitives ---------- */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.15rem, 4vw, 2rem);
}

.section { padding-block: var(--section-y); }
.section--alt { background: var(--bg-alt); }

.section__label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.section__title { font-size: var(--step-3); margin-bottom: 0.85rem; }

.section__intro {
  color: var(--text-muted);
  max-width: 58ch;
  margin-bottom: clamp(2rem, 5vw, 3.25rem);
}

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.skip-link {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% -150%;
  z-index: 200;
  padding: 0.7rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus-visible { translate: -50% 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  /* 44px min touch target. */
  min-height: 44px;
  padding: 0.7rem 1.4rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--grad);
  color: var(--accent-contrast);
  box-shadow: var(--glow);
}
.btn--primary:hover { box-shadow: var(--shadow-lift), var(--glow); }

.btn--ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--ghost:hover { border-color: var(--accent-1); }

/* ---------- Header / nav ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 90;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand__mark {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav { display: flex; align-items: center; gap: 0.35rem; }

.nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--dur) var(--ease);
}
.nav__link:hover { color: var(--text); }

/* Scroll-spy state, set by nav.js */
.nav__link[aria-current="true"] { color: var(--text); }
.nav__link[aria-current="true"]::after {
  content: "";
  position: absolute;
  left: 0.85rem;
  right: 0.85rem;
  bottom: 0.6rem;
  height: 2px;
  border-radius: 2px;
  background: var(--grad);
}

.header__actions { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.icon-btn:hover { border-color: var(--accent-1); }
.icon-btn svg { width: 20px; height: 20px; }

/* Theme toggle shows exactly one glyph per theme. */
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.nav-toggle { display: none; }

@media (max-width: 640px) {
  .nav-toggle { display: inline-grid; }

  .nav {
    position: fixed;
    inset: 4.25rem 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem clamp(1.15rem, 4vw, 2rem) 1.25rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    /* Hidden by default on mobile; nav.js flips [data-open]. */
    display: none;
  }
  .nav[data-open="true"] { display: flex; }

  .nav__link {
    padding: 0.25rem 0.5rem;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--border);
  }
  .nav__link[aria-current="true"]::after { display: none; }
  .nav__link[aria-current="true"] { color: var(--accent-2); }
}

/* ---------- Footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding-block: 3rem 2.25rem;
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.footer__meta { color: var(--text-muted); font-size: var(--step--1); }
.footer__meta a {
  color: var(--text);
  text-decoration-color: var(--border-strong);
  text-underline-offset: 3px;
}
.footer__meta a:hover { color: var(--accent-2); }

.footer__license {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.footer__links { display: flex; align-items: center; gap: 0.5rem; }

@media (max-width: 640px) {
  .footer__inner { flex-direction: column; align-items: flex-start; }
}
