/* Mathematics reader: palette and layout on top of the shared notes-slider component.
   Uses the exact same green theme as the Geography pages (see css/geography.css). */

/* ===== GREEN THEME (identical to geography.css) =====
   theme.css ships blue math variables; these pages use the shared site-wide
   green theme, so the actual --math-* values are redefined here. */
:root {
  --math-primary: #15803d;
  --math-secondary: #16a34a;
  --math-accent: #ff9800;
  --math-success: #4caf50;
  --math-warning: #ff5722;
  --math-success-bg: #4caf50;
  --math-warning-bg: #ff5722;
  --math-info: #0e9f86;
  --math-highlight: #e2f4e6;
  --math-background: #e9efe9;
  --math-card-bg: #ffffff;
  --math-card-alt: #f6fbf7;
  --math-border: #c5d8cb;
  --math-text: #263238;
  --math-text-light: #5c7268;

  /* Remap the blue/purple Math-Literacy component variables onto the green
     subject palette so formula/note/calc boxes and game cards stay green. */
  --math-teal: #0e9f86;
  --math-purple: #16a34a;
  --math-gradient-1: linear-gradient(135deg, #15803d, #16a34a);
  --math-gradient-5: linear-gradient(135deg, #0e9f86, #16a34a);
  --formula-border: #a7d8b6;
  --formula-display: linear-gradient(145deg, #e2f4e6, #c8e6c9);
  --formula-text: #1b5e20;
  --calc-box: linear-gradient(145deg, #e8f5e9, #c8e6c9);
  --calc-text: #1b5e20;
  --note-bg: var(--math-card-alt);
  --note-text: var(--math-text);

  /* Remap the remaining Math-Literacy component boxes onto green too:
     indigo component/scenario cards, purple data/pattern icons & badges,
     and the blue step/formula/game panels. */
  --math-gradient-4: linear-gradient(135deg, #15803d, #16a34a);
  --components-bg: linear-gradient(145deg, #e8f5e9, #c8e6c9);
  --component-name: #1b5e20;
  --scenario-bg: linear-gradient(145deg, #ffffff, #eef8f1);
  --scenario-desc: linear-gradient(145deg, #e2f4e6, #c8e6c9);
  --step-bg: linear-gradient(145deg, #ffffff, #eef8f1);
  --formula-bg: linear-gradient(145deg, #ffffff, #eef8f1);
  --game-bg: linear-gradient(145deg, #ffffff, #f2f8f4);
  --game-option: linear-gradient(135deg, #15803d, #16a34a);
  --data-card: linear-gradient(145deg, #ffffff, #eef8f1);
  --data-border: #a7d8b6;
  --data-heading: #1b5e20;
  --data-text: #2e7d32;
  --resource-card: linear-gradient(145deg, #ffffff, #eef8f1);
  --resource-border: #a7d8b6;
  --resource-heading: #1b5e20;
  --resource-text: #2e7d32;
  --framework-bg: linear-gradient(145deg, #ffffff, #eef8f1);
  --framework-border: #a7d8b6;
  --framework-heading: #1b5e20;
  --framework-text: #2e7d32;
  --prep-card: linear-gradient(145deg, #ffffff, #eef8f1);
  --prep-border: #a7d8b6;
  --prep-heading: #1b5e20;
  --prep-text: #2e7d32;
  --caps-bg: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  --selector-bg: #ffffff;

  --progress-track: #d9e8dc;
  --seq-tile: #5d6e66;
  --seq-tile-placed: #46574e;
  --text-primary: #263238;
  --text-secondary: #546e7a;
  --text-muted: #64748b;

  --primary: var(--math-primary);
  --secondary: var(--math-secondary);
  --accent: var(--math-accent);
  --highlight: #b55a3a;
  --success: var(--math-success);
  --warning: var(--math-warning);
  --dark: var(--math-text);
  --light: var(--math-card-alt);
  --border: var(--math-border);
  --card-bg: var(--math-card-bg);
  --summary-bg: linear-gradient(145deg, var(--math-primary), #1e5f50);
}

[data-theme="dark"] {
  --math-primary: #66d98f;
  --math-secondary: #2fd17d;
  --math-accent: #ffb74d;
  --math-success: #81c784;
  --math-warning: #ff8a65;
  --math-success-bg: #2e7d32;
  --math-warning-bg: #c62828;
  --math-info: #4dd0c2;
  --math-highlight: #1c3326;
  --math-background: #0e1812;
  --math-card-bg: #14241b;
  --math-card-alt: #1b2f24;
  --math-border: #3d5c4a;
  --math-text: #e8edf5;
  --math-text-light: #b6cbbc;

  /* Remap the blue/purple Math-Literacy component variables onto the green
     subject palette so formula/note/calc boxes and game cards stay green. */
  --math-teal: #4dd0c2;
  --math-purple: #2fd17d;
  --math-gradient-1: linear-gradient(135deg, #4ade80, #2fd17d);
  --math-gradient-5: linear-gradient(135deg, #4dd0c2, #4ade80);
  --formula-border: #3d5c4a;
  --formula-display: linear-gradient(145deg, #163c2b, #1b4a34);
  --formula-text: #a7f3c0;
  --calc-box: linear-gradient(145deg, #163c2b, #1b4a34);
  --calc-text: #a7f3c0;
  --note-bg: var(--math-card-alt);
  --note-text: var(--math-text);
  --math-gradient-4: linear-gradient(135deg, #4ade80, #2fd17d);
  --components-bg: linear-gradient(145deg, #163c2b, #1b4a34);
  --component-name: #a7f3c0;
  --scenario-bg: linear-gradient(145deg, #14241b, #1b2f24);
  --scenario-desc: linear-gradient(145deg, #1b2f24, #163c2b);
  --step-bg: linear-gradient(145deg, #14241b, #1b2f24);
  --formula-bg: linear-gradient(145deg, #14241b, #1b2f24);
  --game-bg: linear-gradient(145deg, #14241b, #1b2f24);
  --game-option: linear-gradient(135deg, #2fd17d, #16a34a);
  --data-card: linear-gradient(145deg, #14241b, #1b2f24);
  --data-border: #3d5c4a;
  --data-heading: #a7f3c0;
  --data-text: #b6cbbc;
  --resource-card: linear-gradient(145deg, #14241b, #1b2f24);
  --resource-border: #3d5c4a;
  --resource-heading: #a7f3c0;
  --resource-text: #b6cbbc;
  --framework-bg: linear-gradient(145deg, #14241b, #1b2f24);
  --framework-border: #3d5c4a;
  --framework-heading: #a7f3c0;
  --framework-text: #b6cbbc;
  --prep-card: linear-gradient(145deg, #14241b, #1b2f24);
  --prep-border: #3d5c4a;
  --prep-heading: #a7f3c0;
  --prep-text: #b6cbbc;
  --caps-bg: linear-gradient(135deg, #163c2b, #1b4a34);
  --selector-bg: #1b2f24;
  --progress-track: #4a6e57;
  --seq-tile: #3c5145;
  --seq-tile-placed: #2b3f33;
  --text-primary: #f0f4fa;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary: var(--math-primary);
  --secondary: var(--math-secondary);
  --accent: var(--math-accent);
  --highlight: #ff8a65;
  --success: var(--math-success);
  --warning: var(--math-warning);
  --dark: var(--math-text);
  --light: var(--math-card-alt);
  --border: var(--math-border);
  --card-bg: var(--math-card-bg);
  --summary-bg: linear-gradient(145deg, #1e5f50, #0f3d33);
}

/* The shell/header/progress chrome is intentionally left to the shared
   notes-slider.css defaults — the same green the Geography pages use. */

/* ---- Focus visibility ---- */
.mathematics-reader .notes-btn:focus-visible,
.mathematics-reader .flashcard:focus-visible .flashcard-face {
  outline-color: var(--math-secondary);
}
.mathematics-reader .quiz-item:focus-visible,
.mathematics-reader .blank-option:focus-visible,
.mathematics-reader .match-card:focus-visible,
.mathematics-reader .blank-opt:focus-visible,
.mathematics-reader .quiz-option:focus-visible,
.mathematics-reader .quiz-opt:focus-visible,
.mathematics-reader .prob-option:focus-visible,
.mathematics-reader .option-row:focus-visible {
  outline: 3px solid var(--math-secondary);
  outline-offset: 2px;
}

/* ---- Normal content flow inside a slide ---- */
.mathematics-reader .notes-slide-inner > section,
.mathematics-reader .notes-slide-inner > .subject-note-box {
  margin: 0;
}
.mathematics-reader .notes-slide-inner > .subject-note-box {
  display: block;
  width: 100%;
  box-sizing: border-box;
}
.mathematics-reader .notes-slide-inner > .subject-note-box p {
  max-width: none;
  line-height: 1.65;
}

/* ---- Quiz / game slides ---- */
.mathematics-reader .mathematics-game-slide .notes-slide-inner {
  display: grid;
  place-items: center;
}
.mathematics-reader .mathematics-game-slide .game-card,
.mathematics-reader .mathematics-game-slide .math-atp-question {
  width: min(100%, 820px);
  margin: 0;
}
.mathematics-reader .mathematics-game-slide .game-grid {
  width: min(100%, 820px);
  margin: 0;
}

/* ---- Tables keep their layout; the slide scrolls if a wide table is present ---- */
.mathematics-reader .notes-slide-inner .math-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin: 1rem 0;
}
.mathematics-reader .notes-slide-inner .math-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}
.mathematics-reader .notes-slide-inner .math-table-wrap :is(th, td) {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--math-border);
  text-align: left;
  color: var(--math-text);
}
.mathematics-reader .notes-slide-inner .math-table-wrap th {
  background: var(--math-highlight);
}

/* ---- Beyond-grade enrichment label (ATP alignment) ---- */
.atp-enrichment-note {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--math-highlight);
  border: 1px solid var(--math-border);
  border-left: 5px solid var(--math-accent);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}
.atp-enrichment-note .atp-enrichment-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--math-accent);
}
.atp-enrichment-note .atp-enrichment-icon svg {
  width: 20px;
  height: 20px;
}
.atp-enrichment-note p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--math-text);
}
.atp-enrichment-note strong {
  color: var(--math-text);
}

/* ---- Flashcards grow with longer answers ----
   The base notes-slider flashcard uses absolutely-positioned faces over a fixed
   280px box, which clips longer text. Overlap both faces in one grid cell (the
   same technique the ecosystems/life-sciences readers use) so the card height
   follows the taller face and the 3D flip keeps working. */
.mathematics-reader .flashcard {
  display: grid;
}
.mathematics-reader .flashcard-face {
  position: relative;
  grid-area: 1 / 1;
  min-height: 280px;
}
.mathematics-reader .flashcard-text {
  font-size: 1.05rem;
}

/* ---- Flashcard faces and deck controls are interactive as well ---- */
.main-content .flashcard-face {
  border: 2px solid #166534;
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 4px 0 #14532d,
    0 10px 24px rgba(22, 101, 52, 0.18);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.main-content .flashcard:hover .flashcard-face {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 5px 0 #14532d,
    0 13px 28px rgba(22, 101, 52, 0.22);
}

.main-content .flashcard:focus-visible .flashcard-face {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
}

.main-content .flashcard-controls button.geo-check-btn {
  box-sizing: border-box;
  min-height: 40px;
  padding: 0.45rem 0.75rem;
  border: 2px solid #166534;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 3px 0 #14532d,
    0 6px 12px rgba(22, 101, 52, 0.16);
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    box-shadow 0.18s ease;
}

.main-content .flashcard-controls button.geo-check-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 5px 0 #14532d,
    0 8px 14px rgba(22, 101, 52, 0.18);
}

.main-content .flashcard-controls button.geo-check-btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18);
}

.main-content .flashcard-controls button.geo-check-btn:focus-visible {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
}

[data-theme="dark"] .main-content .flashcard-face {
  border-color: #d1d5db;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 4px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 8px 20px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .main-content .flashcard:hover .flashcard-face {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 5px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.28),
    0 11px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .main-content .flashcard:focus-visible .flashcard-face {
  outline-color: #f3f4f6;
}

[data-theme="dark"] .main-content .flashcard-controls button.geo-check-btn {
  border-color: #d1d5db !important;
  background: #27312b !important;
  color: #f3f4f6 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 3px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 5px 10px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .main-content .flashcard-controls button.geo-check-btn:hover:not(:disabled) {
  background: #3a4740 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.28),
    0 7px 12px rgba(0, 0, 0, 0.6) !important;
}

[data-theme="dark"] .main-content .flashcard-controls button.geo-check-btn:disabled {
  border-color: #8d9991 !important;
  background: #202923 !important;
  color: #aeb8b1 !important;
  box-shadow: 0 2px 0 #050806 !important;
}

[data-theme="dark"] .main-content .flashcard-controls button.geo-check-btn:focus-visible {
  outline-color: #f3f4f6;
}

/* ---- Interactive controls use the shared raised subject-button treatment ---- */
.main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
) {
  box-sizing: border-box;
  min-height: 40px;
  border: 2px solid #166534;
  border-radius: 10px;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 3px 0 #14532d,
    0 6px 12px rgba(22, 101, 52, 0.16);
  transition:
    transform 0.18s ease,
    filter 0.18s ease,
    box-shadow 0.18s ease;
}

.main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):is(:hover, :focus-visible):not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 5px 0 #14532d,
    0 8px 14px rgba(22, 101, 52, 0.18);
}

.main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.18);
}

.main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):focus-visible {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
}

[data-theme="dark"] .main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
) {
  border-color: #d1d5db !important;
  background: #27312b !important;
  color: #f3f4f6 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 3px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 5px 10px rgba(0, 0, 0, 0.5) !important;
}

[data-theme="dark"] .main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):is(:hover, :focus-visible):not(:disabled) {
  background: #3a4740 !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 4px 0 #050806,
    0 0 0 1px rgba(255, 255, 255, 0.28),
    0 7px 12px rgba(0, 0, 0, 0.6) !important;
}

[data-theme="dark"] .main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):disabled {
  border-color: #8d9991 !important;
  background: #202923 !important;
  color: #aeb8b1 !important;
  box-shadow: 0 2px 0 #050806 !important;
}

[data-theme="dark"] .main-content :is(
  button.btn-small,
  a.btn-small,
  button.btn-action,
  button.btn-complement,
  button.reset,
  button.reset-btn,
  button.explorer-tab,
  button.func-btn,
  button.scale-btn,
  button.ghost,
  button.check-btn,
  button.nav-btn,
  button.notes-btn,
  button.notes-toggle-btn,
  button:not([class])
):focus-visible {
  outline-color: #f3f4f6;
}

@media (max-width: 460px) {
  .main-content :is(
    button.btn-small,
    a.btn-small,
    button.btn-action,
    button.btn-complement,
    button.reset,
    button.reset-btn,
    button.explorer-tab,
    button.func-btn,
    button.scale-btn,
    button.ghost,
    button.check-btn,
    button.nav-btn,
    button.notes-btn,
    button:not([class])
  ) {
    min-height: 34px;
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
  }

  .main-content .flashcard-controls button.geo-check-btn {
    min-height: 34px;
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
  }
}
