/* Random Drill — module styles.
   Loaded after main.css. Only NEW tokens are declared on :root; the palette
   itself (--bg, --orange, --blue, --ink, --border) stays owned by main.css so
   the mandated design system has a single source of truth. */

:root {
  --ink-muted:     rgba(240, 240, 240, 0.45);
  --line:          rgba(240, 240, 240, 0.10);
  --hero:          'Bebas Neue', sans-serif;
  --display:       'Syne', sans-serif;
  --mono:          'Fira Code', monospace;

  /* Read back by drill.js through getComputedStyle. Keep them unitless-safe:
     the JS parses the px value of --item-height and the integer count. */
  --item-height:   60px;
  --visible-items: 5;

  /* Driven by JS, 1 -> 0 across a phase. */
  --timer-progress: 1;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */

.drill {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px 64px;
  min-height: 72dvh;
}

.drill-accent {
  height: 2px;
  background: linear-gradient(90deg, var(--orange), var(--blue));
}

/* Subtle technical grid, faded out top and bottom so it never fights the text. */
.drill-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 48px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 48px);
  opacity: 0.35;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}

.drill-inner {
  position: relative;
  z-index: 1;
}

/* main.css sets `section { padding: 72px 0 }` for the site sections; the module
   panels manage their own rhythm. */
.drill section { padding: 0; }

.drill-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 40px;
}

.drill-title {
  font-family: var(--hero);
  font-size: 54px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink);
  margin: 0;
}

.drill-label {
  font-family: var(--display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.drill-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 8px;
  max-width: 56ch;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.drill-btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 12px 26px;
  border: 1px solid var(--orange);
  border-radius: 0;
  background: var(--orange);
  color: var(--bg);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.drill-btn:hover { background: transparent; color: var(--orange); }

.drill-btn.ghost {
  background: transparent;
  color: var(--ink-muted);
  border-color: var(--line);
}

.drill-btn.ghost:hover { color: var(--ink); border-color: var(--ink-muted); }

.drill-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.drill-icon-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.drill-icon-btn:hover { color: var(--orange); border-color: var(--orange); }

.drill :is(button, a, [tabindex]):focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* ── Category tabs ──────────────────────────────────────────────────────── */

.drill-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 28px 0 20px;
  border-bottom: 1px solid var(--line);
}

.drill-tab {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--ink-muted);
  cursor: pointer;
}

.drill-tab:hover { color: var(--ink); }

.drill-tab[aria-selected="true"] {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

/* ── Reel ───────────────────────────────────────────────────────────────── */

.drill-reel-wrap {
  position: relative;
  height: calc(var(--item-height) * var(--visible-items));
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  /* Fades the left and right edges of the strip. */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

/* Selection band, fixed on the centre row. */
.drill-marker {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--item-height) * ((var(--visible-items) - 1) / 2));
  height: var(--item-height);
  border-top: 1px solid var(--orange);
  border-bottom: 1px solid var(--orange);
  background: rgba(233, 130, 19, 0.05);
  pointer-events: none;
  z-index: 2;
}

.drill-reel-track {
  position: absolute;
  left: 0;
  right: 0;
  /* Two buffer rows live above the viewport. */
  top: calc(var(--item-height) * -2);
  will-change: transform;
}

.drill-item {
  height: var(--item-height);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 0 20px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drill-item.is-focused {
  color: var(--orange);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.drill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}

/* ── Session panel ──────────────────────────────────────────────────────── */

.drill-session {
  margin-top: 32px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.drill-session.is-visible { opacity: 1; transform: translateY(0); }

.drill-session-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.drill-phase {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
}

.drill-concept {
  font-family: var(--hero);
  font-size: clamp(34px, 7vw, 64px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 28px 0 8px;
}

/* In the quiz, the question is the subject of attention: the drawn concept
   steps down to a header line so it stops competing with it. */
.drill[data-mode="quiz"] .drill-concept {
  font-size: 24px;
  color: var(--ink-muted);
  margin: 20px 0 0;
}

.drill-actions-center { justify-content: center; }

.drill-concept-detail {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 62ch;
  line-height: 1.7;
}

/* ── Circular timer ─────────────────────────────────────────────────────── */

.drill-timer {
  position: relative;
  width: min(56vw, 240px);
  aspect-ratio: 1;
  margin: 36px auto 8px;
  border-radius: 50%;
  background: conic-gradient(
    var(--orange) calc(var(--timer-progress) * 360deg),
    rgba(240, 240, 240, 0.08) 0
  );
  display: grid;
  place-items: center;
}

/* Hollow centre, punched with a solid disc rather than a mask. */
.drill-timer::after {
  content: '';
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: var(--bg);
}

.drill-timer.is-done {
  background: var(--orange);
}

.drill-timer-value {
  position: relative;
  z-index: 1;
  font-family: var(--hero);
  font-size: clamp(40px, 10vw, 64px);
  line-height: 1;
  color: var(--ink);
  letter-spacing: 0.04em;
}

.drill-timer.is-done .drill-timer-value { color: var(--bg); }

/* ── Quiz ───────────────────────────────────────────────────────────────── */

.drill-quiz-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.drill-mini-timer {
  font-family: var(--hero);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

.drill-mini-timer.is-urgent {
  color: #dc2626;
  animation: drill-pulse 1s ease-in-out infinite;
}

@keyframes drill-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.drill-counter {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-muted);
}

/* Cadre de l'enonce : fond `--surface` et filet orange a gauche, pour qu'il se
   detache nettement du fond de page et des cartes de reponse. */
.drill-question {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(18px, 3vw, 26px);
  line-height: 1.45;
  color: var(--ink);
  margin: 28px 0 18px;
  padding: 20px 22px;
  max-width: 62ch;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3px solid var(--orange);
}

/* Bande de consigne : comment interagir avec ce type de question. Placee avant
   la zone de reponse, pas en note de bas de bloc. */
.drill-howto {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink);
  background: rgba(22, 54, 102, 0.35);
  border-left: 3px solid var(--blue);
  padding: 10px 14px;
  margin-bottom: 18px;
  max-width: 62ch;
}

.drill-plan {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  margin: 20px 0 4px;
}

.drill-plan b { color: var(--orange); font-weight: 500; }

/* ── Progression ────────────────────────────────────────────────────────── */

.drill-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.drill-dot {
  width: 26px;
  height: 5px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--line);
  cursor: pointer;
}

.drill-dot.is-answered { background: var(--ink-muted); }
.drill-dot.is-current  { background: var(--orange); }

/* ── Reponses ───────────────────────────────────────────────────────────── */

.drill-qbody { margin-bottom: 28px; }

.drill-choice {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0;
  padding: 13px 15px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.drill-choice:hover { border-color: var(--ink-muted); background: #16203a; }

.drill-choice.is-picked {
  border-color: var(--orange);
  border-left-width: 3px;
  background: rgba(233, 130, 19, 0.14);
}

.drill-choice-key {
  font-weight: 600;
  color: var(--orange);
  flex-shrink: 0;
  min-width: 1.2em;
}

.drill-choice-tf {
  display: inline-flex;
  width: auto;
  min-width: 140px;
  justify-content: center;
  margin-right: 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* Association gauche-droite */

.drill-match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.drill-match-head {
  font-family: var(--display);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.drill-match-slot {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.drill-match-slot.is-active {
  border-color: var(--orange);
  border-left-width: 3px;
  background: rgba(233, 130, 19, 0.14);
}
.drill-match-slot.is-filled { border-left: 3px solid var(--orange); }
.drill-match-slot:hover      { border-color: var(--ink-muted); }
/* Cible de depot survolee pendant un glisser. */
.drill-match-slot.is-drop { border-color: var(--orange); background: rgba(233,130,19,0.2); }

.drill-match-left  { display: block; }
.drill-match-value { display: block; margin-top: 5px; color: var(--orange); font-size: 11px; }
.drill-match-value.is-empty { color: var(--ink-muted); }

.drill-match-chip {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  background: #131c2f;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0;
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: grab;
}

.drill-match-chip:hover { border-color: var(--ink-muted); }
.drill-match-chip.is-used { opacity: 0.28; cursor: default; }
.drill-match-chip.is-dragging { opacity: 0.5; cursor: grabbing; }

/* Remise en ordre */

.drill-order-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 3px solid var(--blue);
  padding: 11px 13px;
  margin-bottom: 8px;
  cursor: grab;
}

.drill-order-row.is-dragging { opacity: 0.5; cursor: grabbing; }
.drill-order-row.is-drop { border-color: var(--orange); border-left-color: var(--orange); }

.drill-order-num  { color: var(--orange); flex-shrink: 0; }
.drill-order-text { flex: 1; min-width: 0; }
.drill-order-ctrl { display: flex; gap: 4px; flex-shrink: 0; }

.drill-order-btn {
  font-size: 11px;
  line-height: 1;
  padding: 6px 8px;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
}

.drill-order-btn:hover:not([disabled]) { color: var(--orange); border-color: var(--orange); }
.drill-order-btn[disabled] { opacity: 0.25; cursor: not-allowed; }

.drill-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 12px;
}

/* ── Finished ───────────────────────────────────────────────────────────── */

.drill-score {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 24px 0 4px;
}

.drill-score-value {
  font-family: var(--hero);
  font-size: clamp(48px, 11vw, 82px);
  line-height: 1;
  color: var(--orange);
}

.drill-score-label {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
}

.drill-review-main { flex: 1; min-width: 0; }
.drill-review-q { color: var(--ink); margin-bottom: 4px; }

.drill-review-verdict {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.drill-review-item.is-ok .drill-review-verdict { color: #16a34a; }
.drill-review-item.is-ko .drill-review-verdict { color: #dc2626; }

.drill-review-expected {
  font-size: 12px;
  color: var(--orange);
  margin-top: 6px;
  white-space: pre-line;
}

.drill-review-why {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
}

.drill-recap-stat {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 6px;
}

.drill-recap-stat b { color: var(--ink); font-weight: 500; }

.drill-review {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.drill-review-item {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
}

.drill-review-item:last-child { border-bottom: 0; }

.drill-review-num { color: var(--orange); flex-shrink: 0; }

.drill-link {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 2px 0;
  cursor: pointer;
}

.drill-link:hover { color: var(--orange); border-bottom-color: var(--orange); }

/* ── Dev mode ───────────────────────────────────────────────────────────── */

.drill-dev-banner {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
  padding: 5px;
  background: var(--orange);
  color: var(--bg);
}

.drill-dev-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--orange);
  background: rgba(10, 14, 23, 0.88);
  border-top: 1px solid var(--orange);
  padding: 6px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  backdrop-filter: blur(4px);
}

.drill-dev-bar b { color: var(--ink); font-weight: 400; }

.drill-dev-preview {
  margin-top: 24px;
  border: 1px solid var(--orange);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.8;
  color: var(--ink-muted);
}

.drill-dev-preview b {
  display: block;
  color: var(--orange);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10px;
  margin-bottom: 6px;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  :root { --item-height: 52px; }
  .drill { padding: 0 16px 56px; min-height: 100dvh; }
  .drill-title { font-size: 42px; }
  .drill-item { font-size: 13px; }
  .drill-item.is-focused { font-size: 16px; }
  .drill-timer { width: min(74vw, 280px); }
  /* Deux colonnes cote a cote deviennent illisibles : on empile, la colonne
     de gauche restant au-dessus de ses propositions. */
  .drill-match { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 380px) {
  :root { --item-height: 46px; }
  .drill-title { font-size: 36px; }
  .drill-item { font-size: 12px; }
  .drill-item.is-focused { font-size: 15px; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
/* The reel animation is skipped in JS as well; this kills the residual
   transitions so nothing moves at all. */

@media (prefers-reduced-motion: reduce) {
  .drill-session { transition: none; }
  .drill-mini-timer.is-urgent { animation: none; }
}
