/* ============================================================================
   FILE: pod-play-a11y.css
   PURPOSE: Baseline accessibility styling for Pods/Play (Chunk 4.3).
   Student-facing only — does not alter teacher views.
============================================================================ */

/* ---------- Text-to-speech speaker button (§1) ----------------------------- */

.tts-speak-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 0;
    width: 30px;
    height: 30px;
    border: 1.5px solid rgba(99, 102, 241, 0.35);
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    flex-shrink: 0;
    vertical-align: middle;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.tts-speak-btn:hover,
.tts-speak-btn:focus {
    background: rgba(99, 102, 241, 0.18);
    color: #4338ca;
    outline: none;
}

.tts-speak-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
}

.tts-speak-btn.tts-speaking {
    background: #6366f1;
    color: #fff;
    animation: tts-pulse 1.2s ease-in-out infinite;
}

@keyframes tts-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.6); }
    50%      { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

/* Loading state — brief (~1s) while we fetch the audio. Spinner icon
   replaces the speaker icon, and a subtle ring pulse signals activity
   without being distracting. */
.tts-speak-btn .tts-icon-loading { display: none; }
.tts-speak-btn.tts-loading .tts-icon-idle { display: none; }
.tts-speak-btn.tts-loading .tts-icon-loading { display: inline-block; }
.tts-speak-btn.tts-loading {
    background: rgba(99, 102, 241, 0.18);
    color: #4338ca;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

@media (prefers-reduced-motion: reduce) {
    .tts-speak-btn.tts-loading .tts-icon-loading {
        animation: none;
    }
}

/* Slide titles and question stems just need the speaker to ride next to
   the text. The previous `inline-flex; gap: 4px` layout turned every
   text node into a flex item, so any <mark> the highlighter inserted
   became its own flex item and inherited the 4px gap on each side
   (8px per mark, more with multiples) plus opportunistic row breaks
   from `flex-wrap: wrap`. Plain block flow + margin-left on the button
   gives the same visual result with zero impact on inline metrics, so
   highlighter <mark>s sit flush. */
.slide-title.tts-decorated .tts-speak-btn,
.activity-question.tts-decorated .tts-speak-btn,
.question-text.tts-decorated .tts-speak-btn,
.ep-question-number.tts-decorated .tts-speak-btn,
.ixl-question-text.tts-decorated .tts-speak-btn,
.hotspot-question-prompt h4.tts-decorated .tts-speak-btn,
.two-part-part-question.tts-decorated .tts-speak-btn {
    margin-left: 8px;
    vertical-align: middle;
}

/* Inline-choice sentence is a block with embedded <select> blanks; drop the
   speaker button at the end without disturbing sentence line-height. */
.inline-choice-sentence.tts-decorated .tts-speak-btn {
    margin-left: 8px;
    vertical-align: middle;
}

/* Answer-choice read-aloud — the speaker sits inline at the end of the option
   label. A smaller idle footprint keeps it from crowding the choice row, and
   shrink-0 stops the flexed `.option-text` from squashing it on long options. */
.option-text.tts-decorated .tts-speak-btn,
.ixl-option-text.tts-decorated .tts-speak-btn,
.ep-option-text.tts-decorated .tts-speak-btn,
.ixl-match-item.tts-decorated .tts-speak-btn,
.ep-match-item.tts-decorated .tts-speak-btn,
.form-check-label.tts-decorated .tts-speak-btn,
.engage-option.tts-decorated .tts-speak-btn {
    margin-left: 6px;
    vertical-align: middle;
    flex: 0 0 auto;
}

.content-point.tts-decorated {
    /* keep flex-start alignment so the speaker lines up with the first row */
    align-items: flex-start;
}

.content-point.tts-decorated .tts-speak-btn {
    align-self: center;
    margin-top: 2px;
}

[data-theme="dark"] .tts-speak-btn {
    background: rgba(129, 140, 248, 0.15);
    border-color: rgba(129, 140, 248, 0.45);
    color: #c7d2fe;
}

[data-theme="dark"] .tts-speak-btn:hover,
[data-theme="dark"] .tts-speak-btn:focus {
    background: rgba(129, 140, 248, 0.28);
    color: #fff;
}

/* Respect reduced-motion users — skip the pulse animation. */
@media (prefers-reduced-motion: reduce) {
    .tts-speak-btn.tts-speaking {
        animation: none;
    }
}

/* Toast for TTS errors / cap-exceeded notices (Bug 3b) */
.tts-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    background: #374151;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    max-width: 90vw;
    text-align: center;
}
.tts-toast.tts-toast-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.tts-toast-warn  { background: #b45309; }
.tts-toast-error { background: #b91c1c; }
.tts-toast-info  { background: #1e40af; }

/* ---------- Font-size toggle (§3) ----------------------------------------- */
/* The JS module sets --student-font-scale on <html>. We scale the ROOT
   font-size rather than individual selectors so every `rem` unit — including
   the inline style="font-size: 1.1rem" attributes that BuildContentHtml emits
   server-side — scales automatically. Inline styles win on specificity and
   would have overridden any per-selector rule we set here.
   Scale defaults to 1 so unscoped pages and teacher views are unaffected.
   Touch targets (buttons, pills, icons) expand alongside text — deliberate
   a11y win for motor-impaired students.

   Opt-in via [data-student-font-scale] on <html> (Play.cshtml renders it;
   applyFontScale sets it too). A bare `html` rule here overrode the root size
   of any other page that loads this sheet — Daily Review sits in the portal,
   whose site.css sets 14px on phones, and would have been blown up to 16px. */

:root {
    --student-font-scale: 1;
}

html[data-student-font-scale] {
    font-size: calc(100% * var(--student-font-scale));
}

.text-size-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-radius: 22px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.text-size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #4338ca;
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.text-size-btn:hover { background: rgba(99, 102, 241, 0.18); }
.text-size-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
}
.text-size-btn[disabled] {
    opacity: 0.35;
    cursor: not-allowed;
}
.text-size-btn sup {
    font-size: 0.7em;
    margin-left: 1px;
}

.text-size-label {
    min-width: 44px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #4338ca;
    font-family: var(--bs-font-monospace, monospace);
}

[data-theme="dark"] .text-size-toggle {
    background: rgba(129, 140, 248, 0.18);
    border-color: rgba(129, 140, 248, 0.35);
}
[data-theme="dark"] .text-size-btn { color: #c7d2fe; }
[data-theme="dark"] .text-size-btn:hover { background: rgba(129, 140, 248, 0.28); }
[data-theme="dark"] .text-size-label { color: #c7d2fe; }

/* Small screens: shrink the toggle, keep buttons tappable (44px minimum hit
   area is preserved via padding on the wrapper). */
@media (max-width: 640px) {
    .text-size-label { display: none; }
    .text-size-toggle { padding: 2px 4px; }
}

/* ---------- Focus rings (§4) ---------------------------------------------- */
/* Global visible focus indicator on every interactive student element. Uses
   :focus-visible so mouse users don't see focus halos on click; only
   keyboard users (Tab, Shift+Tab, Enter/Space) get the ring. Covers both
   native controls and the promoted role="button" divs. */

.pod-content button:focus-visible,
.pod-content a:focus-visible,
.pod-content input:focus-visible,
.pod-content select:focus-visible,
.pod-content textarea:focus-visible,
.pod-content [role="button"]:focus-visible,
.pod-content [role="checkbox"]:focus-visible,
.pod-content [tabindex="0"]:focus-visible,
.pod-header button:focus-visible,
.pod-nav button:focus-visible,
.multiselect-option:focus-visible,
.hotspot-zone:focus-visible,
.ixl-match-item:focus-visible,
.ep-match-item:focus-visible,
.dip-word-chip:focus-visible,
.dip-drop-zone:focus-visible,
.categorization-item:focus-visible,
.categorization-bucket:focus-visible,
.inline-choice-select:focus-visible,
.short-answer-input:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.25);
    border-radius: 8px;
}

/* Hotspot zones are absolutely-positioned overlays and already have their
   own border-radius; keep outline tight against the zone outline. */
.hotspot-zone:focus-visible {
    outline-offset: 0;
    z-index: 30;
}

/* Skip the ring when the user prefers reduced motion AND it isn't needed —
   keeping the focus ring itself, just no pulsing/animation. */
@media (prefers-reduced-motion: reduce) {
    .pod-content [tabindex="0"]:focus-visible { transition: none; }
}

/* ---------- Word-sync TTS highlight (Prompt 4) ---------------------------- */
/* Each word is wrapped in a .tts-word span during playback. The .active
   class follows the currentTime cursor; cleanup on ended/pause/error
   restores the original DOM so the speaker button (whose click listener
   was preserved as a node reference) keeps working. */
.tts-word {
    transition: background-color 120ms ease, color 120ms ease;
    border-radius: 3px;
    padding: 0 2px;
}
.tts-word.active {
    background-color: var(--cc-cyan, #00e676);
    color: var(--cc-bg-card, #0a0e27);
    font-weight: 600;
    /* Lift above .color-overlay (z-index: 9999) so the active word stays
       readable when a tint is on. Without an own stacking context the cyan
       chip gets washed out by the overlay sitting on top of the document. */
    position: relative;
    z-index: 10000;
}
@media (prefers-reduced-motion: reduce) {
    .tts-word { transition: none; }
}

/* ---------- Answer Eliminator (Prompt 5 §1) ------------------------------- */
/* Reserve a right-hand gutter on options that carry an eliminator so the ×
   sits in its own space instead of overlapping the selection circle (which is
   the right-most item of the option's inner flex row). The class is added by
   injectEliminatorButtons() and survives pod-play.js's innerHTML rewrites. */
.multiselect-option.has-eliminator,
.ixl-option.has-eliminator,
.two-part-option.has-eliminator,
.ep-option.has-eliminator,
.ms-option.has-eliminator {
    padding-right: 36px;
}
.choice-eliminator-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--cc-text-muted, #6b7280);
    color: var(--cc-text-muted, #6b7280);
    width: 22px; height: 22px;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 120ms ease, color 120ms ease, border-color 120ms ease;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem;
    padding: 0; line-height: 1;
    z-index: 5;
    /* Ensure clicks always reach the eliminator even if the option toggles
       pointer-events on selection. */
    pointer-events: auto !important;
}
.choice-eliminator-btn:hover,
.choice-eliminator-btn:focus-visible {
    opacity: 1;
    color: var(--cc-cyan, #00e676);
    border-color: var(--cc-cyan, #00e676);
    outline: none;
}

/* The choice-option's own selected/hover styles use the same properties we
   want to flip when eliminated. !important keeps the eliminated state
   visible regardless of how the choice's CSS evolves. */
.multiselect-option.choice-eliminated,
.ixl-option.choice-eliminated,
.choice-eliminated {
    text-decoration: line-through !important;
    opacity: 0.4 !important;
    color: var(--cc-text-muted, #6b7280) !important;
    border-color: var(--cc-text-muted, #6b7280) !important;
    background-color: transparent !important;
}
/* Strike-through on inner content too — many options nest their text in a
   child span/label, and inheritance of text-decoration is unreliable. */
.choice-eliminated * {
    text-decoration: line-through !important;
}
.choice-eliminated .choice-eliminator-btn {
    opacity: 0.95 !important;
    color: var(--cc-cyan, #00e676) !important;
    border-color: var(--cc-cyan, #00e676) !important;
    /* The × itself must not be struck through — that's our toggle. */
    text-decoration: none !important;
}

/* ---------- Reduced Answer Choices (server-applied) ----------------------- */
/* Reuses the .choice-eliminated visual so a struck choice reads the same
   whether the student crossed it out or the accommodation did. The difference
   is that this one is LOCKED: the server ships it with no onclick, JS refuses
   to select it, no × is injected, and pointer-events seals the rest. */
.choice-auto-eliminated {
    pointer-events: none !important;
    cursor: default !important;
}

/* Named so the student understands the choice was taken off the table for
   them, rather than assuming they struck it by accident. Scoped under
   .choice-eliminated to out-specify the `.choice-eliminated *` line-through. */
.choice-eliminated .auto-eliminated-badge,
.auto-eliminated-badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--cc-text-muted, #6b7280);
    color: #fff;
    opacity: 0.85;
    text-decoration: none !important;
}

/* ---------- Highlighter (Prompt 5 §2) ------------------------------------- */
/* Layout-neutral by design. Bootstrap 5.3's reboot ships
   `mark, .mark { padding: 0.2em; background: #fcf8e3; }` which adds ~4–5px
   on every side of every mark — accumulates fast on long passages and pushes
   lines past their wrap point ("massive gaps / new rows"). We pin padding
   AND margin to 0 with !important so neither Bootstrap nor a future
   theme/skin override can shift inline metrics, then layer our own
   background. No border-radius / box-shadow either — those don't change
   metrics but blur the edge, which read as visual noise on dense text. */
mark.user-highlight {
    background-color: rgba(255, 235, 59, 0.4) !important;
    color: inherit !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    line-height: inherit !important;
    cursor: pointer;
}

/* Generic "on" state for accessibility toolbar toggles (Highlighter +
   Color Overlay). The existing .sound-toggle class handles base styling;
   this adds the cyan-active state without conflicting with the mute
   button's own .sound-on / .sound-off class swap. */
.sound-toggle.a11y-toolbar-active,
.theme-toggle.a11y-toolbar-active {
    background-color: var(--cc-cyan, #00e676);
    color: var(--cc-bg-card, #0a0e27);
    border-color: var(--cc-cyan, #00e676);
}
/* Dark-theme override. pod-nebula-dark.css ships
   `html[data-theme="dark"] .sound-toggle { … }` at specificity (0,2,1),
   which beats the rule above (0,2,0) and forces the button to stay in
   its inactive dark style even when toggled on — students couldn't tell
   whether the highlighter / overlay was actually enabled. Matching the
   theme's `(0,2,1)` selector here puts us back in the cascade with the
   `sound-on` palette (cyan ring + cyan fill) used elsewhere in dark mode. */
html[data-theme="dark"] .sound-toggle.a11y-toolbar-active,
html[data-theme="dark"] .theme-toggle.a11y-toolbar-active {
    background-color: #00e0ff;
    color: #151515;
    border-color: #00e0ff;
    box-shadow: 0 0 8px rgba(0, 224, 255, 0.35);
}

/* Hint ring for a granted tool the student has never chosen either way.
   The overlay no longer switches itself on, so this is what makes the tool
   findable: a quiet outline on the button rather than a tinted screen. It is
   removed on the first tap (on OR off), so it never becomes a nag. Not the
   active palette above — "available" must not read as "running". */
.sound-toggle.a11y-toolbar-hint,
.theme-toggle.a11y-toolbar-hint {
    border-color: rgba(255, 235, 130, 0.55);
    box-shadow: 0 0 0 2px rgba(255, 235, 130, 0.18);
}
html[data-theme="dark"] .sound-toggle.a11y-toolbar-hint,
html[data-theme="dark"] .theme-toggle.a11y-toolbar-hint {
    border-color: rgba(255, 235, 130, 0.5);
    box-shadow: 0 0 0 2px rgba(255, 235, 130, 0.14);
}

/* The same two states for a host page's toolbar buttons (Daily Review), which
   are Bootstrap buttons rather than the player's .sound-toggle. !important
   because Bootstrap's own :hover/:focus/.btn-outline-* colours would otherwise
   win back the "on" look the moment the button is touched. */
.a11y-tool-btn.a11y-toolbar-active {
    background-color: var(--cc-cyan, #00e676) !important;
    color: var(--cc-bg-card, #0a0e27) !important;
    border-color: var(--cc-cyan, #00e676) !important;
}
.a11y-tool-btn.a11y-toolbar-hint {
    border-color: rgba(234, 179, 8, 0.75);
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.2);
}

/* ---------- Color Overlay (Prompt 5 §3) ----------------------------------- */
/* Fixed full-viewport tint. pointer-events:none is REQUIRED so clicks pass
   through to the pod content underneath — without it, the overlay would
   eat every interaction.
   No mix-blend-mode: on the dark pod theme, `multiply` collapses yellow
   against near-black backgrounds into another near-black pixel — the tint
   becomes invisible. Plain alpha overlay reads clearly on both themes. */
.color-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
}
/* Opacity sits in the 0.15–0.20 range — comparable to clinical Irlen
   overlays. The previous 0.40–0.45 read as a heavy film over the screen
   rather than a subtle tint, and tipped cyan UI accents toward yellow-green. */
.color-overlay.overlay-yellow { background: rgba(255, 235, 130, 0.18); }
.color-overlay.overlay-blue   { background: rgba(130, 180, 255, 0.16); }
.color-overlay.overlay-peach  { background: rgba(255, 200, 170, 0.18); }

/* ---------- Dyslexia-friendly font (universal toggle) --------------------- */
/* Zero-asset fallback: no OpenDyslexic webfont ships offline in this repo, so
   we swap the student reading surfaces to a legible SYSTEM stack. Comic Sans
   MS and Verdana have distinct, non-mirrored letterforms and open apertures
   that cut b/d/p/q confusion; the looser letter/word spacing + line-height
   carry much of the OpenDyslexic readability benefit on their own — a
   legitimate, evidence-based no-download option. Scoped to the four student
   content containers so icons, badges, and the toolbar keep their own type.
   Icons (<i>, .fa-*) and code (pre/code/kbd) are excluded so Font Awesome
   glyphs and monospaced samples stay intact. */
body.dyslexia-font #slideContent,
body.dyslexia-font #activityContent,
body.dyslexia-font #completionScreen,
body.dyslexia-font #masteryGateScreen {
    letter-spacing: 0.03em;
    word-spacing: 0.09em;
    line-height: 1.7;
}
body.dyslexia-font #slideContent *:not(i):not(pre):not(code):not(kbd):not([class*="fa-"]),
body.dyslexia-font #activityContent *:not(i):not(pre):not(code):not(kbd):not([class*="fa-"]),
body.dyslexia-font #completionScreen *:not(i):not(pre):not(code):not(kbd):not([class*="fa-"]),
body.dyslexia-font #masteryGateScreen *:not(i):not(pre):not(code):not(kbd):not([class*="fa-"]) {
    font-family: "Comic Sans MS", "Comic Neue", Verdana, sans-serif !important;
}
