/* ══════════════════════════════════════════════════════════════════════════
   base.css — reset, typography, focus, utilities. Shared by every surface.
   ══════════════════════════════════════════════════════════════════════════ */

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

* { margin: 0; }

/* The UA rule for [hidden] is display:none at the lowest specificity, so any
   class that sets display — .btn is inline-flex — silently defeats it. This
   is a real bug source, not a nicety. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Anchor links must not slide under the sticky top bar. */
  scroll-padding-top: calc(var(--topbar-h) + var(--s-4));
}

body {
  font-family: var(--font-ui);
  font-size: var(--t-14);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  /* Every figure in this product is a quantity that lines up in a column. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1, 'cv05' 1;
}

/* Light type on dark reads as lighter weight and needs more air. */
[data-theme='dark'] body { line-height: 1.6; }

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

/* Generated icons default to text size. Containers that size their own
   icons (.btn svg, .badge svg, .callout svg …) are more specific and win. */
.ico { width: 1em; height: 1em; flex: none; }

input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

/* ────────────────────────────────────────────────────── TYPOGRAPHY ── */

h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.2; letter-spacing: -0.011em; }
h1 { font-size: var(--t-26); }
h2 { font-size: var(--t-21); }
h3 { font-size: var(--t-18); }
h4 { font-size: var(--t-16); }
h5, h6 { font-size: var(--t-14); }

/* Even line lengths on headings; fewer orphans in prose. */
h1, h2, h3 { text-wrap: balance; }
p, li { text-wrap: pretty; }

a { color: var(--olive); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }

strong, b { font-weight: 600; }
small { font-size: var(--t-12); }

code, kbd, samp, pre, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code { font-size: 0.92em; }

kbd {
  font-size: var(--t-11);
  padding: 0.1em 0.38em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: var(--r-2);
  background: var(--surface);
  color: var(--ink-2);
}

hr { border: 0; border-top: 1px solid var(--line); }

/* Prose stays inside a readable measure; data may run wider. */
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 0.85em; }

/* ───────────────────────────────────────────────────────── UTILITY ── */

.mono { font-family: var(--font-mono); }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.secondary { color: var(--ink-2); }
.t-12 { font-size: var(--t-12); }
.t-13 { font-size: var(--t-13); }
.t-16 { font-size: var(--t-16); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* A label above a value. Used everywhere data is presented as a fact. */
.field-label {
  display: block;
  font-size: var(--t-11);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* Flex items default to min-width:auto and so refuse to shrink below their
   content's intrinsic minimum — the second-most common cause of horizontal
   overflow after a table with nowhere to scroll. Rows wrap and their
   children are allowed to shrink. */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.row-3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.row > *, .row-3 > *, .between > * { min-width: 0; }
.col { display: flex; flex-direction: column; gap: var(--s-2); }
.wrap-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
/* Wraps by default. A two-up header that refuses to wrap is the single most
   common source of horizontal overflow on a narrow viewport. */
.between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-4); }
.between-firm { flex-wrap: nowrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
/* A <table> with auto layout ignores width:1px and expands to fit its
   content, so a visually-hidden data table silently blows out the page
   width. Fixed layout makes it honour the width without changing the
   element's role, which display:block would destroy. */
/* The type selector is deliberate: `.table { width: 100% }` in
   components.css has equal specificity to `.sr-only` and loads later, so a
   bare class here loses and the hidden table expands to full width. */
table.sr-only, .sr-only table { table-layout: fixed; width: 1px; }

/* ─────────────────────────────────────────────────────────── FOCUS ── */
/* Visible on every interactive element, and never removed. */

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-2);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  left: var(--s-3);
  top: -4rem;
  z-index: var(--z-tooltip);
  padding: var(--s-2) var(--s-4);
  background: var(--citron);
  color: var(--on-citron);
  border: 1px solid var(--citron-edge);
  border-radius: var(--r-3);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--t-base) var(--ease-out);
}
.skip-link:focus { top: var(--s-3); }

/* ────────────────────────────────────────────────── REDUCED MOTION ── */
/* Not optional. Movement goes; crossfades stay, because they still carry
   state. Anything mid-animation is snapped to its end state. */

@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;
  }
  .allow-fade, .allow-fade * {
    transition-property: opacity, background-color, border-color, color !important;
    transition-duration: 160ms !important;
  }
}

/* ─────────────────────────────────────────────────────────── PRINT ── */
@media print {
  .no-print, .app-nav, .app-topbar, .toast-stack { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 9pt; }
}
