/* atelier-quiz.css — extracted from _source/ templates */
/* 3 files share this stylesheet */
/* Design system: uses self-contained color tokens for quiz UI autonomy.
   Neutral grays (#e0e6ef, #d0d5dd, #f0f2f5) are intentionally hardcoded
   to maintain visual consistency specific to quiz interactions. */

:root {
  --blue: #0991E0;
  --teal: #00A398;
  --gold: #DAA520;
  --red: #C03828;
  --bg-blue: #e8f4fd;
  --bg-teal: #e6f5f3;
  --bg-red: #fde8ea;
  --text: #1a202c;
  --muted: #7a8699;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f5f7fa;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh; /* Fallback anciens navigateurs */
  min-height: 100dvh;
}

/* ── App shell ── */
.quiz-app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0.75rem;
  min-height: 100vh; /* Fallback anciens navigateurs */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.quiz-header {
  text-align: center;
  padding: 0.75rem 0 0.5rem;
}
.quiz-header h1 {
  font-size: 1.15rem;
  color: var(--blue);
  margin-bottom: 0.25rem;
}
.quiz-header p {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Name input ── */
.name-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1rem;
}
.name-screen h2 {
  color: var(--blue);
  font-size: 1.3rem;
}
.name-input {
  width: 100%;
  max-width: 300px;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border: 2px solid #d0d5dd;
  border-radius: 8px;
  text-align: center;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: var(--blue); }
.start-btn {
  padding: 0.8rem 2.5rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}
.start-btn:hover { opacity: 0.85; }
.start-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Progress bar ── */
.progress-bar {
  display: flex;
  gap: 3px;
  margin: 0.5rem 0;
}
.progress-dot {
  flex: 1;
  height: 4px;
  background: #e0e6ef;
  border-radius: 2px;
  transition: background 0.3s;
}
.progress-dot.correct { background: var(--teal); }
.progress-dot.wrong { background: var(--red); }
.progress-dot.current { background: var(--gold); }

/* ── Question card ── */
.question-screen { display: none; flex-direction: column; }
.question-screen.active { display: flex; }

.q-counter {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.q-image {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  background: #fff;
  border: 1px solid #e0e6ef;
}

.q-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: #fff;
  border-left: 3px solid var(--blue);
  border-radius: 4px;
}

.q-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.q-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 2px solid #e0e6ef;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  transition: all 0.15s;
  min-height: 48px;
}
.q-option:hover:not(.locked) { border-color: var(--blue); background: var(--bg-blue); }
.q-option .opt-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #f0f2f5;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: all 0.2s;
}
.q-option.selected { border-color: var(--blue); background: var(--bg-blue); }
.q-option.selected .opt-letter { background: var(--blue); color: #fff; }
.q-option.correct-answer { border-color: var(--teal); background: var(--bg-teal); }
.q-option.correct-answer .opt-letter { background: var(--teal); color: #fff; }
.q-option.wrong-answer { border-color: var(--red); background: var(--bg-red); }
.q-option.wrong-answer .opt-letter { background: var(--red); color: #fff; }
.q-option.locked { cursor: default; opacity: 0.7; }
.q-option.correct-answer.locked { opacity: 1; }

.q-feedback {
  margin-top: 0.5rem;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}
.q-feedback.show { display: block; }
.q-feedback.correct { background: var(--bg-teal); border-left: 3px solid var(--teal); color: #145a50; }
.q-feedback.wrong { background: var(--bg-red); border-left: 3px solid var(--red); color: #8b1a1a; }

.next-btn {
  margin-top: 0.75rem;
  padding: 0.7rem;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: none;
  transition: opacity 0.15s;
}
.next-btn.show { display: block; }
.next-btn:hover { opacity: 0.85; }

/* ── Results screen ── */
.results-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 1.5rem;
}
.results-screen.active { display: flex; }

.score-ring {
  position: relative;
  width: 140px;
  height: 140px;
}
.score-ring svg { transform: rotate(-90deg); }
.score-ring circle {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}
.score-ring .bg { stroke: #e0e6ef; }
.score-ring .fg { stroke: var(--teal); transition: stroke-dashoffset 1s ease; }
.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.score-label {
  font-size: 1.15rem;
  font-weight: 700;
}
.score-msg {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 300px;
}

.results-detail {
  width: 100%;
  max-width: 360px;
  margin-top: 0.5rem;
}
.result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e0e6ef;
  font-size: 0.85rem;
}
.result-row .r-icon { font-size: 1rem; flex-shrink: 0; width: 1.5rem; text-align: center; }
.result-row .r-text { flex: 1; text-align: left; }
.result-row .r-answer { font-weight: 600; color: var(--teal); font-size: 0.8rem; }

.retry-btn {
  margin-top: 1rem;
  padding: 0.7rem 2rem;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.retry-btn:hover { opacity: 0.85; }

.back-link {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.back-link a { color: var(--blue); }

/* ── Timer ── */
.timer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════════════════════
   Dark mode
   ══════════════════════════════════════════════════════════════ */
html[data-theme="dark"] {
  --text: var(--dm-text);
  --muted: var(--dm-text-muted);
}
html[data-theme="dark"] .quiz-app {
  background: transparent;
}

/* Question text */
html[data-theme="dark"] .q-text {
  background: var(--dm-surface);
  color: var(--dm-text);
  border-left-color: var(--blue);
}

/* Option cards — dark mode overrides to ensure proper contrast. 
   Originally white (#fff) background needed custom dark surface. */
html[data-theme="dark"] .q-option {
  background: var(--dm-surface);
  border-color: var(--dm-border);
  color: var(--dm-text);
}
html[data-theme="dark"] .q-option:hover:not(.locked) {
  background: var(--dm-surface-hi);
  border-color: var(--blue);
}
html[data-theme="dark"] .q-option.selected {
  background: rgba(9, 145, 224, 0.15);
  border-color: var(--blue);
}
html[data-theme="dark"] .q-option.correct-answer {
  background: rgba(0, 163, 152, 0.18);
  border-color: var(--teal);
}
html[data-theme="dark"] .q-option.wrong-answer {
  background: rgba(192, 56, 40, 0.18);
  border-color: var(--red);
}

/* Letter badge */
html[data-theme="dark"] .opt-letter {
  background: var(--dm-border);
  color: var(--dm-text);
}
html[data-theme="dark"] .q-option.selected .opt-letter {
  background: var(--blue);
  color: #fff;
}
html[data-theme="dark"] .q-option.correct-answer .opt-letter {
  background: var(--teal);
  color: #fff;
}
html[data-theme="dark"] .q-option.wrong-answer .opt-letter {
  background: var(--red);
  color: #fff;
}

/* Feedback */
html[data-theme="dark"] .q-feedback.correct {
  background: rgba(0, 163, 152, 0.15);
  border-left-color: var(--teal);
  color: #5eead4;
}
html[data-theme="dark"] .q-feedback.wrong {
  background: rgba(192, 56, 40, 0.15);
  border-left-color: var(--red);
  color: #fca5a5;
}

/* Image */
html[data-theme="dark"] .q-image {
  background: var(--dm-surface);
  border-color: var(--dm-border);
}

/* Name input */
html[data-theme="dark"] .name-input {
  background: var(--dm-bg);
  border-color: var(--dm-border);
  color: var(--dm-text);
}

/* Progress bar */
html[data-theme="dark"] .progress-dot {
  background: var(--dm-border);
}

/* Results */
html[data-theme="dark"] .score-ring .bg {
  stroke: var(--dm-border);
}
html[data-theme="dark"] .score-value {
  color: var(--dm-text);
}
html[data-theme="dark"] .result-row {
  border-bottom-color: var(--dm-border);
  color: var(--dm-text);
}

/* Misc legacy rule (kept for compatibility) */
html[data-theme="dark"] .q-card {
  background: var(--dm-surface);
  border-color: var(--dm-border);
  color: var(--dm-text);
}
