/* Plateforme Bac de français — 100% local, HTML/CSS/JS vanilla */
:root {
  --ink: #1a1a2e;
  --muted: #5f6070;
  --red: #c0392b;
  --blue: #1a5276;
  --green: #1e8449;
  --gold: #b7860b;
  --purple: #6c3483;
  --teal: #117a65;
  --paper: #fdfaf4;
  --paper2: #f5f0e8;
  --line: #d4c9a8;
  --soft-red: #fff0ed;
  --soft-blue: #edf6ff;
  --shadow: 4px 4px 24px rgba(0, 0, 0, 0.46);
  --radius: 16px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(183,134,11,.18), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(26,82,118,.18), transparent 30rem),
    #2c2c2c;
  color: var(--ink);
  font-family: var(--sans);
  padding: 12px;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  background: var(--paper);
  border-radius: 4px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 24px);
}
.page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(transparent 0px, transparent 31px, var(--line) 31px, var(--line) 32px);
  opacity: .28;
  pointer-events: none;
  z-index: 0;
}
.page::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 58px;
  width: 1.5px;
  background: rgba(192,57,43,.2);
  pointer-events: none;
  z-index: 0;
}
.content {
  position: relative;
  z-index: 1;
  padding: clamp(24px, 5vw, 46px) clamp(18px, 4vw, 42px) 56px clamp(72px, 8vw, 98px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--blue);
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--paper2);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.navlinks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.navlinks a, .pill-link {
  border: 1px solid var(--line);
  background: rgba(253,250,244,.74);
  color: var(--ink);
  border-radius: 999px;
  text-decoration: none;
  padding: 8px 13px;
  font-size: .94rem;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.navlinks a:hover, .pill-link:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(0,0,0,.10); border-color: rgba(183,134,11,.6); }

.hero {
  text-align: center;
  padding: 8px 0 24px;
}
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 800;
  font-size: .78rem;
  margin-bottom: 10px;
}
.titre-principal {
  font-family: var(--serif);
  color: var(--red);
  font-size: clamp(2rem, 7vw, 4.2rem);
  line-height: 1.05;
  text-decoration: underline;
  text-underline-offset: 9px;
  text-decoration-thickness: 1.5px;
  margin-bottom: 10px;
}
.subtitle {
  color: var(--blue);
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.05rem, 3.2vw, 1.45rem);
  margin-bottom: 18px;
}
.intro-bloc {
  background: linear-gradient(135deg, rgba(245,240,232,.95), rgba(253,250,244,.82));
  border-left: 4px solid var(--gold);
  padding: 15px 17px;
  border-radius: 10px;
  line-height: 1.7;
  color: #393847;
  max-width: 820px;
  margin: 0 auto 18px;
}
.hero-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  padding: 11px 17px;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
  min-height: 44px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0,0,0,.14); }
.btn:active { transform: translateY(0); opacity: .88; }
.btn-primary { background: var(--red); color: white; }
.btn-secondary { background: var(--blue); color: white; }
.btn-ghost { background: var(--paper2); color: var(--ink); border: 1px solid var(--line); }
.btn-small { padding: 8px 12px; min-height: 36px; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.section-title {
  font-family: var(--serif);
  color: var(--green);
  font-size: clamp(1.35rem, 4vw, 2rem);
  margin: 30px 0 14px;
  text-decoration: underline;
  text-underline-offset: 5px;
}
.section-lead { color: var(--muted); line-height: 1.65; margin-bottom: 16px; }

.works-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.work-card {
  position: relative;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(253,250,244,.87);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.work-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: var(--blue);
  opacity: .9;
}
.work-card[data-color="red"]::before { background: var(--red); }
.work-card[data-color="blue"]::before { background: var(--blue); }
.work-card[data-color="green"]::before { background: var(--green); }
.work-card[data-color="purple"]::before { background: var(--purple); }
.work-card:hover, .choice-card:hover { transform: translateY(-4px); box-shadow: 0 15px 34px rgba(0,0,0,.16); border-color: rgba(183,134,11,.72); background: #fffdf8; }
.work-emoji { font-size: 2.2rem; }
.work-title { font-family: var(--serif); font-size: 1.35rem; color: var(--red); line-height: 1.15; }
.work-author { color: var(--blue); font-weight: 800; }
.work-parcours { color: var(--green); font-size: .94rem; line-height: 1.35; font-weight: 700; }
.work-desc { color: #4c4b58; line-height: 1.55; font-size: .96rem; }
.work-card .btn { margin-top: auto; width: 100%; }

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 4px;
}
.stat-mini {
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.stat-mini strong { display: block; font-family: var(--serif); color: var(--red); font-size: 1.55rem; }
.stat-mini span { color: var(--muted); font-size: .9rem; }

.setup-panel, .quiz-shell, .stats-panel, .empty-state {
  background: rgba(253,250,244,.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 3vw, 24px);
  box-shadow: 0 8px 22px rgba(0,0,0,.07);
}
.selector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 22px;
}
.choice-card {
  border: 1px solid var(--line);
  background: rgba(245,240,232,.84);
  border-radius: 14px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
  min-height: 86px;
}
.choice-card strong { display: block; color: var(--ink); margin-bottom: 5px; }
.choice-card span { color: var(--muted); font-size: .9rem; line-height: 1.35; }
.choice-card.is-selected {
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px rgba(192,57,43,.15), 0 10px 24px rgba(0,0,0,.08);
  background: var(--soft-red);
}
.choice-card.compact { min-height: auto; }

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.quiz-meta { color: var(--muted); line-height: 1.5; }
.timer {
  white-space: nowrap;
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--blue);
  font-weight: 800;
}
.progress-wrap {
  height: 12px;
  border-radius: 999px;
  background: rgba(212,201,168,.45);
  overflow: hidden;
  margin: 14px 0 22px;
  border: 1px solid rgba(212,201,168,.8);
}
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); width: 0%; transition: width .25s ease; }
.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  padding: clamp(16px, 3vw, 24px);
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--paper2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
}
.badge.red { color: var(--red); }
.badge.blue { color: var(--blue); }
.badge.green { color: var(--green); }
.question-title { font-family: var(--serif); font-size: clamp(1.28rem, 4vw, 1.85rem); color: var(--ink); line-height: 1.22; margin-bottom: 16px; }
.quote-display {
  border-left: 4px solid var(--gold);
  background: #fef9f0;
  border-radius: 10px;
  padding: 14px 16px;
  font-family: var(--serif);
  font-size: 1.14rem;
  line-height: 1.55;
  margin: 10px 0 16px;
}
.options { display: grid; gap: 10px; }
.option-btn, .answer-input, .select-answer {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.option-btn:hover { background: var(--paper2); transform: translateX(2px); }
.option-btn.selected { border-color: var(--blue); background: var(--soft-blue); }
.option-btn.correct { border-color: var(--green); background: #edf9f0; }
.option-btn.wrong { border-color: var(--red); background: var(--soft-red); }
.answer-input { cursor: text; min-height: 92px; resize: vertical; }
.association-grid { display: grid; gap: 12px; }
.association-row {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(180px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--paper2);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.association-left { font-weight: 800; color: var(--blue); }
.flashcard-answer {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--gold);
  background: #fef9f0;
  line-height: 1.65;
}
.flashcard-answer.is-visible { display: block; }
.feedback {
  display: none;
  margin-top: 18px;
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  line-height: 1.65;
}
.feedback.is-visible { display: block; }
.feedback.good { background: #edf9f0; border-color: rgba(30,132,73,.4); }
.feedback.bad { background: var(--soft-red); border-color: rgba(192,57,43,.35); }
.feedback h3 { margin-bottom: 8px; font-family: var(--serif); }
.course-reminder {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0,0,0,.15);
  color: #464555;
}
.quiz-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.result-card {
  text-align: center;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 4vw, 34px);
}
.result-score { font-family: var(--serif); font-size: clamp(2.2rem, 8vw, 5rem); color: var(--red); line-height: 1; margin: 10px 0; }
.result-appreciation { color: var(--blue); font-weight: 900; font-size: 1.25rem; margin-bottom: 14px; }
.correction-list { display: grid; gap: 10px; text-align: left; margin-top: 20px; }
.correction-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--paper); }
.correction-item.good { border-left: 5px solid var(--green); }
.correction-item.bad { border-left: 5px solid var(--red); }
.correction-item strong { color: var(--ink); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 22px;
}
.stat-card {
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px;
}
.stat-card .value { font-family: var(--serif); color: var(--red); font-size: 2rem; display: block; line-height: 1; }
.stat-card .label { color: var(--muted); font-size: .92rem; }
.progress-row { margin: 14px 0; }
.progress-row-head { display: flex; justify-content: space-between; gap: 12px; color: var(--ink); font-weight: 800; margin-bottom: 6px; }
.progress-track { height: 12px; border-radius: 999px; background: rgba(212,201,168,.45); overflow: hidden; border: 1px solid var(--line); }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--green)); }
.history-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .95rem; }
.history-table th, .history-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.history-table th { color: var(--blue); background: var(--paper2); }
.mastery-badge { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .82rem; font-weight: 800; }
.mastery-badge.ok { background: #edf9f0; color: var(--green); }
.mastery-badge.mid { background: #fff8e4; color: #866600; }
.mastery-badge.low { background: var(--soft-red); color: var(--red); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
hr { border: 0; border-top: 1px dashed rgba(26,26,46,.18); margin: 28px 0; }

@media (max-width: 980px) {
  .works-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .selector-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-strip, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { padding: 0; }
  .page { min-height: 100vh; border-radius: 0; }
  .page::after { left: 34px; }
  .content { padding: 20px 14px 42px 48px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .navlinks { justify-content: flex-start; }
  .works-grid, .selector-grid, .dashboard-strip, .stats-grid { grid-template-columns: 1fr; }
  .work-card { min-height: 0; }
  .quiz-header { align-items: flex-start; flex-direction: column; }
  .association-row { grid-template-columns: 1fr; }
  .hero { text-align: left; }
  .titre-principal { text-align: left; }
  .subtitle { text-align: left; }
  .hero-actions { justify-content: flex-start; }
  .history-table { font-size: .84rem; }
  .history-table th, .history-table td { padding: 8px 6px; }
}
