/* base.css — Reset, layout primitives, typography, header, footer, skip link. Tokens only (no colours). */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 96px; }
body {
  margin: 0; background: var(--color-bg); color: var(--color-text-primary);
  font-family: var(--font-ui); font-size: var(--fs-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--color-link); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: var(--radius-sm); }
h1, h2, h3, h4 { text-wrap: balance; }
p, li { overflow-wrap: break-word; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: var(--z-skip);
  padding: var(--space-3) var(--space-4); background: var(--color-surface); color: var(--color-text-primary);
  border: 2px solid var(--color-focus); border-radius: var(--radius-input); font-weight: var(--weight-strong);
}
.skip-link:focus { top: var(--space-3); }
main:focus { outline: none; }

.wrap { width: min(100% - 32px, var(--max-width)); margin-inline: auto; }
.narrow { max-width: 760px; }
.section { margin-block: var(--space-7); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.section__link { font-size: var(--fs-small); font-weight: 500; display: inline-flex; align-items: center; min-height: var(--touch-target); }
.muted { color: var(--color-text-secondary); }
.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Typography ---------- */
.display {
  font-family: var(--font-display); font-weight: var(--weight-display); font-size: var(--fs-display);
  line-height: 1.05; letter-spacing: var(--tracking-display); margin: 0;
}
.display--page { font-size: var(--fs-page-title); margin: 0 0 var(--space-4); }
.display__sub { display: block; font-size: 0.5em; color: var(--color-text-secondary); margin-top: var(--space-2); }
.h-section { font-family: var(--font-display); font-weight: var(--weight-heading); font-size: var(--fs-h2); line-height: var(--lh-tight); margin: 0 0 var(--space-4); }
.h-section--small { font-size: var(--fs-h3); margin-bottom: var(--space-3); }
.plain-list { padding-left: 1.1em; margin: 0 0 var(--space-4); }
.plain-list li + li { margin-top: var(--space-2); }
.error-code { font-size: var(--fs-small); color: var(--color-text-secondary); margin: 0 0 var(--space-2); letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- Header ---------- */
.site-header { background: var(--color-header-bg); border-bottom: 1px solid var(--color-border); }
.site-header__row { display: flex; align-items: center; gap: var(--space-4); min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: var(--touch-target); text-decoration: none; color: var(--color-text-primary); }
.brand__mark { width: 30px; height: 30px; flex: none; }
.brand__mark-bg { fill: var(--brand-mark-bg); }
.brand__mark-a { fill: var(--brand-mark-a); }
.brand__mark-b { fill: var(--brand-mark-b); }
.brand__mark-c { fill: var(--brand-mark-c); }
.brand__name { font-family: var(--font-display); font-weight: var(--weight-heading); font-size: 1.3rem; letter-spacing: -0.01em; }
.nav { margin-left: auto; }
.nav__list { display: flex; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.nav__link {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch-target); padding: 0 14px;
  border-radius: var(--radius-pill); text-decoration: none; color: var(--color-text-secondary);
  font-size: 0.95rem; font-weight: 500;
}
.nav__label { line-height: 1.2; }
.nav__link:hover { color: var(--color-text-primary); background: var(--color-surface-sunken); }
.nav__link[aria-current="page"] { color: var(--color-on-primary); background: var(--color-primary); }

@media (min-width: 721px) {
  .site-header { position: sticky; top: 0; z-index: var(--z-sticky); }
}
/* Phones: the navigation becomes a second row of equal buttons with VISIBLE labels (audit 8/10/16/43): four, or
   three while the signup is off (NEWSMEDIC_SIGNUP=0) — one column per entry, never an empty slot.
   The header scrolls away instead of sticking, so it does not eat a quarter of the screen. */
@media (max-width: 720px) {
  .site-header__row { flex-wrap: wrap; gap: 0; padding-bottom: var(--space-2); }
  .nav { margin-left: 0; width: 100%; }
  .nav__list { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-1); }
  .nav__link { flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 4px 2px; border-radius: var(--radius-input); font-size: var(--fs-xsmall); width: 100%; }
}

/* ---------- Footer ---------- */
.site-footer { margin-top: var(--space-8); border-top: 1px solid var(--color-border); padding: var(--space-6) 0 var(--space-7); font-size: var(--fs-small); color: var(--color-text-secondary); }
.site-footer__grid { display: grid; gap: var(--space-5); }
@media (min-width: 860px) { .site-footer__grid { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer__brand { font-family: var(--font-display); font-size: 1.2rem; color: var(--color-text-primary); margin: 0 0 var(--space-2); }
.site-footer__about p { margin: 0 0 var(--space-2); max-width: 60ch; }
.site-footer__nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0 var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 860px) { .site-footer__nav ul { grid-template-columns: 1fr; } }
.site-footer__nav a { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch-target); color: var(--color-text-secondary); }
.site-footer__nav a:hover { color: var(--color-text-primary); }
