/* ============================================================
   Qwizzer — Main Stylesheet v1.0.0
   All colours use CSS custom properties so the admin theme
   picker can override any of them live without a page reload.
   ============================================================ */

/* --- Custom Properties (set by PHP from DB settings) ------- */
:root {
  --accent:       #6366f1;
  --accent2:      #ec4899;
  --bg:           #0f0f1a;
  --surface:      #1a1a2e;
  --surface2:     #242440;
  --border:       #2e2e50;
  --text:         #f0f0ff;
  --muted:        #8888bb;
  --green:        #22c55e;
  --red:          #ef4444;
  --gold:         #fbbf24;
  --blue:         #3b82f6;
  --r:            12px;
  --r-lg:         16px;
  --font-head:    'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --transition:   0.22s cubic-bezier(.4,0,.2,1);
  --shadow:       0 4px 24px rgba(0,0,0,.35);
}

/* Light theme override class */
body.theme-light {
  --bg:       #f4f4f8;
  --surface:  #ffffff;
  --surface2: #f0f0f5;
  --border:   #dddde8;
  --text:     #111128;
  --muted:    #6666aa;
}

/* ---- Reset ------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); }

/* ---- Typography ------------------------------------------- */
h1,h2,h3,h4 { font-family: var(--font-head); font-weight: 700; line-height: 1.25; }
h1 { font-size: clamp(24px, 5vw, 38px); }
h2 { font-size: clamp(20px, 4vw, 28px); }
h3 { font-size: 18px; }
p  { color: var(--muted); }

/* ---- Layout ----------------------------------------------- */
.container { width: 100%; max-width: 860px; margin: 0 auto; padding: 0 20px; }
.container-lg { max-width: 1100px; }

/* ---- Navigation ------------------------------------------- */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 20px;
}
.nav-logo {
  font-family: var(--font-head);
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  text-decoration: none;
}
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--muted); text-decoration: none;
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: var(--surface2); color: var(--text);
}
.nav-link.active { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-xp {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: var(--gold);
}
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  text-decoration: none; cursor: pointer;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .nav-links { display: none; }
}

/* ---- Cards ------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
}
.card + .card { margin-top: 16px; }
.card-sm { padding: 16px; border-radius: var(--r); }
.card-accent {
  background: linear-gradient(135deg,
    rgba(99,102,241,.15), rgba(236,72,153,.1));
  border-color: rgba(99,102,241,.35);
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px; border: none;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: all var(--transition);
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--accent); color: #fff;
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); }
.btn-gradient {
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff;
}
.btn-gradient:hover { opacity: .88; transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-ghost {
  background: none; color: var(--muted);
  padding: 7px 14px; font-size: 13px;
}
.btn-ghost:hover { color: var(--text); }
.btn-sm  { padding: 7px 16px; font-size: 12px; border-radius: 8px; }
.btn-lg  { padding: 15px 32px; font-size: 16px; }
.btn-danger { background: var(--red); color: #fff; }

/* ---- Forms ------------------------------------------------ */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px;
  color: var(--muted); margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; background: var(--surface2);
  border: 1.5px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 10px 14px;
  font-size: 14px; font-family: var(--font-body);
  outline: none; transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 540px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Alerts ----------------------------------------------- */
.alert {
  padding: 13px 16px; border-radius: 8px;
  font-size: 14px; margin-bottom: 16px; display: flex; gap: 10px;
}
.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-info    { background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.3); color: #a5b4fc; }
.alert-warn    { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); color: #fde68a; }

/* ---- Toggle switch ---------------------------------------- */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 12px; cursor: pointer; transition: var(--transition);
}
.toggle-slider::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  top: 3px; left: 3px; transition: var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::after { transform: translateX(20px); }

/* ---- Chip / Badge ----------------------------------------- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px;
}
.chip-tf     { background: rgba(59,130,246,.15);  color: var(--blue); border: 1px solid rgba(59,130,246,.3); }
.chip-mc     { background: rgba(99,102,241,.15);  color: #a5b4fc;     border: 1px solid rgba(99,102,241,.3); }
.chip-dyk    { background: rgba(34,197,94,.15);   color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.chip-active { background: rgba(34,197,94,.15);   color: var(--green); }
.chip-draft  { background: rgba(251,191,36,.15);  color: var(--gold); }
.chip-closed { background: rgba(100,100,120,.15); color: var(--muted); }

/* ---- Progress bar ----------------------------------------- */
.progress-track {
  height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .4s ease;
}

/* ---- Stat boxes ------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: 12px; }
.stat-box {
  background: var(--surface2); border-radius: var(--r); padding: 16px; text-align: center;
}
.stat-val { font-family: var(--font-head); font-size: 28px; font-weight: 800; }
.stat-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Leaderboard row -------------------------------------- */
.lb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: 10px;
  transition: background var(--transition);
}
.lb-row:hover { background: var(--surface2); }
.lb-row.is-you { background: rgba(99,102,241,.08); }
.lb-rank { font-family: var(--font-head); font-size: 16px; font-weight: 800; width: 28px; text-align: center; }
.lb-rank.gold   { color: var(--gold); }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #b45309; }
.lb-val { font-family: var(--font-head); font-size: 16px; font-weight: 700; }

/* ---- Quiz engine ------------------------------------------ */
.quiz-wrap { max-width: 680px; margin: 0 auto; padding: 24px 20px; }
.quiz-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.q-counter { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.q-timer {
  font-family: var(--font-head); font-size: 22px; font-weight: 800;
  color: var(--gold); min-width: 32px; text-align: right; white-space: nowrap;
}
.q-timer.urgent { color: var(--red); animation: pulse .6s ease infinite; }

.question-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 32px 28px;
  text-align: center; margin-bottom: 20px; position: relative; overflow: hidden;
}
.question-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.q-category {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 14px;
}
.q-text {
  font-family: var(--font-head); font-size: clamp(18px, 3vw, 24px);
  font-weight: 700; line-height: 1.4; color: var(--text);
}

/* Answer buttons */
.answers-grid { display: grid; gap: 12px; }
.answers-grid.tf { grid-template-columns: 1fr 1fr; }
.answers-grid.mc { grid-template-columns: 1fr 1fr; }
@media (max-width: 500px) {
  .answers-grid.tf, .answers-grid.mc { grid-template-columns: 1fr; }
}
.answer-btn {
  padding: 18px 16px; background: var(--surface2);
  border: 2px solid var(--border); border-radius: 12px;
  color: var(--text); font-family: var(--font-body);
  font-size: 14px; font-weight: 500; text-align: center;
  cursor: pointer; transition: all var(--transition);
}
.answer-btn:hover:not(:disabled) {
  border-color: var(--accent); background: rgba(99,102,241,.1);
  transform: translateY(-2px);
}
.answer-btn:disabled { cursor: default; }
.answer-btn.tf-btn {
  font-family: var(--font-head); font-size: 20px; font-weight: 800;
}
.answer-btn.correct { border-color: var(--green); background: rgba(34,197,94,.15); color: var(--green); }
.answer-btn.wrong   { border-color: var(--red);   background: rgba(239,68,68,.15);  color: var(--red); }

/* Explanation */
.explanation-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px; margin-top: 14px;
  font-size: 14px; color: var(--muted); line-height: 1.65;
  display: none;
}
.explanation-card.show { display: block; animation: fadeUp .3s ease; }

/* Did You Know */
.dyk-card {
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(236,72,153,.12));
  border: 1px solid rgba(99,102,241,.35); border-radius: var(--r-lg);
  padding: 36px 28px; text-align: center; margin-bottom: 20px;
}
.dyk-eyebrow {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--accent2); margin-bottom: 14px;
}
.dyk-text {
  font-family: var(--font-head); font-size: clamp(16px,3vw,22px);
  font-weight: 700; line-height: 1.45; color: var(--text);
}

/* Results */
.results-score {
  font-family: var(--font-head); font-size: clamp(64px,15vw,96px);
  font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.share-grid { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.share-btn {
  padding: 10px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 600; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text);
  cursor: pointer; transition: border-color var(--transition); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.share-btn:hover { border-color: var(--accent); }

/* Profile calendar */
.cal-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 12px; }
.cal-day { height: 18px; border-radius: 3px; background: var(--surface2); }
.cal-day.played  { background: rgba(99,102,241,.45); }
.cal-day.perfect { background: var(--accent); }

/* Badge card */
.badge-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.badge-icon { font-size: 20px; flex-shrink: 0; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  padding: 11px 14px; text-align: left;
  font-size: 11px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); background: var(--surface2); border-bottom: 1px solid var(--border);
}
td { padding: 11px 14px; border-bottom: 1px solid rgba(46,46,80,.5); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ---- Animations ------------------------------------------- */
@keyframes fadeUp   { from{opacity:0;transform:translateY(14px)} to{opacity:1;transform:translateY(0)} }
@keyframes fadeIn   { from{opacity:0} to{opacity:1} }
@keyframes pop      { 0%,100%{transform:scale(1)} 50%{transform:scale(1.07)} }
@keyframes shake    { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
@keyframes pulse    { 0%,100%{opacity:1} 50%{opacity:.55} }
@keyframes slideIn  { from{opacity:0;transform:translateX(-18px)} to{opacity:1;transform:translateX(0)} }
@keyframes confetti { 0%{transform:translateY(-20px) rotate(0deg);opacity:1} 100%{transform:translateY(250px) rotate(720deg);opacity:0} }

.anim-fadein  { animation: fadeUp .4s ease; }
.anim-pop     { animation: pop .35s ease; }
.anim-shake   { animation: shake .38s ease; }
.anim-slidein { animation: slideIn .3s ease; }

/* Minimal animation style */
body.anim-minimal .answer-btn,
body.anim-minimal .question-card { transition: opacity .2s; }
body.anim-minimal .anim-pop   { animation: fadeIn .25s ease; }
body.anim-minimal .anim-shake { animation: fadeIn .25s ease; }

/* Bold animation style */
body.anim-bold .anim-fadein { animation: slideIn .35s cubic-bezier(.175,.885,.32,1.275); }
body.anim-bold .anim-pop    { animation: pop .5s cubic-bezier(.175,.885,.32,1.8); }

/* Confetti piece */
.confetti-piece {
  position: fixed; width: 9px; height: 9px; border-radius: 2px;
  pointer-events: none; z-index: 9999;
  animation: confetti 2.2s ease forwards;
}

/* ---- Utilities -------------------------------------------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-gold   { color: var(--gold); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-center { text-align: center; }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 11px; }
.fw-bold     { font-weight: 700; }
.font-head   { font-family: var(--font-head); }
.mt-1{margin-top:4px} .mt-2{margin-top:8px} .mt-3{margin-top:12px}
.mt-4{margin-top:16px} .mt-6{margin-top:24px} .mt-8{margin-top:32px}
.mb-2{margin-bottom:8px} .mb-3{margin-bottom:12px} .mb-4{margin-bottom:16px}
.mb-6{margin-bottom:24px}
.hidden { display: none !important; }
.sr-only { position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0); }
