/* ==========================================================================
   tinkytown-demo Accessibility Panel — a11y-demo.css
   --------------------------------------------------------------------------
   Companion to js/a11y-demo.js. Styles the FAB + modal panel + motor
   feedback (scan-focus ring, dwell-arming fill, big-hit-targets). Self-
   contained — no overrides of styles.css selectors except the demo-tile
   visual feedback classes that motor mode adds dynamically.
   ========================================================================== */

/* ═══ AAA Preset cards + body-class effects (2026-05-04) ═══════════════
   Ports the WCAG 2.1 AAA preset cards from the web kiosk +
   AccessibilitySetupScreen on Android. Each card sets all relevant
   flags at once via a single tap. */
:root {
  --a11y-font-scale: 1;
}
.da11y-presets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.da11y-preset {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: inherit;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
  min-height: 84px;
}
.da11y-preset:hover { border-color: rgba(232,163,61,0.5); transform: translateY(-1px); }
.da11y-preset:active { transform: scale(0.98); }
.da11y-preset-active {
  border-color: #e8a33d;
  background: rgba(232,163,61,0.10);
}
.da11y-preset-emoji { font-size: 1.4rem; line-height: 1; }
.da11y-preset-title { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.01em; }
.da11y-preset-desc  { font-size: 0.72rem; opacity: 0.65; line-height: 1.25; }

/* ── Body-class effects driven by the preset / individual toggles ── */
body.a11y-high-contrast {
  background: #000 !important;
  color: #fff !important;
}
body.a11y-high-contrast .demo-tile,
body.a11y-high-contrast .kiosk-tile {
  background: #fff !important;
  color: #000 !important;
  border: 4px solid #fff !important;
}
body.a11y-high-contrast .sentence-bar.transcript {
  background: #000 !important;
  border-color: #fff !important;
}
body.a11y-high-contrast .sentence-bar.transcript .sentence-foreign,
body.a11y-high-contrast .sentence-bar.transcript .sentence-english,
body.a11y-high-contrast .sentence-bar.transcript .sentence-empty {
  color: #fff !important;
}

body.a11y-dyslexia {
  font-family: "OpenDyslexic", "Comic Sans MS", "General Sans", system-ui, sans-serif !important;
  letter-spacing: 0.04em !important;
  line-height: 1.55 !important;
}

body.a11y-dark-mode { /* placeholder — demo is dark by default */ }

body.big-hit-targets .demo-tile,
body.big-hit-targets .kiosk-tile,
body.big-hit-targets .demo-bottom-nav button,
body.big-hit-targets .sentence-listen-btn,
body.big-hit-targets .sentence-replay-btn {
  min-height: 52px !important;
  min-width:  52px !important;
}

/* Font-scale — applied via the --a11y-font-scale CSS var on :root. */
.demo-tile .tile-label,
.kiosk-tile .tile-label,
.sentence-bar.transcript .sentence-line,
.sentence-bar.transcript .sentence-empty {
  font-size: calc(1rem * var(--a11y-font-scale, 1));
}
.demo-tile .tile-sentence,
.kiosk-tile .tile-sentence {
  font-size: calc(0.85rem * var(--a11y-font-scale, 1));
}

/* ── FAB (top-right floating accessibility button) ─────────────────────── */
.demo-a11y-fab {
  position: fixed;
  top: max(14px, env(safe-area-inset-top, 14px));
  right: 14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45),
              0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  color: #fff;
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.18s ease;
}
.demo-a11y-fab svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}
.demo-a11y-fab:hover { transform: scale(1.06); }
.demo-a11y-fab:active { transform: scale(0.95); }
.demo-a11y-fab:focus-visible {
  outline: 3px solid #e8a33d;
  outline-offset: 3px;
}

/* ── Modal overlay + panel ─────────────────────────────────────────────── */
.demo-a11y-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: da11yFadeIn 0.18s ease;
}
@keyframes da11yFadeIn { from { opacity: 0; } to { opacity: 1; } }

.demo-a11y-panel {
  background: #1a1612;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: da11yPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes da11yPop {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.da11y-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.da11y-head h2 {
  margin: 0;
  font-size: 1.4rem;
  color: #e8a33d;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.da11y-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.da11y-close:hover  { background: rgba(255, 255, 255, 0.14); }
.da11y-close:focus-visible {
  outline: 3px solid #e8a33d;
  outline-offset: 2px;
}

.da11y-sub {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
}

.da11y-section { margin: 18px 0; }
.da11y-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 700;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.da11y-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.da11y-pill {
  flex: 1 1 0;
  min-width: 60px;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, transform 0.08s ease;
}
.da11y-pill:hover  { background: rgba(255, 255, 255, 0.09); }
.da11y-pill:active { transform: scale(0.97); }
.da11y-pill.is-on {
  background: #e8a33d;
  color: #1a1612;
  border-color: #e8a33d;
}
.da11y-pill:focus-visible {
  outline: 3px solid #e8a33d;
  outline-offset: 2px;
}

.da11y-range-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 12px;
  margin-bottom: 6px;
}
.da11y-range {
  width: 100%;
  height: 8px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
  margin-bottom: 6px;
}
.da11y-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e8a33d;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.da11y-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e8a33d;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.da11y-range:focus-visible { outline: 3px solid #e8a33d; }
.da11y-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 8px 0 0;
  line-height: 1.4;
}

/* ── Motor feedback applied to demo tiles ──────────────────────────────── */
/* Switch scan: highlight the tile currently under the scan cursor. */
body.switch-scan .demo-tile.scan-focus {
  outline: 4px solid #e8a33d !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 2px rgba(232, 163, 61, 0.4),
              0 0 24px rgba(232, 163, 61, 0.45) !important;
  position: relative;
  z-index: 2;
}
/* Dwell click: arming ring fills over --dwell-ms then auto-clicks. */
body.dwell-click .demo-tile.dwell-arming {
  position: relative;
  outline: 3px solid rgba(232, 163, 61, 0.55);
  outline-offset: 2px;
}
body.dwell-click .demo-tile.dwell-arming::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 22px;
  pointer-events: none;
  background: conic-gradient(from 0deg, #e8a33d 0%, transparent 0%);
  animation: da11yDwellFill var(--dwell-ms, 1500ms) linear forwards;
  opacity: 0.7;
  mix-blend-mode: screen;
}
@keyframes da11yDwellFill {
  to { background: conic-gradient(from 0deg, #e8a33d 100%, transparent 100%); }
}
/* Big hit targets: bump tile padding + min-height for users with motor
   issues (helps Parkinson's, ALS, post-stroke, MS hand tremor). */
body.big-hit-targets .demo-tile {
  min-height: 140px !important;
}
body.big-hit-targets .demo-tile-emoji { font-size: 92px !important; }
body.big-hit-targets .demo-tile-label { font-size: 0.92rem !important; padding: 10px 6px !important; }

/* Hide the FAB when the demo's blocker overlay is active — the autoplay
   demo controls everything during step playback; the FAB would be a
   distraction and the panel changes would fight the demo's scripted UI. */
body.demo-running .demo-a11y-fab { display: none; }

/* Reduce-motion users: kill the spring + dwell animation. */
@media (prefers-reduced-motion: reduce) {
  .demo-a11y-overlay { animation: none; }
  .demo-a11y-panel   { animation: none; }
  .demo-a11y-fab     { transition: none; }
  body.dwell-click .demo-tile.dwell-arming::before { animation: none; }
}
