/* ==========================================================================
   ACCESSIBILITY & MODALITY STYLES (Criterion 3.1 & 5.1)
   Supports:
   - Font scaling (large / xl)
   - Dyslexia-friendly wide letter/word/line spacing
   - High contrast mode
   - Read-only / No-audio mode captions
   - Strict keyboard focus rings (:focus-visible)
   ========================================================================== */

/* Focus rings for keyboard navigation */
:focus-visible {
  outline: 3px solid #0284C7 !important;
  outline-offset: 3px !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #0284C7 !important;
  outline-offset: 2px !important;
}

/* Font Scaling */
html.a11y-font-large {
  font-size: 118% !important;
}

html.a11y-font-xl {
  font-size: 135% !important;
}

/* Dyslexia-friendly Spacing */
html.a11y-spacing-wide body {
  letter-spacing: 0.05em !important;
  word-spacing: 0.15em !important;
  line-height: 1.8 !important;
}

html.a11y-spacing-wide p,
html.a11y-spacing-wide li,
html.a11y-spacing-wide span,
html.a11y-spacing-wide td {
  letter-spacing: 0.04em !important;
  line-height: 1.85 !important;
}

/* High Contrast Mode */
html.a11y-high-contrast {
  filter: contrast(125%);
}

html.a11y-high-contrast body {
  background: #000000 !important;
  color: #FFFFFF !important;
}

html.a11y-high-contrast .unit-split,
html.a11y-high-contrast .v2-panel,
html.a11y-high-contrast .card-front,
html.a11y-high-contrast .card-back,
html.a11y-high-contrast .wb-card,
html.a11y-high-contrast .a11y-modal-card {
  background: #111111 !important;
  color: #FFFFFF !important;
  border: 3px solid #FACC15 !important;
}

html.a11y-high-contrast a,
html.a11y-high-contrast button {
  color: #FACC15 !important;
}

html.a11y-high-contrast .cta.primary,
html.a11y-high-contrast .v1-link {
  background: #FACC15 !important;
  color: #000000 !important;
  border: 2px solid #FFFFFF !important;
}

/* Read-Only / No Audio Mode */
html.a11y-no-audio .audio-btn,
html.a11y-no-audio .clue-audio-btn,
html.a11y-no-audio .audio-chip-btn,
html.a11y-no-audio .audio-settings-bar {
  opacity: 0.45;
}

html.a11y-no-audio .lab-transcript-box,
html.a11y-no-audio .story-text-container {
  display: block !important;
}

/* Accessibility Modal Dialog */
.a11y-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.a11y-modal-card {
  background: #FFFDF9;
  border: 3.5px solid #0F172A;
  border-radius: 20px;
  box-shadow: 0 12px 0 0 #0F172A;
  width: 100%;
  max-width: 520px;
  padding: 28px;
  position: relative;
}

.a11y-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #E2E8F0;
}

.a11y-modal-header h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  color: #0F172A;
  margin: 0;
}

.a11y-close-btn {
  background: none;
  border: 2px solid #0F172A;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.a11y-option-group {
  margin-bottom: 18px;
}

.a11y-option-group label {
  display: block;
  font-size: 0.95rem;
  color: #0F172A;
  margin-bottom: 6px;
}

.a11y-select {
  width: 100%;
  padding: 10px 14px;
  border: 2.5px solid #0F172A;
  border-radius: 10px;
  background: #FFFFFF;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0F172A;
}

.a11y-modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

/* Morphological Salience Spans (Criterion 1.2) */
.morph-highlight {
  display: inline-block;
  font-weight: 700;
  border-radius: 4px;
  padding: 0 2px;
}

.morph-ing {
  color: #0284C7;
  border-bottom: 2.5px solid #0284C7;
  background: rgba(2, 132, 199, 0.08);
}

.morph-s {
  color: #EA580C;
  border-bottom: 2.5px solid #EA580C;
  background: rgba(234, 88, 12, 0.08);
}

.morph-ed {
  color: #16A34A;
  border-bottom: 2.5px solid #16A34A;
  background: rgba(22, 163, 74, 0.08);
}

.morph-be {
  color: #9333EA;
  border-bottom: 2.5px solid #9333EA;
  background: rgba(147, 51, 234, 0.08);
}

/* Tap-to-Gloss Inline Tooltip (Criterion 2.1) */
.gloss-term {
  border-bottom: 2px dashed #EA580C;
  cursor: pointer;
  background: rgba(254, 215, 170, 0.35);
  padding: 0 2px;
  border-radius: 3px;
  font-weight: 600;
  transition: background 0.15s;
}

.gloss-term:hover,
.gloss-term:focus {
  background: rgba(254, 215, 170, 0.8);
}

.gloss-popover {
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: #0F172A;
  color: #FFFFFF;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.88rem;
  line-height: 1.4;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 1000;
  pointer-events: auto;
}

.gloss-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #0F172A transparent transparent transparent;
}

.gloss-popover .gloss-greek {
  color: #FACC15;
  font-weight: 700;
  margin-left: 6px;
}

.gloss-popover .gloss-audio-btn {
  background: none;
  border: none;
  color: #FFFFFF;
  cursor: pointer;
  margin-left: 6px;
  font-size: 1rem;
}

/* Pragmatic Register Badge (Criterion 5.2) */
.register-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #F1F5F9;
  border: 1.5px solid #CBD5E1;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 12px;
}

/* Recognition-to-Recall Fading UI (Criterion 1.3) */
.quiz-mastery-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1.5px solid #0F172A;
  background: #FEF08A;
  color: #0F172A;
  margin-bottom: 12px;
}
.quiz-mastery-tag.level-0 { background: #E0E7FF; color: #3730A3; }
.quiz-mastery-tag.level-1 { background: #FEF08A; color: #854D0E; }
.quiz-mastery-tag.level-2 { background: #DCFCE7; color: #166534; }

.quiz-fading-box {
  width: 100%;
  max-width: 500px;
  margin: 16px auto;
  padding: 20px;
  background: #FFFFFF;
  border: 2.5px solid #0F172A;
  border-radius: 16px;
  box-shadow: 0 4px 0 0 #0F172A;
  text-align: center;
}

.quiz-fading-clue {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  letter-spacing: 0.25em;
  font-weight: 800;
  color: #0F172A;
  margin: 16px 0;
  padding: 12px;
  background: #F8FAFC;
  border: 2px dashed #CBD5E1;
  border-radius: 10px;
}

.quiz-fading-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 14px;
}

.quiz-fading-input {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 10px 14px;
  border: 2.5px solid #0F172A;
  border-radius: 10px;
  outline: none;
  width: 220px;
  text-align: center;
}

.quiz-fading-input:focus {
  border-color: #EA580C;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.25);
}

.quiz-fading-submit {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  padding: 10px 18px;
  border: 2.5px solid #0F172A;
  border-radius: 10px;
  background: #EA580C;
  color: #FFFFFF;
  cursor: pointer;
  box-shadow: 0 3px 0 0 #0F172A;
  transition: transform 0.1s ease;
}

.quiz-fading-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 #0F172A;
}

.quiz-fading-submit:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 0 #0F172A;
}
