/* ==========================================================
   Les Fous du Bus : style "dessin animé"
   Encre épaisse, ombres décalées pleines, couleurs de bus scolaire.
   ========================================================== */

:root {
  --ink: #231942;
  --sky: #5BC0EB;
  --sky-deep: #3AA6D6;
  --bus: #FFC93C;
  --tomato: #FF5A4E;
  --mint: #3DDC97;
  --paper: #FFFDF4;
  --beer-top: #FFB627;
  --beer-bottom: #E97F02;
  --line: 4px;
  --pop: 5px 5px 0 var(--ink);
  --pop-sm: 3px 3px 0 var(--ink);
  --display: "Luckiest Guy", "Arial Black", "Trebuchet MS", sans-serif;
  --body: "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--sky);
  /* trame de points façon BD */
  background-image: radial-gradient(rgba(255,255,255,.28) 2px, transparent 2.5px);
  background-size: 18px 18px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.area-admin, body.area-staff { background-color: #7FB7E8; }

a { color: inherit; }
img, video { max-width: 100%; }

:focus-visible { outline: 4px dashed var(--tomato); outline-offset: 3px; }

/* ---------- Barre du haut ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--paper);
  border-bottom: var(--line) solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.brand .bus { width: 46px; height: 30px; transform: rotate(-4deg); }
.brand span { font-family: var(--display); font-size: 1.3rem; letter-spacing: .5px; padding-top: 4px; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav a {
  font-weight: 800; text-decoration: none; font-size: .95rem;
  padding: 3px 10px; border: 3px solid var(--ink); border-radius: 999px; background: #fff;
}
.nav a:hover { background: var(--bus); }

.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 18px 14px 40px; }
.area-admin .wrap, .area-staff .wrap { max-width: 920px; }

/* ---------- Titres ---------- */
h1, h2, .display {
  font-family: var(--display); font-weight: 400; letter-spacing: .5px; line-height: 1.05;
  margin: 0 0 .5em;
}
h1 {
  font-size: clamp(2rem, 9vw, 2.9rem);
  color: var(--bus);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-2deg);
}
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; margin: 0 0 .4em; font-weight: 800; }
p { margin: 0 0 .8em; }
.muted { opacity: .72; }
.center { text-align: center; }

/* ---------- Panneaux ---------- */
.panel {
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: 20px 14px 22px 16px;
  box-shadow: var(--pop);
  padding: 18px;
  margin: 0 0 20px;
}
.panel > :last-child { margin-bottom: 0; }
.panel-yellow { background: var(--bus); }
.panel-mint { background: #C9F7E3; }
.panel-red { background: #FFD8D3; }

.grid2 { display: grid; gap: 16px; }
@media (min-width: 720px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 800 1.05rem/1 var(--body);
  padding: 13px 20px 11px;
  min-height: 48px;
  color: var(--ink); background: var(--bus);
  border: var(--line) solid var(--ink); border-radius: 14px;
  box-shadow: var(--pop-sm);
  cursor: pointer; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-red { background: var(--tomato); color: #fff; }
.btn-mint { background: var(--mint); }
.btn-white { background: #fff; }
.btn-sm { min-height: 38px; padding: 8px 12px 6px; font-size: .92rem; border-width: 3px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Formulaires ---------- */
.field { margin: 0 0 14px; }
.field > label, .label { display: block; font-weight: 800; margin-bottom: 4px; }
.hint { font-size: .88rem; opacity: .75; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=datetime-local],
input[type=search], select, textarea {
  width: 100%; font: 600 1rem var(--body); color: var(--ink);
  padding: 10px 12px; min-height: 48px;
  background: #fff; border: 3px solid var(--ink); border-radius: 12px;
}
input[type=color] { width: 64px; height: 48px; border: 3px solid var(--ink); border-radius: 12px; padding: 2px; background: #fff; }
input[type=file] { font: 600 .95rem var(--body); max-width: 100%; }
.code-input { font-family: var(--display) !important; font-size: 1.8rem !important; letter-spacing: 6px; text-align: center; text-transform: uppercase; }

/* choix en cartes (mode de récompense, type de limite) */
.choices { display: grid; gap: 10px; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: block; padding: 12px 14px; border: 3px solid var(--ink); border-radius: 14px; background: #fff;
}
.choice span b { display: block; }
.choice span small { opacity: .75; }
.choice input:checked + span { background: var(--bus); box-shadow: var(--pop-sm); }
.choice input:focus-visible + span { outline: 4px dashed var(--tomato); outline-offset: 2px; }
.choice input:disabled + span { opacity: .4; }

/* ---------- Messages ---------- */
.toast {
  font-weight: 800; padding: 10px 14px; margin: 0 0 16px;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--mint);
  box-shadow: var(--pop-sm);
}
.toast-err { background: var(--tomato); color: #fff; }

/* ==========================================================
   LE VERRE : la vedette
   ========================================================== */
.glass { position: relative; isolation: isolate; width: 190px; margin: 6px auto 0; padding-right: 50px; box-sizing: content-box; }
.glass-body {
  position: relative; width: 190px; height: 240px;
  border: 6px solid var(--ink);
  border-radius: 8px 8px 34px 34px;
  background: #E3F5FF;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
}
/* anse de la chope : bordure claire + double contour d'encre */
.glass::after {
  content: ""; position: absolute; z-index: -1;
  left: 180px; top: 50px; width: 60px; height: 124px;
  border: 15px solid #E3F5FF; border-left: 0;
  border-radius: 0 54px 54px 0;
  box-shadow: 0 0 0 5px var(--ink), inset 0 0 0 5px var(--ink), 6px 6px 0 5px var(--ink);
}
.glass-inner { position: absolute; inset: 0; }
.liquid {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, var(--beer-top), var(--beer-bottom));
  transition: height 1.9s cubic-bezier(.35, 1.25, .5, 1);
}
.foam {
  position: absolute; left: -6px; right: -6px; top: -16px; height: 28px;
  background:
    radial-gradient(circle at 13px 15px, #fff 12px, transparent 12.5px) 0 0 / 26px 28px repeat-x,
    linear-gradient(#fff, #fff) 0 14px / 100% 14px no-repeat;
}
.glass.is-empty .foam, .glass.is-empty .bubbles { display: none; }
.bubbles i {
  position: absolute; bottom: 4px; left: var(--x);
  width: var(--s); height: var(--s); border-radius: 50%;
  border: 2px solid rgba(255,255,255,.85);
  animation: rise var(--d) linear var(--delay) infinite;
}
@keyframes rise {
  0%   { transform: translateY(0); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(-210px); opacity: 0; }
}
.shine {
  position: absolute; left: 16px; top: 14px; width: 14px; height: 58%;
  border-radius: 10px; background: rgba(255,255,255,.7);
}
.shine::after {
  content: ""; position: absolute; left: 0; top: calc(100% + 10px);
  width: 14px; height: 14px; border-radius: 50%; background: rgba(255,255,255,.7);
}
.glass-pct {
  margin-top: 16px; margin-right: -50px; text-align: center;
  font-family: var(--display); font-size: 2.6rem; line-height: 1;
  color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--ink);
}
.glass.is-full .glass-body, .glass.is-full::after { animation: cheers .9s ease-in-out 2; transform-origin: 50% 100%; }
.glass.is-full .foam { top: -22px; height: 34px; }
@keyframes cheers {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

/* mini chope pour les listes */
.glass.glass-sm { width: 40px; padding-right: 12px; margin: 0; }
.glass-sm .glass-body { width: 40px; height: 52px; border-width: 3px; border-radius: 3px 3px 10px 10px; box-shadow: 2px 2px 0 var(--ink); }
.glass-sm::after { left: 37px; top: 11px; width: 14px; height: 28px; border-width: 4px; border-radius: 0 14px 14px 0; box-shadow: 0 0 0 3px var(--ink), inset 0 0 0 3px var(--ink); }
.glass-sm .foam { left: -3px; right: -3px; top: -6px; height: 10px; background: radial-gradient(circle at 5px 5px, #fff 5px, transparent 5.5px) 0 0 / 10px 10px repeat-x, linear-gradient(#fff,#fff) 0 5px / 100% 5px no-repeat; }
.glass-sm .bubbles, .glass-sm .shine, .glass-sm .glass-pct { display: none; }
.glass-sm.is-full .glass-body, .glass-sm.is-full::after { animation: none; }

/* ---------- Écran joueur ---------- */
.hero { text-align: center; padding-top: 6px; }
.count-line { font-weight: 800; font-size: 1.15rem; margin: 10px 0 18px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px 3px; font-weight: 800;
  border: 3px solid var(--ink); border-radius: 999px; background: #fff;
}
.chip .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--c, var(--tomato)); }
.chip.is-missing { background: transparent; border-style: dashed; opacity: .7; }
.chip.is-missing .dot { background: transparent; }

.player-code {
  display: inline-block; font-family: var(--display); font-size: 2rem; letter-spacing: 5px;
  padding: 8px 16px 2px; background: #fff; border: var(--line) solid var(--ink); border-radius: 12px;
  transform: rotate(-1.5deg); box-shadow: var(--pop-sm);
}

.ticket {
  position: relative; text-align: center;
  background: var(--bus); border: var(--line) solid var(--ink); border-radius: 18px;
  box-shadow: var(--pop); padding: 20px 16px; margin: 0 0 20px;
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; top: 50%; width: 26px; height: 26px; margin-top: -13px;
  border-radius: 50%; background: var(--sky); border: var(--line) solid var(--ink);
}
.ticket::before { left: -15px; }
.ticket::after { right: -15px; }
.ticket.is-served { background: #E4E4EC; }
.ticket .big { font-family: var(--display); font-size: 1.9rem; line-height: 1.1; margin: 4px 0 8px; }

/* bulle de BD */
.speech {
  position: relative; display: inline-block; font-weight: 800; font-size: 1.1rem;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 22px;
  padding: 10px 16px; margin-bottom: 18px; max-width: 100%;
}
.speech::after {
  content: ""; position: absolute; left: 34px; bottom: -18px;
  border: 10px solid transparent; border-top: 14px solid var(--ink);
}

/* ---------- Scène d'animation du scan ---------- */
.stage {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 18px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--c, var(--tomato));
  overflow: hidden; cursor: pointer;
  transition: opacity .35s, transform .35s;
}
.stage::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 260vmax; height: 260vmax; margin: -130vmax 0 0 -130vmax;
  background: repeating-conic-gradient(rgba(255,255,255,.22) 0 10deg, transparent 10deg 20deg);
  animation: spin 14s linear infinite;
}
.stage > * { position: relative; }
.stage.is-gone { opacity: 0; transform: scale(1.08); pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage-media {
  max-width: min(86vw, 420px); max-height: 56vh;
  border: 6px solid var(--ink); border-radius: 22px; background: #fff;
  box-shadow: 8px 8px 0 var(--ink);
  animation: popIn .55s cubic-bezier(.3, 1.6, .5, 1) both;
}
.pow {
  display: grid; place-items: center; text-align: center;
  width: min(80vw, 340px); aspect-ratio: 1;
  background: var(--bus);
  clip-path: polygon(50% 0,61% 22%,85% 9%,78% 35%,100% 42%,80% 57%,93% 82%,66% 76%,55% 100%,44% 78%,18% 93%,22% 66%,0 55%,20% 41%,8% 16%,34% 23%);
  animation: popIn .55s cubic-bezier(.3, 1.6, .5, 1) both;
}
.pow span {
  font-family: var(--display); font-size: clamp(2rem, 11vw, 3.4rem); line-height: 1; padding: 0 18%;
  color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-6deg); word-break: break-word;
}
.stage-title {
  font-family: var(--display); font-size: clamp(1.8rem, 8vw, 2.6rem); text-align: center; line-height: 1.1;
  color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink);
  animation: popIn .5s .25s cubic-bezier(.3, 1.6, .5, 1) both;
}
.stage-sub { font-weight: 800; font-size: 1.1rem; background: #fff; border: 3px solid var(--ink); border-radius: 999px; padding: 4px 14px; }
.stage-skip { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); font-weight: 800; color: #fff; opacity: .9; }
@keyframes popIn { from { transform: scale(.2) rotate(-12deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

/* déjà scanné : le verre refuse en secouant la tête */
.stage.is-again { background: #9AA5C9; }
.stage.is-again .no-glass { animation: nope .5s ease-in-out .3s 3; }
@keyframes nope {
  0%, 100% { transform: rotate(0) translateX(0); }
  25% { transform: rotate(-10deg) translateX(-12px); }
  75% { transform: rotate(10deg) translateX(12px); }
}

/* confettis de victoire */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i {
  position: absolute; top: -20px; width: 12px; height: 18px; border: 2px solid var(--ink);
  animation: fall var(--d) linear var(--delay) forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Choix de qui offre ---------- */
.giver-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.giver {
  display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%;
  padding: 14px 8px 10px; font: 800 1.05rem var(--body); color: var(--ink);
  background: #fff; border: var(--line) solid var(--ink); border-radius: 16px; box-shadow: var(--pop-sm); cursor: pointer;
}
.giver .face {
  width: 54px; height: 54px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c);
  display: grid; place-items: center; font-family: var(--display); font-size: 1.6rem; color: #fff;
  -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; padding-top: 4px;
}
.giver small { font-weight: 600; opacity: .75; }
.giver:active { transform: translate(3px, 3px); box-shadow: none; }

/* ---------- Listes admin / service ---------- */
.rows { display: grid; gap: 12px; }
.row {
  display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px;
}
.row-main { min-width: 0; }
.row-title { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.row-meta { font-size: .9rem; opacity: .78; }
.row-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 640px) {
  .row { grid-template-columns: auto 1fr auto; }
  .row-actions { grid-column: auto; justify-content: flex-end; }
}
.row.is-pending { background: #FFF3C4; }
.row.is-served { background: #EEF0F6; }

.badge {
  display: inline-block; font-size: .8rem; font-weight: 800; line-height: 1.2;
  padding: 2px 8px; border: 2px solid var(--ink); border-radius: 999px; background: #fff; white-space: nowrap;
}
.badge-yellow { background: var(--bus); }
.badge-mint { background: var(--mint); }
.badge-red { background: var(--tomato); color: #fff; }
.badge-grey { background: #D8DBE8; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c, var(--tomato));
  display: grid; place-items: center; font-family: var(--display); font-size: 1.3rem; color: #fff;
  -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; padding-top: 3px; overflow: hidden;
}
.avatar img, .avatar video { width: 100%; height: 100%; object-fit: cover; }

.meter { height: 16px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--beer-top), var(--beer-bottom)); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 0 0 20px; }
.stat { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 12px; box-shadow: var(--pop-sm); }
.stat b { display: block; font-family: var(--display); font-size: 2rem; line-height: 1.1; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.filters a { text-decoration: none; }
.filters a.is-on { background: var(--ink); color: #fff; }

.table-scroll { overflow-x: auto; }
table.simple { width: 100%; border-collapse: collapse; }
table.simple td, table.simple th { text-align: left; padding: 8px 6px; border-bottom: 2px dashed rgba(35,25,66,.3); vertical-align: middle; }

/* ---------- QR / tee-shirt ---------- */
.shirt {
  position: relative; width: min(100%, 340px); margin: 10px auto 18px; padding: 70px 40px 40px;
  background: var(--c, var(--tomato));
  clip-path: polygon(30% 0, 70% 0, 100% 14%, 92% 34%, 82% 30%, 82% 100%, 18% 100%, 18% 30%, 8% 34%, 0 14%);
}
.shirt-qr { background: #fff; padding: 10px; border-radius: 6px; width: 62%; margin: 0 auto; }
.shirt-qr canvas, .shirt-qr img { width: 100% !important; height: auto !important; display: block; }
.shirt-name { text-align: center; margin-top: 10px; font-family: var(--display); font-size: 1.4rem; color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }

/* ---------- Scanner caméra ---------- */
.scanner { border: var(--line) solid var(--ink); border-radius: 16px; overflow: hidden; background: #000; min-height: 60px; }
.scanner video { display: block; }
#reader__dashboard_section_csr button, #reader button {
  font: 800 1rem var(--body); padding: 8px 14px; margin: 6px; border: 3px solid var(--ink); border-radius: 10px; background: var(--bus);
}
#reader { background: #fff; }

details.panel summary { cursor: pointer; font-weight: 800; }
hr.dash { border: 0; border-top: 3px dashed var(--ink); opacity: .35; margin: 18px 0; }

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