/*
 * bx-theme-v2-no2 — White & Red gradient theme
 * Clean white base with red gradient accents (inspired by index page)
 */

/* ── CSS VARIABLES ── */

/* ─────────────────────────────────────────────────────────────────────────────
 * TOKEN BRIDGE — every --theme-* name below is DERIVED from the six seeds
 * declared in layouts/main.ejs. Nothing here is a hardcoded colour any more,
 * so the Live Demo Customizer (and any future re-tone) drives the whole theme
 * by changing seeds alone, and all 47 page templates that read --theme-*
 * follow with no edit of their own.
 *
 * The --theme-* names are HISTORICAL and do not describe their values:
 *   --theme-gold     = the accent (red)     --theme-cyan  = deep crimson
 *   --theme-blue     = pink surface         --theme-navy-* = accent triplet
 * They are preserved deliberately — renaming them would touch every page.
 *
 * Alpha-only tints use color-mix(…, transparent); canvas-relative mixes anchor
 * on --seed-fg / --seed-canvas; accent-relative mixes may use literal
 * white/black (canvas-independent by design). See docs/THEME_COLOR_SYSTEM.md.
 * ───────────────────────────────────────────────────────────────────────── */
:root {
  /* Core backgrounds — white / light pink */
  /* Anchored on --elev-4, not on the bare canvas: mixed straight off --elev-0
     this lands within ~2% of a card and is not a step. Same repair as blue. */
  --theme-bg-deep:     color-mix(in srgb, var(--elev-4) 88%, var(--seed-accent));
  --theme-bg-main:     var(--elev-0);        /* page rung */
  /* Written as --elev-* and NOT as var(--bg-card) / var(--bg-input):
     partials/_theme-vars.ejs declares the REVERSE aliases on :root and is
     included after this file, so pointing back at them would close a
     two-node var() cycle and blank both names on every call site. */
  --theme-bg-card:     var(--elev-2);        /* card 6      (was ink-bright 97%) */
  --theme-bg-elevated: var(--elev-4);        /* elevated 11 (was bg-raised 96%) */
  --theme-bg-input:    var(--elev-input);    /* input 4.5   (was ink-bright 92%) */

  /* Primary accent — Red. Tracks --seed-accent. */
  --theme-gold:        var(--seed-accent);
  --theme-gold-bright: color-mix(in srgb, var(--seed-accent) 82%, white);
  --theme-gold-shine:  color-mix(in srgb, var(--seed-canvas) 84%, var(--seed-accent) 16%);
  --theme-gold-dim:    color-mix(in srgb, var(--seed-accent) 10%, transparent);
  --theme-gold-border: color-mix(in srgb, var(--seed-accent) 38%, transparent);
  --theme-gold-glow:   color-mix(in srgb, var(--seed-accent) 22%, transparent);

  /* Secondary accent — Deep crimson. Accent darkened, so it tracks a re-tone. */
  --theme-cyan:        color-mix(in srgb, var(--seed-accent) 62%, black);
  --theme-cyan-bright: color-mix(in srgb, var(--seed-accent) 82%, black);
  --theme-cyan-dim:    color-mix(in srgb, var(--theme-cyan) 7%, transparent);
  --theme-cyan-border: color-mix(in srgb, var(--theme-cyan) 22%, transparent);
  --theme-cyan-glow:   color-mix(in srgb, var(--theme-cyan) 18%, transparent);

  /* Neutral surface tone (pink wash over the canvas) */
  --theme-blue:        color-mix(in srgb, var(--seed-canvas) 90%, var(--seed-accent) 10%);
  --theme-blue-hover:  color-mix(in srgb, var(--seed-canvas) 78%, var(--seed-accent) 22%);
  --theme-blue-subtle: color-mix(in srgb, var(--seed-accent) 10%, transparent);

  /* Brand glossy buttons — dashboard qcard / cat-tab / lotto pill.
     R3: --theme-navy-rgb was a frozen "196, 18, 48" triplet that could not
     track a seed change. Every consumer was rgba(var(--theme-navy-rgb), a),
     which is exactly what color-mix(…, transparent) expresses natively, so the
     triplet is replaced by a real colour token. Same for the -rgb names below. */
  /* Base colour behind the retired --theme-navy-rgb triplet. In THIS theme the
     triplet mirrored the accent; the name is shared with blue and b-yellow so
     the byte-duplicated call sites stay byte-identical. */
  --theme-navy:              var(--seed-accent);
  --theme-navy-tint:         color-mix(in srgb, var(--seed-accent) 30%, transparent);
  --theme-btn-blue-top:      color-mix(in srgb, var(--seed-accent) 68%, white);
  --theme-btn-blue-bot:      color-mix(in srgb, var(--seed-accent) 88%, black);
  --theme-btn-blue-top-h:    color-mix(in srgb, var(--seed-accent) 58%, white);
  --theme-btn-blue-bot-h:    color-mix(in srgb, var(--seed-accent) 96%, black);
  --theme-btn-blue-border:   color-mix(in srgb, var(--seed-accent) 40%, transparent);
  --theme-btn-blue-grad:       linear-gradient(180deg, var(--theme-btn-blue-top) 0%,   var(--theme-btn-blue-bot) 100%);
  --theme-btn-blue-grad-hover: linear-gradient(180deg, var(--theme-btn-blue-top-h) 0%, var(--theme-btn-blue-bot-h) 100%);
  /* Base colour behind the retired --theme-pill-blue-rgb triplet. */
  --theme-pill-blue:         var(--seed-accent);
  --theme-pill-blue-top:     color-mix(in srgb, var(--seed-accent) 62%, white);
  --theme-pill-blue-bot:     color-mix(in srgb, var(--seed-accent) 92%, white);
  --theme-pill-blue-tint:    color-mix(in srgb, var(--seed-accent) 32%, transparent);

  /* Cream active-tab accent — dashboard cat-tab.on. Warm neutral, deliberately
     NOT accent-derived: it must stay cream when the accent is re-toned. */
  /* Base colour behind the retired --theme-tab-cream-rgb triplet, which was the
     only one whose source was a bare literal ('#d8c384') rather than a seed
     mirror — so it could not track a re-tone at all. Anchored on --seed-canvas
     so it inverts correctly if this theme is ever re-toned dark.
     #f3cf9a — dE2000 6.9 from the retired literal. */
  --theme-tab-cream:         color-mix(in srgb, var(--state-warning) 45%, var(--seed-canvas));
  --theme-tab-cream-top:     color-mix(in srgb, var(--ink-bright) 92%, var(--state-warning));
  --theme-tab-cream-bot:     color-mix(in srgb, var(--ink-bright) 78%, var(--state-warning));
  --theme-tab-cream-border:  color-mix(in srgb, var(--ink-bright) 52%, var(--state-warning));
  --theme-tab-cream-tint:    color-mix(in srgb, var(--state-warning) 34%, transparent);
  --theme-tab-cream-grad:    linear-gradient(180deg, var(--theme-tab-cream-top) 0%, var(--theme-tab-cream-bot) 100%);

  /* Status — semantic tokens (danger / success / warning) */
  --theme-red:         var(--state-danger);
  --theme-red-tint:    color-mix(in srgb, var(--state-danger) 32%, transparent);
  --theme-red-subtle:  var(--state-danger-tint);
  --theme-green:       var(--state-success);
  --theme-green-tint:  color-mix(in srgb, var(--state-success) 32%, transparent);
  --theme-green-subtle: var(--state-success-tint);
  /* --theme-info was CONSUMED at partials/_theme-vars.ejs:200-201 but never
     declared anywhere in this theme, so --lotto-blue and --lotto-blue-subtle
     resolved to nothing on every lottery page. Same defect blue carried and
     fixed; declared here for the first time. */
  --theme-info:        var(--state-info);
  --theme-info-subtle: var(--state-info-tint);
  --theme-amber:       var(--state-warning);
  --theme-amber-tint:  color-mix(in srgb, var(--state-warning) 32%, transparent);
  --theme-amber-subtle: var(--state-warning-tint);

  /* Text — dark on light. Tracks --seed-fg, so it inverts correctly if the
     canvas is ever re-toned dark. */
  --theme-text-primary:   var(--ink-hi);
  --theme-text-secondary: var(--ink-mid);
  --theme-text-muted:     var(--ink-faint);  /* was a translucent 38% --seed-fg, which
                                                composited to 2.13:1 on an elevated surface */
  --theme-text-white:     var(--font-on-light);   /* text on coloured buttons */

  /* Borders */
  --theme-border-subtle: var(--line);        /* was seed-ink 7%,  transparent */
  --theme-border-mid:    var(--line-strong); /* was seed-ink 13%, transparent */

  /* UI tokens */
  --theme-radius:     14px;
  --theme-radius-sm:  8px;
  --theme-radius-lg:  20px;
  --theme-transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  --theme-font:       'Kanit', 'Sarabun', sans-serif;
}

html {
  scroll-behavior: auto;
  font-family: 'Kanit', sans-serif;
}

/* ── BODY ── */
body {
  /* B6: three frozen stops, which is why the PAGE itself never re-toned. */
  background: linear-gradient(160deg, var(--elev-1) 0%, var(--elev-0) 50%, var(--elev-1) 100%);
  background-attachment: fixed;
  color: var(--ink-hi);
  font-family: var(--theme-font);
}

/* ── AMBIENT GLOW OVERLAY ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%,   color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 75.5%, black) 7%, transparent) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 80%,   color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 75.5%, black) 4%, transparent) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 10% 100%,  color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 51.3%, black) 3%, transparent) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── GLOBAL CARD STYLE ── */
.theme-card {
  background: var(--theme-bg-card);
  border: 1px solid var(--theme-border-subtle);
  border-radius: var(--theme-radius);
  backdrop-filter: blur(20px) saturate(110%);
  -webkit-backdrop-filter: blur(20px) saturate(110%);
  box-shadow: 0 2px 14px color-mix(in srgb, var(--seed-ink) 7%, transparent);
  transition: var(--theme-transition);
}
.theme-card:hover {
  border-color: var(--theme-gold-border);
  box-shadow: 0 8px 32px color-mix(in srgb, var(--seed-ink) 12%, transparent), 0 0 24px var(--theme-gold-glow);
}

/* ── RED DIVIDER ── */
.theme-divider-gold {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--theme-gold-border) 30%, var(--theme-gold-bright) 50%, var(--theme-gold-border) 70%, transparent 100%);
  border: none;
  margin: 0;
}

/* ── BUTTONS ── */
.theme-btn-gold {
  background: linear-gradient(135deg, color-mix(in srgb, var(--seed-danger) 61.5%, black) 0%, color-mix(in srgb, var(--seed-danger) 91.3%, black) 50%, color-mix(in srgb, var(--seed-danger) 61.5%, black) 100%);
  color: var(--ink-bright);
  border: none;
  padding: 8px 22px;
  border-radius: 50px;
  font-family: var(--theme-font);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--theme-transition);
  box-shadow: 0 4px 18px var(--theme-gold-glow), 0 1px 0 color-mix(in srgb, var(--ink-bright) 15%, transparent) inset;
  letter-spacing: 0.03em;
}
.theme-btn-gold:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 28px var(--theme-gold-glow), 0 0 16px var(--theme-gold-glow);
}

.theme-btn-cyan {
  background: linear-gradient(135deg, color-mix(in srgb, var(--seed-danger) 38.7%, black), color-mix(in srgb, var(--seed-danger) 61.5%, black));
  color: var(--ink-bright);
  border: none;
  padding: 8px 22px;
  border-radius: 50px;
  font-family: var(--theme-font);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--theme-transition);
  box-shadow: 0 4px 18px var(--theme-cyan-glow);
}
.theme-btn-cyan:hover {
  box-shadow: 0 6px 26px var(--theme-cyan-glow);
  filter: brightness(1.08);
}

.theme-btn-outline {
  background: var(--elev-input);
  color: var(--theme-text-secondary);
  border: 1px solid var(--theme-border-mid);
  padding: 7px 18px;
  border-radius: 50px;
  font-family: var(--theme-font);
  font-size: 0.80rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--theme-transition);
}
.theme-btn-outline:hover {
  border-color: var(--theme-gold-border);
  color: var(--theme-gold);
  background: color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 75.5%, black) 8%, transparent);
}

/* ── BADGE ── */
.theme-badge-hot {
  background: var(--seed-danger);
  color: var(--ink-bright);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.theme-badge-new {
  background: linear-gradient(135deg, color-mix(in srgb, var(--seed-danger) 75.5%, black), color-mix(in srgb, var(--seed-danger) 91.3%, black));
  color: var(--ink-bright);
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.theme-badge-live {
  background: color-mix(in srgb, var(--ink-bright) 85%, transparent);
  backdrop-filter: blur(6px);
  color: var(--ink-on-light);
  font-size: 0.62rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 50px;
  border: 1px solid var(--theme-gold-border);
  letter-spacing: 0.05em;
}

/* ── SPINNER ── */
.theme-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 75.5%, black) 15%, transparent);
  border-top-color: var(--theme-gold-bright);
  border-radius: 50%;
  animation: theme-spin 0.85s linear infinite;
  flex-shrink: 0;
}
@keyframes theme-spin { to { transform: rotate(360deg); } }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--elev-input); }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, color-mix(in srgb, var(--seed-danger) 75.5%, black) 30%, transparent); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--theme-gold-bright); }

/* ── UTILITY ── */
.text-gold     { color: var(--theme-gold); }
.text-cyan     { color: var(--theme-cyan); }
.text-dim      { color: var(--theme-text-secondary); }
.text-muted    { color: var(--theme-text-muted); }
.bg-card       { background: var(--theme-bg-card); }
.border-gold   { border-color: var(--theme-gold-border) !important; }
.border-subtle { border-color: var(--theme-border-subtle) !important; }
.glow-gold     { box-shadow: 0 0 18px var(--theme-gold-glow); }
.glow-cyan     { box-shadow: 0 0 16px var(--theme-cyan-glow); }

/* ── TEXT ELEMENT DEFAULTS — dark text on light theme ── */
p   { color: var(--theme-text-secondary); }
li  { color: var(--theme-text-secondary); }
h1, h2, h3, h4, h5, h6 { color: var(--theme-text-primary); }
/* a:not(.btn):not([class*="text-"]):not([class*="nav-"]):not([class*="cn-"]):not([class*="sp-"]) {
  color: var(--theme-gold);
} */
a:not(.btn):not([class*="text-"]):not([class*="nav-"]):not([class*="cn-"]):not([class*="sp-"]):hover {
  /* color: var(--theme-gold-bright); */
  text-decoration: none;
}

/* ── Browser autofill ────────────────────────────────────────────────────────
   Added 2026-09-15. No theme had ANY -webkit-autofill rule, which is a hole the
   polarity work would otherwise have left open: Chrome paints an autofilled
   field with its own background AND its own -webkit-text-fill-color, and
   -webkit-text-fill-color beats `color`. So an input that this pass just made
   legible at every palette goes back to browser-default styling the moment the
   field is autofilled — a pale box with dark text sitting in a dark theme.

   The 1000px inset box-shadow is the standard way to repaint that background,
   since Chrome ignores `background` here. Both halves are canvas-derived, so
   they move together exactly like the input they replace: surface is the canvas
   lifted 8% toward the light pole, ink is the canvas-dependent ladder.
   caret-color is set too — it is a text colour, and it inherits nothing. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--ink-hi);
  -webkit-box-shadow: 0 0 0 1000px color-mix(in srgb, var(--ink-bright) 8%, var(--seed-canvas)) inset;
          box-shadow: 0 0 0 1000px color-mix(in srgb, var(--ink-bright) 8%, var(--seed-canvas)) inset;
  caret-color: var(--ink-hi);
  transition: background-color 5000s ease-in-out 0s;
}
