/* ==========================================================================
   Base: reset, element defaults, layout primitives, accessibility helpers.
   Requires tokens.css.
   ========================================================================== */

/* Self-hosted variable fonts (SIL Open Font License), Latin subset. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/fraunces-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/fraunces-latin-wght-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Faint film grain: keeps flat cream and flat ink from looking printed-on. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection {
  background: var(--gold-400);
  color: var(--gold-ink);
}

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

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--space-4);
  color: var(--color-heading);
  font-family: var(--font-heading);
  font-weight: 540;
  line-height: var(--leading-tight);
  letter-spacing: -0.022em;
  text-wrap: balance;
}

/* The accent word: Fraunces italic in the heart red (gold on dark bands). */
h1 em,
h2 em {
  color: var(--color-accent-word, var(--color-brand));
  font-style: italic;
  font-weight: 460;
}

h1 {
  font-size: var(--text-3xl);
  letter-spacing: -0.03em;
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}

h4 {
  font-size: var(--text-lg);
  line-height: var(--leading-snug);
}

p,
ul,
ol,
dl,
blockquote,
figure {
  margin: 0 0 var(--space-4);
}

p,
li {
  max-width: var(--measure);
  text-wrap: pretty;
}

ul,
ol {
  padding-left: 1.25em;
}

a {
  color: var(--color-link);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
  transition: color var(--duration-fast) var(--ease);
}

a:hover {
  color: var(--color-link-hover);
}

strong {
  color: var(--color-heading);
  font-weight: 700;
}

address {
  font-style: normal;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

/* One focus style everywhere. Never removed. */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

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

.container {
  width: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

.container--narrow {
  --container: 48rem;
}

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

.section--alt {
  background: var(--color-bg-alt);
}

.section--surface {
  background: var(--color-surface);
}

/* Ink band (DFS dark). Text, links and focus ring flip to light. */
.section--brand {
  --color-text: var(--on-ink);
  --color-heading: var(--on-ink);
  --color-muted: var(--on-ink-muted);
  --color-link: var(--gold-400);
  --color-link-hover: var(--gold-200);
  --color-focus: var(--gold-400);
  --color-border: var(--line-on-ink);
  --color-accent-word: var(--gold-400);
  background:
    radial-gradient(120% 80% at 50% -10%, #142017 0%, transparent 55%),
    var(--ink-950);
  color: var(--color-text);
}

/* Red band (NHM heart). One per page: the closing ask. */
.section--red {
  --color-text: var(--sand-100);
  --color-heading: var(--white);
  --color-muted: var(--red-100);
  --color-link: var(--white);
  --color-link-hover: var(--gold-200);
  --color-focus: var(--white);
  --color-accent-word: var(--gold-200);
  background:
    radial-gradient(90% 120% at 50% 120%, var(--red-600) 0%, transparent 60%),
    var(--red-700);
  color: var(--color-text);
}

.section__head {
  max-width: 44rem;
  margin-bottom: var(--space-7);
}

.section__head--center {
  margin-inline: auto;
  text-align: center;
}

.section__head--center p {
  margin-inline: auto;
}

.grid {
  display: grid;
  gap: var(--space-5);
}

@media (min-width: 48rem) {
  .grid--2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid--3 {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 64rem) {
  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stack > * + * {
  margin-top: var(--space-4);
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-4);
}

/* ---- Text helpers ---- */

/* Mono, uppercase, tracked: the DFS label. Sections number themselves. */
main {
  counter-reset: chapter;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  color: var(--color-muted);
  font-family: var(--font-mono);
  font-size: var(--text-label);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section .eyebrow::before {
  content: counter(chapter, decimal-leading-zero);
  content: counter(chapter, decimal-leading-zero) / "";
  counter-increment: chapter;
  color: var(--color-accent-word, var(--color-brand));
}

.section__head--center .eyebrow,
.cta-band .eyebrow {
  justify-content: center;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lead {
  font-size: var(--text-lg);
  line-height: 1.55;
}

.muted {
  color: var(--color-muted);
}

.small {
  font-size: var(--text-sm);
}

/* ---- Accessibility helpers ---- */

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  background: var(--ink-900);
  color: var(--white);
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus {
  color: var(--white);
  transform: none;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-timeline: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Scroll reveal, CSS only. Content is fully visible wherever this is not
   supported, with JavaScript off, and for visitors who ask for less motion. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .section > .container > *,
    .section > .container > .grid > *,
    .section > .container > .steps > * {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 45%;
    }
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(1.25rem);
  }
}
