/* ─── Base styles ────────────────────────────────────────────────────────────
   Mobile-first. Breakpoints (min-width): 480 / 640 / 768 / 992 / 1200 — media
   conditions can't use custom properties, so the pixel values are literal.
   ────────────────────────────────────────────────────────────────────────── */

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

html {
  -webkit-text-size-adjust: 100%;
  /* Themed page scrollbar — never the unstyled OS default (docs/styling.md). */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary-color) 55%, var(--bg-color)) var(--bg-light);
}

@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--bg-light);
  }
  ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--primary-color) 55%, var(--bg-color));
    border: 2px solid var(--bg-light);
    border-radius: 999px;

    &:hover {
      background: var(--primary-color);
    }
  }
}

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-text);
  font-size: clamp(15.5px, 0.3vw + 14.5px, 17.5px);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* walnut grain: fine vertical lines + a warm glow from the top right */
  background-image:
    repeating-linear-gradient(91deg, color-mix(in srgb, var(--text-color) 1.4%, transparent) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(89.3deg, color-mix(in srgb, black 8%, transparent) 0 2px, transparent 2px 11px),
    radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--primary-color) 8%, transparent), transparent 60%);
}

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

a {
  color: var(--accent-hi);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;

  &:hover {
    color: var(--text-color);
  }
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-title);
  font-weight: 400;
  line-height: 1.08;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 144;
  color: var(--text-color);
}

h1 {
  font-size: clamp(2.4rem, 5.4vw + 0.5rem, 5.4rem);
}

h2 {
  font-size: clamp(1.9rem, 3vw + 0.6rem, 3.4rem);
}

h3 {
  font-size: clamp(1.25rem, 1vw + 0.9rem, 1.65rem);
}

h4 {
  font-size: 1.1rem;
  font-family: var(--font-text);
  font-weight: 600;
  letter-spacing: 0;
  font-variation-settings: normal;
}

em {
  font-style: italic;
  color: var(--accent-hi);
}

p {
  margin: 0 0 1em;
}

ul {
  padding-left: 1.1em;
}

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

/* programmatic focus targets need no ring */
[tabindex="-1"]:focus {
  outline: none;
}

/* ─── Layout + utilities ─────────────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  background: var(--accent);
  color: var(--bg-color);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;

  &:focus {
    top: 12px;
    color: var(--bg-color);
  }
}

.sr,
.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.eyebrow {
  font: 500 0.76rem/1.3 var(--font-text);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin-bottom: 1rem;

  &::before {
    content: "";
    width: 22px;
    height: 1px;
    background: currentColor;
  }

  & a {
    color: inherit;
  }
}

.lead {
  font-size: clamp(1.05rem, 0.5vw + 0.95rem, 1.28rem);
  color: var(--text-soft);
  max-width: 62ch;
}

.muted {
  color: var(--muted-hi);
}

.small {
  font-size: 0.86rem;
}

.illus {
  display: inline-block;
  font: 600 0.72rem/1.2 var(--font-text);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bg-color);
  background: var(--accent);
  padding: 0.35em 0.6em;
  border-radius: 3px;
}

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

.block--flush {
  padding-top: 0;
}

.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: clamp(28px, 4vw, 48px);

  & p {
    max-width: 52ch;
    margin: 0;
    color: var(--text-soft);
  }
}

.grid {
  display: grid;
  gap: clamp(14px, 2vw, 24px);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .g2,
  .g3,
  .g4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .g3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .g4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.two {
  display: grid;
  gap: clamp(24px, 5vw, 72px);
  align-items: start;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .two {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  }
}

.sticky {
  position: static;
}

@media (min-width: 768px) {
  .sticky {
    position: sticky;
    top: calc(var(--header-h) + 24px);
  }
}

.note {
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  background: var(--tint);
  font-size: 0.93rem;
  margin: 0 0 1em;

  &.warn {
    border-left-color: var(--secondary-hi);
  }
}

.prose {
  max-width: 74ch;

  & h2 {
    font-size: clamp(1.5rem, 1.5vw + 1rem, 2.1rem);
    margin-top: 2em;
  }

  & h3 {
    margin-top: 1.6em;
  }

  & li {
    margin-bottom: 0.4em;
  }

  & img {
    border-radius: var(--radius-lg);
  }
}

/* text-style buttons (cookie settings links in the prose / footer) */
.linkbtn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent-hi);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;

  &:hover {
    color: var(--text-color);
  }
}

/* ─── Reveal on scroll — pre-state only after the inline `js` class ──────── */

.js .rv {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.js .rv.in {
  opacity: 1;
  transform: none;
}

.js .rv.d1 { transition-delay: 0.08s; }
.js .rv.d2 { transition-delay: 0.16s; }
.js .rv.d3 { transition-delay: 0.24s; }

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

  .js .rv {
    opacity: 1;
    transform: none;
  }
}
