/* ==========================================================================
   Base: reset, document, typography, focus, layout primitives
   ========================================================================== */

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

/* The `hidden` attribute has to beat author display rules, or an element told
   to hide itself (a zero-count badge, a spent "Load more") keeps showing. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  /* Never let a wide child scroll the page sideways. */
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink-900);
  /* Fraunces reads warmer with a slight optical-size bump. */
  font-variation-settings: 'SOFT' 20, 'WONK' 0;
}

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

p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }

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

a {
  color: var(--green-700);
  text-decoration-color: color-mix(in srgb, var(--green-700) 35%, transparent);
  text-underline-offset: 0.18em;
  transition: color var(--t-fast) var(--ease-out);
}
a:hover { color: var(--green-800); }

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

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

button { cursor: pointer; }

ul, ol { margin: 0; padding: 0; }
li { list-style: none; }

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

/* --- Focus: visible, branded, never removed ----------------------------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* --- Accessibility helpers ---------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: calc(var(--safe-top) + var(--space-2));
  left: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-4);
  background: var(--green-700);
  color: #fff;
  border-radius: var(--radius-md);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--t-med) var(--ease-out);
}
.skip-link:focus-visible { transform: translateY(0); color: #fff; }

/* --- Layout primitives -------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: max(var(--gutter), var(--safe-left)) max(var(--gutter), var(--safe-right));
}

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

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

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* --- Icons --------------------------------------------------------------- */
.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--sm { width: 1rem;   height: 1rem; }
.icon--lg { width: 1.5rem; height: 1.5rem; }
.icon--xl { width: 2rem;   height: 2rem; }

/* The inlined sprite itself must never render. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* --- Text utilities ----------------------------------------------------- */
.muted   { color: var(--text-muted); }
.subtle  { color: var(--text-subtle); }
.display { font-family: var(--font-display); }
.tagline {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--ink-700);
  font-style: italic;
}
.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.prose { max-width: var(--prose-max); color: var(--ink-700); }
.prose h2 { margin-top: var(--space-8); margin-bottom: var(--space-3); }
.prose h3 { margin-top: var(--space-6); margin-bottom: var(--space-2); }
.prose ul { margin: 0 0 var(--space-4); padding-left: var(--space-5); }
.prose ul li { list-style: disc; margin-bottom: var(--space-2); }

/* Truncation helpers used by cards. */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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