/* ============================================================================
   Base Styles - Font Faces, Reset, Typography, Layout Utilities
   ============================================================================ */

/* ========================================================================
 * @FONT-FACE DECLARATIONS
 * Self-hosted WOFF2. JetBrains Mono carries display + data duty,
 * Source Sans 3 carries body prose.
 * ======================================================================== */

/* JetBrains Mono - Display / Labels / Data */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/jetbrains-mono/jetbrains-mono-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/jetbrains-mono/jetbrains-mono-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Source Sans 3 - Body text */
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/source-sans-3/source-sans-3-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Source Sans 3';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/source-sans-3/source-sans-3-latin-400-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/source-sans-3/source-sans-3-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/source-sans-3/source-sans-3-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ========================================================================
 * CSS RESET
 * ======================================================================== */

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

html {
  /* "only light" opts out of Chrome force-dark; surfaces are authored in CSS */
  color-scheme: only light;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  line-height: var(--leading-normal);
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  width: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

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

ul,
ol {
  list-style: none;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

/* ========================================================================
 * TYPOGRAPHY SYSTEM
 * Headlines set in mono at weight 500: the system's signature.
 * ======================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-medium);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text-heading);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

p {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

code {
  font-size: 0.9em;
  padding: 0.125em 0.375em;
  background-color: var(--bg-inset);
  border: 1px solid var(--line);
  color: var(--accent);
}

pre {
  padding: var(--space-4);
  background-color: var(--bg-inset);
  border: 1px solid var(--line);
  overflow-x: auto;
  color: var(--text);
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: inherit;
}

/* ========================================================================
 * LAYOUT UTILITIES
 * ======================================================================== */

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

.container--narrow {
  max-width: var(--container-narrow);
}

.container--wide {
  max-width: var(--container-wide);
}

.section {
  padding: var(--section-padding-y) 0;
  position: relative;
  scroll-margin-top: 64px;
  border-top: 1px solid var(--line);
}

/* Section color variants */
.section--dark {
  background-color: var(--bg);
  color: var(--text);
}

.section--dark p {
  color: var(--text-muted);
}

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

.section--dark-alt p {
  color: var(--text-muted);
}

.section--light {
  /* "only light" blocks Chrome force-dark from inverting the paper surface */
  color-scheme: only light;
  background-color: var(--paper);
  color: var(--ink);
  border-top-color: var(--line-ink);
}

.section--light h1,
.section--light h2,
.section--light h3,
.section--light h4,
.section--light h5,
.section--light h6 {
  color: var(--ink);
}

.section--light p {
  color: var(--ink-secondary);
}

/* ========================================================================
 * SECTION LEDGER - numbered index row under each section rule.
 * Crosshair marks sit on the rule at container edges.
 * ======================================================================== */

.ledger {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-10);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--font-medium);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-faint);
}

.ledger::before,
.ledger::after {
  content: '+';
  position: absolute;
  top: calc(-1 * var(--section-padding-y) - 0.52em);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: var(--font-normal);
  letter-spacing: 0;
  line-height: 1;
  color: var(--text-faint);
}

.ledger::before { left: -0.32em; }
.ledger::after { right: -0.32em; }

.section--light .ledger::before,
.section--light .ledger::after {
  color: var(--ink-muted);
}

.ledger__index {
  color: var(--accent);
}

.section--light .ledger__index {
  color: var(--ink);
}

.ledger__note {
  text-align: right;
  letter-spacing: var(--tracking-wider);
}

/* ========================================================================
 * ACCESSIBILITY
 * ======================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-tooltip);
  padding: var(--space-3) var(--space-6);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  color: var(--text-heading);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus {
  top: var(--space-4);
}

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

/* ========================================================================
 * SELECTION
 * ======================================================================== */

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