/* ============================================================
   DAWAH COURSE — QUIZ STYLESHEET
   Modern, dark/light, responsive
   ============================================================ */

:root {
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  /* DARK theme (default) */
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e28;
  --surface: #1e2230;
  --surface2: #252b3b;
  --border: rgba(255,255,255,0.07);
  --text: #eef0f7;
  --text-muted: #7a8099;
  --text-faint: #444c65;
  --accent: #6c8fff;
  --accent-glow: rgba(108,143,255,0.25);
  --accent2: #a78bfa;
  --good: #34d399;
  --good-bg: rgba(52,211,153,0.12);
  --bad: #f87171;
  --bad-bg: rgba(248,113,113,0.12);
  --card-shadow: 0 8px 40px rgba(0,0,0,0.45);
  --header-bg: rgba(13,15,20,0.92);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

[data-theme="light"] {
  --bg: #f0f2f9;
  --bg2: #e8eaf5;
  --bg3: #dde0f0;
  --surface: #ffffff;
  --surface2: #f5f6fc;
  --border: rgba(0,0,0,0.08);
  --text: #1a1e2e;
  --text-muted: #5a6080;
  --text-faint: #9aa0bb;
  --accent: #4a6ef5;
  --accent-glow: rgba(74,110,245,0.18);
  --accent2: #7c3aed;
  --good: #059669;
  --good-bg: rgba(5,150,105,0.1);
  --bad: #dc2626;
  --bad-bg: rgba(220,38,38,0.1);
  --card-shadow: 0 4px 24px rgba(0,0,0,0.10);
  --header-bg: rgba(240,242,249,0.92);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
  transition: background var(--transition), color var(--transition);
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#screen-login {
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  animation: orb-drift 12s ease-in-out infinite alternate;
}
.orb1 { width: 500px; height: 500px; background: #6c8fff; top: -15%; left: -10%; animation-delay: 0s; }
.orb2 { width: 380px; height: 380px; background: #a78bfa; bottom: -10%; right: -10%; animation-delay: -4s; }
.orb3 { width: 280px; height: 280px; background: #34d399; top: 40%; left: 50%; animation-delay: -8s; }

@keyframes orb-drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(30px, 20px) scale(1.08); }
}

.login-card {
  position: relative; z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 40px;
  width: min(440px, 92vw);
  box-shadow: var(--card-shadow), 0 0 0 1px rgba(108,143,255,0.1);
  backdrop-filter: blur(20px);
  display: flex; flex-direction: column; gap: 20px;
}

.login-badge {
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  font-weight: 600;
  font-family: var(--font-display);
}

.login-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.5rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: -12px;
}

.form-group {
  display: flex; flex-direction: column; gap: 8px;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.form-group select,
.form-group input {
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 14px 16px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  appearance: none;
}
.form-group select:focus,
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 48px; }
.pw-toggle {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 4px; line-height: 1; transition: color var(--transition);
}
.pw-toggle:hover { color: var(--accent); }
.pw-toggle svg { width: 18px; height: 18px; display: block; }

.login-error {
  background: var(--bad-bg);
  color: var(--bad);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 500;
}
.hidden { display: none !important; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  padding: 15px 24px;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px var(--accent-glow);
  letter-spacing: 0.02em;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: 0 8px 28px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  padding: 15px 24px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--accent); transform: translateY(-1px); }

.theme-toggle-wrap {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  margin-top: 4px;
}
.theme-label { font-size: 0.8rem; color: var(--text-muted); }

.theme-toggle, .icon-btn {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  cursor: pointer;
  padding: 8px 14px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.theme-toggle:hover, .icon-btn:hover { background: var(--bg3); color: var(--text); border-color: var(--accent); }

.theme-icon { font-size: 1rem; }
[data-theme="dark"] .sun { display: none; }
[data-theme="dark"] .moon { display: inline; }
[data-theme="light"] .moon { display: none; }
[data-theme="light"] .sun { display: inline; }

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-arabic { font-size: 1.3rem; color: var(--accent); }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--text); }

.header-actions { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 6px 14px 6px 6px;
  font-size: 0.88rem; font-weight: 600; color: var(--text);
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 800; color: #fff;
}

.icon-btn { border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.85rem; }
.logout-btn { color: var(--bad); border-color: rgba(248,113,113,0.2); }
.logout-btn:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.icon-btn svg { width: 16px; height: 16px; }

/* ============================================================
   HOME SCREEN
   ============================================================ */
.home-main {
  max-width: 900px; width: 100%; margin: 0 auto;
  padding: 40px 24px 60px;
  flex: 1;
}

.home-hero { margin-bottom: 40px; }
.home-heading {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}
.home-heading span { color: var(--accent); }
.home-desc { color: var(--text-muted); max-width: 560px; font-size: 1rem; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.cat-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex; flex-direction: column; gap: 10px;
}
.cat-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 30px var(--accent-glow);
}
.cat-icon { font-size: 1.8rem; }
.cat-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.cat-count { font-size: 0.82rem; color: var(--text-muted); }
.cat-bar-wrap { height: 4px; background: var(--bg3); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.cat-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 99px; transition: width 0.5s ease; }

.home-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-big { padding: 16px 28px; font-size: 1rem; display: flex; align-items: center; gap: 10px; }
.btn-icon { font-size: 1.1rem; }

/* ============================================================
   QUIZ SCREEN
   ============================================================ */
.quiz-progress-bar { height: 3px; background: var(--bg3); position: relative; }
.quiz-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.4s ease; border-radius: 0 99px 99px 0; }

.quiz-main {
  max-width: 780px; width: 100%; margin: 0 auto;
  padding: 32px 24px 60px;
  flex: 1;
  display: flex; flex-direction: column; gap: 24px;
}

.quiz-status-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.quiz-counter { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: var(--text-muted); letter-spacing: 0.05em; }
.quiz-score-inline { display: flex; gap: 14px; }
.score-good { color: var(--good); font-weight: 700; font-size: 0.95rem; }
.score-bad  { color: var(--bad);  font-weight: 700; font-size: 0.95rem; }

.quiz-meta { display: flex; align-items: center; }
.quiz-cat-label {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-glow); padding: 4px 12px; border-radius: 50px;
}

.question-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  box-shadow: var(--card-shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.question-tag {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent2);
}
.question-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 700;
  color: var(--text);
  line-height: 1.45;
}

.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) { .answers-grid { grid-template-columns: 1fr; } }

.answer-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 18px 20px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex; align-items: flex-start; gap: 12px;
  line-height: 1.5;
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.answer-btn .ans-letter {
  min-width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--bg3);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.answer-btn:hover:not(:disabled) .ans-letter { background: var(--accent); color: #fff; }

.answer-btn.correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.answer-btn.correct .ans-letter { background: var(--good); color: #fff; }
.answer-btn.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.answer-btn.wrong .ans-letter { background: var(--bad); color: #fff; }
.answer-btn:disabled { cursor: default; }

.feedback-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 18px;
  animation: slide-up 0.3s cubic-bezier(.4,0,.2,1);
}
@keyframes slide-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.feedback-inner { display: flex; align-items: flex-start; gap: 16px; }
.feedback-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
  font-weight: 800;
}
.feedback-box.correct-fb .feedback-icon { background: var(--good-bg); color: var(--good); }
.feedback-box.wrong-fb  .feedback-icon { background: var(--bad-bg);  color: var(--bad);  }
.feedback-verdict {
  font-family: var(--font-display);
  font-weight: 700; font-size: 1rem;
  margin-bottom: 4px;
}
.feedback-box.correct-fb .feedback-verdict { color: var(--good); }
.feedback-box.wrong-fb  .feedback-verdict { color: var(--bad);  }
.feedback-explain { color: var(--text-muted); font-size: 0.9rem; line-height: 1.55; }
.btn-next { align-self: flex-end; }

/* ============================================================
   RESULTS SCREEN
   ============================================================ */
.results-main {
  max-width: 780px; width: 100%; margin: 0 auto;
  padding: 40px 24px 80px;
  flex: 1;
  display: flex; flex-direction: column; gap: 36px;
}

.results-hero { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.results-emoji { font-size: 3rem; }
.results-title { font-family: var(--font-display); font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; color: var(--text); }

.score-ring-wrap { position: relative; width: 140px; height: 140px; }
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg  { fill: none; stroke: var(--bg3); stroke-width: 10; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1); }
.score-ring-text {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-pct { font-family: var(--font-display); font-size: 1.7rem; font-weight: 800; color: var(--text); }
.ring-sub  { font-size: 0.8rem; color: var(--text-muted); }

.results-breakdown { display: flex; flex-direction: column; gap: 10px; }
.breakdown-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px;
}
.breakdown-item.bd-correct { border-color: rgba(52,211,153,0.25); }
.breakdown-item.bd-wrong   { border-color: rgba(248,113,113,0.20); }
.bd-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.bd-content { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bd-q  { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.bd-a  { font-size: 0.82rem; color: var(--text-muted); }
.bd-correct-ans { font-size: 0.82rem; color: var(--good); }

.results-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.history-section { border-top: 1px solid var(--border); padding-top: 28px; }
.history-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--text-muted); margin-bottom: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.86rem; color: var(--text-muted);
  gap: 12px; flex-wrap: wrap;
}
.history-item strong { color: var(--text); font-weight: 600; }
.history-score { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: var(--accent); }
.history-empty { color: var(--text-faint); font-size: 0.88rem; text-align: center; padding: 20px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .quiz-main, .home-main, .results-main { padding-left: 16px; padding-right: 16px; }
  .login-card { padding: 36px 24px; }
  .question-card { padding: 24px 20px; }
  .home-actions { flex-direction: column; }
  .results-actions { flex-direction: column; align-items: stretch; }
  .btn-big { justify-content: center; }
  .user-chip span:last-child { display: none; }
}
@media (max-width: 420px) {
  .category-grid { grid-template-columns: 1fr; }
}
