/* ═══════════════════════════════════════════════════════════════════
   Bon Carburant — design system commun aux 3 interfaces
   Signature : le compteur de pompe (chiffres qui défilent) et le ticket perforé
   ═══════════════════════════════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,400..800&family=Hanken+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap");

:root {
  /* palette — tirée de l'affiche */
  --nuit: #071B3D;
  --encre: #0B2A5B;
  --encre-2: #1A3F7A;
  --feuille: #13965A;
  --feuille-2: #0E7A49;
  --pompe: #F08A1C;
  --pompe-2: #C96A06;
  --papier: #F3F6FA;
  --surface: #FFFFFF;
  --surface-2: #EEF2F8;
  --brume: #DCE3EE;
  --texte: #0E1B33;
  --texte-2: #4D5B75;
  --texte-3: #8592A8;
  --danger: #D23B3B;
  --danger-fond: #FDECEC;

  /* statuts du bon — une couleur par étape, la même partout */
  --st-genere: #2F6FDB;
  --st-presente: #F08A1C;
  --st-valide: #13965A;
  --st-reglement_demande: #7B5BD6;
  --st-regle: #0E7A49;
  --st-expire: #8592A8;
  --st-annule: #D23B3B;

  --f-titre: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --f-texte: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --f-code: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;
  --r-xl: 32px;
  --ombre-1: 0 1px 2px rgba(7, 27, 61, .06), 0 1px 1px rgba(7, 27, 61, .04);
  --ombre-2: 0 8px 24px -8px rgba(7, 27, 61, .18), 0 2px 6px rgba(7, 27, 61, .06);
  --ombre-3: 0 24px 60px -16px rgba(7, 27, 61, .35);
  --ressort: cubic-bezier(.2, 1.2, .35, 1);
  --doux: cubic-bezier(.22, .8, .25, 1);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --papier: #06142E; --surface: #0C1F42; --surface-2: #12295A; --brume: #1E3769;
    --texte: #EAF0FA; --texte-2: #A9B7D0; --texte-3: #6F82A6; --danger-fond: #3A1520;
    --ombre-1: 0 1px 2px rgba(0,0,0,.4); --ombre-2: 0 10px 30px -10px rgba(0,0,0,.6); --ombre-3: 0 30px 70px -20px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --papier: #06142E; --surface: #0C1F42; --surface-2: #12295A; --brume: #1E3769;
  --texte: #EAF0FA; --texte-2: #A9B7D0; --texte-3: #6F82A6; --danger-fond: #3A1520;
  --ombre-1: 0 1px 2px rgba(0,0,0,.4); --ombre-2: 0 10px 30px -10px rgba(0,0,0,.6); --ombre-3: 0 30px 70px -20px rgba(0,0,0,.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--papier); color: var(--texte);
  font: 500 15px/1.5 var(--f-texte); font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pompe) 70%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ───────── typographie ───────── */
.titre-xl, .titre-l, .titre-m, .titre-s { font-family: var(--f-titre); margin: 0; letter-spacing: -.02em; line-height: 1.05; }
.titre-xl { font-size: clamp(34px, 6vw, 48px); font-weight: 800; font-variation-settings: "wdth" 85; }
.titre-l { font-size: 26px; font-weight: 750; font-variation-settings: "wdth" 88; }
.titre-m { font-size: 19px; font-weight: 700; }
.titre-s { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.surtitre { font: 700 11px/1.2 var(--f-texte); letter-spacing: .12em; text-transform: uppercase; color: var(--texte-3); }
.discret { color: var(--texte-2); }
.tres-discret { color: var(--texte-3); font-size: 13px; }
.code-bon { font: 700 15px/1 var(--f-code); letter-spacing: .06em; }
.chiffre { font-family: var(--f-titre); font-variation-settings: "wdth" 80; font-weight: 750; letter-spacing: -.02em; }

/* ───────── compteur de pompe (signature) ─────────
   <span class="compteur" data-valeur="25000"></span> ; animé par kit.compteur() */
.compteur { display: inline-flex; align-items: baseline; font-family: var(--f-titre); font-variation-settings: "wdth" 78; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.compteur .cpt-chiffre { display: inline-block; height: 1em; overflow: hidden; position: relative; width: .62em; text-align: center; }
.compteur .cpt-rouleau { display: flex; flex-direction: column; transition: transform 1.1s var(--doux); }
.compteur .cpt-rouleau > span { height: 1em; display: block; }
.compteur .cpt-sep { width: .24em; }
.compteur .cpt-unite { font-size: .38em; font-weight: 700; margin-left: .3em; letter-spacing: .04em; opacity: .7; font-variation-settings: "wdth" 100; }
.compteur.lcd { background: #04122B; color: #FFB24A; padding: .18em .3em; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), inset 0 8px 18px rgba(0,0,0,.5); text-shadow: 0 0 12px rgba(255,166,50,.45); }

/* ───────── boutons ───────── */
.btn {
  --fond: var(--surface-2); --coul: var(--texte);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border: 0; border-radius: 14px;
  background: var(--fond); color: var(--coul); font-weight: 700; font-size: 15px; letter-spacing: -.005em;
  transition: transform .18s var(--ressort), box-shadow .2s, background .2s, opacity .2s; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-principal { --fond: var(--encre); --coul: #fff; box-shadow: 0 8px 20px -8px rgba(11, 42, 91, .6); }
.btn-vert { --fond: var(--feuille); --coul: #fff; box-shadow: 0 8px 20px -8px rgba(19, 150, 90, .6); }
.btn-pompe { --fond: var(--pompe); --coul: #1B0F00; box-shadow: 0 8px 20px -8px rgba(240, 138, 28, .7); }
.btn-danger { --fond: var(--danger-fond); --coul: var(--danger); }
.btn-fantome { --fond: transparent; --coul: var(--texte-2); }
.btn-fantome:hover { --fond: var(--surface-2); }
.btn-l { min-height: 56px; font-size: 16px; border-radius: 18px; padding: 0 22px; }
.btn-s { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-bloc { width: 100%; }
.btn-icone { width: 42px; min-height: 42px; padding: 0; border-radius: 12px; }
.btn[aria-busy="true"]::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: tourne .7s linear infinite; }

/* ───────── champs ───────── */
.champ { display: grid; gap: 6px; }
.champ > span { font-size: 13px; font-weight: 700; color: var(--texte-2); }
.saisie {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px;
  background: var(--surface); border: 1.5px solid var(--brume); outline: 0;
  transition: border-color .2s, box-shadow .2s; font-weight: 600;
}
.saisie:focus { border-color: var(--encre-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--encre-2) 18%, transparent); }
select.saisie { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238592A8' stroke-width='2'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.grille-champs { display: grid; gap: 14px; }
@media (min-width: 640px) { .grille-champs.deux { grid-template-columns: 1fr 1fr; } }

/* ───────── surfaces ───────── */
.carte { background: var(--surface); border-radius: var(--r-l); box-shadow: var(--ombre-1); border: 1px solid color-mix(in srgb, var(--brume) 60%, transparent); }
.carte-pad { padding: 20px; }
.separateur { height: 1px; background: var(--brume); border: 0; margin: 0; }

/* pastille de statut */
.statut { --c: var(--texte-3); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; }
.statut::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.statut[data-s="genere"] { --c: var(--st-genere); }
.statut[data-s="presente"] { --c: var(--st-presente); }
.statut[data-s="valide"] { --c: var(--st-valide); }
.statut[data-s="reglement_demande"] { --c: var(--st-reglement_demande); }
.statut[data-s="regle"] { --c: var(--st-regle); }
.statut[data-s="expire"] { --c: var(--st-expire); }
.statut[data-s="annule"] { --c: var(--st-annule); }
.statut[data-s="presente"]::before, .statut[data-s="genere"]::before { animation: pulse 1.6s ease-in-out infinite; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--texte-2); }

/* ───────── ticket (signature) ───────── */
.ticket {
  --entaille: 14px; position: relative; background: var(--surface); border-radius: var(--r-l);
  box-shadow: var(--ombre-2);
  -webkit-mask: radial-gradient(circle var(--entaille) at 0 var(--coupe, 62%), transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle var(--entaille) at 100% var(--coupe, 62%), transparent 98%, #000) right / 51% 100% no-repeat;
          mask: radial-gradient(circle var(--entaille) at 0 var(--coupe, 62%), transparent 98%, #000) left / 51% 100% no-repeat,
                radial-gradient(circle var(--entaille) at 100% var(--coupe, 62%), transparent 98%, #000) right / 51% 100% no-repeat;
}
.perforation { height: 0; border-top: 2px dashed var(--brume); margin: 0 22px; }

/* jauge de carburant : se vide avec le temps restant */
.jauge { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.jauge > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--pompe), var(--feuille)); transition: width 1s linear; }
.jauge.basse > i { background: linear-gradient(90deg, var(--danger), var(--pompe)); }

/* anneau de quota */
.anneau { position: relative; width: var(--t, 132px); height: var(--t, 132px); }
.anneau svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.anneau circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.anneau .fond { stroke: rgba(255,255,255,.14); }
.anneau .val { stroke: url(#degradeQuota); transition: stroke-dashoffset 1.3s var(--doux); }
.anneau .centre { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }

/* ───────── toasts ───────── */
.toasts { position: fixed; z-index: 90; left: 50%; top: calc(12px + var(--haut)); transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--nuit); color: #fff; box-shadow: var(--ombre-3); animation: toastIn .45s var(--ressort); font-weight: 600; }
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.toast.ok svg { color: #4ADE95; }
.toast.erreur svg { color: #FF8B8B; }
.toast.info svg { color: #FFB24A; }
.toast.sortie { animation: toastOut .3s var(--doux) forwards; }

/* ───────── feuille (bottom sheet) & tiroir ───────── */
.voile { position: fixed; inset: 0; z-index: 70; background: rgba(4, 14, 33, .5); backdrop-filter: blur(3px); animation: fondu .25s ease; }
.feuille {
  position: fixed; z-index: 71; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px calc(24px + var(--bas));
  box-shadow: var(--ombre-3); animation: monte .42s var(--ressort); touch-action: pan-y;
}
.feuille::before { content: ""; display: block; width: 40px; height: 5px; border-radius: 9px; background: var(--brume); margin: 0 auto 14px; }
@media (min-width: 760px) {
  .feuille { left: 50%; bottom: auto; top: 50%; width: min(560px, 92vw); transform: translate(-50%, -50%); border-radius: 28px; animation: zoomIn .35s var(--ressort); padding-bottom: 24px; }
  .feuille::before { display: none; }
}
.tiroir { position: fixed; z-index: 71; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); box-shadow: var(--ombre-3); overflow: auto; animation: glisse .4s var(--doux); }
.sortie.feuille { animation: descend .28s var(--doux) forwards; }
@media (min-width: 760px) { .sortie.feuille { animation: zoomOut .2s ease forwards; } }
.sortie.tiroir { animation: glisseOut .28s var(--doux) forwards; }
.sortie.voile { animation: fonduOut .28s ease forwards; }

/* ───────── squelettes & vides ───────── */
.squelette { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 0%, color-mix(in srgb, var(--surface-2) 40%, var(--surface)) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: brille 1.3s linear infinite; }
.vide { display: grid; justify-items: center; gap: 10px; padding: 40px 20px; text-align: center; color: var(--texte-2); }
.vide svg { width: 44px; height: 44px; color: var(--texte-3); }

/* ───────── tableaux (admin) ───────── */
.tableau-wrap { overflow-x: auto; }
.tableau { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.tableau th { text-align: left; font: 700 11px/1 var(--f-texte); letter-spacing: .1em; text-transform: uppercase; color: var(--texte-3); padding: 12px 14px; border-bottom: 1px solid var(--brume); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.tableau td { padding: 13px 14px; border-bottom: 1px solid color-mix(in srgb, var(--brume) 60%, transparent); vertical-align: middle; }
.tableau tbody tr { transition: background .15s; }
.tableau tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tableau tbody tr[data-clic] { cursor: pointer; }
.tableau .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ───────── navigation mobile ───────── */
.barre-onglets {
  position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(10px + var(--bas));
  display: flex; justify-content: space-around; padding: 6px; border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: var(--ombre-3); border: 1px solid color-mix(in srgb, var(--brume) 70%, transparent);
  max-width: 520px; margin: 0 auto;
}
.onglet { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border: 0; background: none; border-radius: 18px; color: var(--texte-3); font-size: 11px; font-weight: 700; transition: color .2s, background .2s; }
.onglet svg { width: 22px; height: 22px; transition: transform .3s var(--ressort); }
.onglet[aria-current="page"] { color: var(--encre); background: color-mix(in srgb, var(--encre) 8%, transparent); }
:root[data-theme="dark"] .onglet[aria-current="page"] { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .onglet[aria-current="page"] { color: #fff; } }
.onglet[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }

/* transitions d'écran */
.ecran { animation: ecranIn .38s var(--doux); }

/* ───────── connexion (commune) ───────── */
.connexion { min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; background: radial-gradient(120% 80% at 100% 0%, var(--encre-2) 0%, var(--encre) 45%, var(--nuit) 100%); color: #fff; overflow: hidden; position: relative; }
.connexion-haut { padding: calc(40px + var(--haut)) 24px 24px; display: grid; align-content: end; gap: 14px; position: relative; z-index: 1; }
.connexion-carte { background: var(--surface); color: var(--texte); border-radius: 32px 32px 0 0; padding: 28px 24px calc(28px + var(--bas)); display: grid; gap: 16px; position: relative; z-index: 1; animation: monte .6s var(--ressort); }
@media (min-width: 760px) {
  .connexion { grid-template-columns: 1.1fr 1fr; grid-template-rows: 1fr; }
  .connexion-haut { padding: 64px; align-content: center; }
  .connexion-carte { margin: auto 64px auto 0; border-radius: 32px; width: min(440px, 100%); justify-self: end; padding: 36px; }
}
.marque { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-titre); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.marque svg { width: 30px; height: 30px; }
.pin { display: flex; gap: 10px; justify-content: space-between; }
.pin input { width: 100%; aspect-ratio: 1; max-width: 64px; text-align: center; font: 800 26px var(--f-titre); border-radius: 16px; border: 1.5px solid var(--brume); background: var(--surface-2); outline: 0; transition: border-color .2s, transform .2s var(--ressort); }
.pin input:focus { border-color: var(--encre-2); background: var(--surface); transform: translateY(-2px); }
.secoue { animation: secoue .45s; }
.trace-carburant { position: absolute; right: -60px; top: -40px; width: 340px; opacity: .14; pointer-events: none; }

/* ───────── animations ───────── */
@keyframes tourne { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
@keyframes brille { to { background-position: -200% 0; } }
@keyframes fondu { from { opacity: 0; } }
@keyframes fonduOut { to { opacity: 0; } }
@keyframes monte { from { transform: translateY(100%); } }
@keyframes descend { to { transform: translateY(100%); } }
@keyframes zoomIn { from { opacity: 0; transform: translate(-50%, -46%) scale(.96); } }
@keyframes zoomOut { to { opacity: 0; transform: translate(-50%, -48%) scale(.97); } }
@keyframes glisse { from { transform: translateX(100%); } }
@keyframes glisseOut { to { transform: translateX(100%); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes ecranIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes secoue { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes apparait { from { opacity: 0; transform: translateY(14px); } }
.apparait { animation: apparait .5s var(--doux) both; animation-delay: calc(var(--i, 0) * 55ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
