:root,
[data-theme="dark"] {
    color-scheme: dark;
    --theme-surface: #0a1f44;
    --theme-surface-raised: rgba(15, 32, 67, 0.82);
    --theme-surface-solid: #10284f;
    --theme-text: #ffffff;
    --theme-text-muted: #b0c4de;
    --theme-border: rgba(255, 255, 255, 0.1);
    --theme-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
}

[data-theme="light"] {
    color-scheme: light;
    --primary-bg: #f5f7fc;
    --primary-bg-darker: #e8edf6;
    --text-white: #10213f;
    --text-gray: #52637d;
    --glass-bg: rgba(255, 255, 255, 0.84);
    --glass-border: rgba(10, 31, 68, 0.1);
    --glass-border-gold: rgba(168, 124, 29, 0.28);
    --accent-gold: #a8781d;
    --accent-gold-hover: #8c6212;
    --accent-gold-glow: rgba(168, 120, 29, 0.22);
    --theme-surface: #f5f7fc;
    --theme-surface-raised: rgba(255, 255, 255, 0.88);
    --theme-surface-solid: #ffffff;
    --theme-text: #10213f;
    --theme-text-muted: #52637d;
    --theme-border: rgba(10, 31, 68, 0.1);
    --theme-shadow: 0 14px 36px rgba(25, 52, 91, 0.1);
}

body {
    transition: background-color 220ms ease, color 220ms ease;
}

[data-theme="light"] body {
    background-color: var(--theme-surface);
    color: var(--theme-text);
}

[data-theme="light"] .cosmic-bg {
    background: radial-gradient(circle at 50% 20%, #ffffff 0%, #eef3fb 54%, #e5ebf5 100%);
}

[data-theme="light"] .stars {
    opacity: 0.08;
    filter: invert(1);
}

[data-theme="light"] .nebula-1,
[data-theme="light"] .nebula-2 {
    opacity: 0.08;
}

[data-theme="light"] .physics-grid {
    background-image:
        linear-gradient(to right, rgba(10, 31, 68, 0.035) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(10, 31, 68, 0.035) 1px, transparent 1px);
}

[data-theme="light"] .main-header {
    background: rgba(255, 255, 255, 0.84);
    border-bottom-color: var(--theme-border);
    box-shadow: 0 8px 28px rgba(31, 56, 91, 0.08);
}

[data-theme="light"] .main-header.scrolled {
    background: rgba(255, 255, 255, 0.96);
}

[data-theme="light"] .brand-logo,
[data-theme="light"] .footer-logo {
    filter: brightness(0) saturate(100%) drop-shadow(0 5px 12px rgba(10, 31, 68, 0.14));
}

[data-theme="light"] .btn-secondary {
    background: rgba(255, 255, 255, 0.78);
    color: var(--theme-text);
    border-color: var(--theme-border);
}

[data-theme="light"] .btn-secondary:hover {
    background: #ffffff;
}

[data-theme="light"] .curriculum-section,
[data-theme="light"] .stats-row-section {
    background: transparent !important;
}

[data-theme="light"] .glass-card,
[data-theme="light"] .stat-card,
[data-theme="light"] .brutal-card,
[data-theme="light"] .curriculum-card,
[data-theme="light"] .feature-card,
[data-theme="light"] .booking-alert-banner {
    background: var(--theme-surface-raised) !important;
    border-color: var(--theme-border) !important;
    box-shadow: var(--theme-shadow) !important;
    color: var(--theme-text) !important;
}

[data-theme="light"] .white-text,
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] h5,
[data-theme="light"] h6 {
    color: var(--theme-text);
}

[data-theme="light"] p,
[data-theme="light"] .hero-description,
[data-theme="light"] .section-subtitle,
[data-theme="light"] .about-body,
[data-theme="light"] .about-lead {
    color: var(--theme-text-muted);
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background-color: #ffffff !important;
    color: var(--theme-text) !important;
    border-color: var(--theme-border) !important;
}

[data-theme="light"] .bg-white,
[data-theme="light"] .bg-gray-50,
[data-theme="light"] .bg-gray-100,
[data-theme="light"] .bg-slate-50,
[data-theme="light"] .bg-slate-100 {
    background-color: var(--theme-surface-solid) !important;
}

[data-theme="light"] .text-gray-900,
[data-theme="light"] .text-slate-900,
[data-theme="light"] .text-gray-800,
[data-theme="light"] .text-slate-800,
[data-theme="light"] .text-gray-700,
[data-theme="light"] .text-slate-700 {
    color: var(--theme-text) !important;
}

[data-theme="light"] .text-gray-600,
[data-theme="light"] .text-slate-600,
[data-theme="light"] .text-gray-500,
[data-theme="light"] .text-slate-500 {
    color: var(--theme-text-muted) !important;
}

/* Course cards always sit on a dark media overlay, including in light mode. */
[data-theme="light"] .course-card-modern .course-card-content,
[data-theme="light"] .course-card-modern .course-card-content h3 {
    color: #ffffff !important;
}

[data-theme="light"] .course-card-modern .course-card-content p,
[data-theme="light"] .course-card-modern .course-card-content .text-gray-200 {
    color: #e5e7eb !important;
}

[data-theme="light"] .course-card-modern .course-card-content .text-gray-900 {
    color: #111827 !important;
}

/* The instructor biography is rendered over a dark image panel in both themes. */
[data-theme="light"] .glass-card-overlay h4,
[data-theme="light"] .glass-card-overlay p {
    color: #ffffff !important;
}

[data-theme="light"] .app-coming-soon-card,
[data-theme="light"] .app-coming-soon-card h3,
[data-theme="light"] .app-coming-soon-card p {
    color: #ffffff !important;
}

.site-theme-toggle {
    display: inline-flex;
    min-width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--theme-border);
    border-radius: 14px;
    background: var(--theme-surface-raised);
    color: var(--theme-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    backdrop-filter: blur(14px);
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.site-theme-toggle:hover {
    transform: translateY(-2px);
    border-color: var(--accent-gold);
}

.site-theme-toggle:focus-visible {
    outline: 3px solid var(--accent-gold-glow);
    outline-offset: 3px;
}

.site-theme-toggle__icon {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.site-theme-toggle__icon--moon,
[data-theme="light"] .site-theme-toggle__icon--sun {
    display: none;
}

[data-theme="light"] .site-theme-toggle__icon--moon {
    display: block;
}

.site-theme-toggle__label {
    font-family: var(--font-tajawal, 'Tajawal', sans-serif);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.site-theme-toggle--floating {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 9998;
}

@media (max-width: 1024px) {
    .site-theme-toggle {
        min-width: 42px !important;
        width: 42px !important;
        height: 42px !important;
        padding: 0 !important;
        border-radius: 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .site-theme-toggle__label {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body,
    .site-theme-toggle {
        transition: none;
    }
}


/* Curriculum Grade Titles Contrast in Light & Dark Mode */
.curr-grade-title {
    color: var(--text-white, #ffffff);
    transition: color 0.2s ease;
}

.featured-curr-card .curr-grade-title,
.curr-grade-title.gold-text {
    color: #fbbf24;
}

[data-theme="light"] .curr-grade-title {
    color: #0f172a !important;
}

[data-theme="light"] .featured-curr-card .curr-grade-title,
[data-theme="light"] .curr-grade-title.gold-text {
    color: #b45309 !important;
}
