/* ============================================================
   Quiz Brevet — Styles
   ============================================================ */
:root {
  --bg1: #eef2ff;
  --bg2: #f8fafc;
  --ink: #1e293b;
  --muted: #64748b;
  --card: #ffffff;
  --line: #e2e8f0;
  --accent: #6366f1;          /* couleur par défaut, surchargée par matière */
  --accent-soft: #eef2ff;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --ko: #dc2626;
  --ko-soft: #fee2e2;
  --radius: 16px;
  --shadow: 0 10px 25px rgba(2, 6, 23, .08);
}

/* Couleurs par matière (appliquées sur l'écran courant) */
.subj-histoire { --accent: #ea580c; --accent-soft: #fff1e6; } /* orange */
.subj-geo      { --accent: #0d9488; --accent-soft: #e6fffa; } /* turquoise */
.subj-emc      { --accent: #2563eb; --accent-soft: #e8efff; } /* bleu */
.subj-maths    { --accent: #7c3aed; --accent-soft: #f1ebff; } /* violet */
.subj-francais { --accent: #db2777; --accent-soft: #ffe9f3; } /* rose */
.subj-svt      { --accent: #16a34a; --accent-soft: #e6f8ec; } /* vert */
.subj-physique { --accent: #0891b2; --accent-soft: #e2f7fb; } /* cyan */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2) 60%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* En-tête / pied de page */
.site-header {
  text-align: center;
  padding: 28px 16px 18px;
  background: linear-gradient(120deg, #6366f1, #8b5cf6 45%, #ec4899);
  color: #fff;
  box-shadow: var(--shadow);
}
.site-header h1 { margin: 0; font-size: 2rem; letter-spacing: .5px; }
.site-header p { margin: 6px 0 0; opacity: .92; font-size: 1rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  padding: 18px 16px 28px;
}

main { flex: 1; width: 100%; }

/* Conteneur d'écran */
.screen {
  max-width: 760px;
  margin: 0 auto;
  padding: 26px 18px;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.screen-title { font-size: 1.5rem; margin: 4px 0 4px; }
.screen-sub { color: var(--muted); margin: 0 0 18px; }
.hint { color: var(--muted); font-size: .9rem; text-align: center; margin-top: 22px; }
.error { text-align: center; color: var(--ko); font-weight: 600; }

/* Bouton retour */
.back-btn {
  background: none; border: none; color: var(--muted);
  font-size: .95rem; cursor: pointer; padding: 6px 0; margin-bottom: 8px;
}
.back-btn:hover { color: var(--ink); }

/* ---- Accueil : cartes des matières ---- */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.subject-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
  text-align: center;
}
.subject-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.subject-emoji { font-size: 2.6rem; }
.subject-title { font-size: 1.25rem; font-weight: 700; color: var(--accent); }
.subject-sub { color: var(--muted); font-size: .9rem; }
.subject-count {
  margin-top: 8px; font-size: .8rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  padding: 3px 10px; border-radius: 999px;
}

/* ---- Liste des thèmes ---- */
.theme-list { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.theme-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  background: var(--card);
  border: 2px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  padding: 16px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .1s ease, border-color .1s ease;
  text-align: left;
}
.theme-btn:hover { transform: translateX(3px); border-color: var(--accent); border-left-color: var(--accent); }
.theme-name { font-size: 1.08rem; font-weight: 700; }
.theme-meta { font-size: .85rem; color: var(--muted); }
.best-badge {
  margin-left: 8px; background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: .78rem;
}

/* ---- Quiz ---- */
.quiz-top { display: flex; align-items: center; justify-content: space-between; }
.progress-label { font-weight: 700; color: var(--accent); font-size: .9rem; }
.progress {
  height: 10px; background: var(--line); border-radius: 999px; overflow: hidden;
  margin: 6px 0 20px;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

.question {
  font-size: 1.25rem; font-weight: 700; margin-bottom: 18px; line-height: 1.35;
}

.options { display: flex; flex-direction: column; gap: 11px; }
.option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 1.02rem;
  cursor: pointer;
  transition: border-color .1s ease, background .1s ease, transform .06s ease;
}
.option:hover:not(.disabled) { border-color: var(--accent); transform: translateY(-1px); }
.option-key {
  flex: none;
  width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: .9rem;
}
.option-text { flex: 1; }
.option.disabled { cursor: default; }
.option.correct {
  border-color: var(--ok); background: var(--ok-soft);
}
.option.correct .option-key { background: var(--ok); color: #fff; }
.option.wrong {
  border-color: var(--ko); background: var(--ko-soft);
}
.option.wrong .option-key { background: var(--ko); color: #fff; }

/* Feedback */
.feedback-box {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px;
  font-size: .98rem; line-height: 1.45;
  animation: fade .2s ease;
}
.feedback-box.ok { background: var(--ok-soft); border: 1px solid var(--ok); }
.feedback-box.ko { background: var(--ko-soft); border: 1px solid var(--ko); }

.quiz-actions { margin-top: 18px; display: flex; justify-content: flex-end; }

/* Boutons d'action */
.next-btn, .primary-btn {
  background: var(--accent); color: #fff; border: none;
  padding: 13px 22px; border-radius: 12px; font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
  transition: filter .1s ease, transform .06s ease;
}
.next-btn:hover, .primary-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }

.secondary-btn {
  background: var(--accent-soft); color: var(--accent);
  border: 2px solid var(--accent);
  padding: 11px 18px; border-radius: 12px; font-weight: 700; cursor: pointer;
}
.secondary-btn:hover { filter: brightness(.98); }

.ghost-btn {
  background: none; color: var(--muted); border: 2px solid var(--line);
  padding: 11px 18px; border-radius: 12px; font-weight: 600; cursor: pointer;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ---- Résultat ---- */
.result { text-align: center; }
.score-circle {
  width: 150px; height: 150px; margin: 10px auto 6px;
  border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #fff;
  background: var(--accent);
  box-shadow: var(--shadow);
}
.score-pct { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.score-frac { font-size: 1rem; opacity: .9; margin-top: 4px; }
.result-msg { font-size: 1.3rem; margin: 14px 0 22px; }
.result-actions {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
}

/* Revoir ses erreurs */
.review-title { margin: 28px 0 12px; text-align: left; }
.review-item {
  text-align: left; background: var(--card);
  border: 1px solid var(--line); border-left: 5px solid var(--ko);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
}
.review-q { font-weight: 700; margin-bottom: 6px; }
.review-a { color: var(--ok); font-weight: 700; margin-bottom: 6px; }
.review-e { color: var(--muted); font-size: .92rem; }

/* ---- Choix de la difficulté ---- */
.difficulty { display: flex; gap: 10px; margin: 6px 0 8px; flex-wrap: wrap; }
.diff-btn {
  flex: 1; min-width: 90px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 10px 8px; cursor: pointer;
  transition: border-color .1s ease, background .1s ease;
}
.diff-btn:hover { border-color: var(--accent); }
.diff-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.diff-label { font-weight: 700; }
.diff-note { font-size: .78rem; color: var(--muted); }
.diff-help { font-size: .85rem; color: var(--muted); margin: 0 0 16px; }

/* ---- Réponse à écrire (mode Difficile) ---- */
.type-form { display: flex; gap: 10px; margin-top: 4px; }
.type-input {
  flex: 1; font-size: 1.05rem; padding: 13px 14px; font-family: inherit;
  border: 2px solid var(--line); border-radius: 12px; outline: none;
}
.type-input:focus { border-color: var(--accent); }
.type-input.correct { border-color: var(--ok); background: var(--ok-soft); }
.type-input.wrong { border-color: var(--ko); background: var(--ko-soft); }
.give-up { margin-top: 12px; font-size: .9rem; }

.fb-answer { margin-top: 6px; }
.fb-explain { margin-top: 6px; }

/* ---- Pseudo ---- */
.pseudo-screen { text-align: center; }
.pseudo-form { display: flex; gap: 10px; justify-content: center; margin: 18px 0 6px; flex-wrap: wrap; }
.pseudo-form .type-input { max-width: 320px; text-align: center; }

/* ---- Accueil : salut + boutons mis en avant ---- */
.hello { color: var(--muted); margin-bottom: 14px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: .9rem; padding: 0; text-decoration: underline; }
.section-gap { margin-top: 26px; }

.compet-cta {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  border: none; cursor: pointer; color: #fff; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 12px; box-shadow: var(--shadow);
  background: linear-gradient(120deg, #f59e0b, #ef4444);
  transition: transform .12s ease, filter .12s ease;
}
.compet-cta:hover { transform: translateY(-3px); filter: brightness(1.05); }
.compet-emoji { font-size: 2.2rem; }
.compet-txt { display: flex; flex-direction: column; line-height: 1.25; }
.compet-txt small { opacity: .92; font-weight: 400; }

.board-cta {
  width: 100%; border: 2px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 12px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.board-cta:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Compétition : choix de catégorie ---- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 12px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 22px 14px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.cat-btn:hover { transform: translateY(-4px); border-color: var(--accent); }
.cat-emoji { font-size: 2.4rem; }
.cat-label { font-weight: 700; color: var(--accent); text-align: center; }

/* ---- Points gagnés (compétition) ---- */
.pts-gain { color: var(--ok); font-weight: 800; }

/* ---- Résultat compétition ---- */
.score-circle.big .score-pct { font-size: 2.3rem; }
.comp-meta { color: var(--muted); margin: 0 0 18px; }

/* ---- Classement ---- */
.board-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }
.board-tab { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .85rem; font-weight: 600; color: var(--ink); }
.board-tab.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.board-list { list-style: none; padding: 0; margin: 0; }
.board-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--card); }
.board-row.me { border-color: var(--accent); background: var(--accent-soft); }
.board-rank { font-weight: 800; min-width: 34px; font-size: 1.05rem; }
.board-name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-cat { opacity: .85; }
.board-score { font-weight: 800; color: var(--accent); }
.board-empty { color: var(--muted); text-align: center; margin: 24px 0; }
.board-note { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }

/* Mobile */
@media (max-width: 520px) {
  .site-header h1 { font-size: 1.6rem; }
  .question { font-size: 1.12rem; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .type-form { flex-direction: column; }
  .type-input { width: 100%; }
  .diff-note { display: none; }
}
