/*
 * Site-wide dark mode for islamtics.com.
 * Activates on [data-theme="dark"] (set by theme-switch.php).
 * Strategy: override Blocksy's palette CSS vars so anything
 * that consumes them (header, content, sidebars, buttons)
 * picks up dark colors automatically.
 */

[data-theme="dark"] { color-scheme: dark; }

/* ── Override Blocksy palette ─────────────────────────────────── */
[data-theme="dark"] body {
  --theme-palette-color-3: #cbd5e1;  /* body text (was dark green) */
  --theme-palette-color-4: #f1f5f9;  /* headings */
  --theme-palette-color-5: #262626;  /* borders */
  --theme-palette-color-6: #171717;  /* card bg */
  --theme-palette-color-7: #0a0a0a;  /* page bg */
  --theme-palette-color-8: #171717;  /* "white" → near-black */
  --theme-text-color: #cbd5e1;
  --theme-headings-color: #f1f5f9;
  --theme-border-color: #262626;
  --theme-link-initial-color: #34d399;
  --theme-link-hover-color: #6ee7b7;
  --theme-form-field-border-initial-color: #262626;
  --theme-form-text-initial-color: #e2e8f0;
  --theme-form-text-focus-color: #ffffff;
  --theme-form-background-initial-color: #171717;
  background-color: #0a0a0a;
  color: #cbd5e1;
}

/* Force-override hardcoded whites in Blocksy's inline CSS */
[data-theme="dark"] body { background-color: #0a0a0a !important; background-image: none !important; }
[data-theme="dark"] .ct-container,
[data-theme="dark"] [class*="ct-container"] { background-color: transparent; }

/* Headings */
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: #f1f5f9;
}

/* Cards (post lists, related posts, sidebar widgets) */
[data-theme="dark"] .entry-card,
[data-theme="dark"] [data-prefix] .entry-card {
  background-color: #171717 !important;
  --theme-box-shadow: 0 12px 18px -6px rgba(0, 0, 0, 0.4) !important;
  border: 1px solid #262626;
}
[data-theme="dark"] .entry-card .entry-title,
[data-theme="dark"] .entry-card .entry-title a { color: #f1f5f9; }
[data-theme="dark"] .entry-card .entry-meta,
[data-theme="dark"] .entry-card .entry-excerpt { color: #94a3b8; }

/* Sidebar / widgets */
[data-theme="dark"] .ct-sidebar .widget,
[data-theme="dark"] .ct-sidebar [class*="widget_"] {
  background-color: #171717;
  border: 1px solid #262626;
  border-radius: 8px;
}
[data-theme="dark"] .ct-sidebar .widget-title { color: #f1f5f9; }

/* Hero / page header strip */
[data-theme="dark"] .hero-section,
[data-theme="dark"] [data-prefix] .hero-section[data-type] {
  background-color: #0f0f0f !important;
  background-image: none !important;
}
[data-theme="dark"] .entry-header .page-title { color: #f1f5f9; }
[data-theme="dark"] .entry-header .entry-meta,
[data-theme="dark"] .ct-breadcrumbs { color: #94a3b8; }
[data-theme="dark"] .ct-breadcrumbs a { color: #cbd5e1; }
[data-theme="dark"] .ct-breadcrumbs a:hover { color: #34d399; }

/* Article body */
[data-theme="dark"] .entry-content { color: #cbd5e1; }
[data-theme="dark"] .entry-content a { color: #34d399; }
[data-theme="dark"] .entry-content a:hover { color: #6ee7b7; }
[data-theme="dark"] .entry-content blockquote {
  background-color: #171717;
  border-left-color: #34d399;
  color: #e2e8f0;
}
[data-theme="dark"] .entry-content code,
[data-theme="dark"] .entry-content pre {
  background-color: #1c1c1c;
  color: #f1f5f9;
  border: 1px solid #262626;
}
[data-theme="dark"] .entry-content hr { border-color: #262626; }
[data-theme="dark"] .entry-content table {
  background-color: #171717;
  border-color: #262626;
}
[data-theme="dark"] .entry-content table th,
[data-theme="dark"] .entry-content table td { border-color: #262626; }

/* Forms */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background-color: #171717;
  border-color: #262626;
  color: #e2e8f0;
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: #64748b; }

/* Buttons keep emerald in dark mode */
[data-theme="dark"] .ct-button,
[data-theme="dark"] button.ct-button,
[data-theme="dark"] a.ct-button {
  --theme-button-background-initial-color: #059669;
  --theme-button-background-hover-color: #34d399;
  --theme-button-text-initial-color: #ffffff;
  --theme-button-text-hover-color: #ffffff;
}

/* Footer (custom Islamtics footer) */
[data-theme="dark"] .ct-footer { background-color: #0a0a0a !important; color: #cbd5e1; }
[data-theme="dark"] .ct-footer .widget,
[data-theme="dark"] .ct-footer [class*="widget_"] { background-color: transparent; }
[data-theme="dark"] .ct-footer .widget-title { color: #f1f5f9; }
[data-theme="dark"] .ct-footer a { color: #cbd5e1; }
[data-theme="dark"] .ct-footer a:hover { color: #34d399; }
[data-theme="dark"] .ct-footer-socials a { color: #94a3b8 !important; background: transparent !important; }
[data-theme="dark"] .ct-footer-socials a:hover { color: #34d399 !important; }

/* Search modal */
[data-theme="dark"] [data-header*="type-1"] #search-modal { background-color: rgba(10, 10, 10, 0.98) !important; }
[data-theme="dark"] [data-header*="type-1"] #search-modal .ct-search-form {
  --theme-link-initial-color: #f1f5f9 !important;
  --theme-form-text-initial-color: #f1f5f9 !important;
  --theme-form-field-border-initial-color: rgba(241, 245, 249, 0.2) !important;
}

/* ── Toggle button styling ────────────────────────────────────── */
.itx-theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: #64748b;
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.itx-theme-toggle:hover { color: #059669; background-color: rgba(16, 185, 129, 0.06); }
.itx-theme-toggle:focus-visible { outline: 2px solid #10b981; outline-offset: 2px; }

.itx-theme-toggle .itx-icon-sun,
.itx-theme-toggle .itx-icon-moon {
  position: absolute;
  transition: opacity .25s ease, transform .25s ease;
}
/* Light mode: show moon */
.itx-theme-toggle .itx-icon-sun  { opacity: 0; transform: rotate(90deg) scale(.5); }
.itx-theme-toggle .itx-icon-moon { opacity: 1; transform: rotate(0) scale(1); }
/* Dark mode: show sun */
[data-theme="dark"] .itx-theme-toggle { color: #94a3b8; }
[data-theme="dark"] .itx-theme-toggle:hover { color: #34d399; background-color: rgba(52, 211, 153, 0.1); }
[data-theme="dark"] .itx-theme-toggle .itx-icon-sun  { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .itx-theme-toggle .itx-icon-moon { opacity: 0; transform: rotate(-90deg) scale(.5); }

/* Floating fallback if header injection failed */
.itx-theme-toggle--floating {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 100;
  background-color: rgba(255, 255, 255, 0.85);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(226, 232, 240, 0.6);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
[data-theme="dark"] .itx-theme-toggle--floating {
  background-color: rgba(10, 10, 10, 0.85);
  border-color: rgba(38, 38, 38, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
