/*
 Theme Name: Erewhon - Accessibility
 Description: Accessibility features, focus management, and inclusive design
 */
/* ============================================
 SKIP LINKS
 ============================================ */
.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 999;
}
.skip-link:focus {
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  background: oklch(0% 0 0);
  /* #000 */
  color: oklch(100% 0 0);
  /* #fff */
  padding: 0.625rem 1.25rem;
  text-decoration: none;
  border-radius: var(--radius-s);
}
/* ============================================
 SCREEN READER UTILITIES
 ============================================ */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.sr-only-focusable:active, .sr-only-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}
/* ============================================
 FOCUS RING SYSTEM
 ============================================ */
:where(a, button, [role="button"], input, textarea, select, summary, [tabindex], [contenteditable="true"], input[type="file"]::file-selector-button):focus-visible {
  outline: var(--focus-width) solid var(--focus-ring-primary-outline);
  outline-offset: 2px;
  border-radius: var(--radius-s);
  box-shadow: 0 0 0 2px var(--focus-ring-primary), 0 0 0 6px var(--focus-shadow-primary);
}
/* Fallback for browsers without :focus-visible */
@supports not selector(:focus-visible) {
  :where(a, button, [role="button"], input, textarea, select, summary, [tabindex], [contenteditable="true"], input[type="file"]::file-selector-button):focus {
    outline: var(--focus-width) solid var(--focus-ring-primary-outline);
    outline-offset: 2px;
    border-radius: var(--radius-s);
    box-shadow: 0 0 0 2px var(--focus-ring-primary), 0 0 0 6px var(--focus-shadow-primary);
  }
}
/* Don’t show focus when programmatically focused for scrolling anchors */
[tabindex="-1"]:focus:not(:focus-visible) {
  outline: 0 !important;
}
/* Make role=button navigable if author forgets tabindex */
[role="button"]:not([tabindex]) {
  cursor: pointer;
}
[role="button"][tabindex="0"]:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring-primary-outline);
  outline-offset: 2px;
}
/* ============================================
 CONTRAST & USER PREFS
 ============================================ */
@media (prefers-contrast: more) {
  /* Stronger focus ring */
  :is(a, button, [role="button"], input, textarea, select, summary, [tabindex], [contenteditable="true"]):focus-visible {
    outline-width: 3px;
    box-shadow: 0 0 0 3px var(--focus-ring-primary);
    /* Clearer link underline for unclassed content links */
  }
  a:not([class]) {
    text-decoration-thickness: 0.15em;
    text-underline-offset: 0.08em;
  }
  a:not([class]):hover {
    text-decoration-thickness: 0.2em;
  }
}
/* Reduced motion: keep essential feedback only.
 (Global animation/transition clamp lives in performance.css) */
@media (prefers-reduced-motion: reduce) {
  :is(button, [role="button"], .btn):hover, :is(button, [role="button"], .btn):focus {
    transition: background-color 0.15s ease, color 0.15s ease;
  }
}
/* Windows High Contrast / Forced Colors */
@media (forced-colors: active) {
  :where(a, button, [role="button"], input, textarea, select, summary, [tabindex], [contenteditable="true"]):focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
  .btn, button, [role="button"] {
    border: 1px solid CanvasText;
    background: ButtonFace;
    color: ButtonText;
  }
}
/* Legacy IE/Edge HCM (optional safety net) */
@media screen and (-ms-high-contrast: active) {
  .btn, button, [role="button"] {
    border: 1px solid;
  }
  :focus {
    outline: 2px solid;
  }
}
/* ============================================
 SELECTION STYLING
 ============================================ */
::selection {
  background: var(--primary-light);
  color: var(--primary-ultra-dark);
  text-shadow: none;
}
::-moz-selection {
  background: var(--primary-light);
  color: var(--primary-ultra-dark);
  text-shadow: none;
}
/* ============================================
 PRINT ACCESSIBILITY
 ============================================ */
@media print {
  :root {
    --text-primary: oklch(0% 0 0);
    /* #000 */
    --text-secondary: oklch(23% 0 0);
    /* ~#333 */
    --text-tertiary: oklch(35% 0 0);
    /* ~#555 */
    --bg-body: oklch(100% 0 0);
    /* #fff */
    --bg-surface: oklch(100% 0 0);
    /* #fff */
  }
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: oklch(53% 0 0);
    /* ~#666 */
  }
  .skip-link, .visually-hidden, .sr-only {
    display: none !important;
  }
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
  }
  p, li {
    page-break-inside: avoid;
    orphans: 3;
    widows: 3;
  }
}
/* ============================================
 DARK MODE PREP (placeholder)
 ============================================ */
@media (prefers-color-scheme: dark) {
  .skip-link:focus {
    background: oklch(100% 0 0);
    /* #fff */
    color: oklch(0% 0 0);
    /* #000 */
  }
}
