/* ==========================================================================
   Retrobörse — Accessibility (toolbar + modes). See inc/accessibility.php.
   ========================================================================== */

/* ── Basics: skip link + visible keyboard focus ─────────────────────────── */

.rb-skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100000;
  padding: 12px 18px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  text-decoration: none;
  border-radius: 8px;
  transform: translateY(-200%);
}

.rb-skip-link:focus {
  transform: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.rb-a11y {
  position: fixed;
  left: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 9990;
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: normal;
  text-transform: none;
}

.rb-a11y-toggle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.25);
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s;
}

.rb-a11y-toggle:hover { transform: scale(1.06); }

.rb-a11y.is-reading .rb-a11y-toggle {
  animation: rb-a11y-pulse 1.6s ease-out infinite;
}

@keyframes rb-a11y-pulse {
  0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
  100% { box-shadow: 0 0 0 16px transparent; }
}

.rb-a11y-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.rb-a11y-panel {
  position: absolute;
  left: 0;
  bottom: 66px;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.6);
}

.rb-a11y-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.rb-a11y-head h2 {
  margin: 0;
  font: 700 18px/1.2 'DM Sans', sans-serif;
  color: var(--text);
}

.rb-a11y-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.rb-a11y-close:hover { background: rgba(255, 255, 255, 0.08); }

.rb-a11y-group {
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.rb-a11y-group h3 {
  margin: 0 0 10px;
  font: 600 12px/1.2 'DM Sans', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.rb-a11y-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rb-a11y-btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font: 600 15px/1 'DM Sans', sans-serif;
  cursor: pointer;
}

.rb-a11y-btn:hover:not(:disabled) { border-color: var(--accent); }
.rb-a11y-btn:disabled { opacity: 0.4; cursor: default; }

.rb-a11y-btn--primary {
  flex: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.rb-a11y-font output {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rb-a11y-rate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  color: var(--text-secondary);
}

.rb-a11y-rate select {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

.rb-a11y-hint {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Toggle switches (aria-pressed) */
.rb-a11y-switch {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 2px;
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 15px/1.2 'DM Sans', sans-serif;
  text-align: left;
  cursor: pointer;
}

.rb-a11y-switch::after {
  content: '';
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2) radial-gradient(circle at 12px 50%, #fff 8px, transparent 9px) no-repeat;
  transition: background-position 0.15s, background-color 0.15s;
}

.rb-a11y-switch[aria-pressed="true"]::after {
  background-color: var(--accent);
  background-image: radial-gradient(circle at 30px 50%, #000 8px, transparent 9px);
}

.rb-a11y-reset {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font: 500 14px/1 'DM Sans', sans-serif;
  text-decoration: underline;
  cursor: pointer;
}

/* Currently read-aloud block */
.rb-a11y-reading {
  outline: 3px solid var(--accent) !important;
  outline-offset: 6px;
  background-color: var(--accent-dim) !important;
  border-radius: 4px;
  scroll-margin: 120px;
}

@media (max-width: 768px) {
  .rb-a11y { left: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .rb-a11y-toggle { width: 48px; height: 48px; }
  .rb-a11y-panel { bottom: 60px; max-width: calc(100vw - 28px); }
}

@media print {
  .rb-a11y, .rb-skip-link { display: none !important; }
}

/* ── Mode: text size (zooms content + footer, the navigation stays as is) ── */

html.rb-a11y-font-1 #rb-content, html.rb-a11y-font-1 #rb-front-page, html.rb-a11y-font-1 .rb-footer { zoom: 1.15; }
html.rb-a11y-font-2 #rb-content, html.rb-a11y-font-2 #rb-front-page, html.rb-a11y-font-2 .rb-footer { zoom: 1.3; }
html.rb-a11y-font-3 #rb-content, html.rb-a11y-font-3 #rb-front-page, html.rb-a11y-font-3 .rb-footer { zoom: 1.5; }

/* ── Mode: high contrast ────────────────────────────────────────────────── */

html.rb-a11y-contrast {
  --bg: #000;
  --surface: #000;
  --surface2: #0d0d0d;
  --text: #fff;
  --text-secondary: #f2f2f2;
  --text-muted: #d6d6d6;
  --border: rgba(255, 255, 255, 0.7);
  --accent: #d4ff3a;
  --accent-dim: rgba(212, 255, 58, 0.18);
  --accent-glow: rgba(212, 255, 58, 0.4);
}

html.rb-a11y-contrast #rb-grain,
html.rb-a11y-contrast .rb-shop-scan {
  display: none !important;
}

html.rb-a11y-contrast #rb-content a:not([class*="btn"]):not([class*="cta"]):not(.button),
html.rb-a11y-contrast .rb-footer a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

html.rb-a11y-contrast :focus-visible {
  outline: 4px solid #fff;
  box-shadow: 0 0 0 8px #000;
}

html.rb-a11y-contrast input,
html.rb-a11y-contrast select,
html.rb-a11y-contrast textarea {
  border-color: #fff !important;
}

/* ── Mode: readable font ────────────────────────────────────────────────── */

html.rb-a11y-readable {
  --font-display: 'DM Sans', Arial, sans-serif;
}

html.rb-a11y-readable body :not(.star-rating):not(.star-rating *):not([class*="icon"]):not(.dashicons) {
  font-family: 'DM Sans', Arial, sans-serif !important;
  letter-spacing: 0.01em !important;
}

html.rb-a11y-readable #rb-content,
html.rb-a11y-readable .rb-footer {
  line-height: 1.8;
}

html.rb-a11y-readable #rb-content :is(h1, h2, h3, h4, h5, h6) {
  text-transform: none !important;
  line-height: 1.2 !important;
}

/* ── Mode: highlight links ──────────────────────────────────────────────── */

html.rb-a11y-links #rb-content a,
html.rb-a11y-links #rb-front-page a,
html.rb-a11y-links .rb-footer a,
html.rb-a11y-links .rb-nav a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 4px !important;
  outline: 1px dashed var(--accent);
  outline-offset: 2px;
}

/* ── Mode: stop animations ──────────────────────────────────────────────── */

html.rb-a11y-motion {
  scroll-behavior: auto !important;
  scroll-snap-type: none !important;
}

html.rb-a11y-motion *,
html.rb-a11y-motion *::before,
html.rb-a11y-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

html.rb-a11y-motion .reveal,
html.rb-a11y-motion .hero-reveal,
html.rb-a11y-motion [data-animate] {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}

html.rb-a11y-motion #rb-grain,
html.rb-a11y-motion .rb-shop-scan,
html.rb-a11y-motion #rb-canvas-wrap,
html.rb-a11y-motion #rb-loader {
  display: none !important;
}
