/* ==========================================================================
   Global styles
   --------------------------------------------------------------------------
   Loaded after Bootstrap. Bridges Bootstrap's own variables to our tokens,
   then sets base typography, layout primitives and accessibility helpers.
   ========================================================================== */

/* Bootstrap bridge ---------------------------------------------------------
   Bootstrap's grid and utilities stay available; these overrides stop its
   defaults from setting the site's visual identity. */
:root {
  --bs-body-font-family: var(--font-body);
  --bs-body-font-size: var(--fs-base);
  --bs-body-font-weight: var(--fw-regular);
  --bs-body-line-height: var(--lh-body);
  --bs-body-color: var(--color-text);
  --bs-body-bg: var(--color-bg);
  --bs-heading-color: var(--color-text);
  --bs-border-color: var(--color-border);
  --bs-secondary-color: var(--color-text-muted);
  --bs-emphasis-color: var(--color-text);
}

/* Base ---------------------------------------------------------------------- */
html {
  scroll-padding-top: calc(var(--header-height) + var(--space-4));
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

main {
  flex: 1 0 auto;
}

main:focus {
  outline: none; /* Target of the skip link; not interactive itself */
}

::selection {
  background-color: var(--color-selection);
  color: var(--color-text);
}

/* Typography --------------------------------------------------------------
   One rule sets the heading font for every heading element and for any
   element given .heading-font. Change --font-heading to restyle them all. */
h1, h2, h3, h4, h5, h6,
.heading-font {
  font-family: var(--font-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  color: var(--bs-heading-color);
}

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: var(--space-4);
  line-height: var(--lh-snug);
  text-wrap: balance;
}

h1, .h1 { font-size: var(--fs-h1); line-height: var(--lh-tight); }
h2, .h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
h3, .h3 { font-size: var(--fs-h3); }
h4, .h4 { font-size: var(--fs-h4); }
h5, .h5 { font-size: var(--fs-h5); }
h6, .h6 { font-size: var(--fs-h6); }

.display {
  font-family: var(--font-heading);
  font-weight: var(--fw-heading);
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--ls-heading);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-4);
  text-wrap: pretty;
}

.lede {
  font-size: var(--fs-lg);
  color: var(--color-text-muted);
  max-width: var(--measure-narrow);
}

.prose {
  max-width: var(--measure);
}

/* Long-form text such as the legal pages */
.prose h2 {
  margin-top: var(--space-7);
  font-size: var(--fs-h3);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose li + li {
  margin-top: var(--space-2);
}

.text-muted-brand {
  color: var(--color-text-muted);
}

small,
.text-small {
  font-size: var(--fs-sm);
}

address {
  font-style: normal;
  margin-bottom: 0;
}

/* Links -------------------------------------------------------------------- */
a {
  color: var(--color-primary);
  text-decoration-thickness: var(--border-width);
  text-underline-offset: 0.2em;
  transition: color var(--duration-fast) var(--ease-standard);
}

a:hover {
  color: var(--color-primary-hover);
}

/* Focus --------------------------------------------------------------------
   Visible for keyboard users only; never removed without a replacement. */
:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus);
  outline-offset: var(--focus-ring-offset);
}

.section--inverse :focus-visible,
.site-footer :focus-visible {
  outline-color: var(--color-focus-inverse);
}

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

img {
  height: auto;
}

/* Inline icons stay inline. */
.icon {
  display: inline-block;
  flex-shrink: 0;
  width: var(--icon-size);
  height: var(--icon-size);
  vertical-align: -0.15em;
  fill: currentColor;
}

/* Layout primitives -------------------------------------------------------- */
.site-container {
  width: 100%;
  max-width: calc(var(--container-max) + var(--page-gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
  /* Bootstrap rows with wide gutters (.g-5) have negative margins larger than
     the page gutter on small phones; clip that empty bleed so it can't cause
     horizontal scrolling. */
  overflow-x: clip;
}

.site-container--narrow {
  max-width: calc(var(--container-narrow) + var(--page-gutter) * 2);
}

.site-container--wide {
  max-width: calc(var(--container-wide) + var(--page-gutter) * 2);
}

.section {
  padding-block: var(--section-space);
}

.section--tight {
  padding-block: var(--section-space-tight);
}

.section--surface {
  background-color: var(--color-surface);
}

/* Use sparingly: the design calls for restrained green backgrounds. */
.section--inverse {
  --bs-heading-color: var(--color-text-inverse);
  background-color: var(--color-surface-inverse);
  color: var(--color-text-inverse);
}

.section--inverse a:not(.button) {
  color: var(--color-text-inverse);
}

.section--inverse .lede,
.section--inverse .text-muted-brand {
  color: var(--color-text-inverse-muted);
}

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

/* Accessibility helpers ---------------------------------------------------- */
.skip-link {
  position: fixed;
  top: var(--space-3);
  left: var(--space-3);
  z-index: var(--z-skip-link);
  padding: var(--space-3) var(--space-5);
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  border-radius: var(--radius-xs);
  transform: translateY(calc(-100% - var(--space-6)));
}

.skip-link:focus {
  transform: none;
  color: var(--color-text-inverse);
}

/* .visually-hidden is supplied by Bootstrap. */

/* Reduced motion -----------------------------------------------------------
   A global safety net in addition to per-component handling. */
@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;
  }
}
