/* ============================================================
   Dark mode (الوضع الليلي). <html data-theme="dark"> turns it on.
   dark-auto.css (generated by tools/make-dark.ps1) swaps every light colour in the
   other stylesheets; this file sets the base palette and hand-tunes what needs more care.
   ============================================================ */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121212;          /* page background: charcoal */
  --card: #1b1b1f;           /* cards and panels sit a step above the page */
  --raised: #232328;         /* menus, dialogs, pop-outs */
  --ink: #e8eaf1;
  --muted: #9aa3b5;
  --line: #2c2c33;
  --soft: #18181c;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --pop-shadow: 0 16px 40px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .3);
}
:root[data-theme="dark"] body { background: var(--paper); color: var(--ink); }

/* header + hero */
:root[data-theme="dark"] .brand .code { color: #e8eaf1; }
:root[data-theme="dark"] .hero {
  background:
    radial-gradient(900px 400px at 85% 110%, rgba(34, 211, 238, .10), transparent 60%),
    radial-gradient(700px 400px at 10% 20%, rgba(139, 92, 246, .14), transparent 60%),
    linear-gradient(180deg, #161618, #121212);
}
:root[data-theme="dark"] .features { border-top-color: var(--line); }
:root[data-theme="dark"] .hero-badge { background: #1d2136; border-color: #323765; color: #b4bffd; }
:root[data-theme="dark"] .login-link:hover { background: #232637; }
:root[data-theme="dark"] .main-nav a.active { color: #7aa7ff; }
:root[data-theme="dark"] .main-nav a.active::after { background: #7aa7ff; }
:root[data-theme="dark"] .level { color: #d8ccff; }
:root[data-theme="dark"] .level.beginner { background: #143823; color: #86efac; }

/* cards, menus, dialogs, inputs */
:root[data-theme="dark"] .course-card, :root[data-theme="dark"] .feature,
:root[data-theme="dark"] .faq-item, :root[data-theme="dark"] .season-card,
:root[data-theme="dark"] .board-list, :root[data-theme="dark"] .rules { background: var(--card); }
:root[data-theme="dark"] .menu-popup, :root[data-theme="dark"] .select-popup,
:root[data-theme="dark"] .dlg, :root[data-theme="dark"] .ai-drawer { background: var(--raised); border-color: var(--line); }
:root[data-theme="dark"] .dlg-desc { color: #b9c0cf; }
:root[data-theme="dark"] .menu-item:hover, :root[data-theme="dark"] .menu-item[data-highlighted],
:root[data-theme="dark"] .select-item[data-highlighted] { background: #252947; }
:root[data-theme="dark"] .field input { border-color: #3a3f54; }
:root[data-theme="dark"] .auth-switch { background: #232637; }
:root[data-theme="dark"] .auth-switch button.on { background: #2e3350; color: #e0e5ff; }
:root[data-theme="dark"] .form-note { background: #12291c; border-color: #1f5135; color: #86efac; }
:root[data-theme="dark"] .seg { background: #232637; }
:root[data-theme="dark"] .seg-indicator { background: #2e3350; }
:root[data-theme="dark"] .seg-tab[data-active] { color: #e0e5ff; }
:root[data-theme="dark"] .tip, :root[data-theme="dark"] .toast { background: #2a2e45; color: #f1f3f9; }
:root[data-theme="dark"] .site-footer { background: #0c0c0e; border-top: 1px solid var(--line); }

/* leaderboard */
:root[data-theme="dark"] .demo-note { background: #2f2610; border-color: #6b5414; color: #fcd34d; }
:root[data-theme="dark"] .winner-banner { background: linear-gradient(90deg, #3a2e0c, #574410); color: #fde68a; }
:root[data-theme="dark"] .my-rank { background: #1f2340; border-color: #3a3f6b; color: #c7d2fe; }
:root[data-theme="dark"] .board-row.me { background: #1f2340; }
:root[data-theme="dark"] .season-pill.running { background: #143823; color: #86efac; }
:root[data-theme="dark"] .season-pill.upcoming { background: #252947; color: #c7d2fe; }
:root[data-theme="dark"] .season-pill.ended { background: #262a3a; color: #d4d8e3; }
:root[data-theme="dark"] .season-count b { color: #a5b4fc; }
:root[data-theme="dark"] .season-track { background: #262a3a; }
:root[data-theme="dark"] .p1 .podium-block { background: linear-gradient(180deg, #b8891a, #8a6410); }
:root[data-theme="dark"] .p2 .podium-block { background: linear-gradient(180deg, #4b5266, #363b4d); }
:root[data-theme="dark"] .p3 .podium-block { background: linear-gradient(180deg, #8a4f22, #66391a); }
:root[data-theme="dark"] .podium-block { background: #262a3a; }

/* lesson page */
:root[data-theme="dark"] .task.question { background: var(--card); border-color: #323765; border-inline-start-color: #6366f1; }
:root[data-theme="dark"] .q-btn:not(.q-ai) { background: #1d2136; border-color: #3a3f6b; color: #c7d2fe; }
:root[data-theme="dark"] .q-btn:not(.q-ai):hover { background: #252947; }
:root[data-theme="dark"] .expected pre, :root[data-theme="dark"] .ai-code { background: #0b0b0d; }
:root[data-theme="dark"] .lesson-page .viz-stage { background: radial-gradient(circle at 1px 1px, #26262b 1px, transparent 0) 0 0 / 22px 22px, var(--paper); }
:root[data-theme="dark"] .rail-btn { color: #aeb6c6; }
:root[data-theme="dark"] .rail-btn:hover:not(:disabled) { background: #20233a; color: #c7d2fe; }
:root[data-theme="dark"] .rail-btn.active { background: #252947; color: #c7d2fe; border-color: #3a3f6b; }
:root[data-theme="dark"] .rail-btn.rail-ai { background: linear-gradient(160deg, #252947, #2a2547); border-color: #3a3f6b; color: #c7d2fe; }
:root[data-theme="dark"] .rail-badge { box-shadow: 0 0 0 2px var(--paper); }
:root[data-theme="dark"] .panel-x:hover { background: #232637; border-color: #3a3f6b; color: #c7d2fe; }
:root[data-theme="dark"] .resizer::after { background: #6f78d6; }
:root[data-theme="dark"] .editor-hint { background: #2a2e45; color: #f1f3f9; }
:root[data-theme="dark"] .lesson-page .editor-card.focused { box-shadow: inset 0 2px 0 #6f78d6; }

/* theme toggle button itself */
.theme-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: #374151; display: grid; place-items: center; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.theme-btn:hover { background: #f1f3fb; color: #4338ca; border-color: #c7d2fe; }
.lesson-header .theme-btn { width: 36px; height: 36px; border-radius: 10px; }
:root[data-theme="dark"] .theme-btn { color: #fcd34d; }
:root[data-theme="dark"] .theme-btn:hover { background: #232637; border-color: #3a3f6b; }

/* "شوف كودك" flow blocks use a translucent white card */
:root[data-theme="dark"] .fb { background: rgba(27, 27, 31, .94); border-color: #303038; }

/* customer support */
:root[data-theme="dark"] .contact-card, :root[data-theme="dark"] .ticket-card { background: var(--card); }
:root[data-theme="dark"] .contact-side > div { border-color: #3a3a44; }
:root[data-theme="dark"] .field select, :root[data-theme="dark"] .field textarea,
:root[data-theme="dark"] .reply-box textarea, :root[data-theme="dark"] .reply-actions select { border-color: #3a3a44; background: var(--soft); }
:root[data-theme="dark"] .muted-box { background: var(--card); }
:root[data-theme="dark"] .ticket-msg { color: #d4d8e3; }
:root[data-theme="dark"] .ticket-reply { background: #1f2340; }
:root[data-theme="dark"] .ticket-reply span, :root[data-theme="dark"] .help-dlg-link,
:root[data-theme="dark"] .contact-side a, :root[data-theme="dark"] .reply-meta a, :root[data-theme="dark"] .ticket-sent a { color: #a5b4fc; }
:root[data-theme="dark"] .ticket-status.open { background: #3a2e0c; color: #fcd34d; }
:root[data-theme="dark"] .ticket-status.answered { background: #143823; color: #86efac; }
:root[data-theme="dark"] .ticket-status.closed { background: #2a2a31; color: #c3c8d4; }
:root[data-theme="dark"] .ticket-sent-ic { background: #143823; color: #4ade80; }
:root[data-theme="dark"] .field-error { color: #fca5a5; }
