/* =====================================================================
   Révisions Master 2 — design clair, aéré & animé
   ===================================================================== */
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }

:root {
  --bg:        #f4f7fe;
  --bg-soft:   #eef2fb;
  --card:      #ffffff;
  --card-2:    #f7f9ff;
  --line:      #e6ebf5;
  --txt:       #1f2a44;
  --txt-soft:  #5b6b8c;
  --muted:     #98a4c0;
  --brand:     #5b7cfa;
  --brand-2:   #a06bff;
  --brand-3:   #33c9dc;
  --green:     #17b890;
  --green-bg:  #e2f7f0;
  --red:       #f26d6d;
  --red-bg:    #fdeaea;
  --amber:     #f0a93b;
  --amber-bg:  #fdf1de;
  --radius:    20px;
  --shadow:    0 14px 40px rgba(60,86,160,.12);
  --shadow-sm: 0 6px 18px rgba(60,86,160,.08);
  --maxw:      940px;
  --ease:      cubic-bezier(.22,.9,.3,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--txt);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
}

/* ---- Fond animé : blobs pastel qui respirent ---- */
body::before, body::after {
  content: ""; position: fixed; z-index: -1; border-radius: 50%;
  filter: blur(70px); opacity: .55; pointer-events: none;
}
body::before {
  width: 46vw; height: 46vw; top: -12vw; left: -8vw;
  background: radial-gradient(circle at 30% 30%, #b8c9ff, #d8b8ff 70%);
  animation: float1 18s var(--ease) infinite alternate;
}
body::after {
  width: 40vw; height: 40vw; top: -6vw; right: -10vw;
  background: radial-gradient(circle at 60% 40%, #a8ecf5, #b9d4ff 70%);
  animation: float2 22s var(--ease) infinite alternate;
}
@keyframes float1 { to { transform: translate(6vw, 8vw) scale(1.15); } }
@keyframes float2 { to { transform: translate(-5vw, 10vw) scale(1.1); } }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 30px 22px 90px; position: relative; }

/* ---- Header ---- */
.topbar { display: flex; align-items: center; gap: 15px; padding: 6px 2px 34px; }
.topbar .logo {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; font-size: 24px;
  box-shadow: 0 8px 22px rgba(91,124,250,.4);
  animation: pop .6s var(--ease) both;
}
.topbar h1 { font-size: 1.2rem; margin: 0; letter-spacing: .2px; }
.topbar p  { margin: 2px 0 0; color: var(--txt-soft); font-size: .85rem; }
.topbar .spacer { flex: 1; }

.btn-ghost {
  background: #fff; border: 1px solid var(--line); color: var(--txt-soft);
  padding: 9px 15px; border-radius: 11px; cursor: pointer; font-size: .85rem;
  transition: .18s var(--ease); box-shadow: var(--shadow-sm);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-weight: 600; font-size: .95rem;
  padding: 13px 24px; border-radius: 13px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px rgba(91,124,250,.32);
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), filter .16s;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,.35), transparent 45%);
  opacity: 0; transition: opacity .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(91,124,250,.4); }
.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.secondary {
  background: #fff; color: var(--txt); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn.wide { width: 100%; }

/* ---- Grilles / cartes ---- */
.grid { display: grid; gap: 18px; }
.subjects { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.subject-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; cursor: pointer; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 10px; min-height: 158px;
  box-shadow: var(--shadow-sm); transition: transform .22s var(--ease), box-shadow .22s var(--ease), border-color .2s;
  animation: rise .5s var(--ease) both;
}
.subject-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2), var(--brand-3));
  transform: scaleX(0); transform-origin: left; transition: transform .3s var(--ease);
}
.subject-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: transparent; }
.subject-card:hover::before { transform: scaleX(1); }
.subject-card.locked { cursor: not-allowed; opacity: .6; }
.subject-card.locked:hover { transform: none; box-shadow: var(--shadow-sm); }
.subject-card.locked:hover::before { transform: scaleX(0); }
.subject-card .emoji { font-size: 32px; transition: transform .3s var(--ease); }
.subject-card:hover .emoji { transform: scale(1.15) rotate(-6deg); }
.subject-card h3 { margin: 0; font-size: 1.08rem; }
.subject-card .meta { color: var(--txt-soft); font-size: .82rem; }

.badge {
  display: inline-block; font-size: .68rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; padding: 4px 10px; border-radius: 20px;
}
.badge.ready { background: var(--green-bg); color: var(--green); }
.badge.soon  { background: var(--amber-bg); color: var(--amber); }

/* stagger d'entrée */
.subject-card:nth-child(1){animation-delay:.04s} .subject-card:nth-child(2){animation-delay:.1s}
.subject-card:nth-child(3){animation-delay:.16s} .subject-card:nth-child(4){animation-delay:.22s}

/* ---- Choix du mode ---- */
.modes { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px){ .modes { grid-template-columns: 1fr; } }
.mode-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; cursor: pointer; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-sm); transition: transform .22s var(--ease), box-shadow .22s var(--ease);
  animation: rise .5s var(--ease) both; position: relative; overflow: hidden;
}
.mode-card:nth-child(2){ animation-delay:.08s }
.mode-card::after {
  content: ""; position: absolute; width: 130px; height: 130px; right: -30px; top: -30px;
  border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2));
  opacity: .08; transition: transform .3s var(--ease);
}
.mode-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.mode-card:hover::after { transform: scale(1.5); }
.mode-card .emoji { font-size: 38px; transition: transform .3s var(--ease); }
.mode-card:hover .emoji { transform: scale(1.15) translateY(-2px); }
.mode-card h3 { margin: 0; font-size: 1.18rem; }
.mode-card p { margin: 0; color: var(--txt-soft); font-size: .9rem; }

.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin: 34px 2px 14px; font-weight: 700; }

/* ---- Thèmes (entraînement) ---- */
.themes { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.theme-chip {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 15px 17px; cursor: pointer; display: flex; align-items: center; gap: 11px;
  box-shadow: var(--shadow-sm); transition: .18s var(--ease); animation: rise .45s var(--ease) both;
}
.theme-chip:hover { border-color: var(--brand); transform: translateX(4px); box-shadow: var(--shadow); }
.theme-chip .count { margin-left: auto; font-size: .74rem; color: var(--brand); background: var(--bg-soft); padding: 3px 9px; border-radius: 10px; font-weight: 600; }

/* ---- Quiz ---- */
.quiz-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; animation: fade .4s var(--ease); }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.05rem;
  padding: 9px 15px; border-radius: 12px; background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: .3s;
}
.timer.warn { color: var(--amber); border-color: var(--amber); background: var(--amber-bg); }
.timer.danger { color: var(--red); border-color: var(--red); background: var(--red-bg); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(1.04); } }
.progress-pill { font-size: .85rem; color: var(--txt-soft); background: #fff; border: 1px solid var(--line); padding: 9px 15px; border-radius: 12px; box-shadow: var(--shadow-sm); }

.qcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 30px; box-shadow: var(--shadow); animation: rise .45s var(--ease) both;
}
.qtag {
  display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px; color: var(--brand);
  background: #eef2ff; padding: 5px 12px; border-radius: 20px; margin-bottom: 8px;
}
.qtag.multi { color: var(--brand-2); background: #f5eeff; }
.scoring {
  font-size: .78rem; color: var(--txt-soft); margin: 10px 0 20px; padding: 11px 15px;
  border-left: 3px solid var(--brand); background: var(--bg-soft); border-radius: 0 10px 10px 0;
}
.scoring b { color: var(--txt); }
.qtext { font-size: 1.18rem; font-weight: 600; margin: 6px 0 22px; line-height: 1.5; }

.options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex; align-items: flex-start; gap: 13px; padding: 15px 17px;
  border: 1.5px solid var(--line); border-radius: 14px; cursor: pointer; background: #fff;
  transition: border-color .16s, background .16s, transform .12s var(--ease);
  animation: rise .4s var(--ease) both;
}
.opt:nth-child(1){animation-delay:.02s}.opt:nth-child(2){animation-delay:.06s}
.opt:nth-child(3){animation-delay:.1s}.opt:nth-child(4){animation-delay:.14s}
.opt:nth-child(5){animation-delay:.18s}.opt:nth-child(6){animation-delay:.22s}
.opt:hover { border-color: var(--brand); background: #fafbff; transform: translateX(3px); }
.opt.selected { border-color: var(--brand); background: #eef2ff; }
.opt .box {
  width: 23px; height: 23px; flex: none; border: 2px solid var(--muted); display: grid; place-items: center;
  font-size: 13px; color: #fff; margin-top: 1px; transition: .18s var(--ease);
}
.opt[data-shape="radio"] .box { border-radius: 50%; }
.opt[data-shape="check"] .box { border-radius: 7px; }
.opt.selected .box { background: var(--brand); border-color: var(--brand); animation: boxpop .3s var(--ease); }
.opt .label { flex: 1; }
.opt .letter { font-weight: 700; color: var(--muted); margin-right: 4px; }

/* états de correction */
.opt.correct { border-color: var(--green); background: var(--green-bg); }
.opt.correct .box { background: var(--green); border-color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt.wrong .box { background: var(--red); border-color: var(--red); }
.opt.missed { border-color: var(--green); border-style: dashed; background: #fff; }

.explain {
  margin-top: 20px; padding: 17px 19px; border-radius: 14px; background: var(--bg-soft);
  border: 1px solid var(--line); font-size: .92rem; animation: rise .35s var(--ease); color: var(--txt-soft);
}
.explain .verdict { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.explain .verdict.ok { color: var(--green); }
.explain .verdict.ko { color: var(--red); }
.explain .verdict.part { color: var(--amber); }
.explain > div:not(.verdict):not(.src) { color: var(--txt); }
.explain .src { margin-top: 11px; font-size: .78rem; color: var(--muted); }

/* nav */
.quiz-nav { display: flex; gap: 11px; margin-top: 24px; align-items: center; flex-wrap: wrap; }
.quiz-nav .spacer { flex: 1; }

.navigator {
  display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; padding: 18px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-sm);
}
.navigator .dot {
  width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; color: var(--txt-soft); cursor: pointer; font-size: .82rem; font-weight: 600;
  display: grid; place-items: center; transition: .15s var(--ease); position: relative;
}
.navigator .dot:hover { border-color: var(--brand); transform: translateY(-2px); }
.navigator .dot.answered { background: var(--brand); color: #fff; border-color: var(--brand); }
.navigator .dot.current { outline: 3px solid #c7d2ff; outline-offset: 1px; }
.navigator .dot.flagged::after { content: "🚩"; position: absolute; top: -8px; right: -6px; font-size: 11px; }

/* ---- Résultats ---- */
.result-hero {
  text-align: center; padding: 40px 22px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 26px; animation: rise .5s var(--ease) both;
}
.score-ring {
  width: 176px; height: 176px; margin: 0 auto 18px; border-radius: 50%;
  background: conic-gradient(var(--ring-color) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center; position: relative; transition: --p 1.1s var(--ease);
}
.score-ring::before { content: ""; position: absolute; inset: 13px; border-radius: 50%; background: var(--card); box-shadow: inset 0 2px 10px rgba(60,86,160,.08); }
.score-ring .val { position: relative; font-size: 2.3rem; font-weight: 800; }
.score-ring .val small { display: block; font-size: .82rem; font-weight: 500; color: var(--txt-soft); }
.result-hero h2 { margin: 8px 0 4px; font-size: 1.5rem; }
.result-hero .msg { color: var(--txt-soft); font-size: 1rem; }
.stat-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px 20px; min-width: 96px; animation: rise .5s var(--ease) both; }
.stat:nth-child(2){animation-delay:.06s}.stat:nth-child(3){animation-delay:.12s}.stat:nth-child(4){animation-delay:.18s}
.stat .n { font-size: 1.5rem; font-weight: 800; }
.stat .n.good { color: var(--green); } .stat .n.bad { color: var(--red); } .stat .n.skip { color: var(--muted); }
.stat .k { font-size: .72rem; color: var(--txt-soft); text-transform: uppercase; letter-spacing: .5px; }

.review-item { margin-bottom: 15px; }
.review-item .qtext { font-size: 1.02rem; }

/* ---- Historique ---- */
.history { margin-top: 28px; }
.hrow {
  display: flex; align-items: center; gap: 12px; padding: 13px 17px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 9px; font-size: .88rem;
  box-shadow: var(--shadow-sm); animation: rise .4s var(--ease) both; transition: transform .16s var(--ease);
}
.hrow:hover { transform: translateX(3px); }
.hrow .when { color: var(--muted); font-size: .78rem; }
.hrow .hscore { font-weight: 700; margin-left: auto; }

.empty { color: var(--muted); text-align: center; padding: 30px; font-size: .9rem; }
.hint { color: var(--txt-soft); font-size: .9rem; }

/* ---- Confettis ---- */
.confetti {
  position: fixed; top: -12px; width: 10px; height: 14px; z-index: 999;
  border-radius: 2px; will-change: transform, opacity; pointer-events: none;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ---- Keyframes globales ---- */
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop  { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.1); } 100% { transform: scale(1); opacity: 1; } }
@keyframes boxpop { 0% { transform: scale(.4); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }

.fadein { animation: fade .35s var(--ease); }

/* respect des préférences d'accessibilité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
