/* ============================================================================
   theme-switcher.css — Cyber Brief + AI Daily theme palette + widget
   5 themes from lightest (snow) to darkest (midnight) + auto/system mode.
   Apply via: <html data-theme="snow|cream|slate|graphite|midnight|system">
   ============================================================================ */

/* Default (when no data-theme is set) — current dark palette */
:root {
  --bg: #08100f;
  --surface: #0f1a18;
  --surface-2: #162521;
  --line: #29413a;
  --text: #edf7f2;
  --muted: #a9bdb5;
  --accent: #54d6ac;
  --accent-2: #f0b85a;
  --shadow: rgba(0, 0, 0, 0.28);

  --ts-bg-page: var(--bg);
  --ts-bg-card: var(--surface);
  --ts-text: var(--text);
  --ts-border: var(--line);

  --ts-shadow: 0 18px 42px var(--shadow);
  --ts-btn-bg: var(--surface);
  --ts-btn-text: var(--text);
  --ts-btn-border: var(--line);
  --ts-panel-bg: var(--surface);
  --ts-panel-text: var(--text);
  --ts-panel-border: var(--line);
}

/* ----- THEME 1: SNOW (pure white, classic light) ----- */
html[data-theme="snow"] {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eef1f5;
  --line: #d0d7de;
  --text: #1f2328;
  --muted: #57606a;
  --accent: #0969da;
  --accent-2: #bf8700;
  --shadow: rgba(15, 23, 42, 0.08);
}

/* ----- THEME 2: CREAM (soft warm light, easy on eyes) ----- */
html[data-theme="cream"] {
  --bg: #faf6ec;
  --surface: #f3ecdc;
  --surface-2: #ebe1cb;
  --line: #d9c9a3;
  --text: #2a1f10;
  --muted: #6b5a3e;
  --accent: #b45309;
  --accent-2: #7c2d12;
  --shadow: rgba(120, 80, 20, 0.10);
}

/* ----- THEME 3: SLATE (medium grey, neutral) ----- */
html[data-theme="slate"] {
  --bg: #3a4451;
  --surface: #475569;
  --surface-2: #525d6c;
  --line: #64748b;
  --text: #f1f5f9;
  --muted: #cbd5e1;
  --accent: #06b6d4;
  --accent-2: #fbbf24;
  --shadow: rgba(0, 0, 0, 0.25);
}

/* ----- THEME 4: GRAPHITE (dark grey, easy dark) ----- */
html[data-theme="graphite"] {
  --bg: #1a1d24;
  --surface: #232730;
  --surface-2: #2d313c;
  --line: #3a3f4b;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #2dd4bf;
  --accent-2: #f59e0b;
  --shadow: rgba(0, 0, 0, 0.45);
}

/* ----- THEME 5: MIDNIGHT (deep blue-black, current default) ----- */
html[data-theme="midnight"] {
  --bg: #08100f;
  --surface: #0f1a18;
  --surface-2: #162521;
  --line: #29413a;
  --text: #edf7f2;
  --muted: #a9bdb5;
  --accent: #54d6ac;
  --accent-2: #f0b85a;
  --shadow: rgba(0, 0, 0, 0.28);
}

/* ----- prefers-color-scheme auto-mode (default unless user picks) ----- */
@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    --bg: #ffffff;
    --surface: #f6f8fa;
    --surface-2: #eef1f5;
    --line: #d0d7de;
    --text: #1f2328;
    --muted: #57606a;
    --accent: #0969da;
    --accent-2: #bf8700;
    --shadow: rgba(15, 23, 42, 0.08);
  }
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #08100f;
    --surface: #0f1a18;
    --surface-2: #162521;
    --line: #29413a;
    --text: #edf7f2;
    --muted: #a9bdb5;
    --accent: #54d6ac;
    --accent-2: #f0b85a;
    --shadow: rgba(0, 0, 0, 0.28);
  }
}

/* ----- Override inline-style hardcoded rgba() in AI Daily mirror ----- */
html[data-theme="snow"] .briefing-hero,
html[data-theme="cream"] .briefing-hero,
html[data-theme="slate"] .briefing-hero,
html[data-theme="graphite"] .briefing-hero,
html[data-theme="midnight"] .briefing-hero {
  background: var(--surface) !important;
  border-bottom-color: var(--line) !important;
}

html[data-theme="snow"] .site-header,
html[data-theme="cream"] .site-header,
html[data-theme="slate"] .site-header,
html[data-theme="graphite"] .site-header {
  background: var(--surface) !important;
  border-bottom-color: var(--line) !important;
}

html[data-theme="snow"] .item-card.ai,
html[data-theme="cream"] .item-card.ai,
html[data-theme="slate"] .item-card.ai,
html[data-theme="graphite"] .item-card.ai {
  /* keep accent border; override any hardcoded green tint */
  background: var(--surface) !important;
}

html[data-theme="snow"] .badge,
html[data-theme="cream"] .badge,
html[data-theme="slate"] .badge,
html[data-theme="graphite"] .badge,
html[data-theme="midnight"] .badge {
  background: var(--surface-2) !important;
}

/* ============================================================================
   THEME SWITCHER WIDGET
   A floating button bottom-right with palette dropdown.
   ============================================================================ */

.ts-root {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1;
}

.ts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--ts-btn-bg);
  color: var(--ts-btn-text);
  border: 1px solid var(--ts-btn-border);
  border-radius: 999px;
  box-shadow: 0 6px 18px var(--shadow);
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.ts-toggle:hover { transform: translateY(-1px); box-shadow: 0 10px 26px var(--shadow); }
.ts-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ts-toggle svg { width: 16px; height: 16px; display: block; }

.ts-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  min-width: 240px;
  padding: 14px;
  background: var(--ts-panel-bg);
  color: var(--ts-panel-text);
  border: 1px solid var(--ts-panel-border);
  border-radius: 12px;
  box-shadow: 0 18px 42px var(--shadow);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.ts-root[data-open="1"] .ts-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ts-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.ts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.ts-grid-2 { grid-template-columns: repeat(2, 1fr); }

.ts-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px;
  background: transparent;
  color: inherit;
  border: 1px solid var(--ts-panel-border);
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: border-color .15s ease, transform .12s ease;
}
.ts-swatch:hover { transform: translateY(-1px); }
.ts-swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ts-swatch[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.ts-chip {
  display: block;
  width: 100%;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
}
.ts-chip::before,
.ts-chip::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
}
.ts-chip::before { left: 0; }
.ts-chip::after  { right: 0; }

.ts-chip[data-palette="snow"]::before      { background: #ffffff; }
.ts-chip[data-palette="snow"]::after       { background: #1f2328; }
.ts-chip[data-palette="cream"]::before     { background: #faf6ec; }
.ts-chip[data-palette="cream"]::after      { background: #2a1f10; }
.ts-chip[data-palette="slate"]::before     { background: #3a4451; }
.ts-chip[data-palette="slate"]::after      { background: #f1f5f9; }
.ts-chip[data-palette="graphite"]::before  { background: #1a1d24; }
.ts-chip[data-palette="graphite"]::after   { background: #e5e7eb; }
.ts-chip[data-palette="midnight"]::before  { background: #08100f; }
.ts-chip[data-palette="midnight"]::after   { background: #54d6ac; }
.ts-chip[data-palette="system"] {
  background:
    linear-gradient(135deg, #ffffff 0 50%, #08100f 50% 100%);
  border-color: rgba(0,0,0,0.2);
}

.ts-swatch-label {
  display: block;
  font-size: 11px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

@media (max-width: 540px) {
  .ts-root { right: 12px; bottom: 12px; }
  .ts-panel { min-width: 220px; }
  .ts-toggle span { display: none; }
}