/* ============================================================
   HB Battle — Light / Dark theme toggle
   Default: dark (matches marketing pages)
   Toggle sets data-theme="light" | "dark" on <html>
   ============================================================ */

:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --tt-bg: #07150f;
  --tt-bg-elevated: #0c1f17;
  --tt-card: #0f241b;
  --tt-ink: #eef7f1;
  --tt-muted: #9bb5a6;
  --tt-line: rgba(80, 140, 110, 0.22);
  --tt-brand: #32c48d;
  --tt-brand-soft: rgba(50, 196, 141, 0.12);
  --tt-header-bg: rgba(7, 21, 15, 0.88);
  --tt-hero-grad: radial-gradient(900px 420px at 85% -80px, rgba(50, 196, 141, 0.14), transparent 70%);
}

html[data-theme="light"] {
  color-scheme: light;
  --tt-bg: #f6faf7;
  --tt-bg-elevated: #ffffff;
  --tt-card: #ffffff;
  --tt-ink: #10231a;
  --tt-muted: #56675d;
  --tt-line: #e2ebe5;
  --tt-brand: #0a8050;
  --tt-brand-soft: #e8f6ef;
  --tt-header-bg: rgba(255, 255, 255, 0.90);
  --tt-hero-grad: radial-gradient(900px 420px at 85% -80px, rgba(20, 178, 108, 0.10), transparent 70%);
}

/* Apply theme variables to key surfaces when toggle is active */
html[data-theme] body {
  background-color: var(--tt-bg) !important;
  color: var(--tt-ink);
}

html[data-theme] .site-header {
  background: var(--tt-header-bg) !important;
  border-bottom-color: var(--tt-line) !important;
}

html[data-theme] .brand,
html[data-theme] .brand span {
  color: var(--tt-ink) !important;
}

html[data-theme] .links a {
  color: var(--tt-ink) !important;
}

html[data-theme] .sec-head h2,
html[data-theme] .prose h2,
html[data-theme] .prose h3,
html[data-theme] .content h1,
html[data-theme] .content h2,
html[data-theme] .content h3 {
  color: var(--tt-ink) !important;
}

html[data-theme] .prose p,
html[data-theme] .prose li,
html[data-theme] .content p,
html[data-theme] .content li {
  color: var(--tt-muted) !important;
}

html[data-theme] .card,
html[data-theme] .mp-card,
html[data-theme] .faq-preview details {
  background: var(--tt-card) !important;
  border-color: var(--tt-line) !important;
  color: var(--tt-ink) !important;
}

html[data-theme] .card h3,
html[data-theme] .card h3 a,
html[data-theme] .mp-card h3 {
  color: var(--tt-ink) !important;
}

html[data-theme] .card p,
html[data-theme] .mp-card p {
  color: var(--tt-muted) !important;
}

html[data-theme] .site-footer {
  background: var(--tt-bg-elevated) !important;
  border-top: 1px solid var(--tt-line) !important;
  color: var(--tt-muted) !important;
}

html[data-theme] .site-footer a {
  color: var(--tt-muted) !important;
}

html[data-theme] .site-footer a:hover {
  color: var(--tt-brand) !important;
}

html[data-theme] .soft-band {
  background: var(--tt-bg-elevated) !important;
}

/* Toggle button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--tt-line, rgba(80,140,110,.25));
  background: var(--tt-brand-soft, rgba(50,196,141,.12));
  color: var(--tt-ink, #eef7f1);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, transform .15s, border-color .2s;
  padding: 0;
  margin-left: 6px;
}

.theme-toggle:hover {
  background: var(--tt-brand-soft, rgba(50,196,141,.2));
  border-color: var(--tt-brand, #32c48d);
  transform: scale(1.05);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(50, 196, 141, 0.45);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Hide the opposite icon */
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }
html:not([data-theme]) .theme-toggle .icon-sun { display: none; } /* default dark */

/* Mobile: keep toggle visible next to hamburger */
@media (max-width: 860px) {
  .theme-toggle {
    margin-left: 4px;
    width: 38px;
    height: 38px;
  }
}
