/* ==========================================================================
   Reset + element defaults + typography
   ========================================================================== */

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

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* keep anchored headings clear of the sticky header */
  scroll-padding-top: var(--below-header);
}

body {
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Inter: single-storey a alternates + better punctuation */
  font-feature-settings: "cv11", "ss01";
  text-rendering: optimizeLegibility;
  /* footer sits at the bottom even on short pages */
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
}

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

img,
video {
  height: auto;
}

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

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Headings --------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: var(--weight-semibold);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-5xl);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-3xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
}

h3 {
  font-size: var(--text-2xl);
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
}

h4 {
  font-size: var(--text-xl);
  line-height: var(--leading-snug);
}

p {
  text-wrap: pretty;
}

/* ---------- Links ------------------------------------------------------ */

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-in-out);
}

/* prose links get an underline; nav/card links opt out via their own classes */
.prose a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.prose a:hover {
  color: var(--color-accent-hover);
}

/* ---------- Focus ------------------------------------------------------ */

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

/* on accent surfaces the blue ring is invisible — switch to white */
.footer :focus-visible {
  outline-color: var(--color-on-accent);
}

/* ---------- Utilities -------------------------------------------------- */

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-accent);
  color: var(--color-on-accent);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transform: translateY(-200%);
  transition: transform var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* Icons inherit color via currentColor. Size is an explicit px token rather
   than 1em so a glyph never lands on a fractional pixel and blurs; each
   component overrides with the size it needs. */
.icon {
  width: var(--icon-16);
  height: var(--icon-16);
  flex-shrink: 0;
}

/* ---------- Reduced motion --------------------------------------------- */

@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;
  }

  /* reveals must land at their final state, never stay hidden */
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }

  /* The cursor-following star sits still. js/star.js checks this too and never
     starts; this also covers the case where the setting is turned on after the
     page has loaded and an inline angle is already set. */
  [data-star] {
    rotate: none !important;
  }
}
