/* ============================================================================
 * Fablely — global a11y helpers (Wave 4)
 * Loaded by every public-facing HTML page via <link rel="stylesheet" href="/a11y.css">.
 * Keep this file SMALL and SAFE: it should never visually disturb existing
 * styling, only add a11y affordances.
 * ============================================================================ */

/* Visually-hidden utility for screen-reader-only labels.
 * Use when you want a <label> tied to an input via for=… but
 * don't want it visible (because the placeholder + context makes
 * the field self-evident sighted-users-only).
 */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global visible focus ring for keyboard navigation.
 * :focus-visible only triggers on actual keyboard focus (not mouse clicks),
 * so it doesn't disturb mouse users. Critical for WCAG 2.4.7.
 *
 * We use a dual-color outline so the ring contrasts on both
 * light AND dark backgrounds.
 */
:focus-visible {
  outline: 3px solid #F4A261;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Suppress the outline on elements that already have their own
 * visually-clear focus state (so we don't double-style them) */
.theme-btn:focus-visible,
.name-pill:focus-visible,
.radio-pill:focus-visible {
  outline-offset: 3px;
}

/* Make sure interactive elements receiving focus aren't visually clipped */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  position: relative;
  z-index: 1;
}

/* Skip-to-content link (added to HTML; hidden until focused) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: #1A1F25;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  z-index: 9999;
  transition: top 0.2s ease-out;
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 8px;
  outline: 3px solid #fff;
}

/* Reduced-motion: respect user OS setting */
@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;
  }
}

/* Forced-colors mode (Windows High Contrast): ensure borders stay visible
 * on buttons that rely on background color alone for definition */
@media (forced-colors: active) {
  button,
  .icon-btn,
  .theme-btn,
  .name-pill,
  .radio-pill,
  .action-btn {
    border: 1px solid ButtonText !important;
  }
}
