/* Roadmap auto-école — feuille de style v1 (verrou + suivi, nuit par défaut) */

:root {
  --font: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --bg: #10141b;
  --surface: #171d27;
  --surface-2: #202836;
  --ink: #f2f0ea;
  --ink-2: #98a1b0;
  --ink-3: #6b7482;
  --line: rgba(255, 255, 255, 0.09);
  --gold: #f0b84b;
  --gold-soft: rgba(240, 184, 75, 0.16);
  --gold-ink: #17120a;
  --danger: #ff6f6f;
  --danger-soft: rgba(255, 111, 111, 0.14);
  --ok: #4ec98b;
  --ok-soft: rgba(78, 201, 139, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --r-l: 22px;
  --r-m: 14px;
  --r-s: 10px;
}

html[data-theme="light"] {
  --bg: #e9edf2;
  --surface: #ffffff;
  --surface-2: #f2f4f8;
  --ink: #151a22;
  --ink-2: #5d6774;
  --ink-3: #838d9b;
  --line: rgba(21, 26, 34, 0.1);
  --gold: #b8801a;
  --gold-soft: rgba(217, 162, 58, 0.18);
  --gold-ink: #1b1405;
  --danger: #cf3535;
  --danger-soft: rgba(207, 53, 53, 0.1);
  --ok: #1f9b62;
  --ok-soft: rgba(31, 155, 98, 0.12);
  --shadow: 0 14px 34px rgba(21, 26, 34, 0.1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body.locked { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, textarea { font-size: 16px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

/* ------------------------------------------------------------------ */
/* Verrou                                                              */
/* ------------------------------------------------------------------ */

.lock {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #06080c;
  color: #fff;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}

.lock[hidden] { display: none; }

.lock-halo {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 45% at 78% 96%, rgba(240, 184, 75, 0.28), transparent 70%),
    radial-gradient(90% 60% at 50% 120%, rgba(48, 74, 120, 0.55), transparent 70%);
  pointer-events: none;
}

.lock-body {
  position: relative;
  width: min(100%, 380px);
  padding: 20px;
  text-align: center;
}

.lock-title { font-size: 21px; font-weight: 500; margin-bottom: 8px; }
.lock-sub { font-size: 13px; color: rgba(255, 255, 255, 0.45); margin-bottom: 24px; }

.lock-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  height: 12px;
  margin-bottom: 14px;
}

.lock-dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  transition: background 0.12s ease;
}

.lock-dots span.filled { background: #fff; }
.lock-dots.shake { animation: shake 0.45s ease; }

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-9px); }
  40%, 60% { transform: translateX(9px); }
}

.lock-hint {
  min-height: 22px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 26px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 74px);
  gap: 16px 24px;
  justify-content: center;
}

.keypad button {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  transition: transform 0.08s ease, background 0.12s ease;
}

.keypad button:active { background: rgba(255, 255, 255, 0.3); transform: scale(0.96); }
.keypad button b { font-size: 30px; font-weight: 400; line-height: 1; }
.keypad button i { font-size: 9.5px; letter-spacing: 0.14em; font-style: normal; color: rgba(255, 255, 255, 0.65); }
.keypad .key-text { font-size: 14px; background: none; border: 0; -webkit-backdrop-filter: none; backdrop-filter: none; }
.keypad .key-text:active { background: none; }

.lock.denied .keypad { opacity: 0.35; pointer-events: none; }

/* ------------------------------------------------------------------ */
/* Enveloppe                                                           */
/* ------------------------------------------------------------------ */

.app {
  max-width: 900px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 14px)
    max(14px, env(safe-area-inset-right))
    calc(env(safe-area-inset-bottom) + 48px)
    max(14px, env(safe-area-inset-left));
}

.app[hidden] { display: none; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topbar h1 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; flex: 1; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-2); letter-spacing: 0; }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: var(--ink-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { background: var(--surface-2); }
html[data-theme="light"] .ico-moon { display: none; }
html:not([data-theme="light"]) .ico-sun { display: none; }

/* ------------------------------------------------------------------ */
/* Avancement                                                          */
/* ------------------------------------------------------------------ */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 20px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.hero-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.hero-pct { font-size: 42px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.hero-pct span { font-size: 22px; color: var(--ink-2); }
.hero-count { font-size: 13px; color: var(--ink-2); margin-left: auto; text-align: right; }

.bar { height: 9px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width 0.35s ease; }

.hero-legend { margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }

/* ------------------------------------------------------------------ */
/* Verrous du projet                                                   */
/* ------------------------------------------------------------------ */

.gates { display: grid; gap: 10px; margin-bottom: 14px; }
@media (min-width: 620px) { .gates { grid-template-columns: repeat(2, 1fr); } }

.gate {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: var(--r-m);
  padding: 13px 14px;
}

.gate.open { border-color: var(--ok); }

.gate-head { display: flex; align-items: center; gap: 8px; }
.gate-id {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 6px;
  background: var(--danger-soft); color: var(--danger);
}
.gate.open .gate-id { background: var(--ok-soft); color: var(--ok); }
.gate-nom { font-size: 15px; font-weight: 600; flex: 1; }
.gate-etat { font-size: 12px; color: var(--danger); font-weight: 600; }
.gate.open .gate-etat { color: var(--ok); }

.gate-q { font-size: 13px; color: var(--ink-2); margin-top: 7px; }
.gate details { margin-top: 8px; }
.gate summary { font-size: 12.5px; color: var(--gold); cursor: pointer; list-style: none; }
.gate summary::-webkit-details-marker { display: none; }
.gate dl { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.gate dt { font-weight: 600; color: var(--ink); margin-top: 7px; }
.gate dd { margin: 2px 0 0; }

.gate-preuve {
  width: 100%; margin-top: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 9px 11px;
  color: var(--ink); resize: vertical; min-height: 44px; font-size: 14px;
}
.gate-preuve::placeholder { color: var(--ink-3); }

/* ------------------------------------------------------------------ */
/* Onglets et filtres                                                  */
/* ------------------------------------------------------------------ */

.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border-radius: 12px; margin-bottom: 12px;
}

.tabs button {
  flex: 1; padding: 9px 4px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tabs button b { display: inline-block; margin-left: 5px; font-weight: 700; font-size: 12px; color: var(--ink-3); }

.search {
  width: 100%; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 14px; color: var(--ink);
}
.search::placeholder { color: var(--ink-3); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto; padding: 6px 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Liste                                                               */
/* ------------------------------------------------------------------ */

.groupe { margin-top: 18px; }

.groupe-head {
  display: flex; align-items: center; gap: 9px;
  padding: 0 3px 8px;
}
.groupe-head h2 { font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.groupe-head .mini { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; max-width: 120px; }
.groupe-head .mini i { display: block; height: 100%; background: var(--gold); }
.groupe-head span { font-size: 12px; color: var(--ink-3); }

.liste { display: grid; gap: 8px; }

.tache {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 12px 13px;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 11px;
  align-items: start;
}

.tache.bloquee { border-style: dashed; }
.tache.faite { opacity: 0.62; }

.coche {
  width: 26px; height: 26px; border-radius: 8px;
  border: 1.8px solid var(--ink-3); background: transparent;
  display: grid; place-items: center; margin-top: 1px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.coche svg { width: 15px; height: 15px; fill: none; stroke: var(--gold-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.coche[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); }
.coche[aria-pressed="true"] svg { opacity: 1; }
.coche:active { transform: scale(0.92); }

.tache-corps { min-width: 0; }

.tache-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 3px; }
.tache-id { font-size: 11px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.05em; }

.pill { font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; }
.pill.bloquant { background: var(--danger-soft); color: var(--danger); }
.pill.p0 { background: var(--gold-soft); color: var(--gold); }
.pill.p1 { background: var(--surface-2); color: var(--ink-2); }
.pill.p2 { background: var(--surface-2); color: var(--ink-3); }
.pill.decision { background: rgba(120, 160, 255, 0.16); color: #8fb0ff; }
html[data-theme="light"] .pill.decision { background: rgba(45, 90, 200, 0.12); color: #2d5ac8; }
.pill.leve { background: var(--danger); color: #fff; }

.tache-titre { font-size: 15px; line-height: 1.35; }
.tache.faite .tache-titre { text-decoration: line-through; text-decoration-color: var(--ink-3); }

.tache-bloc { margin-top: 6px; font-size: 12.5px; color: var(--danger); display: flex; align-items: center; gap: 5px; }

.tache details { margin-top: 7px; }
.tache summary { font-size: 12.5px; color: var(--gold); cursor: pointer; list-style: none; }
.tache summary::-webkit-details-marker { display: none; }
.tache dl { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.tache dt { font-weight: 600; color: var(--ink); margin-top: 6px; font-size: 12px; }
.tache dd { margin: 2px 0 0; }

.note {
  width: 100%; margin-top: 9px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 8px 10px;
  color: var(--ink); resize: vertical; min-height: 38px; font-size: 14px;
}
.note::placeholder { color: var(--ink-3); }

.vide { text-align: center; color: var(--ink-3); font-size: 14px; padding: 34px 16px; }

/* ------------------------------------------------------------------ */
/* Chaînes de dépendances                                              */
/* ------------------------------------------------------------------ */

.chaine {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-m); padding: 15px 16px; margin-bottom: 10px;
}
.chaine h3 { font-size: 14px; font-weight: 700; margin-bottom: 11px; }
.chaine ol { margin: 0; padding: 0; list-style: none; }
.chaine li { position: relative; padding-left: 20px; padding-bottom: 13px; font-size: 14px; color: var(--ink-2); }
.chaine li:last-child { padding-bottom: 0; }
.chaine li::before {
  content: ""; position: absolute; left: 3px; top: 7px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--gold);
}
.chaine li:not(:last-child)::after {
  content: ""; position: absolute; left: 6.5px; top: 17px; bottom: 1px; width: 1.5px; background: var(--line);
}
.chaine li:first-child { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ */
/* Divers                                                              */
/* ------------------------------------------------------------------ */

.etat-sync {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12.5px;
  padding: 7px 15px; border-radius: 99px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  z-index: 40;
}
.etat-sync.visible { opacity: 1; }
.etat-sync.erreur { color: var(--danger); border-color: var(--danger); }

.pied { margin-top: 26px; text-align: center; font-size: 12px; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
