/* ==========================================================================
   Base: reset and element defaults
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Offset for the sticky header when jumping to an anchor. */
  scroll-padding-top: calc(var(--header-h, 4.5rem) + var(--space-5));
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  color: var(--ink-muted);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
  text-rendering: optimizeLegibility;
}

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

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

/* ------------------------------------------------------------- typography */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); line-height: var(--leading-snug); }
h4 { font-size: var(--text-lg); line-height: var(--leading-snug); }

p { text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--duration) var(--ease),
              text-decoration-color var(--duration) var(--ease);
}
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }

strong, b { font-weight: 600; color: var(--ink); }

ul, ol { padding-inline-start: 1.25em; }

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

/* ------------------------------------------------------------------ focus
   Visible only for keyboard users, but always clearly visible for them. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ------------------------------------------------------------- utilities */

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

.section { padding-block: var(--section-y); }
.section--sunken { background: var(--surface-sunken); }
.section--bordered { border-top: 1px solid var(--line); }

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

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

/* Small caps label above a heading: the main device for giving a section a
   quiet second voice without adding another type size. */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: var(--ink-muted);
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 100;
  padding: var(--space-3) var(--space-4);
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--duration) var(--ease);
}
.skip-link:focus { transform: translateY(0); color: #fff; }

/* Nothing may cause the page itself to scroll sideways. Wide content (tables,
   code, overflowing grids) scrolls inside its own container instead. */
html, body { overflow-x: clip; }

/* The `hidden` attribute must beat a component's own display value. A class
   rule like `.cart-empty { display: grid }` outranks the user-agent's
   `[hidden] { display: none }`, so without this an element stays visible while
   scripts believe they have hidden it. This is the one justified !important in
   the codebase: `hidden` is a statement about whether an element exists for the
   user, not a style any component should be able to overrule. */
[hidden] { display: none !important; }
