/* ==========================================================================
   Base — Global reset, defaults, and typography
   Depends on: tokens.css

   Load order: 2 of 5 (tokens → base → layout → components → utilities)
   ========================================================================== */

/* -----------------------------------------------------------------------
   Reset (modern, minimal)
   ----------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@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;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -----------------------------------------------------------------------
   Typography defaults
   ----------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
}

h3 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
}

h4 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
}

h5 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

h6 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
}

p {
  max-width: 65ch;
}

/* Responsive heading scale — scale down on mobile */
@media (max-width: 47.999rem) {
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  h3 { font-size: var(--text-xl); }
}

/* -----------------------------------------------------------------------
   Links
   ----------------------------------------------------------------------- */

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  transition: color var(--duration-fast) var(--easing-default);
}

a:hover {
  color: var(--link-hover);
}

/* -----------------------------------------------------------------------
   Inline elements
   ----------------------------------------------------------------------- */

strong, b {
  font-weight: var(--weight-semibold);
}

small {
  font-size: var(--text-sm);
}

/* -----------------------------------------------------------------------
   Focus styles (WCAG 2.2 AA compliant)
   ----------------------------------------------------------------------- */

:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* -----------------------------------------------------------------------
   Media defaults
   ----------------------------------------------------------------------- */

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* -----------------------------------------------------------------------
   Form element resets
   ----------------------------------------------------------------------- */

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

fieldset {
  border: none;
}

/* -----------------------------------------------------------------------
   Lists
   ----------------------------------------------------------------------- */

ul, ol {
  list-style: none;
}

/* -----------------------------------------------------------------------
   Table defaults
   ----------------------------------------------------------------------- */

table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* -----------------------------------------------------------------------
   Selection
   ----------------------------------------------------------------------- */

::selection {
  background-color: var(--color-brand-cyan-400);
  color: var(--color-navy-900);
}

/* -----------------------------------------------------------------------
   Skip link (accessibility)
   ----------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: var(--z-toast);
  padding: var(--space-3) var(--space-6);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--action-primary-text);
  background-color: var(--action-primary-bg);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--duration-fast) var(--easing-default);
}

.skip-link:focus {
  top: var(--space-4);
}

/* -----------------------------------------------------------------------
   Screen reader only
   ----------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
