/* =============================================================================
   SmartMBX Academy — Commerce theme
   Dark, near-black background with gold (#c9a227) accents. No frameworks.
   ============================================================================= */

:root {
  --bg: #0b0b0d;
  --panel: #15151a;
  --panel-2: #1d1d24;
  --ink: #f2f2f0;
  --muted: #9a9aa2;
  --gold: #c9a227;
  --gold-soft: #e7cf7a;
  --line: #2a2a32;
  --ok: #4caf7d;
  --err: #e06a6a;
  --radius: 12px;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

/* =============================================================================
   THEME TOGGLE (base) — used on admin + blog pages (lib/view.php) which load
   only style.css. Wired by assets/theme.js via [data-theme-toggle]; the inner
   .theme-toggle-ico shows a CSS-drawn moon (dark active) and a sun when .is-light
   is added. Themeable via the vars; CSP-safe (class-driven only). The store layer
   (store.css) carries its own richer copy that wins where both are loaded.
   ============================================================================= */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0; cursor: pointer;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid rgba(201,162,39,.34);
  color: var(--ink);
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.theme-toggle:hover { background: rgba(201,162,39,.10); border-color: var(--gold-soft); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }
.theme-toggle-ico {
  display: block; width: 18px; height: 18px;
  background: var(--gold-soft);
  transition: background .2s ease;
  -webkit-mask: radial-gradient(circle at 67% 33%, transparent 52%, #000 53%) center / contain no-repeat;
          mask: radial-gradient(circle at 67% 33%, transparent 52%, #000 53%) center / contain no-repeat;
}
.theme-toggle-ico.is-light {
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 33%, transparent 34% 44%, #000 45% 50%, transparent 51%) center / contain no-repeat;
          mask: radial-gradient(circle at 50% 50%, #000 33%, transparent 34% 44%, #000 45% 50%, transparent 51%) center / contain no-repeat;
}
@media (prefers-reduced-motion: reduce) { .theme-toggle, .theme-toggle-ico { transition: none; } .theme-toggle:hover { transform: none; } }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { color: var(--gold); text-decoration: underline; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

main.wrap { padding-top: 28px; padding-bottom: 56px; }

/* ---- Header ---------------------------------------------------------------*/
.smbx-top {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #101014, #0b0b0d);
  position: sticky; top: 0; z-index: 10;
}
.smbx-top .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: .3px; color: var(--ink); }
.brand span { color: var(--gold); font-weight: 700; }
.brand:hover { text-decoration: none; }
.smbx-top nav a { margin-left: 22px; color: var(--muted); font-weight: 600; font-size: 15px; }
.smbx-top nav a:hover { color: var(--gold); text-decoration: none; }

/* ---- Footer ---------------------------------------------------------------*/
.smbx-foot {
  border-top: 1px solid var(--line);
  background: #0a0a0c;
  padding: 28px 0;
  color: var(--muted);
  font-size: 13px;
}
.smbx-foot .disclaimer { max-width: 760px; }
.smbx-foot .honest { color: var(--gold-soft); font-weight: 600; }
.smbx-foot .copy { color: #6a6a72; margin-top: 8px; }

/* ---- Headings -------------------------------------------------------------*/
h1 { font-size: 30px; margin: 6px 0 6px; letter-spacing: .2px; }
h2 { font-size: 22px; margin: 26px 0 12px; }
.lead { color: var(--muted); font-size: 17px; margin-top: 0; }

/* ---- Product grid ---------------------------------------------------------*/
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin-top: 22px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; flex-direction: column;
  position: relative;
}
.card.primary {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(201,162,39,.35), 0 14px 40px rgba(0,0,0,.4);
}
.card .badge {
  position: absolute; top: -11px; left: 22px;
  background: var(--gold); color: #1a1300;
  font-size: 12px; font-weight: 800; letter-spacing: .4px;
  padding: 3px 10px; border-radius: 999px; text-transform: uppercase;
}
.card h3 { margin: 4px 0 6px; font-size: 19px; }
.card .price { font-size: 30px; font-weight: 800; color: var(--gold); }
.card .price .cents { font-size: 16px; color: var(--muted); font-weight: 600; }
.card .save { color: var(--ok); font-size: 13px; font-weight: 700; margin-top: 2px; }
.card .desc { color: var(--muted); font-size: 14px; margin: 10px 0 16px; flex: 1; }
.card form { margin: 0; }

/* ---- Buttons --------------------------------------------------------------*/
.btn {
  display: inline-block; width: 100%;
  background: var(--gold); color: #1a1300;
  border: 0; border-radius: 10px;
  font-size: 15px; font-weight: 800; letter-spacing: .2px;
  padding: 12px 16px; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--gold-soft); text-decoration: none; color: #1a1300; }
.btn.secondary { background: transparent; color: var(--gold-soft); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--gold); color: var(--gold); }
.btn.danger { background: #3a1f1f; color: var(--err); border: 1px solid #5a2a2a; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { width: auto; }

/* ---- Forms ----------------------------------------------------------------*/
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 460px;
}
.panel.wide { max-width: 100%; }
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
input[type=text], input[type=email], input[type=password] {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--ink); border-radius: 9px; padding: 11px 12px; font-size: 15px;
}
input:focus { outline: none; border-color: var(--gold); }
.help { color: #6a6a72; font-size: 12px; margin-top: 6px; }
.form-actions { margin-top: 20px; }

/* ---- Notices --------------------------------------------------------------*/
.notice {
  border-radius: 10px; padding: 12px 14px; margin: 14px 0; font-size: 14px;
  border: 1px solid var(--line); background: var(--panel);
}
.notice.error { border-color: #5a2a2a; background: #2a1717; color: #f0b9b9; }
.notice.success { border-color: #2a5a3f; background: #16271f; color: #b9f0d3; }
.notice.info { border-color: #2a3a5a; background: #161d27; color: #b9d3f0; }

/* ---- BIG notice (prominent, friendly checkout/cart error) -----------------
   Used when a buyer needs to fix their selection. Base lives here in style.css
   so checkout.php (which loads only style.css) renders it; store.css layers a
   richer brand skin on top for the storefront/cart. CSP-safe: class-driven. */
.notice-big {
  display: flex; gap: 16px; align-items: flex-start;
  margin: 18px 0 22px; padding: 22px 24px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--panel);
}
.notice-big.error { border-color: #6a3030; background: #2a1717; }
.notice-big .nb-icon {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; line-height: 1;
  color: #2a1717; background: var(--gold-soft);
}
.notice-big .nb-body { min-width: 0; flex: 1 1 auto; }
.notice-big .nb-title {
  margin: 2px 0 6px; font-size: 22px; font-weight: 800; line-height: 1.2;
  color: #f7e6c8;
}
.notice-big .nb-text { margin: 0; font-size: 16px; line-height: 1.55; color: #e7c9c9; }
.notice-big .nb-text strong { color: #fff; }
.notice-big .nb-actions { margin: 16px 0 0; }
.notice-big .nb-btn { display: inline-block; width: auto; max-width: 280px; }

/* Narrow button utility (replaces an inline max-width; CSP-safe). */
.btn-narrow { display: inline-block; width: auto; max-width: 200px; }

/* ---- Tables (admin dashboards) -------------------------------------------*/
.table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tr:hover td { background: var(--panel-2); }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.tag.paid { background: #16271f; color: var(--ok); }
.tag.pending { background: #2a2417; color: var(--gold-soft); }
.tag.refunded, .tag.revoked { background: #2a1717; color: var(--err); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---- Stat cards -----------------------------------------------------------*/
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin: 18px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .n { font-size: 28px; font-weight: 800; color: var(--gold); }
.stat .l { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }

/* ---- Key reveal -----------------------------------------------------------*/
.keybox {
  font-family: ui-monospace, Consolas, monospace; font-size: 20px; font-weight: 700;
  letter-spacing: 1px; background: #1a1607; border: 1px solid var(--gold);
  border-radius: 10px; padding: 16px; text-align: center; color: var(--gold-soft);
  margin: 14px 0;
}

/* ---- Misc -----------------------------------------------------------------*/
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { height: 18px; }
.adminbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.adminbar nav a { margin-left: 18px; color: var(--muted); font-weight: 600; }
.adminbar nav a:hover { color: var(--gold); text-decoration: none; }

/* =============================================================================
   LIGHT THEME  ([data-theme="light"] on <html>, set by assets/theme.js)
   -----------------------------------------------------------------------------
   Ivory + warm gold "quiet-luxury daylight". Default stays DARK (the :root vars
   above); this block is an OPT-IN override applied only when the visitor (or
   their device on first visit) chooses light. Higher specificity than :root, so
   it wins cleanly. AA contrast: espresso ink (#211c16) on ivory; gold used for
   TEXT is the deep #9a7613, while the brighter --gold-soft is reserved for FILLS
   /accents. CSP-safe — pure class/attribute-scoped CSS, no inline anything.
   ============================================================================= */
[data-theme="light"] {
  --bg: #f6f1e7;        /* ivory page */
  --panel: #fffdf8;     /* card / panel — near-white warm */
  --panel-2: #f1ebdb;   /* sunk inputs / alt rows */
  --ink: #211c16;       /* espresso — primary text */
  --muted: #6b6457;     /* warm taupe — secondary text (AA on ivory) */
  --gold: #9a7613;      /* DEEP gold — safe as TEXT on light */
  --gold-soft: #c2a047; /* brighter gold — fills / accents only */
  --line: #e4ddcb;      /* warm hairline */
  --ok: #2e8b63;        /* deep green — readable on light */
  --err: #c0504e;       /* deep red — readable on light */
}

/* ---- Hardcoded dark surfaces re-skinned for light ------------------------ */
/* Header: swap the near-black gradient for a soft ivory glass bar. */
[data-theme="light"] .smbx-top {
  background: linear-gradient(180deg, #fffdf8, #f3eede);
}
/* Footer: warm parchment, espresso ink. */
[data-theme="light"] .smbx-foot { background: #f1ead9; }
[data-theme="light"] .smbx-foot .copy { color: #8a8170; }

/* Primary card glow: soften the heavy black drop-shadow to a warm whisper. */
[data-theme="light"] .card.primary {
  box-shadow: 0 0 0 1px rgba(154,118,19,.30), 0 14px 40px rgba(60,50,30,.12);
}
/* Gold badge / buttons keep gold FILLS but flip the ink text to deep espresso
   so the contrast reads on the lighter gold. */
[data-theme="light"] .card .badge { color: #2a2009; }
[data-theme="light"] .btn { color: #2a2009; }
[data-theme="light"] .btn:hover { color: #2a2009; }
[data-theme="light"] .btn.danger { background: #f6e3e1; color: #9c3b39; border-color: #e7c2c0; }

/* Notices: light tints of each state (the dark hexes go ivory). */
[data-theme="light"] .notice.error   { border-color: #e0b3b1; background: #fbecea; color: #8c2f2d; }
[data-theme="light"] .notice.success { border-color: #b6dcc6; background: #ecf6f0; color: #1f6b49; }
[data-theme="light"] .notice.info    { border-color: #bcd0e6; background: #eef3fa; color: #2c5680; }
[data-theme="light"] .notice-big.error { border-color: #e0b3b1; background: #fbecea; }
[data-theme="light"] .notice-big .nb-icon { color: #2a2009; background: var(--gold-soft); }
[data-theme="light"] .notice-big .nb-title { color: #5a3f12; }
[data-theme="light"] .notice-big .nb-text { color: #6b4a4a; }
[data-theme="light"] .notice-big .nb-text strong { color: #2a2009; }

/* Status tags: light tints. */
[data-theme="light"] .tag.paid { background: #ecf6f0; color: #1f6b49; }
[data-theme="light"] .tag.pending { background: #f6efd9; color: #6f5512; }
[data-theme="light"] .tag.refunded,
[data-theme="light"] .tag.revoked { background: #fbecea; color: #9c3b39; }

/* Key-reveal box: warm parchment with a deep-gold frame instead of near-black. */
[data-theme="light"] .keybox {
  background: #fbf3dd; border-color: var(--gold); color: #6f5512;
}

/* =============================================================================
   CSP-SAFE UTILITY CLASSES (replace former inline style="" on storefront pages)
   The strict commerce CSP (`style-src 'self'`) drops inline style="" attributes,
   so success.php / cancel.php constrain their CTA buttons via these classes
   instead of an inline max-width. Class-only → CSP-clean.
   ========================================================================== */
.btn-w220 { max-width: 220px; }
.btn-w240 { max-width: 240px; }

/* Standalone mini-pages (account/course.php locked + coming-soon fallbacks).
   These render OUTSIDE the normal chrome under the strict CSP, so they link
   style.css and use these classes instead of former inline body/heading styles. */
.course-gate {
  font-family: var(--font-ui, system-ui, "Segoe UI", Arial, sans-serif);
  max-width: 680px; margin: 0 auto; padding: 48px 40px; line-height: 1.6;
}
.course-gate h1 { color: var(--gold, #c9a227); margin: 0 0 12px; }
.course-gate a { color: var(--gold-soft, #e7cf7a); font-weight: 600; }
