/* Le billet : panneau de droite (état A photo, état B impression), papier, talon ; feuille basse et mentions. */
.billet { position: relative; min-height: 0; overflow: hidden; scroll-margin-top: 80px; border-radius: 6px; background: var(--blanc); }
.billet__a { position: absolute; inset: 0; display: flex; flex-direction: column; transition: opacity .32s var(--ease), visibility 0s .32s; }
/* Tant que la photo n'est pas arrivée : son aperçu flou (18 × 24 px) et la couleur de son ciel, jamais un panneau blanc. */
.billet__photo {
  display: block; flex: 1 1 auto; min-height: 0; overflow: hidden;
  background: #7FA3D6 url("data:image/webp;base64,UklGRnwAAABXRUJQVlA4IHAAAABQBACdASoSABgAPt1Yo02opSMiN/qoARAbiWIAACgjZg4Tqo9PFl7MyCWAAPGCgU5dBH1w4zn/9St+p/ov+qqeavvgtx7sD0MEFOCJVxucz6eLvpFjsI0g2ZxJELrLc0lUBJzyRQwdUkyeJmcmAAAA") 60% 92% / cover no-repeat;
  transition: transform .32s var(--ease);
}
.billet__photo img { width: 100%; height: 100%; object-fit: cover; object-position: 60% 92%; }
.cartouche { flex: none; display: grid; justify-items: start; gap: 0; padding: 16px 20px 8px; background: var(--blanc); }
.cartouche p { font: 800 22px/1.2 var(--sans); letter-spacing: -.01em; }
.billet[data-etat="b"] .billet__a { opacity: 0; visibility: hidden; }
.billet[data-etat="b"] .billet__photo { transform: translateY(-6%); }
.billet .imprimante { display: none; }
.billet[data-etat="b"] .imprimante { display: flex; }

/* ---------- L'imprimante : bandeau, fente, papier ---------- */
/* Le bandeau photo : le bassin de Port-Joinville, dans la hauteur que le billet laisse, de 120 à 300 px ;
   sur un écran bas (moins de 820 px), il s'efface et la fente passe en tête. */
.imprimante { position: absolute; inset: 0; flex-direction: column; background: #EEF2F5; }
.imprimante__bandeau { flex: 1 1 0; min-height: 120px; max-height: 300px; overflow: hidden; background: #9BB4CF; }
.imprimante__bandeau picture { display: block; height: 100%; }
.imprimante__bandeau img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }
@media (max-height: 819px) { .billet .imprimante__bandeau { display: none; } }
.feuille .imprimante__bandeau img { object-position: 50% 52%; }
.fente {
  position: relative; z-index: 2; flex: none; height: 12px; margin: 10px 10px 0; border-radius: 6px;
  background: var(--tableau); box-shadow: inset 0 3px 0 #000;
}
.fenetre { position: relative; flex: 0 1 auto; min-height: 0; margin: -6px 18px 0; padding-top: 6px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.papier { background: var(--blanc); border: 1px solid var(--filet); border-top: 0; container: papier / inline-size; }
.papier__corps { display: grid; gap: 2px; padding: 12px 16px 8px; }

/* Billet étroit : le nom du champ passe au-dessus, en petit ; billet large : sur la même ligne, en palettes. */
.champ { position: relative; display: flex; flex-wrap: wrap; align-items: center; column-gap: 11px; min-height: 34px; font: 400 22px/1 var(--mono); color: var(--encre); }
.champ__nom { flex: 0 0 100%; padding-top: 6px; font: 600 12.5px/1.2 var(--sans); color: var(--granit); }
@container papier (min-width: 400px) {
  .champ__nom { flex: none; padding-top: 0; font: 400 22px/1 var(--mono); text-transform: uppercase; }
}
.champ__val { padding: 3px 0 4px; border-bottom: 2px dotted rgb(13 27 41 / .4); white-space: nowrap; }
.champ select, .champ__part select {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; cursor: pointer; appearance: none; border: 0;
}
.champ--deux { column-gap: 11px; }
.champ__part { position: relative; display: inline-flex; align-items: center; }
/* Dans la feuille (écran tactile) : chaque liste est une cible de 44 px, le jour et l'heure écartés. */
.feuille .champ { min-height: 44px; }
.feuille .champ--deux { column-gap: 18px; }
.feuille .champ__part { min-height: 44px; }
.champ:has(select:focus-visible) > .champ__val, .champ__part:has(select:focus-visible) > .champ__val { outline: 2px solid var(--encre); outline-offset: 2px; }
@media (hover: hover) { .champ:hover > .champ__val, .champ__part:hover > .champ__val { border-bottom-color: var(--encre); } }
.champ__note { font: 400 22px/1.3 var(--mono); color: var(--granit); }

.vehicules { display: grid; margin: 6px 0; }
.veh {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "nom qte prix" "reste qte prix";
  align-items: center; column-gap: 10px; min-height: 36px; font: 400 22px/1.1 var(--mono); color: var(--granit);
}
.veh--on { color: var(--encre); }
.veh__nom { grid-area: nom; white-space: nowrap; }
.veh__reste { grid-area: reste; font: 600 12.5px/1.2 var(--sans); color: var(--orange-fonce); }
.veh__reste:empty { display: none; }
.veh__qte { grid-area: qte; display: flex; align-items: center; }
.veh__qte button {
  display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--encre); border-radius: 3px;
  font: 400 22px/1 var(--mono); color: var(--encre);
}
.veh__qte button:disabled { border-color: #c3cad1; color: #9aa4ad; cursor: default; }
.veh__qte output { width: 26px; text-align: center; color: var(--encre); }
.veh__prix { grid-area: prix; min-width: 4.4ch; text-align: right; white-space: nowrap; }
@media (hover: hover) { .veh__qte button:not(:disabled):hover { background: var(--encre); color: var(--blanc); } }

.perforation {
  height: 20px; margin: 0 -1px;
  background:
    radial-gradient(circle 9px at 0 50%, #EEF2F5 97%, transparent 100%) left / 50% 100% no-repeat,
    radial-gradient(circle 9px at 100% 50%, #EEF2F5 97%, transparent 100%) right / 50% 100% no-repeat,
    linear-gradient(to right, #9aa4ad 50%, transparent 50%) center / 10px 2px repeat-x;
}
.talon { position: relative; display: grid; gap: 6px; padding: 8px 16px 14px; background: var(--blanc); transform-origin: 0 0; transition: transform .35s var(--ease); }
.talon.dechire { transform: translateY(10px) rotate(3deg); }
.talon__haut { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.talon__total { display: grid; gap: 4px; }
.talon__nom { font: 600 12.5px/1 var(--sans); color: var(--granit); }
.talon__chiffre { display: flex; align-items: center; gap: 6px; }
.ft--talon { --cw: 30px; --ch: 44px; --cg: 2px; --by: 0px; --fs: 33px; }
.talon__eur { font: 400 33px/1 var(--mono); color: var(--encre); }
.ft--talon .fc-vide { opacity: .22; }
.talon__go { min-width: 140px; }
.talon__go:disabled { filter: grayscale(1) opacity(.45); cursor: default; }
.talon__eco { font-size: 13px; color: var(--orange-fonce); }
.talon__caution { font-size: 14px; line-height: 1.45; color: var(--granit); }
.talon__caution strong { color: var(--encre); }
/* Le talon déchiré descend de 10 px et pivote de 3° (18 px au bout) : la ligne d'état se tient 32 px plus bas, hors de sa course. */
.talon__etat { position: relative; margin: 32px 0 0; padding: 12px 14px 14px 16px; border-left: 4px solid var(--orange); background: var(--blanc); font-size: 15px; line-height: 1.45; color: var(--encre); }
.talon__etat:empty { display: none; }

/* ---------- Feuille basse (sous 1 200 px de large ou 620 px de haut) ---------- */
.feuille {
  position: fixed; inset: auto 0 0 0; width: 100%; max-width: 640px; max-height: 88dvh; margin: 0 auto; padding: 0; border: 0;
  border-radius: 14px 14px 0 0; background: #EEF2F5; color: var(--encre); overflow: hidden;
  transform: translateY(100%); transition: transform .35s var(--ease), display .35s allow-discrete, overlay .35s allow-discrete;
}
.feuille[open] { display: flex; flex-direction: column; transform: none; }
@starting-style { .feuille[open] { transform: translateY(100%); } }
.feuille::backdrop { background: rgb(8 12 18 / .55); }
html:has(dialog[open]) { overflow: hidden; }
.feuille__barre {
  position: relative; flex: none; display: flex; justify-content: flex-end; align-items: center; min-height: 52px;
  padding: 2px max(8px, env(safe-area-inset-right)) 2px 16px;
}
.feuille__barre::before { content: ""; position: absolute; left: 50%; top: 8px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #b7c0c8; }
.feuille__fermer { min-width: 48px; min-height: 48px; padding: 0 12px; font: 600 15px/1 var(--sans); color: var(--encre); text-decoration: underline; text-underline-offset: 4px; }
.feuille__corps { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.feuille .imprimante { position: static; display: flex; background: none; }
/* Feuille : le bandeau garde le rapport de son fichier (4,5:1), la ville entière avec son reflet. */
.feuille .imprimante__bandeau { flex: none; height: auto; min-height: 0; max-height: none; aspect-ratio: 1600 / 355; margin-inline: 12px; border-radius: 4px; }
.feuille .fenetre { overflow: clip; margin-inline: 12px; }

@media (max-width: 859px) {
  .feuille .papier__corps, .feuille .talon { padding-inline: 12px; }
  .veh { min-height: 52px; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "nom prix qte" "reste reste qte"; column-gap: 8px; padding: 4px 0; }
  .veh__qte button { width: 44px; height: 44px; }
  .veh__qte output { width: 30px; }
  .ft--talon { --cw: 36px; --ch: 56px; --fs: 44px; }
  .talon__eur { font-size: 44px; }
  .talon__haut { flex-wrap: wrap; }
}

@media (max-width: 379px) {
  .feuille .fenetre { margin-inline: 8px; }
  .veh { grid-template-areas: "nom qte" "prix qte" "reste qte"; grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .veh__prix { text-align: left; }
}
/* ---------- Mentions et crédits ---------- */
.mentions {
  width: min(560px, calc(100% - 32px)); max-height: 86dvh; padding: 24px; border: 0; border-radius: 8px; background: var(--blanc); color: var(--encre);
  font-size: 15px; line-height: 1.5; overflow-y: auto;
}
.mentions::backdrop { background: rgb(8 12 18 / .6); }
.mentions > * + * { margin-top: 12px; }
.mentions__titre { font: 800 22px/1.2 var(--sans); }
.mentions ul { display: grid; gap: 6px; padding-left: 0; }
.mentions form { margin-top: 18px; }

/* Vue unique sur un grand écran (1 000 px de haut et plus) : le billet s'aère, il descend jusqu'au pied du panneau. */
@media (min-width: 1200px) and (min-height: 1000px) {
  .billet .champ, .billet .veh { min-height: 44px; }
  .billet .papier__corps { padding-block: 16px 12px; }
  .billet .talon { gap: 8px; padding-block: 14px 20px; }
}
/* Vue unique sur un écran bas (1 280 × 660) : le billet se resserre pour que le talon reste visible. */
@media (min-width: 1200px) and (max-height: 759px) {
  .papier__corps { padding: 6px 14px 4px; gap: 0; }
  .champ { min-height: 30px; }
  .champ__nom { padding-top: 2px; }
  .veh { min-height: 30px; }
  .vehicules { margin: 2px 0; }
  .perforation { height: 16px; }
  .talon { gap: 4px; padding: 4px 14px 10px; }
  .talon__caution { font-size: 13.5px; line-height: 1.35; }
}

@media (prefers-reduced-motion: reduce) {
  .billet__a, .billet__photo, .talon, .feuille { transition: none; }
}
