/* ═══════════════════════════════════════════════════════════════════════════
   Code de la Route Suisse — Feuille de style
   Palette: rouge suisse #D52B1E, blanc, gris doux
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --red:        #D52B1E;
  --red-dark:   #a82015;
  --red-light:  #fdf0ef;
  --green:      #1a7a3c;
  --green-bg:   #edfaf2;
  --orange:     #e07b00;
  --orange-bg:  #fff7e6;
  --gray-100:   #f8f8f8;
  --gray-200:   #ececec;
  --gray-400:   #aaa;
  --gray-600:   #666;
  --gray-800:   #2c2c2c;
  --white:      #ffffff;
  --shadow-sm:  0 2px 8px rgba(0,0,0,.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.14);
  --radius:     14px;
  --radius-sm:  8px;
  --font-main:  'Outfit', sans-serif;
  --font-serif: 'Lora', serif;
  --transition: .18s ease;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img { max-width: 100%; display: block; }
a   { color: var(--red); }

/* ── Header ───────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--white);
  border-bottom: 3px solid var(--red);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 860px; margin: 0 auto;
  padding: .9rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: .6rem; }
.logo-flag { font-size: 1.6rem; }
.logo-text {
  font-size: 1.1rem; font-weight: 700; color: var(--gray-800);
}
.logo-text em { color: var(--red); font-style: normal; }
.progress-info {
  font-size: .85rem; font-weight: 600; color: var(--gray-600);
  background: var(--gray-100); padding: .3rem .8rem; border-radius: 20px;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  max-width: 860px; margin: 0 auto; width: 100%;
  padding: 1.5rem 1rem 3rem;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  text-align: center;
  padding: 1rem;
  font-size: .78rem; color: var(--gray-600);
}

/* ══════════════════════════════════════════════════════════ HOME PAGE ══════ */
.home-screen {
  display: flex; justify-content: center; align-items: flex-start;
  padding: 2rem 0;
}
.home-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 2rem;
  max-width: 520px; width: 100%;
  text-align: center;
}
.home-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.home-card h1 {
  font-size: 1.6rem; font-weight: 800;
  color: var(--gray-800); margin-bottom: .8rem; line-height: 1.3;
}
.home-subtitle {
  color: var(--gray-600); font-size: .95rem; line-height: 1.6;
  margin-bottom: 1.5rem;
}
.home-features {
  list-style: none;
  text-align: left;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  margin-bottom: 2rem;
}
.home-features li {
  padding: .35rem 0;
  font-size: .93rem; color: var(--gray-800);
}

/* ══════════════════════════════════════════════════════════ QUIZ SCREEN ════ */
.quiz-screen { max-width: 720px; margin: 0 auto; }

/* Barre de progression */
.progress-bar-wrap {
  display: flex; align-items: center; gap: .8rem;
  margin-bottom: 1.2rem;
}
.progress-bar-track {
  flex: 1; height: 8px;
  background: var(--gray-200); border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), #ff6b5b);
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-label {
  font-size: .78rem; font-weight: 700;
  color: var(--gray-600); min-width: 36px;
}

/* Card question */
.question-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Badge type */
.q-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .78rem; font-weight: 700;
  padding: .4rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  margin: 1rem 0 0 1rem;
}
.badge-situation { background: #e8f4ff; color: #1a5fa8; }
.badge-theorie   { background: var(--red-light); color: var(--red-dark); }

/* Image mise en situation */
.q-image-wrap {
  margin: 1rem 1rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--gray-100);
  max-height: 280px;
  display: flex; align-items: center; justify-content: center;
}
.q-image {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.img-placeholder {
  padding: 2rem;
  text-align: center;
  color: var(--gray-600);
  font-size: .85rem; line-height: 1.6;
}

/* Texte question */
.question-text {
  font-size: 1.15rem; font-weight: 700;
  line-height: 1.5; color: var(--gray-800);
  padding: 1.2rem 1.2rem .5rem;
}
.multi-hint {
  margin: 0 1.2rem .5rem;
  font-size: .82rem; color: var(--orange);
  font-weight: 600;
}

/* Grille réponses */
.answers-grid {
  display: flex; flex-direction: column; gap: .6rem;
  padding: .8rem 1rem 1rem;
}

.answer-option {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .85rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  user-select: none;
  position: relative;
}
.answer-option:hover {
  border-color: var(--red);
  background: var(--red-light);
  transform: translateX(2px);
}
.answer-option.selected {
  border-color: var(--red);
  background: var(--red-light);
}

.answer-input { display: none; }

.answer-key {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .82rem;
  transition: background var(--transition), color var(--transition);
  color: var(--gray-600);
}
.answer-option.selected .answer-key,
.answer-option:hover .answer-key {
  background: var(--red);
  color: var(--white);
}

.answer-text {
  flex: 1; font-size: .95rem; line-height: 1.4; padding-top: 3px;
}

/* Footer bouton valider */
.q-footer {
  padding: .8rem 1rem 1.2rem;
  border-top: 1px solid var(--gray-200);
  text-align: right;
}

/* ══════════════════════════════════════════════════════════ BUTTONS ════════ */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-main);
  font-size: .95rem; font-weight: 700;
  padding: .7rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--red);
  color: var(--white);
}
.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
  box-shadow: 0 4px 14px rgba(213,43,30,.3);
}
.btn-primary:disabled {
  background: var(--gray-400);
  cursor: not-allowed; opacity: .7;
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-800);
  border-color: var(--gray-200);
}
.btn-secondary:hover {
  border-color: var(--red);
  color: var(--red);
  background: var(--red-light);
}

.btn-large { padding: .9rem 2rem; font-size: 1.05rem; }
.btn-arrow { font-size: 1.1rem; }

/* ══════════════════════════════════════════════════════════ RESULTS ════════ */
.results-screen { max-width: 720px; margin: 0 auto; }

.results-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.score-circle {
  width: 110px; height: 110px;
  border-radius: 50%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto 1.2rem;
  border: 5px solid;
}
.score-pass { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.score-fail { border-color: var(--red);   background: var(--red-light); color: var(--red); }

.score-number { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.score-denom  { font-size: .85rem; font-weight: 600; opacity: .8; }

.results-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 1.5rem; }

.score-stats {
  display: flex; gap: 1rem; justify-content: center;
  margin-bottom: 1.8rem; flex-wrap: wrap;
}
.stat-box {
  flex: 1; min-width: 80px; max-width: 120px;
  border-radius: var(--radius-sm);
  padding: .8rem .5rem;
}
.stat-correct { background: var(--green-bg); color: var(--green); }
.stat-wrong   { background: var(--red-light); color: var(--red); }
.stat-pct     { background: var(--gray-100); color: var(--gray-800); }

.stat-num { display: block; font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-lbl { display: block; font-size: .75rem; font-weight: 600; margin-top: .2rem; opacity: .8; }

.results-actions {
  display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap;
}

/* ── Corrections ─────────────────────────────────────────────────────────── */
.review-section { }
.review-title {
  font-size: 1.2rem; font-weight: 800;
  color: var(--gray-800); margin-bottom: 1rem;
  padding: 0 .2rem;
}

.review-item {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border-left: 5px solid var(--gray-200);
}
.review-ok { border-left-color: var(--green); }
.review-ko { border-left-color: var(--red); }

.review-header {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: .8rem;
}
.review-num {
  font-size: .78rem; font-weight: 800;
  background: var(--gray-200); color: var(--gray-600);
  padding: .2rem .55rem; border-radius: 4px;
}
.review-status { font-size: .85rem; font-weight: 700; flex: 1; }

.review-image-wrap {
  margin-bottom: .8rem;
  border-radius: var(--radius-sm); overflow: hidden;
  max-height: 200px;
}
.review-image { width: 100%; object-fit: cover; }

.review-question {
  font-size: .97rem; font-weight: 700;
  color: var(--gray-800); margin-bottom: .8rem; line-height: 1.45;
}

.review-answers {
  display: flex; flex-direction: column; gap: .4rem;
  margin-bottom: .8rem;
}
.review-answer {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  background: var(--gray-100);
  font-size: .88rem;
}
.ans-correct { background: var(--green-bg); color: var(--green); font-weight: 600; }
.ans-wrong   { background: var(--red-light); color: var(--red); font-weight: 600; text-decoration: line-through; }

.ans-tick  { margin-left: auto; font-size: 1rem; color: var(--green); }
.ans-cross { margin-left: auto; font-size: 1rem; color: var(--red); }

.review-explanation {
  background: var(--orange-bg);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  font-size: .85rem; line-height: 1.5;
  color: #5a4000;
}

.review-restart {
  text-align: center;
  padding: 1.5rem 0;
}

/* ══════════════════════════════════════════════════════════ RESPONSIVE ═════ */
@media (max-width: 600px) {
  .header-inner { padding: .7rem .9rem; }
  .logo-text { font-size: .95rem; }

  .home-card { padding: 1.8rem 1.2rem; }
  .home-card h1 { font-size: 1.35rem; }

  .question-text { font-size: 1.05rem; padding: 1rem 1rem .4rem; }
  .answers-grid  { padding: .6rem .7rem .8rem; gap: .5rem; }
  .answer-option { padding: .7rem .8rem; }
  .answer-text   { font-size: .9rem; }

  .q-footer { text-align: center; }
  .btn-large { width: 100%; justify-content: center; }

  .score-stats { gap: .6rem; }
  .stat-num { font-size: 1.5rem; }

  .results-actions { flex-direction: column; align-items: stretch; }
  .results-actions .btn { justify-content: center; }
}

@media (min-width: 601px) {
  .answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* ══════════════════════════════════════════════════════ DISCLAIMER / CGU ══ */
.disclaimer-box {
  background: #fffbf0;
  border: 1.5px solid #e8c84a;
  border-radius: var(--radius-sm);
  margin-bottom: 1.2rem;
  overflow: hidden;
}
.disclaimer-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1rem;
  background: #fff8dc;
  border-bottom: 1px solid #e8c84a;
  font-size: .88rem; color: #5a4500;
}
.disclaimer-icon { font-size: 1.1rem; flex-shrink: 0; }

.disclaimer-body {
  padding: 1rem;
  font-size: .82rem; line-height: 1.65; color: #4a4030;
  max-height: 0; overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
  padding-top: 0; padding-bottom: 0;
}
.disclaimer-body.open {
  max-height: 600px;
  padding-top: 1rem; padding-bottom: .5rem;
}
.disclaimer-body p { margin-bottom: .7rem; }
.disclaimer-body p:last-child { margin-bottom: 0; }

.disclaimer-links {
  list-style: none;
  margin: .5rem 0 .8rem .2rem;
}
.disclaimer-links li {
  padding: .25rem 0;
  font-size: .82rem;
}
.disclaimer-links a {
  color: var(--red-dark);
  text-decoration: underline;
}
.disclaimer-footer-note {
  font-style: italic; color: #7a6040; font-size: .8rem;
}

.disclaimer-toggle {
  display: block; width: 100%;
  background: none; border: none;
  padding: .6rem 1rem;
  font-family: var(--font-main);
  font-size: .82rem; font-weight: 700;
  color: #7a6020; cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.disclaimer-toggle:hover { background: #fff3c0; }

/* ── Checkbox CGU ──────────────────────────────────────────────────────── */
.accept-label {
  display: flex; align-items: flex-start; gap: .8rem;
  padding: .9rem 0 1rem;
  cursor: pointer;
  user-select: none;
}
.accept-label input[type="checkbox"] { display: none; }

.accept-checkmark {
  flex-shrink: 0;
  width: 22px; height: 22px; margin-top: 1px;
  border: 2px solid var(--gray-400);
  border-radius: 5px;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.accept-checkmark::after {
  content: '✓';
  font-size: .85rem; font-weight: 800;
  color: var(--white);
  opacity: 0;
  transition: opacity .15s;
}
.accept-label:has(input:checked) .accept-checkmark {
  background: var(--green);
  border-color: var(--green);
}
.accept-label:has(input:checked) .accept-checkmark::after {
  opacity: 1;
}
.accept-label:hover .accept-checkmark {
  border-color: var(--green);
}

.accept-text {
  font-size: .85rem; line-height: 1.5; color: var(--gray-800);
}

.link-btn {
  background: none; border: none; padding: 0;
  font-family: var(--font-main); font-size: .85rem;
  color: var(--red); text-decoration: underline;
  cursor: pointer; font-weight: 600;
}
.link-btn:hover { color: var(--red-dark); }

/* Bouton start désactivé */
#startBtn:disabled {
  background: var(--gray-400) !important;
  cursor: not-allowed;
  opacity: .65;
  box-shadow: none !important;
}

/* Shake animation pour checkbox CGU non cochée */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake { animation: shake .5s ease; }
