/* ==========================================================================
   Mammoth Club themes
   --------------------------------------------------------------------------
   How it works
   - The theme is the `data-theme` attribute on <html>. No attribute (or
     "light") is the original site, untouched: every rule below that restyles
     components is scoped to non-light themes.
   - A theme is ONLY a block of --mt-* tokens (section 1). Section 2 maps those
     tokens onto the existing --mc-* / --mammoth-* / --wb-* variables and the
     hard-coded colours in the Mammoth header, footer and public pages, so a
     new theme never needs to touch section 2.
   - Themes are registered in public/frontend/js/mammoth-theme.js.

   To add a theme
   1. Copy the TEMPLATE block in section 3, rename it, fill in every token.
   2. Add one entry to THEMES in mammoth-theme.js (id must match data-theme).
   ========================================================================== */

/* ---- 1. Theme tokens --------------------------------------------------- */

/* Dark: dark blue surfaces with white text. */
html[data-theme="dark"] {
  color-scheme: dark;

  --mt-bg: #0e0e1e;            /* page background */
  --mt-surface: #161629;       /* cards, panels, inputs */
  --mt-surface-2: #1e1e38;     /* raised / hovered / alternate rows */
  --mt-surface-3: #2a2a4a;     /* placeholders, image wells */
  --mt-nav-bg: #0a0a17;        /* header bar and menus */
  --mt-footer-bg: #080812;     /* footer */
  --mt-heading: #ffffff;       /* headings, strong text, outline buttons */
  --mt-text: #f4f7ff;          /* body text */
  --mt-text-2: #d3dcf3;        /* secondary text */
  --mt-text-muted: #9fb0d6;    /* captions, meta */
  --mt-border: rgba(255, 255, 255, .14);
  --mt-border-2: rgba(255, 255, 255, .28);
  --mt-accent: #f97316;        /* buttons, links on hover */
  --mt-accent-strong: #fb8a3c; /* accent text on dark */
  --mt-accent-soft: rgba(249, 115, 22, .16);
  --mt-accent-soft-border: rgba(249, 115, 22, .45);
  --mt-on-accent: #ffffff;     /* text on accent fills */
  --mt-code-bg: #080812;
  --mt-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

/* ---- 2. Token mapping (shared by every non-light theme) ---------------- */
/* `T` below = html[data-theme]:not([data-theme="light"]) */

/* Some page wrappers re-declare --mc-* locally, so map them there too. */
html[data-theme]:not([data-theme="light"]),
html[data-theme]:not([data-theme="light"]) .mammoth-editorial,
html[data-theme]:not([data-theme="light"]) .mammoth-courses-page {
  /* Shared Mammoth theme + page-builder variables */
  --mc-paper: var(--mt-surface);
  --mc-paper-2: var(--mt-surface-2);
  --mc-paper-3: var(--mt-surface-3);
  --mc-ink: var(--mt-text);
  --mc-ink-2: var(--mt-text-2);
  --mc-ink-3: var(--mt-text-muted);
  --mc-line: var(--mt-border);
  --mc-line-2: var(--mt-border-2);
  --mc-navy-800: var(--mt-heading);
  --mc-navy-050: var(--mt-surface-2);
  --mc-orange-050: var(--mt-accent-soft);
  --mc-orange-600: var(--mt-accent-strong);

  --wb-page-background: var(--mt-bg);
  --wb-surface: var(--mt-surface);
  --wb-muted-surface: var(--mt-surface-2);
  --wb-text: var(--mt-text);
  --wb-ink: var(--mt-text);
  --wb-muted: var(--mt-text-muted);
  --wb-muted-foreground: var(--mt-text-muted);
  --wb-border: var(--mt-border);
}

html[data-theme]:not([data-theme="light"]) body.website-builder-page { background: var(--mt-bg); color: var(--mt-text); }
html[data-theme]:not([data-theme="light"]) body.website-builder-page::before { opacity: .15; }
html[data-theme]:not([data-theme="light"]) .mammoth-theme { background: var(--mt-bg); color: var(--mt-text); }

/* Header and footer define their own copies of the variables on the element */
html[data-theme]:not([data-theme="light"]) .mammoth-chrome {
  --mammoth-ink: var(--mt-text);
  --mammoth-ink-2: var(--mt-text-2);
  --mammoth-ink-3: var(--mt-text-muted);
  --mammoth-line: var(--mt-border) !important;
  --mammoth-navy-800: var(--mt-heading);
  --mammoth-orange-050: var(--mt-accent-soft);
  --mammoth-orange-600: var(--mt-accent-strong);
  --mammoth-paper-2: var(--mt-surface-2);
  --mammoth-nav-bg: var(--mt-nav-bg) !important;
  --mammoth-nav-fg: var(--mt-text) !important;
  --mammoth-nav-link: var(--mt-text) !important;
}
html[data-theme]:not([data-theme="light"]) .mammoth-footer { --mammoth-footer-bg: var(--mt-footer-bg) !important; }

/* Header: bars, menus, dropdowns */
html[data-theme]:not([data-theme="light"]) .mammoth-logo,
html[data-theme]:not([data-theme="light"]) .mammoth-nav-links,
html[data-theme]:not([data-theme="light"]) .mammoth-login,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-menu,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-link { color: var(--mt-text); }

html[data-theme]:not([data-theme="light"]) .mammoth-nav-links a:hover,
html[data-theme]:not([data-theme="light"]) .mammoth-login:hover { color: var(--mt-accent-strong); }

html[data-theme]:not([data-theme="light"]) .mammoth-nav,
html[data-theme]:not([data-theme="light"]) .mammoth-submenu,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-menu,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-top,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-langs { background: var(--mt-nav-bg); }

html[data-theme]:not([data-theme="light"]) .mammoth-megamenu,
html[data-theme]:not([data-theme="light"]) .mammoth-mega-side { background: var(--mt-surface); }

html[data-theme]:not([data-theme="light"]) .mammoth-mega-main,
html[data-theme]:not([data-theme="light"]) .mammoth-mega-tile,
html[data-theme]:not([data-theme="light"]) .mammoth-icon-button,
html[data-theme]:not([data-theme="light"]) .mammoth-language summary,
html[data-theme]:not([data-theme="light"]) .mammoth-menu-toggle,
html[data-theme]:not([data-theme="light"]) .mammoth-dropdown { background: var(--mt-surface); color: var(--mt-text); }

html[data-theme]:not([data-theme="light"]) .mammoth-mega-side-item:hover,
html[data-theme]:not([data-theme="light"]) .mammoth-mega-side-item.is-active,
html[data-theme]:not([data-theme="light"]) .mammoth-submenu a:hover,
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-langs button:hover { background: var(--mt-surface-2); }

html[data-theme]:not([data-theme="light"]) .mammoth-mark { background: #1e3a8a; }
html[data-theme]:not([data-theme="light"]) .mammoth-mobile-langs button.is-active { background: var(--mt-accent); color: var(--mt-on-accent); }

/* Buttons */
html[data-theme]:not([data-theme="light"]) .mammoth-btn-outline { border-color: var(--mt-border-2); color: var(--mt-heading); }
html[data-theme]:not([data-theme="light"]) .mammoth-btn-outline:hover { background: var(--mt-heading); color: var(--mt-bg); }
html[data-theme]:not([data-theme="light"]) .mammoth-kicker { border-color: var(--mt-accent-soft-border); color: var(--mt-text); }

/* Page sections and cards that hard-code white */
html[data-theme]:not([data-theme="light"]) .mammoth-courses-hero {
  background: linear-gradient(180deg, var(--mt-bg) 0%, var(--mt-surface) 100%);
}
html[data-theme]:not([data-theme="light"]) .mammoth-search-row,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-hero,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-feature,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-article-section,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-article-card,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-recent,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-card,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-search,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-search-row input,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-filter-card,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list-card { background: var(--mt-surface); }

html[data-theme]:not([data-theme="light"]) .mammoth-blog-hero,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-article-section,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-recent { background: var(--mt-bg); }

html[data-theme]:not([data-theme="light"]) .mammoth-blog-hero-grid,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list-hero-panel {
  background: linear-gradient(135deg, var(--mt-surface), var(--mt-surface-2));
}

html[data-theme]:not([data-theme="light"]) .mammoth-blog-feature-media,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-card-media,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list-card-media {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0 6px, transparent 6px 12px),
    var(--mt-surface-3);
}

html[data-theme]:not([data-theme="light"]) .mammoth-blog-content pre { background: var(--mt-code-bg) !important; border-color: var(--mt-border-2); }
html[data-theme]:not([data-theme="light"]) .mammoth-blog-search-row input { color: var(--mt-text); border-color: var(--mt-border-2); }
html[data-theme]:not([data-theme="light"]) .mammoth-blog-search-row input::placeholder { color: var(--mt-text-muted); }
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list nav[aria-label] a[class*="bg-"],
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list nav[aria-label] a:hover {
  background: var(--mt-accent) !important;
  border-color: var(--mt-accent) !important;
}

/* Shadows read badly on dark surfaces */
html[data-theme]:not([data-theme="light"]) .mammoth-blog-card,
html[data-theme]:not([data-theme="light"]) .mammoth-blog-list-card,
html[data-theme]:not([data-theme="light"]) .mammoth-mega-tile,
html[data-theme]:not([data-theme="light"]) .mammoth-megamenu { box-shadow: var(--mt-shadow); }

/* Form fields and media anywhere on the public site */
html[data-theme]:not([data-theme="light"]) input, html[data-theme]:not([data-theme="light"]) select, html[data-theme]:not([data-theme="light"]) textarea {
  background-color: var(--mt-surface);
  color: var(--mt-text);
  border-color: var(--mt-border-2);
}
html[data-theme]:not([data-theme="light"]) ::placeholder { color: var(--mt-text-muted); }
html[data-theme]:not([data-theme="light"]) img { filter: brightness(.92); }
html[data-theme]:not([data-theme="light"]) .mammoth-logo-img,
html[data-theme]:not([data-theme="light"]) .mammoth-footer img { filter: none; }


/* Courses page and editorial pages hard-code white in their own inline styles */
html[data-theme]:not([data-theme="light"]) .mammoth-courses-page,
html[data-theme]:not([data-theme="light"]) .mammoth-stats-band,
html[data-theme]:not([data-theme="light"]) .mammoth-filter-opt .box,
html[data-theme]:not([data-theme="light"]) .mammoth-sort-label,
html[data-theme]:not([data-theme="light"]) .mammoth-chip,
html[data-theme]:not([data-theme="light"]) .mammoth-course,
html[data-theme]:not([data-theme="light"]) .mammoth-empty,
html[data-theme]:not([data-theme="light"]) .mammoth-filter-dismiss,
html[data-theme]:not([data-theme="light"]) .mammoth-filter-actions,
html[data-theme]:not([data-theme="light"]) .mammoth-filter-trigger,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-title,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-manifesto,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-band.white,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-card,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-cta,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-contact-panel,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-form-panel,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-field input,
html[data-theme]:not([data-theme="light"]) .mammoth-editorial .mc-field textarea {
  background: var(--mt-surface);
  color: var(--mt-text);
}
html[data-theme]:not([data-theme="light"]) .mammoth-courses-page { background: var(--mt-bg); }
html[data-theme]:not([data-theme="light"]) .mammoth-course .rate { background: var(--mt-surface-2); color: var(--mt-text); }
html[data-theme]:not([data-theme="light"]) .mammoth-course h3, html[data-theme]:not([data-theme="light"]) .mammoth-course h2 { color: var(--mt-heading); }


/* ---- Auto-adapt tags (set by mammoth-theme.js on elements that hard-code
   light colours; see the "Auto-adapt" comment there) ---------------------- */
html[data-theme]:not([data-theme="light"]) [data-mt-bg="1"] { background-color: var(--mt-surface) !important; }
html[data-theme]:not([data-theme="light"]) [data-mt-bg="2"] { background-color: var(--mt-surface-2) !important; }
html[data-theme]:not([data-theme="light"]) [data-mt-grad] { background-image: none !important; }
html[data-theme]:not([data-theme="light"]) [data-mt-fg="1"] { color: var(--mt-text) !important; }
html[data-theme]:not([data-theme="light"]) [data-mt-fg="2"] { color: var(--mt-text-muted) !important; }
html[data-theme]:not([data-theme="light"]) [data-mt-bd] { border-color: var(--mt-border) !important; }

/* ---- Theme switcher (rendered by mammoth-theme.js) --------------------- */
.mt-switcher { position: relative; display: inline-flex; }
.mt-switcher-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; cursor: pointer;
  border: 1px solid var(--mc-line, #e4e8f2); border-radius: 10px;
  background: var(--mc-paper, #fff); color: inherit;
}
.mt-switcher-btn:hover { border-color: var(--mc-orange, #f97316); }
.mt-switcher-btn svg { width: 20px; height: 20px; }
.mt-switcher-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; min-width: 160px;
  margin: 0; padding: 6px; list-style: none;
  border: 1px solid var(--mc-line, #e4e8f2); border-radius: 12px;
  background: var(--mc-paper, #fff); color: var(--mc-ink, #0b1220);
  box-shadow: 0 12px 32px rgba(8, 26, 66, .18);
}
.mt-switcher-menu[hidden] { display: none; }
.mt-switcher-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; color: inherit; font: inherit; font-size: 14px; text-align: left;
}
.mt-switcher-menu button:hover,
.mt-switcher-menu button[aria-checked="true"] { background: var(--mc-paper-3, #eef2fb); }
.mt-swatch { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .5); flex: none; }

/* ---- 3. TEMPLATE for a new theme (copy, rename, fill every token) ------ */
/*
html[data-theme="my-theme"] {
  color-scheme: light;            // or dark: controls native form controls and scrollbars
  --mt-bg: ;  --mt-surface: ;  --mt-surface-2: ;  --mt-surface-3: ;
  --mt-nav-bg: ;  --mt-footer-bg: ;
  --mt-heading: ;  --mt-text: ;  --mt-text-2: ;  --mt-text-muted: ;
  --mt-border: ;  --mt-border-2: ;
  --mt-accent: ;  --mt-accent-strong: ;  --mt-accent-soft: ;  --mt-accent-soft-border: ;
  --mt-on-accent: ;
  --mt-code-bg: ;  --mt-shadow: ;
}
*/
