/* ============================================================================
   Nottaker — base.css   ("Slate & Ember" v2)
   ----------------------------------------------------------------------------
   Element resets + base typography wired to the type-scale tokens. References
   ONLY var(--token) from tokens.css (loaded first). NO raw hex; NO off-scale px
   for spacing/radius. See DESIGN.md §16.1 / §16.6 / §16.10.

   Load order: tokens.css -> base.css -> components.css -> editor.css
   ============================================================================ */

/* ============================================================================
   FONTS  (§16.1 — self-hosted woff2; graceful fallback)
   ----------------------------------------------------------------------------
   @font-face references local files under assets/fonts/. If a woff2 file is
   ABSENT the browser silently falls through to the system stack defined in the
   font-family tokens (--font-sans / --font-serif / --font-mono) — the app
   degrades gracefully (see README "Self-host fonts"). NEVER a Google Fonts CDN.

   font-display: swap keeps text visible during font load (no FOIT).
   Filenames are conventional; drop the matching woff2 files in to activate.
   ============================================================================ */
/* Geist Sans / Mono ship as VARIABLE woff2 (one file spans the weight axis);
   only the weights named in the type scale (400/500/600 sans, 400/500 mono) are
   used — see DESIGN.md §16.1 weight discipline. */
@font-face {
  font-family: "Geist Sans";
  src: url("../fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Sans";
  src: url("../fonts/Geist-Italic-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Instrument Serif — a high-contrast EDITORIAL display serif (replaces Fraunces,
   §16.1). It ships a SINGLE weight (400), regular + italic, and is NOT variable
   (no opsz axis). Its contrast/character is intrinsic at 400, so serif headings
   render at weight 400 with font-synthesis:none (set on body) to prevent any
   faux-bold — heavier weight tokens collapse to the 400 face cleanly. */
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/InstrumentSerif-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("../fonts/InstrumentSerif-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ============================================================================
   RESET  (modern, minimal)
   ============================================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Prevent iOS tap-highlight tinting (not a design token; behavioral reset). */
  -webkit-tap-highlight-color: transparent;
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd,
ul, ol, fieldset, legend {
  margin: 0;
  padding: 0;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

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

/* ============================================================================
   ROOT / BODY  (§16.1 / §16.2 — Geist Sans body on warm dark slate)
   ============================================================================ */
html {
  font-size: 100%; /* base 16px = 1rem (type scale anchor) */
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--text-base-lh);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-body);
  /* Single-weight serif (Instrument Serif): never synthesize bold/italic — heavy
     serif weight tokens render as the real 400 face instead of a faux-bold. Geist
     sans/mono have real weights + a real italic, so this never harms them. */
  font-synthesis: none;
  /* Crisper type on the dark surface; not a token (rendering hint). */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-variant-numeric: normal;
}

/* ============================================================================
   HEADINGS  (§16.1 — Instrument Serif: single-weight 400 editorial display serif)
   Sizes map to the fixed type scale. Instrument Serif has one weight; its high
   stroke contrast (not weight) carries the display drama, and font-synthesis:none
   (body) keeps the heavier weight tokens below rendering as the real 400 face.
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
  line-height: var(--text-2xl-lh);
  letter-spacing: var(--tracking-display);
}

h1 {
  font-size: var(--text-3xl);
  line-height: var(--text-3xl-lh);
  font-weight: var(--weight-bold); /* display-only 700 (§16.1) */
}
h2 {
  font-size: var(--text-2xl);
  line-height: var(--text-2xl-lh);
}
h3 {
  font-size: var(--text-xl);
  line-height: var(--text-xl-lh);
}
h4 {
  font-size: var(--text-lg);
  line-height: var(--text-lg-lh);
  font-weight: var(--weight-medium);
}
h5,
h6 {
  font-size: var(--text-base);
  line-height: var(--text-base-lh);
  font-weight: var(--weight-medium);
}

/* ============================================================================
   PROSE  (§16.1 — body & transcription max ~70ch; never full-width)
   ============================================================================ */
p {
  max-width: var(--prose-max);
}
p + p {
  margin-top: var(--space-4);
}

/* ============================================================================
   LINKS  (accent is spot-ink; underline on hover/focus for affordance)
   ============================================================================ */
a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 0.15em;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ============================================================================
   LISTS  (default content lists; reset lists opt in via role="list")
   ============================================================================ */
ul,
ol {
  padding-left: var(--space-5);
}
li + li {
  margin-top: var(--space-1);
}

/* ============================================================================
   CODE / MONO  (§16.1 — Geist Mono as the data/technical voice)
   ============================================================================ */
code,
kbd,
samp,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em; /* one inline-mono down-scale, shared with .md-rendered code / .tag-link */
}
pre {
  background-color: var(--surface-1);
  border: var(--rule-hairline) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  line-height: var(--text-sm-lh);
}
pre code {
  font-size: var(--text-sm);
}
:not(pre) > code {
  background-color: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
}

/* ============================================================================
   TABLES  (base; the library data-table is styled in components.css)
   ============================================================================ */
table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums; /* §16.1a — data context */
}
th,
td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
}

/* ============================================================================
   FORM ELEMENTS  (inherit type; full styling in components.css)
   ============================================================================ */
input,
button,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: none;
}
textarea {
  resize: vertical;
}
::placeholder {
  color: var(--text-muted);
  opacity: 1; /* Firefox dims placeholders by default; keep token contrast */
}

/* Numerals in data contexts use tabular figures (§16.1a). Apply to mono,
   timestamps, metadata, table cells, figure refs. Helper class .tabular is
   defined in components.css; mono inherently tabular-aligns via this rule. */
.font-mono,
time,
.tabular {
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
   FOCUS  (§16.6 — accessibility-critical; visible on EVERY interactive el)
   Never remove an outline without an equivalent visible replacement.
   :focus-visible keeps the ring for keyboard users without flashing on click.
   ============================================================================ */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
  border-radius: var(--radius-sm);
}
/* Fallback for engines without :focus-visible — still show a ring on focus. */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus,
[tabindex]:focus {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}
a:focus:not(:focus-visible),
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible),
[tabindex]:focus:not(:focus-visible) {
  outline: none;
}

/* ============================================================================
   SELECTION  (warm, low-chroma accent tint — not the loud accent)
   ============================================================================ */
::selection {
  background-color: var(--accent-subtle);
  color: var(--text-primary);
}

/* ============================================================================
   ACCESSIBILITY UTILITIES
   ============================================================================ */
/* Visually hidden but available to screen readers. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link — visible on focus; first tab stop. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-2);
  transform: translateY(-200%);
  background-color: var(--surface-3);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: var(--rule-hairline) solid var(--border-strong);
  z-index: 100;
  transition: transform var(--transition-fast);
}
.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

/* ============================================================================
   REDUCED MOTION  (§16.9 / §16.10)
   tokens.css already zeroes the --transition-* vars under this query; this
   blanket rule also neutralizes any direct animation/transition declarations.
   ============================================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
