/* ==========================================================================
   base.css — reset, base elements, layout, header, footer.
   Depends on tokens.css.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

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

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

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

/* ----- Document ----------------------------------------------------------- */
html {
  font-family: var(--font-body);
  font-size: 100%;
  line-height: var(--lh-normal);
  background: var(--bg);
  color: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-base);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ----- Headings (serif display) ------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--ink);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 {
  font-size: var(--fs-2xl);
}
h2 {
  font-size: var(--fs-xl);
}
h3 {
  font-size: var(--fs-lg);
}
h4 {
  font-size: var(--fs-md);
}

p {
  max-width: 68ch;
}

/* ----- Links -------------------------------------------------------------- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

/* ----- Numerals: tabular everywhere, mono for stats ----------------------- */
.num,
td.num,
th.num,
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.01em;
}

/* Body too should use lining tabular figures for inline stats consistency. */
body {
  font-variant-numeric: tabular-nums;
}

/* ----- Focus visibility (WCAG 2.2) ---------------------------------------- */
:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Remove default outline only where focus-visible is supported. */
:focus:not(:focus-visible) {
  outline: none;
}

/* ----- Selection ---------------------------------------------------------- */
::selection {
  background: var(--barca-soft);
  color: var(--ink);
}

/* ----- Skip link ---------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -4rem;
  z-index: 100;
  background: var(--surface);
  color: var(--ink);
  border: var(--rule-width) solid var(--rule-strong);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  box-shadow: var(--shadow-md);
  transition: top var(--motion-fast) var(--ease);
}

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

/* ----- Layout container --------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

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

main {
  flex: 1 0 auto;
  padding-block: var(--space-6) var(--space-8);
}

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

/* Thin horizontal rule, almanac style. */
hr,
.rule {
  border: none;
  border-top: var(--rule-width) solid var(--rule);
  margin-block: var(--space-5);
}

/* Section header with hairline underline. */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--ink);
  margin-bottom: var(--space-4);
}

.section-head__note {
  font-size: var(--fs-sm);
  color: var(--ink-muted);
}

.eyebrow {
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--ink-muted);
}

/* ==========================================================================
   Header / site masthead
   ========================================================================== */
.site-header {
  border-bottom: var(--rule-width) solid var(--rule);
  background: var(--surface);
}

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

.wordmark {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

.wordmark:hover {
  color: var(--ink);
}

.wordmark .wordmark__dot {
  color: var(--barca-ink);
}
.wordmark .wordmark__co {
  color: var(--real-ink);
}

.masthead__search {
  flex: 1 1 14rem;
  min-width: 0;
}

.masthead__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* Primary nav */
.site-nav {
  border-bottom: var(--rule-width) solid var(--rule);
  background: var(--surface);
}

.site-nav__list {
  display: flex;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.site-nav__link {
  display: inline-block;
  padding: var(--space-3) var(--space-3);
  text-decoration: none;
  color: var(--ink-muted);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.site-nav__link:hover {
  color: var(--ink);
}

.site-nav__link[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  flex-shrink: 0;
  border-top: 2px solid var(--ink);
  background: var(--surface);
  padding-block: var(--space-6);
  margin-top: var(--space-8);
  font-size: var(--fs-sm);
  color: var(--ink-muted);
}

.site-footer__cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-5);
}

.site-footer h2 {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
  font-weight: var(--fw-semibold);
}

.site-footer ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-footer li + li {
  margin-top: var(--space-1);
}

.footer-disclaimer {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: var(--rule-width) solid var(--rule);
  font-size: var(--fs-xs);
  color: var(--ink-muted);
  max-width: 70ch;
}

.footer-consent {
  margin-top: var(--space-4);
}

/* Inline, button-shaped-as-link (used for the analytics-preferences re-open). */
.link-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--link);
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--link-hover);
}

.link-btn:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Consent banner (GA4 analytics opt-in — T6.2). Fixed to the bottom; uses the
   surface token so it meets AA contrast in both themes. Only ever inserted by
   consent.js when GA is active.
   ========================================================================== */
.consent {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1000;
  background: var(--surface);
  color: var(--ink);
  border-top: var(--rule-width) solid var(--rule-strong);
  box-shadow: var(--shadow-md);
}

.consent[hidden] {
  display: none;
}

.consent__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}

.consent__text {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink);
  max-width: 70ch;
}

.consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--ink-muted);
}
.text-sm {
  font-size: var(--fs-sm);
}
.text-xs {
  font-size: var(--fs-xs);
}
.lede {
  font-size: var(--fs-md);
  color: var(--ink-muted);
  max-width: 60ch;
}

/* ----- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
