/* ============================================================
   DigitalKiddo™ Maths — Dark Mode Theme
   ------------------------------------------------------------
   Activated by the `dark-mode` class on <html>, which
   assets/js/theme.js applies before first paint from the saved
   localStorage preference ('dk_dark_mode').

   Almost everything is themed by remapping the CSS custom
   properties defined in style.css — components keep using the
   same tokens (--surface, --light, --dark, --gray-*) and pick
   up the dark palette automatically. The rules further down are
   the small set of exceptions: hard-coded colours (mostly the
   chat UI) and elements that must NOT invert (dark text on the
   yellow accent, the already-dark footer, etc.).

   To add another theme later: add a new class + a file like
   this one that remaps the same tokens.
============================================================ */

/* --- 1. Token remaps ---------------------------------------- */
html.dark-mode {
  color-scheme: dark;              /* native controls, scrollbars */

  --light:      #131624;           /* page background */
  --surface:    #1e2235;           /* cards / panels / modals */
  --surface-2:  #181b2b;           /* soft gradient partner */
  --dark:       #edf0fb;           /* primary text (was near-black) */
  --gray-50:    #242940;
  --gray-100:   #272c44;           /* subtle fills, hover rows */
  --gray-200:   #363d5c;           /* borders, dividers, switch tracks */
  --gray-400:   #7e88ad;
  --gray-600:   #a9b2d0;           /* muted / secondary text */
  --shadow:     0 10px 40px rgba(0,0,0,0.45);
  --shadow-sm:  0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg:  0 20px 60px rgba(0,0,0,0.55);
}

/* --- 2. Global fixes ---------------------------------------- */
/* Some pages set a decorative light gradient on <body> in their own
   <style> block (e.g. payment-success). In dark mode, always use the
   dark page background. */
html.dark-mode body { background: var(--light); }

/* Form controls don't inherit body colour in every browser. */
html.dark-mode input,
html.dark-mode select,
html.dark-mode textarea {
  color: var(--dark);
}
html.dark-mode ::placeholder { color: var(--gray-400); }

/* --- 3. Keep-dark exceptions --------------------------------- */
/* Dark text must STAY dark on the yellow/orange accent. */
html.dark-mode .btn-accent,
html.dark-mode .badge-premium,
html.dark-mode .age-card .btn:hover {
  color: #2d3436;
}

/* Footer + comparison-table header are dark-on-purpose surfaces;
   --dark now maps to a light colour, so pin them. */
html.dark-mode footer { background: #0d0f1a; }
html.dark-mode .comparison-table thead tr th:first-child { background: #0d0f1a; }
/* Hover tints on comparison rows were light lavender. */
html.dark-mode .comparison-table tbody tr:not(.cat-row):hover td { background: rgba(108,99,255,0.12); }
html.dark-mode .comparison-table tbody tr:not(.cat-row):hover td:first-child { background: rgba(108,99,255,0.20); }

/* --- 4. Marketing / shared chrome ---------------------------- */
/* Frosted navbar on scroll — dark glass instead of white glass. */
html.dark-mode .navbar.scrolled {
  background: rgba(19,22,36,0.85);
}
/* Decorative pricing blob was a pale lavender disc. */
html.dark-mode .bp-blob-2 { background: rgba(108,99,255,0.22); }

/* Featured pricing card was a white→lavender gradient. */
html.dark-mode .pricing-card.featured {
  background: linear-gradient(160deg, rgba(108,99,255,0.16) 0%, var(--surface) 55%);
}

/* Video Academy pastel badges. */
html.dark-mode .va-badge[data-kind="recommended"] { background: rgba(255,217,61,0.18); color: #ffd93d; }
html.dark-mode .va-badge[data-kind="popular"]     { background: rgba(255,107,107,0.18); color: #ff8e8e; }

/* --- 5. Kiddo Coach chat (hard-coded palette in chat.css) ---- */
html.dark-mode .chat-page { background: var(--light); }
html.dark-mode .chat-topbar,
html.dark-mode .chat-chips-bar,
html.dark-mode .chat-input-row {
  background: var(--surface);
  border-color: var(--gray-100);
}
html.dark-mode .chat-topbar-name { color: var(--dark); }
html.dark-mode .chat-back-btn { background: var(--gray-100); color: var(--dark); }
html.dark-mode .chat-back-btn:hover { background: var(--gray-200); }
html.dark-mode .chat-topbar-user { background: rgba(108,99,255,0.18); }
html.dark-mode .chat-bubble-avatar { background: var(--gray-100); }
html.dark-mode .ai-bubble {
  background: var(--surface);
  color: var(--dark);
  box-shadow: 0 1px 6px rgba(0,0,0,0.35);
}
html.dark-mode .chat-chips-hint { color: var(--gray-400); }
html.dark-mode .chat-chips-bar::after {
  background: linear-gradient(to right, rgba(30,34,53,0), var(--surface));
}
html.dark-mode .chat-input {
  background: var(--gray-100);
  border-color: var(--gray-200);
}
html.dark-mode .chat-input:focus { border-color: var(--primary); background: var(--gray-50); }
/* Quick-prompt chips: keep each category hue, move it onto a dark
   translucent fill so text stays readable. */
html.dark-mode .chat-chip   { background: rgba(108,99,255,0.16); border-color: #5a52d5; color: #b9b3ff; }
html.dark-mode .chip-help      { background: rgba(37,99,235,0.16);  border-color: #2563eb; color: #8db8ff; }
html.dark-mode .chip-practice  { background: rgba(21,146,78,0.16);  border-color: #15924e; color: #7fe0a9; }
html.dark-mode .chip-fractions { background: rgba(214,51,108,0.16); border-color: #d6336c; color: #ff9dc0; }
html.dark-mode .chip-challenge { background: rgba(217,130,0,0.16);  border-color: #d98200; color: #ffce85; }
html.dark-mode .chip-easier    { background: rgba(15,155,138,0.16); border-color: #0f9b8a; color: #8ce0d4; }
html.dark-mode .chip-fun       { background: rgba(122,63,240,0.16); border-color: #7a3ff0; color: #c9aeff; }
html.dark-mode .chip-test      { background: rgba(11,134,194,0.16); border-color: #0b86c2; color: #8ad4f5; }
html.dark-mode .chip-confused  { background: rgba(232,89,12,0.16);  border-color: #e8590c; color: #ffb98a; }
/* Desktop chat column. */
@media (min-width: 960px) {
  html.dark-mode .chat-page   { background: var(--surface-2); }
  html.dark-mode .chat-window { background: var(--light); }
  html.dark-mode .chat-chips-bar { background: var(--surface); }
  html.dark-mode .chat-chips-bar::after {
    background: linear-gradient(to right, rgba(30,34,53,0), var(--surface));
  }
}
