/* ============================================================================
   a11y.css: WCAG 2.2 AA accessibility baseline. REQUIRED on every site built
   with the ada-compliant-build skill. This copy reads its colours from the
   site's design tokens (tokens.css) so the focus ring matches the palette.

   Provides:
     - Skip link (bypass blocks, 2.4.1)
     - Visible focus indicator with DUAL :focus and :focus-visible rules (2.4.7)
     - .sr-only screen-reader-only utility
     - prefers-reduced-motion handling (2.3.3 / motion)

   Copyright (c) 2026 Sean Wilson.
   ============================================================================ */

/* --- Skip link: first focusable element; hidden until focused (2.4.1) ------ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-skip);
  padding: 0.75rem 1rem;
  background: var(--color-paper);
  color: var(--color-ink);          /* 14.75:1 */
  font-weight: 700;
  text-decoration: underline;
}
.skip-link:focus,
.skip-link:focus-visible {
  left: 0;                 /* slide into view for keyboard users */
}

/* --- Visible focus indicator (2.4.7) --------------------------------------
   Dual rule for broad support. :focus guarantees a visible indicator in every
   browser; :focus-visible refines it for keyboard interaction. Both keep the
   outline VISIBLE. The ring is never transitioned, so it appears instantly. --*/
:focus {
  outline: 3px solid var(--color-focus);   /* 5.95:1 on paper, 8.72:1 on navy via the on-deep override */
  outline-offset: 3px;
}
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}
/* Pointer users do not need the ring on click, but keyboard users always get it. */
:focus:not(:focus-visible) {
  outline-color: transparent;
}

/* --- Screen-reader-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: 0;
}
/* Visible again when focused (e.g. a hidden-but-focusable skip target) */
.sr-only-focusable:focus,
.sr-only-focusable:focus-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

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