/*
 * Leroy Jenkins Crew — seasonal dark-mode layer
 * Load this file AFTER your existing stylesheet.
 * Works with themes-dark.js, which sets data-theme and data-mode="dark"
 * and supplies --theme-* variables on <html> and <body>.
 */

:root,
html[data-mode="dark"],
body[data-mode="dark"] {
  color-scheme: dark;
}

/* Connect the palette variables supplied by themes-dark.js to the
   variables already used throughout the existing stylesheet. */
html[data-mode="dark"],
body[data-mode="dark"] {
  --bg: var(--theme-bg, #17191d);
  --panel: var(--theme-surface, #22252b);
  --panel-soft: var(--theme-surface-elevated, #2b2f36);
  --text: var(--theme-text, #f1f2f3);
  --muted: var(--theme-muted, #a5a9b0);
  --accent: var(--theme-accent, #c6cbd2);
  --accent-bright: var(--theme-accent, #e2e5e9);
  --border: color-mix(in srgb, var(--theme-border, #ffffff) 78%, transparent);

  --glow: color-mix(in srgb, var(--theme-accent, #c6cbd2) 17%, transparent);
  --glow-secondary: color-mix(in srgb, var(--theme-accent-strong, #858d98) 13%, transparent);
  --gradient-start: var(--theme-text, #f1f2f3);
  --gradient-middle: var(--theme-accent, #c6cbd2);
  --gradient-end: var(--theme-accent-strong, #858d98);
  --button-bg: color-mix(in srgb, var(--theme-accent, #c6cbd2) 13%, transparent);
  --button-hover: color-mix(in srgb, var(--theme-accent, #c6cbd2) 24%, transparent);
  --widget-start: color-mix(in srgb, var(--theme-surface-elevated, #2b2f36) 96%, #ffffff 4%);
  --widget-end: var(--theme-surface, #22252b);
  --orbit-color: color-mix(in srgb, var(--theme-accent, #c6cbd2) 42%, transparent);
  --effect-color: var(--theme-accent, #c6cbd2);
}

html[data-mode="dark"] {
  background: var(--bg);
}

body[data-mode="dark"] {
  color: var(--text);
  background: transparent !important;
}

body[data-mode="dark"]::before {
  background:
    radial-gradient(ellipse at 78% 8%, var(--glow), transparent 34rem),
    radial-gradient(ellipse at 8% 48%, var(--glow-secondary), transparent 30rem),
    var(--bg) !important;
}

/* Consistent typography across all nine themes. This also neutralizes
   the light-theme-specific heading and paragraph overrides above. */
body[data-mode="dark"] h1,
body[data-mode="dark"] h2,
body[data-mode="dark"] h3,
body[data-mode="dark"] .hero h1,
body[data-mode="dark"] .about-item h3,
body[data-mode="dark"] .server-details h3 {
  color: var(--text) !important;
}

body[data-mode="dark"] .hero h1 span {
  background: linear-gradient(100deg, var(--gradient-start) 5%, var(--gradient-middle) 55%, var(--gradient-end) 115%);
  -webkit-background-clip: text;
  background-clip: text;
}

body[data-mode="dark"] .hero-description,
body[data-mode="dark"] .hero p,
body[data-mode="dark"] .section-note,
body[data-mode="dark"] .about-item p,
body[data-mode="dark"] .widget-footnote,
body[data-mode="dark"] .site-footer,
body[data-mode="dark"] .member-game {
  color: var(--muted) !important;
}

body[data-mode="dark"] .eyebrow,
body[data-mode="dark"] .header-pill,
body[data-mode="dark"] .section-header,
body[data-mode="dark"] .section-icon {
  color: var(--accent) !important;
}

/* Header, cards, orbit and other surfaces */
body[data-mode="dark"] .site-header::before {
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom-color: var(--border);
}

body[data-mode="dark"] .discord-widget {
  color: var(--text);
  border-color: var(--border);
  background: linear-gradient(145deg, var(--widget-start), var(--widget-end));
}

body[data-mode="dark"] .discord-widget,
body[data-mode="dark"] .discord-widget * {
  color: var(--text);
}

body[data-mode="dark"] .discord-widget .member-game,
body[data-mode="dark"] .discord-widget .channel-empty,
body[data-mode="dark"] .discord-widget .section-header {
  color: var(--muted) !important;
}

body[data-mode="dark"] .server-header,
body[data-mode="dark"] .site-footer,
body[data-mode="dark"] .about-strip,
body[data-mode="dark"] .about-item + .about-item {
  border-color: var(--border);
}

body[data-mode="dark"] .server-avatar-wrap {
  background: linear-gradient(135deg, var(--accent), var(--theme-accent-strong, var(--accent)));
}

body[data-mode="dark"] .channel-member,
body[data-mode="dark"] .member {
  color: var(--text);
}

body[data-mode="dark"] .channel-member:hover,
body[data-mode="dark"] .member:hover {
  background: var(--button-bg);
}

body[data-mode="dark"] .orbit,
body[data-mode="dark"] .orbit-two {
  border-color: var(--orbit-color);
}

body[data-mode="dark"] .orbit-core {
  color: var(--text);
  border-color: var(--border);
  background: linear-gradient(145deg, var(--panel-soft), var(--panel) 70%);
}

body[data-mode="dark"] .orbit-core span,
body[data-mode="dark"] .orbit-star,
body[data-mode="dark"] .star-two {
  color: var(--accent);
}

body[data-mode="dark"] .hero-cta {
  color: var(--text);
  border-color: var(--border);
  background: var(--button-bg);
}

body[data-mode="dark"] .hero-cta:hover {
  background: var(--button-hover);
  border-color: var(--accent);
}

body[data-mode="dark"] .hero-sticker {
  color: var(--bg);
  background: var(--accent);
}

/* The join action remains high-contrast, using each theme's accent. */
body[data-mode="dark"] .join-button {
  color: var(--bg) !important;
  background: linear-gradient(100deg, var(--accent), var(--theme-accent-strong, var(--accent)));
  border-color: var(--accent);
}

body[data-mode="dark"] .join-button:hover {
  filter: brightness(1.12);
}

body[data-mode="dark"] #online-count {
  color: #75d99b !important;
}

body[data-mode="dark"] .live-indicator {
  color: #91e5b0 !important;
  border-color: rgba(101, 201, 139, .28);
  background: rgba(101, 201, 139, .08);
}

body[data-mode="dark"] .widget-status {
  color: var(--text);
  background: var(--panel);
  border-color: var(--border);
}

body[data-mode="dark"] .widget-retry {
  color: var(--text);
  border-color: var(--accent);
}

body[data-mode="dark"] input,
body[data-mode="dark"] textarea,
body[data-mode="dark"] select,
body[data-mode="dark"] button {
  color-scheme: dark;
}

body[data-mode="dark"] :focus-visible {
  outline-color: var(--accent);
}

/* Seasonal accent refinements: keep each theme recognizable at night. */
body[data-mode="dark"][data-theme="spring"] {
  --theme-accent: #8bd5a5;
  --theme-accent-strong: #4ca873;
}
body[data-mode="dark"][data-theme="summer"] {
  --theme-accent: #ffd166;
  --theme-accent-strong: #e5a92f;
}
body[data-mode="dark"][data-theme="autumn"] {
  --theme-accent: #e99a5b;
  --theme-accent-strong: #c76d36;
}
body[data-mode="dark"][data-theme="winter"] {
  --theme-accent: #9bdcff;
  --theme-accent-strong: #5ba9d6;
}
body[data-mode="dark"][data-theme="new-year"] {
  --theme-accent: #f6d477;
  --theme-accent-strong: #c7a64e;
}
body[data-mode="dark"][data-theme="valentines"] {
  --theme-accent: #f39abb;
  --theme-accent-strong: #d66c99;
}
body[data-mode="dark"][data-theme="easter"] {
  --theme-accent: #ffdf24;
  --theme-accent-strong: #ffdf24;
}
body[data-mode="dark"][data-theme="halloween"] {
  --theme-accent: #c69aff;
  --theme-accent-strong: #965dcc;
}
body[data-mode="dark"][data-theme="christmas"] {
  --theme-accent: #e7c86d;
  --theme-accent-strong: #c49b3f;
}

/* Preserve the seasonal Christmas atmosphere without the old bright red page wash. */
body[data-mode="dark"][data-theme="christmas"]::before {
  background:
    radial-gradient(ellipse at 12% 12%, rgba(168, 23, 39, .22), transparent 38rem),
    radial-gradient(ellipse at 88% 88%, rgba(20, 107, 58, .24), transparent 40rem),
    var(--bg) !important;
}
