/* ==========================================================================
   base.css - reset, document shell, typography, focus, motion.
   Nothing here hardcodes a color. Everything comes from tokens.css.
   ========================================================================== */

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

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

body {
  margin: 0;
  padding: var(--space-4) var(--space-3) var(--space-7);
  background-color: var(--bg);
  background-image: var(--bg-tile);
  background-repeat: repeat;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.2;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}

h1 {
  font-size: clamp(2rem, 7vw, 3.25rem);
  color: var(--accent);
}

h2 {
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  color: var(--accent);
}

p,
ul,
ol,
dl {
  margin: 0 0 var(--space-4);
  max-width: var(--measure);
}

a {
  color: var(--link);
  text-decoration: underline;
}

a:visited {
  color: var(--link-visited);
}

a:hover {
  color: var(--accent);
  text-decoration-thickness: 3px;
}

/* Focus is deliberately NOT the same treatment as hover: hover recolors,
   focus draws a ring. Keyboard users get an unambiguous indicator. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

strong {
  color: var(--accent);
}

sup {
  font-size: 0.6em;
}

hr.rule {
  height: 6px;
  margin: var(--space-6) 0;
  border: 0;
  background: linear-gradient(
    90deg,
    var(--accent) 0%,
    var(--decor) 33%,
    var(--accent-2) 66%,
    var(--accent) 100%
  );
}

/* A solid bar rather than the rainbow, and not a hairline: this era is
   restrained, not delicate, and it keeps the same weight as its 3px borders. */
[data-theme="websafe"] hr.rule {
  height: 3px;
  background: var(--accent);
}

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

.nowrap {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Skip link - first focusable element on the page.
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  z-index: 10;
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Page shell
   -------------------------------------------------------------------------- */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
}

main {
  margin: var(--space-6) 0;
}

section {
  margin: 0 0 var(--space-6);
}

/* --------------------------------------------------------------------------
   Motion. Everything decorative that moves is switched off here, and the
   moving elements are authored so that stopping them leaves them readable.
   -------------------------------------------------------------------------- */

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