/*!
 * sls-lang-widgets.css — styling for the Spanish/LOTE interaction widgets.
 *
 * Inherits the child theme's design tokens (--dark, --slate, --muted, --body-text,
 * --accent) with fallbacks, so it drops into the Nexus-variant theme without a
 * palette of its own. Nothing here is layout-critical: with the stylesheet absent
 * the widgets still render as legible, operable forms.
 *
 * Accessibility rules that are load-bearing, not decorative:
 *   - Correct/incorrect are never signalled by color alone; every state carries a
 *     text label and a left border weight change.
 *   - Focus rings are never removed. :focus-visible is thickened, not hidden.
 *   - Tap targets are >= 44px tall.
 *   - prefers-reduced-motion removes every transition and the shake animation.
 */

:root {
  --sls-lang-correct: #15803d;
  --sls-lang-almost: #b45309;
  --sls-lang-wrong: #b91c1c;
  --sls-lang-surface: rgba(15, 23, 42, 0.04);
  --sls-lang-border: rgba(15, 23, 42, 0.14);
  --sls-lang-radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sls-lang-correct: #4ade80;
    --sls-lang-almost: #fbbf24;
    --sls-lang-wrong: #f87171;
    --sls-lang-surface: rgba(255, 255, 255, 0.06);
    --sls-lang-border: rgba(255, 255, 255, 0.18);
  }
}

/* ── shared shell ───────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-wordbank,
#grit-lesson-wrapper .sls-listen-choose,
#grit-lesson-wrapper .sls-dictation,
#grit-lesson-wrapper .sls-speak,
#grit-lesson-wrapper .sls-matchpairs,
#grit-lesson-wrapper .sls-conjugation,
#grit-lesson-wrapper .sls-translate,
#grit-lesson-wrapper .sls-roleplay,
#grit-lesson-wrapper .sls-reading {
  position: relative;
  margin: 2.5rem 0;
  padding: 1.5rem 1.5rem 1.25rem;
  background: var(--sls-lang-surface);
  border: 1px solid var(--sls-lang-border);
  border-left: 4px solid var(--accent, #b45309);
  border-radius: var(--sls-lang-radius);
}

#grit-lesson-wrapper .sls-tag,
#grit-lesson-wrapper .sls-tf-tag,
#grit-lesson-wrapper .sls-cn-tag,
#grit-lesson-wrapper .sls-cando-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  margin-bottom: 0.5rem;
}

#grit-lesson-wrapper .sls-xp-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--accent, #b45309);
  color: #fff;
}

#grit-lesson-wrapper .sls-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Buttons: one base style, 44px minimum target. */
#grit-lesson-wrapper .sls-wb-tile,
#grit-lesson-wrapper .sls-lc-btn,
#grit-lesson-wrapper .sls-rd-btn,
#grit-lesson-wrapper .sls-mp-item,
#grit-lesson-wrapper .sls-tf-btn,
#grit-lesson-wrapper .sls-audio-btn,
#grit-lesson-wrapper .sls-accent-key,
#grit-lesson-wrapper .sls-wb-check,
#grit-lesson-wrapper .sls-wb-undo,
#grit-lesson-wrapper .sls-lc-check,
#grit-lesson-wrapper .sls-dict-check,
#grit-lesson-wrapper .sls-conj-check,
#grit-lesson-wrapper .sls-tr-check,
#grit-lesson-wrapper .sls-rp-start,
#grit-lesson-wrapper .sls-speak-rec,
#grit-lesson-wrapper .sls-speak-play {
  min-height: 44px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--dark, #0f172a);
  background: #fff;
  border: 1.5px solid var(--sls-lang-border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

@media (prefers-color-scheme: dark) {
  #grit-lesson-wrapper .sls-wb-tile,
  #grit-lesson-wrapper .sls-lc-btn,
  #grit-lesson-wrapper .sls-rd-btn,
  #grit-lesson-wrapper .sls-mp-item,
  #grit-lesson-wrapper .sls-audio-btn,
  #grit-lesson-wrapper .sls-accent-key {
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
  }
}

#grit-lesson-wrapper button:focus-visible,
#grit-lesson-wrapper input:focus-visible,
#grit-lesson-wrapper textarea:focus-visible,
#grit-lesson-wrapper summary:focus-visible {
  outline: 3px solid var(--accent, #b45309);
  outline-offset: 2px;
}

#grit-lesson-wrapper button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#grit-lesson-wrapper input[type="text"],
#grit-lesson-wrapper textarea {
  font: inherit;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  width: 100%;
  max-width: 32rem;
  color: var(--dark, #0f172a);
  background: #fff;
  border: 1.5px solid var(--sls-lang-border);
  border-radius: 10px;
}

/* ── result region ──────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-result {
  margin-top: 0.9rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
#grit-lesson-wrapper .sls-result:empty { display: none; }
#grit-lesson-wrapper .sls-result.is-correct { color: var(--sls-lang-correct); }
#grit-lesson-wrapper .sls-result.is-almost { color: var(--sls-lang-almost); }
#grit-lesson-wrapper .sls-result.is-incorrect { color: var(--sls-lang-wrong); }
#grit-lesson-wrapper .sls-result.is-progress { color: var(--muted, #64748b); }

#grit-lesson-wrapper .sls-target-reveal {
  display: inline-block;
  margin-top: 0.35rem;
  font-weight: 700;
}

/* ── audio cue ──────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-audio-cue { margin: 0.9rem 0; }
#grit-lesson-wrapper .sls-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}
#grit-lesson-wrapper .sls-audio-btn.is-loading { opacity: 0.6; }
#grit-lesson-wrapper .sls-audio-icon { font-size: 0.8rem; }
#grit-lesson-wrapper .sls-audio-transcript {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-audio-transcript summary { cursor: pointer; }

/* ── word bank ──────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-wb-answer {
  min-height: 3.2rem;
  margin: 0.9rem 0;
  padding: 0.6rem;
  border-bottom: 2px dashed var(--sls-lang-border);
}
#grit-lesson-wrapper .sls-wb-chip {
  display: inline-block;
  margin: 0.15rem 0.25rem;
  padding: 0.3rem 0.6rem;
  background: var(--accent, #b45309);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
}
#grit-lesson-wrapper .sls-wb-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
#grit-lesson-wrapper .sls-wb-tile.is-used {
  opacity: 0.3;
  pointer-events: none;
}
#grit-lesson-wrapper .sls-wb-actions {
  display: flex;
  gap: 0.6rem;
}

/* ── choice-style widgets ───────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-lc-options,
#grit-lesson-wrapper .sls-rd-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.9rem 0;
}
#grit-lesson-wrapper .sls-lc-btn,
#grit-lesson-wrapper .sls-rd-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  width: 100%;
}
#grit-lesson-wrapper .sls-lc-letter {
  flex: 0 0 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  border-radius: 50%;
  background: var(--sls-lang-border);
}
#grit-lesson-wrapper .sls-lc-btn.is-selected,
#grit-lesson-wrapper .sls-rd-btn.is-selected,
#grit-lesson-wrapper .sls-mp-item.is-selected {
  border-color: var(--accent, #b45309);
  border-width: 2.5px;
  background: rgba(180, 83, 9, 0.08);
}

/* ── dictation ──────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-accent-help {
  margin: 0.75rem 0;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-accent-help summary { cursor: pointer; }
#grit-lesson-wrapper .sls-accent-pad {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
#grit-lesson-wrapper .sls-accent-key {
  min-width: 44px;
  padding: 0.4rem 0.6rem;
  font-size: 1.05rem;
}
#grit-lesson-wrapper .sls-dict-check,
#grit-lesson-wrapper .sls-tr-check,
#grit-lesson-wrapper .sls-conj-check { margin-top: 0.9rem; }
#grit-lesson-wrapper .sls-hint {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted, #64748b);
}

/* ── speak and score ────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-speak-target {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0.75rem 0;
}
#grit-lesson-wrapper .sls-speak-controls {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
#grit-lesson-wrapper .sls-speak-rec {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
}
#grit-lesson-wrapper .sls-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--sls-lang-wrong);
}
#grit-lesson-wrapper .sls-speak-rec.is-recording .sls-rec-dot {
  animation: sls-pulse 1s infinite;
}
@keyframes sls-pulse { 50% { opacity: 0.25; } }
#grit-lesson-wrapper .sls-speak-help {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-score-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
  font-size: 0.85rem;
}
#grit-lesson-wrapper .sls-score-label { flex: 0 0 7rem; }
#grit-lesson-wrapper .sls-score-bar {
  flex: 1 1 auto;
  height: 8px;
  border-radius: 4px;
  background: var(--sls-lang-border);
  overflow: hidden;
}
#grit-lesson-wrapper .sls-score-bar > span {
  display: block;
  height: 100%;
  background: var(--sls-lang-correct);
}
#grit-lesson-wrapper .sls-score-val { flex: 0 0 2.5rem; text-align: right; font-weight: 700; }
#grit-lesson-wrapper .sls-score-note { margin-top: 0.6rem; font-size: 0.9rem; }

/* ── match pairs ────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-mp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.9rem 0;
}
#grit-lesson-wrapper .sls-mp-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#grit-lesson-wrapper .sls-mp-item { width: 100%; text-align: left; }
#grit-lesson-wrapper .sls-mp-item.is-matched {
  border-color: var(--sls-lang-correct);
  color: var(--sls-lang-correct);
  opacity: 0.65;
}
#grit-lesson-wrapper .sls-mp-item.is-wrong {
  border-color: var(--sls-lang-wrong);
  animation: sls-shake 0.3s;
}
@keyframes sls-shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ── conjugation ────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-conj-table {
  width: 100%;
  max-width: 32rem;
  border-collapse: collapse;
  margin: 0.9rem 0;
}
#grit-lesson-wrapper .sls-conj-table caption {
  text-align: left;
  font-weight: 800;
  font-style: italic;
  padding-bottom: 0.5rem;
}
#grit-lesson-wrapper .sls-conj-table th,
#grit-lesson-wrapper .sls-conj-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--sls-lang-border);
  text-align: left;
}
#grit-lesson-wrapper .sls-conj-table th { font-weight: 600; width: 45%; }
#grit-lesson-wrapper .sls-conj-input { max-width: 9rem; min-height: 40px; }
#grit-lesson-wrapper .sls-conj-input.is-correct { border-color: var(--sls-lang-correct); }
#grit-lesson-wrapper .sls-conj-input.is-almost { border-color: var(--sls-lang-almost); }
#grit-lesson-wrapper .sls-conj-input.is-incorrect { border-color: var(--sls-lang-wrong); }
#grit-lesson-wrapper .sls-conj-given { font-weight: 700; }
#grit-lesson-wrapper .sls-conj-note {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted, #64748b);
}

/* ── role-play ──────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-rp-opening {
  margin: 0.9rem 0;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--accent, #b45309);
  font-size: 1.05rem;
  font-style: italic;
}
#grit-lesson-wrapper .sls-rp-moves ul { margin: 0.4rem 0 0.9rem 1.25rem; }
#grit-lesson-wrapper .sls-rp-help {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-rp-transcript:empty { display: none; }
#grit-lesson-wrapper .sls-rp-line {
  margin: 0.4rem 0;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  max-width: 85%;
}
#grit-lesson-wrapper .sls-rp-siera {
  background: var(--sls-lang-border);
}
#grit-lesson-wrapper .sls-rp-you {
  margin-left: auto;
  background: var(--accent, #b45309);
  color: #fff;
}
#grit-lesson-wrapper .sls-rp-typed {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
#grit-lesson-wrapper .sls-rp-typed button {
  min-height: 44px;
  padding: 0.55rem 1rem;
  font: inherit;
  border: 1.5px solid var(--sls-lang-border);
  border-radius: 10px;
  cursor: pointer;
}

/* ── reading ────────────────────────────────────────────────────────────── */

#grit-lesson-wrapper .sls-rd-text {
  margin: 0.9rem 0;
  padding: 1rem 1.25rem;
  background: #fff;
  border-radius: 10px;
  font-size: 1.05rem;
  line-height: 1.7;
}
@media (prefers-color-scheme: dark) {
  #grit-lesson-wrapper .sls-rd-text { background: rgba(255, 255, 255, 0.05); }
}
#grit-lesson-wrapper .sls-rd-q {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--sls-lang-border);
}

/* ── can-do, culture note, standards footer ─────────────────────────────── */

#grit-lesson-wrapper .sls-cando {
  margin: 0 0 2rem;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--sls-lang-correct);
  background: var(--sls-lang-surface);
  border-radius: 0 var(--sls-lang-radius) var(--sls-lang-radius) 0;
}
#grit-lesson-wrapper .sls-cando-text {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
#grit-lesson-wrapper .sls-culture-note {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--sls-lang-surface);
  border: 1px dashed var(--sls-lang-border);
  border-radius: var(--sls-lang-radius);
}
#grit-lesson-wrapper .sls-culture-note h3 { margin-top: 0.25rem; }
#grit-lesson-wrapper .sls-standards-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--sls-lang-border);
  font-size: 0.8rem;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-rubric {
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
#grit-lesson-wrapper .sls-rubric ul { margin: 0.5rem 0 0 1.25rem; }
#grit-lesson-wrapper .sls-alt-input {
  margin-top: 0.9rem;
  font-size: 0.9rem;
}
#grit-lesson-wrapper .sls-alt-input summary {
  cursor: pointer;
  color: var(--muted, #64748b);
}
#grit-lesson-wrapper .sls-alt-input input { margin: 0.5rem 0; }

/* ── answered state ─────────────────────────────────────────────────────── */

#grit-lesson-wrapper .is-answered .sls-wb-pool,
#grit-lesson-wrapper .is-answered .sls-wb-actions,
#grit-lesson-wrapper .is-answered .sls-lc-check,
#grit-lesson-wrapper .is-answered .sls-dict-check,
#grit-lesson-wrapper .is-answered .sls-tr-check,
#grit-lesson-wrapper .is-answered .sls-conj-check {
  opacity: 0.4;
  pointer-events: none;
}

/* ── responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #grit-lesson-wrapper .sls-mp-grid { grid-template-columns: 1fr; }
  #grit-lesson-wrapper .sls-score-label { flex-basis: 5rem; }
  #grit-lesson-wrapper .sls-conj-table th { width: 50%; }
}

/* ── reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  #grit-lesson-wrapper * {
    animation: none !important;
    transition: none !important;
  }
}
