/* ============================================
   MUSÉE DU VÉLO — AUDIOGUIDE
   ============================================
   Style : Bande Dessinée
   Couleurs : Noir #060F06 / Jaune #F9B000 / Rouge #B81738
   Police : Comma Sans (Adobe Typekit)
   Layout : Mobile-first, scroll vertical
   ============================================ */


/* ─────────────────────────────────────────────
   1. VARIABLES & RESET
   ───────────────────────────────────────────── */

:root {
  --noir:       #060F06;
  --jaune:      #F9B000;
  --rouge:      #B81738;
  --blanc:      #FEFEFE;
  --gris-clair: #F2F0EA;
  --gris-moyen: #D4D0C8;

  --ombre:       4px 4px 0 rgba(6, 15, 6, 0.3);
  --ombre-forte: 5px 5px 0 rgba(6, 15, 6, 0.35);

  --bordure:       3px solid var(--noir);
  --bordure-forte: 4px solid var(--noir);
  --radius:        6px;
}

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

body {
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-style: normal;
  background-color: var(--gris-clair);
  color: var(--noir);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeSpeed; /* Faster text layout for long pages */
}

/* Accessibility: skip-to-content link */
.ag-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  background: var(--jaune);
  color: var(--noir);
  padding: 8px 16px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.ag-skip-link:focus {
  left: 50%;
  transform: translateX(-50%);
}


/* Focus indicators for keyboard navigation (WCAG 2.1 AA) */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--jaune);
  outline-offset: 2px;
}

.ag-btn-play:focus-visible {
  outline-offset: 3px;
  box-shadow: 0 0 0 3px rgba(249, 176, 0, 0.5);
}

.ag-lang-option:focus-visible {
  outline-color: var(--jaune);
  outline-offset: -2px;
}

.ag-barre:focus-visible {
  outline: 3px solid var(--jaune);
  outline-offset: 3px;
}


/* ─────────────────────────────────────────────
   2. TEXTURE GRAIN (overlay global)
   ───────────────────────────────────────────── */

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  /* No will-change — static overlay doesn't need permanent GPU compositing layer */
}


/* ─────────────────────────────────────────────
   3. HEADER
   ───────────────────────────────────────────── */

.ag-header {
  background-color: var(--noir);
  padding: 28px 16px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  border-bottom: 5px solid var(--jaune);
}

/* Bande rouge/jaune en bas du header */
.ag-header::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 5px;
  background: repeating-linear-gradient(
    90deg,
    var(--rouge) 0 18px,
    var(--jaune) 18px 36px
  );
}

/* Trame de points BD */
.ag-header-dots {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background: radial-gradient(circle, var(--noir) 1px, transparent 1px);
  background-size: 7px 7px;
}

.ag-header h1 {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  color: var(--jaune);
  text-shadow:
    2px 2px 0 var(--rouge),
    4px 4px 0 rgba(6, 15, 6, 0.35);
  letter-spacing: 0.04em;
  position: relative;
  z-index: 1;
}

.ag-header-subtitle {
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-style: italic;
  color: var(--blanc);
  font-size: clamp(0.8rem, 2.5vw, 1.1rem);
  margin-top: 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}


/* ─────────────────────────────────────────────
   4. SÉLECTEUR DE LANGUE (dropdown)
   ───────────────────────────────────────────── */

.ag-lang {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--noir);
  border-bottom: var(--bordure-forte);
  padding: 10px 16px;
  display: flex;
  justify-content: center;
}

/* Bouton principal */
.ag-lang-btn {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  padding: 9px 20px;
  min-height: 44px;
  border: 3px solid var(--jaune);
  background-color: var(--jaune);
  color: var(--noir);
  cursor: pointer;
  border-radius: var(--radius);
  box-shadow: var(--ombre-forte);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

@media (hover: hover) {
  .ag-lang-btn:hover {
    background-color: var(--blanc);
    border-color: var(--jaune);
    color: var(--noir);
  }
}

.ag-lang-btn:active {
  transform: scale(0.97);
}

.ag-lang-flag {
  font-style: normal;
  font-size: 1.05rem;
}

.ag-lang-arrow {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--noir);
  transition: transform 0.25s ease;
}

.ag-lang.open .ag-lang-arrow {
  transform: rotate(180deg);
}

/* Panneau déroulant */
.ag-lang-panel {
  max-height: 0;
  overflow: hidden;
  background-color: var(--noir);
  transition: max-height 0.3s ease;
}

.ag-lang-panel.open {
  max-height: 260px;
  border-bottom: var(--bordure-forte);
}

.ag-lang-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 16px 14px;
  max-width: 540px;
  margin: 0 auto;
}

/* Options de langue */
.ag-lang-option {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  padding: 11px 16px;
  min-height: 44px;
  border: 2px solid rgba(249, 176, 0, 0.25);
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--jaune);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
}

@media (hover: hover) {
  .ag-lang-option:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(249, 176, 0, 0.5);
  }
}

.ag-lang-option:active {
  transform: scale(0.98);
}

.ag-lang-option.active {
  background-color: var(--jaune);
  color: var(--noir);
  border-color: var(--jaune);
  box-shadow: var(--ombre);
}

.ag-lang-check {
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.ag-lang-option.active .ag-lang-check {
  opacity: 1;
}


/* ─────────────────────────────────────────────
   5. GRILLE DES POSTES (layout vertical)
   ───────────────────────────────────────────── */

.ag-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 12px 80px;
  max-width: 540px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .ag-grid {
    gap: 22px;
    padding: 26px 20px 80px;
    max-width: 600px;
  }
}


/* ─────────────────────────────────────────────
   6. VIGNETTE (carte d'un poste audio)
   ───────────────────────────────────────────── */

.ag-vignette {
  background-color: var(--blanc);
  border: var(--bordure-forte);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--ombre-forte);
  position: relative;
  contain: content; /* Layout containment — isolate reflows per card */
}

/* Bloc introduction (style spécial) */
.ag-intro {
  background-color: var(--noir);
  border-color: var(--jaune);
}

.ag-intro-contenu {
  padding: 20px 18px 16px;
}

.ag-intro-titre {
  color: var(--jaune) !important;
  font-size: clamp(1.2rem, 3vw, 1.5rem) !important;
  margin-bottom: 14px;
  text-align: center;
  text-shadow: 1px 1px 0 rgba(249, 176, 0, 0.2);
}

/* Badge numéro */
.ag-numero {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  background-color: var(--rouge);
  color: var(--blanc);
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 1rem;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 3px solid var(--noir);
  box-shadow: 2px 2px 0 rgba(6, 15, 6, 0.3);
  text-shadow: 1px 1px 0 rgba(6, 15, 6, 0.4);
}

/* Illustration 16:9 */
.ag-illustration {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: var(--bordure-forte);
  position: relative;
  background-color: var(--gris-moyen);
}

.ag-illustration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ag-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--gris-moyen), var(--gris-clair));
  color: var(--noir);
  opacity: 0.35;
}

.ag-placeholder svg {
  width: 50px;
  height: 50px;
}

/* Contour progressif directionnel (dégradé bas) */
.ag-illustration::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 45%;
  background: linear-gradient(to top, rgba(6, 15, 6, 0.22), transparent);
  pointer-events: none;
}

/* Zone de contenu */
.ag-contenu {
  padding: 14px 16px 16px;
}

.ag-titre {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: clamp(0.95rem, 2.5vw, 1.2rem);
  color: var(--noir);
  margin-bottom: 3px;
  line-height: 1.25;
}

.ag-soustitre {
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--rouge);
  margin-bottom: 12px;
}


/* ─────────────────────────────────────────────
   7. LECTEUR AUDIO
   ───────────────────────────────────────────── */

.ag-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--noir);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--ombre);
}

/* Bouton Play / Pause */
.ag-btn-play {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: 3px solid var(--jaune);
  background-color: var(--jaune);
  color: var(--noir);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  box-shadow: 2px 2px 0 rgba(249, 176, 0, 0.3);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

@media (hover: hover) {
  .ag-btn-play:not(.playing):not(.ag-error):hover {
    background-color: var(--blanc);
    border-color: var(--jaune);
  }
}

.ag-btn-play:active {
  transform: scale(0.92);
  background-color: var(--rouge);
  border-color: var(--rouge);
  color: var(--blanc);
}

/* État lecture en cours */
.ag-btn-play.playing {
  border-color: var(--rouge);
  background-color: var(--rouge);
  color: var(--blanc);
  box-shadow: 0 0 0 3px rgba(184, 23, 56, 0.3);
}

/* Icônes Play / Pause */
.ag-btn-play svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  position: absolute;
}

.ag-btn-play .ico-pause {
  display: none;
}

.ag-btn-play.playing .ico-play {
  display: none;
}

.ag-btn-play.playing .ico-pause {
  display: block;
}

/* Barre de progression */
.ag-progression {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ag-barre {
  width: 100%;
  height: 10px;
  background-color: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.08);
  -webkit-tap-highlight-color: transparent;
}

/* Enlarged touch target (44px) without changing visual size */
.ag-barre::before {
  content: '';
  position: absolute;
  top: -17px;
  bottom: -17px;
  left: 0;
  right: 0;
}

.ag-barre-remplissage {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--jaune), var(--rouge));
  border-radius: 5px;
  overflow: hidden;
  /* No transition — width is updated every rAF; a CSS transition would
     fight the JS updates and cause unnecessary style recalculations. */
  position: relative;
  will-change: width; /* Hint compositor during active playback */
}

/* Curseur rond */
.ag-barre-remplissage::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  background-color: var(--jaune);
  border: 2px solid var(--noir);
  border-radius: 50%;
  box-shadow: 1px 1px 0 rgba(6, 15, 6, 0.25);
}

.ag-temps {
  display: flex;
  justify-content: space-between;
  font-family: "comma-sans", sans-serif;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.78);
}


/* ─────────────────────────────────────────────
   7b. ÉTATS D'ERREUR AUDIO
   ───────────────────────────────────────────── */

.ag-player-error {
  opacity: 0.5;
}

.ag-btn-play.ag-error {
  background-color: var(--gris-moyen);
  border-color: var(--gris-moyen);
  color: var(--noir);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.6;
}

.ag-btn-play.ag-error::after {
  content: '!';
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  position: absolute;
}

.ag-btn-play.ag-error svg {
  display: none;
}


/* ─────────────────────────────────────────────
   8. BOUTON RETRANSCRIPTION
   ───────────────────────────────────────────── */

.ag-btn-transcript-wrap {
  margin-top: 10px;
}

.ag-btn-transcript {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  min-height: 44px;
  width: 100%;
  border: var(--bordure);
  background-color: var(--blanc);
  color: var(--noir);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.12s ease;
  box-shadow: var(--ombre);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  .ag-btn-transcript:hover {
    background-color: var(--gris-clair);
    border-color: var(--jaune);
  }
}

.ag-btn-transcript:active,
.ag-btn-transcript.active {
  background-color: var(--jaune);
  color: var(--noir);
  box-shadow: var(--ombre-forte);
}

.ag-btn-transcript svg {
  width: 15px;
  height: 15px;
}


/* ─────────────────────────────────────────────
   9. PANNEAU RETRANSCRIPTION
   ───────────────────────────────────────────── */

.ag-transcript {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
  background-color: var(--gris-clair);
  contain: content; /* Prevent hidden transcript from triggering layout */
}

.ag-transcript.open {
  max-height: 500px;
  border-top: 3px solid var(--noir);
  overflow-y: auto;
}

.ag-transcript-inner {
  padding: 14px 16px;
}

/* Phrase individuelle */
.ag-phrase {
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.75;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 4px;
  border-left: 4px solid transparent;
  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    opacity 0.25s ease;
  color: var(--noir);
  opacity: 0.85;
}

/* Phrase active (en cours de lecture) */
.ag-phrase.active {
  background-color: rgba(249, 176, 0, 0.2);
  border-left-color: var(--jaune);
  opacity: 1;
  font-weight: 700;
  font-size: 1.05rem;
}

/* Phrase déjà lue */
.ag-phrase.past {
  opacity: 0.65;
}

/* Scrollbar personnalisée */
.ag-transcript::-webkit-scrollbar {
  width: 6px;
}

.ag-transcript::-webkit-scrollbar-track {
  background-color: var(--gris-clair);
}

.ag-transcript::-webkit-scrollbar-thumb {
  background-color: var(--jaune);
  border-radius: 3px;
}


/* ─────────────────────────────────────────────
   10. FOOTER
   ───────────────────────────────────────────── */

.ag-footer {
  text-align: center;
  padding: 24px 16px;
  background-color: var(--noir);
  color: var(--jaune);
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-style: italic;
  font-size: 0.8rem;
  border-top: 4px solid var(--jaune);
  letter-spacing: 0.04em;
}

.ag-footer-link {
  color: var(--blanc);
  text-decoration: none;
  font-size: 0.72rem;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

@media (hover: hover) {
  .ag-footer-link:hover {
    opacity: 1;
    color: var(--jaune);
  }
}


/* ─────────────────────────────────────────────
   11. RESPONSIVE (petits écrans)
   ───────────────────────────────────────────── */

@media (max-width: 380px) {
  .ag-grid {
    padding: 14px 8px 80px;
    gap: 14px;
  }

  .ag-contenu {
    padding: 12px 12px 14px;
  }

  .ag-player {
    padding: 8px 10px;
    gap: 8px;
  }

  .ag-btn-play {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  .ag-lang {
    padding: 8px 10px;
  }

  .ag-lang-btn {
    font-size: 0.75rem;
    padding: 7px 16px;
  }

  .ag-fab-scan {
    bottom: 16px;
    right: 12px;
    width: 50px;
    height: 50px;
  }
}


/* ─────────────────────────────────────────────
   12. ANIMATIONS D'ENTRÉE
   ───────────────────────────────────────────── */

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation uniquement sur les 6 premières vignettes visibles (above the fold).
   Les suivantes apparaissent immédiatement pour éviter le CLS et les repaints. */
.ag-vignette:nth-child(-n+6) {
  animation: fadeUp 0.35s ease both;
  /* will-change removed: animation is short-lived; keeping will-change
     permanently wastes GPU memory on 6 compositing layers. */
}

.ag-vignette:nth-child(1) { animation-delay: 0.03s; }
.ag-vignette:nth-child(2) { animation-delay: 0.08s; }
.ag-vignette:nth-child(3) { animation-delay: 0.13s; }
.ag-vignette:nth-child(4) { animation-delay: 0.18s; }
.ag-vignette:nth-child(5) { animation-delay: 0.23s; }
.ag-vignette:nth-child(6) { animation-delay: 0.28s; }

/* Respect de prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .ag-vignette:nth-child(-n+6) {
    animation: none;
  }

  .ag-lang-panel,
  .ag-transcript,
  .ag-lang-arrow,
  .ag-btn-play,
  .ag-lang-btn,
  .ag-lang-option,
  .ag-btn-transcript,
  .ag-phrase,
  .ag-fab-scan,
  .ag-scan-close {
    transition: none;
  }
}


/* ─────────────────────────────────────────────
   13. SCANNER QR — Bouton flottant (FAB)
   ───────────────────────────────────────────── */

.ag-fab-scan {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 90;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--noir);
  background-color: var(--jaune);
  color: var(--noir);
  cursor: pointer;
  box-shadow: var(--ombre-forte);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.ag-fab-scan svg {
  width: 24px;
  height: 24px;
}

@media (hover: hover) {
  .ag-fab-scan:hover {
    background-color: var(--blanc);
    transform: scale(1.08);
  }
}

.ag-fab-scan:active {
  transform: scale(0.92);
  background-color: var(--rouge);
  color: var(--blanc);
  border-color: var(--rouge);
}


/* ─────────────────────────────────────────────
   14. SCANNER QR — Overlay caméra
   ───────────────────────────────────────────── */

/* Le user-agent stylesheet des <dialog> impose display:block et overflow:auto
   quand showModal() est appelé. On doit écraser ces valeurs explicitement. */
.ag-scan-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background-color: rgba(6, 15, 6, 0.92);
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
}

.ag-scan-overlay[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ag-scan-overlay::backdrop {
  background: transparent;
}

.ag-scan-container {
  width: 100%;
  max-width: 480px;
  max-height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  overflow: hidden;
}

.ag-scan-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 10;
}

.ag-scan-title {
  font-family: "comma-sans", sans-serif;
  font-weight: 700;
  font-style: italic;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--jaune);
}

.ag-scan-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  border: 2px solid rgba(249, 176, 0, 0.4);
  background-color: rgba(6, 15, 6, 0.8);
  color: var(--jaune);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 10;
}

.ag-scan-close svg {
  width: 20px;
  height: 20px;
}

@media (hover: hover) {
  .ag-scan-close:hover {
    background-color: var(--rouge);
    border-color: var(--rouge);
    color: var(--blanc);
  }
}

.ag-scan-reader {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 55vh;
  border: 4px solid var(--jaune);
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--noir);
  position: relative;
  flex-shrink: 1;
}

/* Spinner de chargement — visible tant que la vidéo n'est pas active */
.ag-scan-reader::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid rgba(249, 176, 0, 0.2);
  border-top-color: var(--jaune);
  border-radius: 50%;
  animation: scanSpin 0.8s linear infinite;
  z-index: 1;
  pointer-events: none;
}

.ag-scan-reader.ag-scan-active::before {
  display: none;
}

@keyframes scanSpin {
  to { transform: rotate(360deg); }
}

/* html5-qrcode injects a <video> and dashboard — style overrides */
.ag-scan-reader video {
  border-radius: 0 !important;
}

#agScanReader img[alt="Info icon"] {
  display: none !important;
}

.ag-scan-hint {
  font-family: "comma-sans", sans-serif;
  font-weight: 400;
  font-style: italic;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.ag-scan-hint.ag-scan-success {
  color: var(--jaune);
  font-weight: 700;
}

.ag-scan-hint.ag-scan-error {
  color: var(--rouge);
  font-weight: 700;
}
