/*
 * Accessibility fixes.
 *
 * Brand-neutral. All colors come from brand tokens (--sss-focus, --sss-text,
 * --sss-bg, --sss-accent), so this file applies identically to every brand.
 *
 * Covers:
 *   - Visible focus rings for keyboard users
 *   - Skip-to-main-content link
 *   - Screen-reader-only utility class
 *   - Minimum tap target enforcement on nav / buttons
 *   - Reduced-motion respect
 *   - Print-friendly visible-on-focus utilities
 */

/* ---- Focus ring. Only on keyboard focus (not mouse clicks). ---- */
:where(a, button, [role="button"], input, select, textarea, summary, [tabindex]):focus {
  outline: none; /* Remove default UA ring — we replace it below. */
}
:where(a, button, [role="button"], input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--sss-focus-width) solid var(--sss-focus);
  outline-offset: var(--sss-focus-offset);
  border-radius: var(--sss-radius-sm);
}

/* ---- Skip link (emitted by inc/accessibility.php on wp_body_open). ---- */
.sss-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: var(--sss-z-skiplink);
  background: var(--sss-text);
  color: var(--sss-bg);
  padding: var(--sss-space-3) var(--sss-space-4);
  font-family: var(--sss-font-body);
  font-weight: 700;
  border-radius: 0 0 var(--sss-radius-md) 0;
  text-decoration: none;
}
.sss-skip-link:focus,
.sss-skip-link:focus-visible {
  position: fixed;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  overflow: visible;
  outline: var(--sss-focus-width) solid var(--sss-focus);
  outline-offset: var(--sss-focus-offset);
}

/* ---- Screen-reader-only utility (matches WP core `.screen-reader-text`). ---- */
.sss-visually-hidden,
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  -webkit-clip-path: inset(50%);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal !important;
}
.sss-visually-hidden:focus,
.screen-reader-text:focus {
  background-color: var(--sss-bg);
  color: var(--sss-text);
  clip: auto;
  -webkit-clip-path: none;
  clip-path: none;
  display: block;
  height: auto;
  left: 5px;
  padding: var(--sss-space-3) var(--sss-space-4);
  top: 5px;
  width: auto;
  z-index: var(--sss-z-skiplink);
  text-decoration: none;
}

/* ---- Minimum tap target. Applies to header/footer nav links and icon buttons. ---- */
.sss-nav a,
nav[role="navigation"] a,
header nav a,
footer nav a,
button.sss-icon-btn,
.wp-block-navigation-item__content {
  min-height: var(--sss-tap-target);
  display: inline-flex;
  align-items: center;
}

/* ---- Reduced motion. ---- */
@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;
  }
}

/* ---- Smooth focus scroll (except for reduced-motion users, handled above). ---- */
html {
  scroll-behavior: smooth;
}

/* ---- Ensure `:target` elements (e.g., `#main` after skip link) get a small
   scroll-margin so they're not pinned to the top edge of the viewport. ---- */
:target {
  scroll-margin-top: var(--sss-space-16);
}

/* ---- Force high-contrast outlines inside forced-colors / Windows High Contrast. ---- */
@media (forced-colors: active) {
  :where(a, button, [role="button"], input, select, textarea, summary):focus-visible {
    outline: 2px solid CanvasText;
    outline-offset: 3px;
  }
}
