/* ============================================
   base.css - Reset, typography base, links
   ============================================ */

/* Reset */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: var(--letter-spacing-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Respect 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;
  }
}

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

/* Typography base */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  overflow-wrap: break-word;
  text-wrap: balance;
  color: var(--color-text);
}

p {
  overflow-wrap: break-word;
  text-wrap: pretty;
}

/* Links */
a {
  color: var(--color-accent-ink);
  text-decoration: none;
  transition: color var(--transition-fast);
}

/* Generic hover must not win the specificity fight against styled controls
   (.btn, .card__link, etc. all define their own hover colors with higher
   specificity). Restricting the broad selector to non-button anchors keeps
   `.btn--primary:hover` text black on the sage hover background (AA ~12.7:1). */
a:not(.btn):not(.skip-link):hover {
  color: var(--color-accent-ink-hover);
}

/* Focus visible - all interactive elements */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Remove focus ring for mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Selection */
::selection {
  background: var(--color-accent-subtle);
  color: var(--color-text);
}

/* Lists */
ul, ol {
  list-style: none;
}

/* Button reset */
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* Input reset */
input,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* Sr-only utility */
.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;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: 0;
  left: var(--space-4);
  z-index: calc(var(--z-overlay) + 1);
  padding: var(--space-3) var(--space-6);
  background: var(--color-primary);
  color: var(--color-accent-on-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  text-decoration: none;
  /* Off-screen until focused. Transform (not `top`) keeps it outside the
     clipping cascade and animates without layout thrash. */
  transform: translateY(-150%);
  transition: transform var(--transition-fast) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(var(--space-4));
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Skip-link is a sage solid control: keep black text on hover too (AA ~10:1) */
.skip-link:hover {
  color: var(--color-accent-on-primary);
}

/* Remove focus outline on main for skip link */
main:focus {
  outline: none;
}
