/* help the UA know we support both schemes */
html { color-scheme: light dark; }


:root{
  --bg: #ffffff;
  --surface: #f7f7f8;
  --text: #111111;
  --muted: #555555;
  --accent: #06f;
  --shadow: rgba(17,17,17,0.08);
}

/* dark theme variables */
:root[data-theme="dark"]{
  --bg: #0f1113;
  --surface: #111316;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #5ab4ff;
  --shadow: rgba(0,0,0,0.6);
}

html,body{
  background: var(--bg);
  color: var(--text);
}

/* example surface */
.card{
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 6px 18px var(--shadow);
}

/* optional: style the toggle button */
.theme-toggle{
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  padding: .25rem .5rem;
}

/* Respect user preferred color scheme if no explicit selection */
@media (prefers-color-scheme: dark) {
  :root:not([data-user-theme]) {
    --bg: #0f1113;
    --surface: #111316;
    --text: #e6e6e6;
    --muted: #9aa0a6;
    --accent: #5ab4ff;
    --shadow: rgba(0,0,0,0.6);
  }
}

/* =========================
   TABLE: DARK MODE OVERRIDE
   ========================= */

:root[data-theme="dark"] table,
:root[data-theme="dark"] table th,
:root[data-theme="dark"] table td {
  background-color: var(--bg) !important;
  color: var(--text);
  border-color: #333;
}


/* =========================
   THEME-DEPENDENT IMAGES
   ========================= */

/* default (light mode) */
.theme-img.dark {
  display: none;
}

/* dark mode */
:root[data-theme="dark"] .theme-img.light {
  display: none;
}

:root[data-theme="dark"] .theme-img.dark {
  display: inline-block;
}

/* default: show light, hide dark */
.sponsor-logo.dark { display: none; }

/* dark mode: hide light, show dark */
:root[data-theme="dark"] .sponsor-logo.light { display: none; }
:root[data-theme="dark"] .sponsor-logo.dark  { display: inline-block; }

/* graceful fallback if dark logo missing: invert light logo */
:root[data-theme="dark"] .sponsor-logo.light[loading="lazy"]:not([data-dark-exists]) {
  filter: invert(1) brightness(1.1);
}

.theme-toggle {
  position: relative;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  padding: 0;
}

.theme-toggle i {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* visible icon */
.theme-toggle i.active {
  opacity: 1;
  transform: scale(1);
}
