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

:root {
  --blue:      #2563eb;
  --blue-dark: #1d4ed8;
  --blue-light:#eff6ff;
  --green:     #16a34a;
  --green-bg:  #f0fdf4;
  --red:       #dc2626;
  --red-bg:    #fef2f2;
  --yellow-bg: #fefce8;
  --yellow:    #ca8a04;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --text:      #0f172a;
  --muted:     #64748b;
  --border:    #e2e8f0;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
}

#app { width: 100%; max-width: 680px; }

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px;
}

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.brand-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--blue); color: #fff;
  font-size: 22px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.brand h1 { font-size: 24px; font-weight: 800; line-height: 1; }
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
  margin-bottom: 20px;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--blue);
  background: var(--blue-light);
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-icon { font-size: 36px; margin-bottom: 10px; }
.drop-title { font-size: 15px; font-weight: 600; color: var(--text); }
.drop-hint  { font-size: 13px; color: var(--muted); margin-top: 4px; }

.file-name {
  font-size: 13px; font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  padding: 8px 14px; border-radius: 8px;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 6px;
}

/* ── Field / Stepper ── */
.field { margin-bottom: 24px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.stepper {
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: 10px;
  overflow: hidden; width: fit-content;
}
.stepper-btn {
  width: 40px; height: 40px;
  border: none; background: var(--bg);
  font-size: 20px; cursor: pointer; color: var(--text);
  transition: background .15s;
  line-height: 1;
}
.stepper-btn:hover { background: var(--border); }
.stepper input[type="number"] {
  width: 64px; height: 40px;
  border: none; outline: none;
  text-align: center; font-size: 16px; font-weight: 700;
  color: var(--text);
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  border: 2px solid transparent; transition: all .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--blue); color: #fff; border-color: var(--blue);
  width: 100%;
}
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }

.btn-outline {
  background: transparent; color: var(--blue); border-color: var(--blue);
}
.btn-outline:hover { background: var(--blue-light); }

.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; width: auto; }

/* ── Error ── */
.error-msg {
  margin-top: 14px;
  font-size: 13px; color: var(--red);
  background: var(--red-bg); padding: 10px 14px;
  border-radius: 8px; text-align: center;
}

/* ── Loading ── */
.loading-card { text-align: center; padding: 52px 36px; }
.loading-card h2 { margin: 20px 0 28px; font-size: 20px; }

.spinner {
  width: 52px; height: 52px; margin: 0 auto;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-steps { text-align: left; display: flex; flex-direction: column; gap: 14px; }

.load-step {
  display: flex; align-items: center; gap: 12px;
  font-size: 14px; color: var(--muted);
  padding: 10px 14px; border-radius: 8px;
  transition: all .3s;
}
.load-step.done   { color: var(--green); background: var(--green-bg); }
.load-step.active { color: var(--blue);  background: var(--blue-light); font-weight: 600; }

.step-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.load-step.active .step-dot { animation: pulse 1s ease infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.4); opacity: .6; }
}

/* ── Quiz Header ── */
.quiz-header {
  margin-bottom: 20px;
}
.quiz-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.quiz-file { font-size: 13px; color: var(--muted); font-weight: 500; }

.progress-bar {
  height: 8px; background: var(--border); border-radius: 99px; overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%; background: var(--blue);
  border-radius: 99px; transition: width .4s ease;
}
.progress-info {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted);
}
.progress-info strong { color: var(--text); }

/* ── Quiz Card ── */
.quiz-card { padding: 32px; }
.q-label { font-size: 12px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }

.question-text {
  font-size: 20px; font-weight: 700; line-height: 1.4;
  margin-bottom: 28px;
}

/* ── Options ── */
.options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }

.option-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card); cursor: pointer;
  font-size: 15px; font-weight: 500; color: var(--text);
  text-align: left; transition: all .15s;
  line-height: 1.4;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--blue); background: var(--blue-light);
}
.option-btn .opt-letter {
  min-width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--muted);
  flex-shrink: 0; transition: all .15s;
}

.option-btn.correct {
  border-color: var(--green); background: var(--green-bg); color: var(--green);
}
.option-btn.correct .opt-letter {
  background: var(--green); border-color: var(--green); color: #fff;
}
.option-btn.wrong {
  border-color: var(--red); background: var(--red-bg); color: var(--red);
}
.option-btn.wrong .opt-letter {
  background: var(--red); border-color: var(--red); color: #fff;
}
.option-btn:disabled { cursor: default; }

/* ── Explanation ── */
.explanation {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--yellow-bg); border: 1.5px solid #fde68a;
  border-radius: 10px; padding: 14px 16px;
  font-size: 14px; line-height: 1.5;
  margin-bottom: 20px;
  animation: fadeIn .2s ease;
}
.expl-icon { font-size: 18px; flex-shrink: 0; }

/* ── Score ── */
.score-card { text-align: center; padding: 40px 36px; }
.trophy { font-size: 56px; margin-bottom: 12px; }
.score-card h2 { font-size: 24px; font-weight: 800; margin-bottom: 16px; }

.score-display {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 12px;
}
.score-num  { font-size: 56px; font-weight: 900; color: var(--blue); line-height: 1; }
.score-sep  { font-size: 36px; color: var(--muted); }
.score-den  { font-size: 36px; font-weight: 700; color: var(--muted); }

.score-msg { font-size: 16px; color: var(--muted); margin-bottom: 28px; }

.score-actions { display: flex; gap: 12px; margin-bottom: 32px; }
.score-actions .btn { flex: 1; }

/* ── Recap ── */
.recap-details summary {
  cursor: pointer; font-size: 14px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 0;
  border-top: 1.5px solid var(--border);
  padding-top: 20px;
  list-style: none;
}
.recap-details summary::-webkit-details-marker { display: none; }

.recap-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }

.recap-item {
  padding: 12px 16px; border-radius: 10px; font-size: 13px;
  display: flex; gap: 10px; align-items: flex-start;
  border: 1.5px solid var(--border);
}
.recap-item.ok  { border-color: var(--green); background: var(--green-bg); }
.recap-item.nok { border-color: var(--red);   background: var(--red-bg);   }

.recap-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.recap-content { flex: 1; }
.recap-q  { font-weight: 600; margin-bottom: 4px; }
.recap-a  { color: var(--muted); }
.recap-a strong { color: var(--text); }

/* ── Brand header ── */
.brand-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: -36px -36px 28px -36px;
  padding: 32px 24px 28px;
  background: linear-gradient(160deg, #0f2449 0%, #1d4ed8 100%);
  border-radius: var(--radius) var(--radius) 0 0;
}

.lang-btn {
  position: absolute;
  top: 14px;
  right: 14px;
}

.brand-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.lsm-logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.3));
}

.brand-text {
  text-align: center;
}

.brand-text h1 {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  margin-bottom: 6px;
  letter-spacing: -.01em;
}

.brand-sub {
  font-size: 13px;
  color: #93c5fd;
}

/* ── Brand (removed, replaced by brand-header) ── */
.brand { display: none; }
.brand-icon { display: none; }

/* ── Language toggle ── */
.lang-btn {
  padding: 6px 14px; border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,.3);
  background: rgba(255,255,255,.12); color: #fff;
  font-size: 13px; font-weight: 700; cursor: pointer;
  transition: all .15s; white-space: nowrap;
  backdrop-filter: blur(4px);
}
.lang-btn:hover { background: rgba(255,255,255,.25); border-color: rgba(255,255,255,.6); }
.lang-btn.en    { background: rgba(255,255,255,.22); border-color: #fff; }

/* ── Difficulty picker ── */
.difficulty-picker {
  display: flex; gap: 10px;
}
.diff-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--card);
  cursor: pointer; transition: all .15s; text-align: center;
}
.diff-btn:hover { border-color: var(--blue); background: var(--blue-light); }
.diff-btn.active { border-color: var(--blue); background: var(--blue-light); }
.diff-icon  { font-size: 22px; }
.diff-label { font-size: 13px; font-weight: 700; color: var(--text); }
.diff-desc  { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* Colour per level when active */
.diff-btn[data-level="debutant"].active      { border-color: var(--green); background: var(--green-bg); }
.diff-btn[data-level="intermediaire"].active { border-color: #d97706;      background: #fffbeb; }
.diff-btn[data-level="avance"].active        { border-color: var(--red);   background: var(--red-bg); }

/* ── Difficulty badge (in quiz) ── */
.diff-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 2px 9px;
  border-radius: 99px; text-transform: uppercase; letter-spacing: .05em;
  vertical-align: middle; margin-left: 6px;
}
.diff-badge.debutant      { background: var(--green-bg); color: var(--green); }
.diff-badge.intermediaire { background: #fffbeb;         color: #d97706; }
.diff-badge.avance        { background: var(--red-bg);   color: var(--red); }

/* ── Utilities ── */
.hidden { display: none !important; }

@media (max-width: 480px) {
  .card { padding: 24px 18px; }
  .quiz-card { padding: 24px 18px; }
  .question-text { font-size: 17px; }
  .score-num { font-size: 44px; }
  .score-actions { flex-direction: column; }
}
