/* ===== Contrôle des entrées (scanner de billets) — js/controle-billets.js =====
   Plein écran à toutes les largeurs (téléphone, tablette à la porte, portable) :
   un <dialog> modal, donc au-dessus de tout, y compris d'un autre dialogue.
   Les règles « dialog » du thème (biseau, feuille mobile) sont neutralisées. */

#dlg-controle {
  position: fixed; inset: 0;
  width: 100%; height: 100%; height: 100dvh;
  max-width: none !important; max-height: none;
  margin: 0; padding: 0; border: 0;
  clip-path: none; animation: none; overflow: hidden;
  background: #0D0208; color: var(--cream);
}
#dlg-controle[open] { display: flex; flex-direction: column; }
#dlg-controle::backdrop { background: #0D0208; }

/* ----- En-tête : titre, événement contrôlé, compteur, réglages ----- */
.ctl-tete {
  display: flex; align-items: center; gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.ctl-titre { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ctl-titre b { font-family: 'Anton', sans-serif; font-weight: 400; font-size: 17px; letter-spacing: 1px; text-transform: uppercase; }
.ctl-titre b span { color: var(--gold); }
#ctl-evt {
  width: 100%; max-width: 560px; min-width: 0;
  background: var(--card); color: var(--cream); border: 1px solid var(--line-strong);
  font: inherit; font-size: 16px; padding: 5px 8px; border-radius: 0; /* 16 px : pas de zoom iPhone */
}
.ctl-compteur { text-align: right; line-height: 1.05; padding: 0 6px; flex: none; }
.ctl-compteur b { display: block; font-family: 'Anton', sans-serif; font-weight: 400; font-size: 22px; color: var(--gold); white-space: nowrap; }
.ctl-compteur span { font-size: 9.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cream-45); }
.ctl-ico {
  flex: none; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--cream-70); font-size: 18px; cursor: pointer;
}
.ctl-ico:hover { color: var(--cream); }
#ctl-lampe[aria-pressed="true"] { color: var(--gold); }
#ctl-son .ctl-muet { display: none; }
#ctl-son.muet { color: var(--cream-45); }
#ctl-son.muet .ctl-onde { display: none; }
#ctl-son.muet .ctl-muet { display: inline; }

/* ----- Caméra et viseur ----- */
.ctl-cam {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #241018, #0D0208 75%);
}
#ctl-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ctl-vise { position: relative; width: min(64vw, 44vh, 300px); height: min(64vw, 44vh, 300px); pointer-events: none; }
.ctl-vise i { position: absolute; width: 38px; height: 38px; border: 0 solid var(--gold); }
.ctl-vise i:nth-child(1) { top: 0; left: 0; border-top-width: 4px; border-left-width: 4px; }
.ctl-vise i:nth-child(2) { top: 0; right: 0; border-top-width: 4px; border-right-width: 4px; }
.ctl-vise i:nth-child(3) { bottom: 0; left: 0; border-bottom-width: 4px; border-left-width: 4px; }
.ctl-vise i:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 4px; border-right-width: 4px; }
.ctl-hint {
  position: absolute; top: 12px; left: 16px; right: 16px; margin: 0;
  text-align: center; font-size: 12.5px; color: rgba(255, 247, 230, 0.78); text-shadow: 0 1px 4px #000;
}

/* ----- Verdict : un grand bandeau coloré, lisible à bout de bras ----- */
.ctl-verdict {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 100%; overflow-y: auto;
  padding: 18px 18px 16px; text-align: center;
  border-top: 5px solid var(--line-strong); background: var(--card);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
}
.ctl-verdict.ok { border-top-color: var(--ok); background: linear-gradient(180deg, #13461F, #0B2A13); }
.ctl-verdict.att { border-top-color: #F59E0B; background: linear-gradient(180deg, #4D3006, #2B1A03); }
.ctl-verdict.ko { border-top-color: var(--red); background: linear-gradient(180deg, #5E0E1F, #340612); }
.ctl-rond {
  width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; border: 2px solid currentColor; color: var(--cream-70);
}
.ok .ctl-rond { color: #8BEA8B; background: rgba(111, 207, 111, 0.16); }
.att .ctl-rond { color: #FFC560; background: rgba(245, 158, 11, 0.16); }
.ko .ctl-rond { color: #FF8FA5; background: rgba(228, 64, 95, 0.18); }
.ctl-kicker { font-weight: 800; font-size: 18px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--cream-70); }
.ok .ctl-kicker { color: #8BEA8B; }
.att .ctl-kicker { color: #FFC560; }
.ko .ctl-kicker { color: #FF8FA5; }
.ctl-nom {
  font-family: 'Anton', sans-serif; font-weight: 400; text-transform: uppercase;
  font-size: clamp(26px, 7.5vw, 42px); line-height: 1.05; margin: 6px 0 2px; overflow-wrap: anywhere;
}
.ctl-ref { font-family: 'Anton', sans-serif; font-size: 26px; margin-top: 4px; }
.ctl-detail { font-size: 14.5px; color: rgba(255, 247, 230, 0.82); margin-top: 6px; }
.ctl-alerte {
  margin: 10px auto 0; max-width: 520px; padding: 8px 10px;
  font-size: 13.5px; font-weight: 700; color: #FFD27A;
  background: rgba(245, 158, 11, 0.16); border: 1px solid rgba(245, 158, 11, 0.5);
}
.ctl-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; margin-top: 14px; }
.ctl-actions:empty { display: none; }
.ctl-suivant, .ctl-entrer { flex: 1 1 100%; max-width: 440px; padding: 15px 0; font-size: 15px; }
.ctl-lien {
  background: none; border: 0; padding: 8px; cursor: pointer;
  font: inherit; font-size: 13.5px; color: rgba(255, 247, 230, 0.75); text-decoration: underline;
}
.ctl-lien:hover { color: var(--cream); }
.ctl-stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--line-strong); background: rgba(0, 0, 0, 0.25); }
.ctl-stepper button {
  width: 56px; height: 52px; border: 0; cursor: pointer;
  background: var(--card2); color: var(--cream); font-size: 26px; line-height: 1;
}
.ctl-stepper button:active { background: var(--gold); color: #160505; }
.ctl-stepper output {
  min-width: 64px; display: flex; align-items: center; justify-content: center;
  font-family: 'Anton', sans-serif; font-size: 28px;
}

/* ----- Saisie à la main (et douchette en mode clavier) ----- */
.ctl-bas {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.ctl-bas input {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 0;
  background: var(--card); color: var(--cream); border: 1px solid var(--line-strong);
  font: inherit; font-size: 16px; /* 16 px : pas de zoom automatique sur iPhone */
}
.ctl-bas input:focus { outline: none; border-color: var(--gold-soft); }

/* Écran large (tablette en paysage, portable) : le verdict devient une carte
   centrée au lieu d'un bandeau sur toute la largeur. */
@media (min-width: 821px) {
  .ctl-verdict {
    left: 50%; right: auto; bottom: 18px; transform: translateX(-50%);
    width: min(640px, calc(100% - 32px)); max-height: calc(100% - 36px);
    border: 1px solid rgba(255, 247, 230, 0.18); border-top-width: 5px;
  }
}

/* Téléphone en paysage (peu de hauteur) : verdict compact, sinon le bouton
   « Faire entrer » sortirait de l'écran. */
@media (max-height: 520px) {
  .ctl-tete { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 6px; }
  .ctl-titre b { font-size: 14px; }
  .ctl-verdict { padding: 10px 14px; max-height: calc(100% - 8px); }
  .ctl-rond { display: none; }
  .ctl-nom { font-size: 24px; margin: 2px 0 0; }
  .ctl-detail { font-size: 13px; margin-top: 2px; }
  .ctl-actions { margin-top: 8px; flex-wrap: nowrap; }
  .ctl-suivant, .ctl-entrer { flex: 1 1 auto; padding: 11px 0; }
  .ctl-stepper button { height: 42px; width: 46px; }
  .ctl-bas { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
}
