/* Global accessibility layer — linkable from every page.
 * Apply by adding: <link rel="stylesheet" href="/a11y.css"> to <head>
 * Covers: reduced-motion respect, high-contrast mode, focus indicators,
 * forced colors mode, skip-link, screen-reader-only utility class.
 */

/* === Respect prefers-reduced-motion === */
@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;
  }
  html { scroll-behavior: auto !important; }
}

/* === Visible focus for keyboard navigation === */
:focus-visible {
  outline: 3px solid #ffd34d !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}
a:focus-visible, button:focus-visible {
  box-shadow: 0 0 0 4px rgba(255, 211, 77, 0.35) !important;
}

/* === Screen-reader-only utility === */
.sr-only, .visually-hidden {
  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;
}

/* === Skip-to-main link (add <a class="skip-link" href="#main">Skip to main content</a> as first child of body) === */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: #000;
  color: #ffd34d;
  padding: 0.9rem 1.3rem;
  text-decoration: none;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  z-index: 100001;
  border: 2px solid #ffd34d;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 0;
}

/* === High-contrast / forced-colors mode === */
@media (forced-colors: active) {
  body { background: Canvas !important; color: CanvasText !important; }
  a, button { color: LinkText !important; }
  .neon-green, .neon-cyan, .neon-pink, .neon-gold, .neon-yellow { color: CanvasText !important; text-shadow: none !important; }
}

@media (prefers-contrast: more) {
  body { color: #ffffff !important; }
  .dim, [class*="dim"], [style*="color:#6"], [style*="color:#7"], [style*="color:#8"] { color: #cccccc !important; }
}

/* === Larger tap targets on mobile === */
@media (pointer: coarse) {
  a, button, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }
}

/* === Live region styling (for aria-live="polite" wrappers) === */
[aria-live] { /* no visual change, just semantic for screen readers */ }

/* === Unified top navigation — fallback styling for pages that lack their own .topnav CSS === */
nav.topnav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-family: 'JetBrains Mono', 'Space Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  border-bottom: 1px solid rgba(155, 140, 255, 0.18);
  position: relative;
  z-index: 50;
}
nav.topnav a {
  color: inherit;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
  padding: 0.2rem 0.3rem;
}
nav.topnav a:hover { opacity: 1; }
nav.topnav .links {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}
@media (max-width: 600px) {
  nav.topnav { font-size: 0.62rem; }
  nav.topnav .links { gap: 0.4rem; }
}
