/*
  QuizForge — styles.css
  Bold editorial design. Dark-first, light mode toggle.
  Fonts: Syne (display) + DM Sans (body)
*/

/* ── VARIABLES ── */
:root {
  --bg-base:        #0d0d12;
  --bg-surface:     #13131c;
  --bg-card:        #1a1a27;
  --bg-card-hover:  #20203a;
  --bg-input:       #1e1e2e;
  --border:         rgba(255,255,255,0.08);
  --border-strong:  rgba(255,255,255,0.15);
  --text-primary:   #f0f0f8;
  --text-secondary: #9898b8;
  --text-muted:     #5a5a7a;
  --accent:         #7c6bff;
  --accent-light:   #a99fff;
  --accent-glow:    rgba(124,107,255,0.25);
  --correct:        #30d196;
  --correct-bg:     rgba(48,209,150,0.1);
  --wrong:          #ff5a6a;
  --wrong-bg:       rgba(255,90,106,0.1);
  --neutral-bg:     rgba(255,255,255,0.04);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:      0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg:      0 20px 60px rgba(0,0,0,0.5);
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --radius-xl:      28px;
  --font-display:   'Syne', sans-serif;
  --font-body:      'DM Sans', sans-serif;
  --transition:     0.2s cubic-bezier(0.4,0,0.2,1);
  --max-w:          680px;
  --header-h:       64px;
}

[data-theme="light"] {
  --bg-base:        #f4f3ff;
  --bg-surface:     #eceaff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f8f7ff;
  --bg-input:       #f0eeff;
  --border:         rgba(0,0,0,0.08);
  --border-strong:  rgba(0,0,0,0.15);
  --text-primary:   #12121e;
  --text-secondary: #5858a0;
  --text-muted:     #9898c0;
  --accent:         #6a58f5;
  --accent-light:   #8a78ff;
  --accent-glow:    rgba(106,88,245,0.15);
  --correct:        #18a870;
  --correct-bg:     rgba(24,168,112,0.08);
  --wrong:          #e53e4e;
  --wrong-bg:       rgba(229,62,78,0.08);
  --neutral-bg:     rgba(0,0,0,0.03);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 8px 32px rgba(0,0,0,0.12);
  --shadow-lg:      0 20px 60px rgba(0,0,0,0.15);
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.35s, color 0.35s;
  -webkit-font-smoothing: antialiased;
}

/* subtle gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(124,107,255,0.1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 80% 110%, rgba(107,255,224,0.05) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent-light); text-decoration: none; }
a:hover { color: var(--accent); }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }
select, input { font-family: inherit; }

/* ── HEADER ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(13,13,18,0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .app-header { background: rgba(244,243,255,0.88); }

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}
.logo-icon {
  font-size: 20px;
  color: var(--accent);
  display: inline-block;
  animation: spin-slow 12s linear infinite;
}
@keyframes spin-slow { to { transform: rotate(360deg); } }
.logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.header-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn.danger:hover { background: var(--wrong-bg); color: var(--wrong); border-color: rgba(255,90,106,0.3); }

/* Theme icon — pure CSS swap */
[data-theme="dark"]  .theme-icon::before { content: '☀'; }
[data-theme="light"] .theme-icon::before { content: '☾'; }

/* ── MAIN LAYOUT ── */
.app-main {
  flex: 1;
  position: relative;
  z-index: 1;
  padding: 40px 24px 80px;
  max-width: var(--max-w);
  margin: 0 auto;
  width: 100%;
}

/* ── SCREENS ──
   Only .active screen is shown. No hidden attribute used. */
.screen {
  display: none;
}
.screen.active {
  display: block;
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── SETUP SCREEN ── */
.setup-hero {
  margin-bottom: 44px;
  text-align: center;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.title-line { display: block; }
.title-line.accent { color: var(--accent); }

.hero-sub { color: var(--text-secondary); font-size: 1rem; }

.setup-form { display: flex; flex-direction: column; gap: 24px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

.form-group { display: flex; flex-direction: column; gap: 7px; }

.form-label {
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.label-icon { font-size: 11px; color: var(--accent); }

.select-wrapper { position: relative; }
.form-select {
  width: 100%;
  padding: 13px 42px 13px 15px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.93rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all var(--transition);
}
.form-select:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }
.form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.select-arrow {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 11px;
}
.form-hint { font-size: 0.73rem; color: var(--text-muted); }

.diff-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.diff-badge {
  padding: 8px 18px;
  border-radius: 99px;
  font-size: 0.83rem; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition);
}
.diff-badge:hover { border-color: var(--border-strong); color: var(--text-primary); }
.diff-badge.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.diff-badge.easy.active   { background: var(--correct); border-color: var(--correct); color: #fff; }
.diff-badge.medium.active { background: #f5a623; border-color: #f5a623; color: #1a1000; }
.diff-badge.hard.active   { background: var(--wrong); border-color: var(--wrong); color: #fff; }

.status-message {
  margin-top: 6px;
  font-size: 0.83rem;
  color: var(--text-secondary);
  text-align: center;
  min-height: 20px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 13px 26px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.93rem; font-weight: 700; letter-spacing: 0.01em;
  transition: all var(--transition);
  cursor: pointer;
  position: relative; overflow: hidden;
}
.btn:disabled { opacity: 0.38; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent); color: #fff;
  border: none;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 28px var(--accent-glow); filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-xl { padding: 17px 36px; font-size: 1.03rem; border-radius: var(--radius-lg); width: 100%; justify-content: center; }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-strong); }

.btn-danger { background: var(--wrong); color: #fff; border: none; }
.btn-warning { background: #f5a623; color: #1a1000; border: none; font-weight: 700; }

.btn-arrow { font-size: 1.1em; transition: transform var(--transition); }
.btn:hover:not(:disabled) .btn-arrow { transform: translateX(3px); }

/* ── SCORE PANEL ── */
.score-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px 14px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--header-h) + 10px);
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.score-inner { display: flex; align-items: center; }
.score-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.score-num {
  font-family: var(--font-display);
  font-size: 1.75rem; font-weight: 800; line-height: 1;
  transition: transform 0.15s, color 0.2s;
}
.score-num small { font-size: 0.55em; opacity: 0.6; font-weight: 600; }
.score-num.bump { animation: scoreBump 0.28s ease; }
@keyframes scoreBump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.score-lbl { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.score-item.correct .score-num { color: var(--correct); }
.score-item.wrong .score-num   { color: var(--wrong); }
.score-item.progress .score-num { color: var(--accent-light); }
.score-divider { width: 1px; height: 38px; background: var(--border); flex-shrink: 0; }

.score-bar-wrap { margin-top: 12px; }
.score-bar-track { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.score-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--correct));
  border-radius: 99px; width: 0%;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
}

.batch-info {
  text-align: center; font-size: 0.75rem; color: var(--text-muted);
  margin-bottom: 14px; letter-spacing: 0.04em; font-weight: 500; text-transform: uppercase;
}

/* ── QUESTION CARDS ── */
.questions-container { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  animation: cardIn 0.35s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.question-card:nth-child(1) { animation-delay: 0.04s; }
.question-card:nth-child(2) { animation-delay: 0.09s; }
.question-card:nth-child(3) { animation-delay: 0.14s; }
.question-card:nth-child(4) { animation-delay: 0.19s; }
.question-card:nth-child(5) { animation-delay: 0.24s; }
.question-card.answered { border-color: var(--border-strong); }

.question-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.question-num {
  font-size: 0.68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent); font-family: var(--font-display);
}
.q-tag {
  font-size: 0.66rem; padding: 2px 8px;
  border-radius: 99px; font-weight: 600; border: 1px solid;
}
.q-tag.easy   { color: var(--correct);      border-color: rgba(48,209,150,0.3);  background: var(--correct-bg); }
.q-tag.medium { color: #f5a623;             border-color: rgba(245,166,35,0.3);  background: rgba(245,166,35,0.08); }
.q-tag.hard   { color: var(--wrong);        border-color: rgba(255,90,106,0.3);  background: var(--wrong-bg); }
.q-tag.boolean  { color: var(--accent-light); border-color: rgba(169,159,255,0.3); background: rgba(169,159,255,0.08); }
.q-tag.multiple { color: var(--text-secondary); border-color: var(--border); background: var(--neutral-bg); }

.question-text { font-size: 0.98rem; line-height: 1.65; color: var(--text-primary); margin-bottom: 16px; }

.answers-list { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.answer-item { width: 100%; }

.answer-btn {
  width: 100%; text-align: left;
  padding: 12px 15px;
  border-radius: var(--radius-md);
  background: var(--neutral-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem; line-height: 1.5;
  display: flex; align-items: center; gap: 11px;
  transition: all var(--transition);
  cursor: pointer;
}
.answer-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateX(4px);
}
.answer-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.answer-btn:disabled { cursor: not-allowed; }

.answer-indicator {
  width: 27px; height: 27px; border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 700; font-family: var(--font-display);
  flex-shrink: 0; transition: all var(--transition);
  color: var(--text-muted);
}
.answer-text { flex: 1; }

.answer-btn.correct-choice {
  background: var(--correct-bg); border-color: var(--correct);
  animation: correctPop 0.35s ease;
}
.answer-btn.correct-choice .answer-indicator { background: var(--correct); border-color: var(--correct); color: #fff; }
@keyframes correctPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.answer-btn.wrong-choice { background: var(--wrong-bg); border-color: var(--wrong); }
.answer-btn.wrong-choice .answer-indicator { background: var(--wrong); border-color: var(--wrong); color: #fff; }

.answer-btn.reveal-correct {
  background: rgba(48,209,150,0.05);
  border-color: rgba(48,209,150,0.4);
  color: var(--correct);
}
.answer-btn.reveal-correct .answer-indicator { border-color: var(--correct); color: var(--correct); }

/* ── QUIZ NAV ── */
.quiz-nav { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.quiz-nav .btn { width: 100%; justify-content: center; }
.nav-hint { font-size: 0.76rem; color: var(--text-muted); text-align: center; min-height: 18px; }

/* ── RESULTS ── */
.results-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  animation: fadeUp 0.45s ease;
}
.results-trophy {
  font-size: 3.8rem; margin-bottom: 14px; display: block;
  animation: trophyBounce 0.7s cubic-bezier(0.36,0.07,0.19,0.97);
}
@keyframes trophyBounce {
  0%   { transform: scale(0) rotate(-15deg); }
  60%  { transform: scale(1.2) rotate(4deg);  }
  80%  { transform: scale(0.95) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg);    }
}
.results-title {
  font-family: var(--font-display); font-size: 1.9rem; font-weight: 800;
  margin-bottom: 28px; letter-spacing: -0.02em;
}
.results-stats { display: flex; justify-content: center; gap: 10px; margin-bottom: 24px; }
.result-stat {
  flex: 1; max-width: 120px;
  background: var(--neutral-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.result-stat.highlight { background: var(--correct-bg); border-color: rgba(48,209,150,0.3); }
.result-num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; line-height: 1; }
.result-stat.highlight .result-num { color: var(--correct); }
.result-lbl { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 600; }
.results-msg { color: var(--text-secondary); font-size: 0.98rem; margin-bottom: 28px; line-height: 1.5; }
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ── OVERLAY ──
   Controlled by .overlay-hidden class (NOT the hidden attribute).
   This is the key fix — 'hidden' attribute overrides all CSS. */
.overlay {
  position: fixed; inset: 0;
  background: rgba(13,13,18,0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity 0.2s;
}
.overlay.overlay-hidden {
  display: none;   /* key fix: hide overlay by default without conflict */
}
[data-theme="light"] .overlay { background: rgba(244,243,255,0.72); }

.overlay-box {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 38px 32px;
  text-align: center;
  max-width: 400px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.28s ease;
}
.overlay-icon { font-size: 2.4rem; margin-bottom: 14px; }
.overlay-icon.spin { display: inline-block; animation: rotateSpin 1s linear infinite; }
@keyframes rotateSpin { to { transform: rotate(360deg); } }
.overlay-msg { font-size: 0.97rem; line-height: 1.6; color: var(--text-secondary); margin-bottom: 22px; }
.overlay-actions { display: flex; flex-direction: column; gap: 9px; }

/* ── FOOTER ── */
.app-footer {
  text-align: center; padding: 18px 24px;
  font-size: 0.73rem; color: var(--text-muted);
  border-top: 1px solid var(--border);
  position: relative; z-index: 1;
}

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .app-main { padding: 20px 14px 60px; }
  .score-panel { padding: 14px 14px 10px; border-radius: var(--radius-md); }
  .score-num { font-size: 1.35rem; }
  .question-card { padding: 16px 14px; }
  .question-text { font-size: 0.93rem; }
  .answer-btn { padding: 10px 12px; font-size: 0.86rem; }
  .hero-title { font-size: 2.2rem; }
  .results-stats { gap: 7px; }
}

@media (min-width: 768px) {
  .app-main { padding: 52px 36px 90px; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}