/* Concept « l'affiche de la mosquée » : fond crème, arc en dôme cerné d'orange sur bandeau
   olive, titres sarcelle en capitales, cercle sauge, puces de couleur, traits verts à main levée.
   Pendant le direct, l'écran passe en sombre (salle, batterie) avec les mêmes accents. */
:root {
  /* Palette des affiches */
  --creme: #fbf8f1;
  --papier: #f3eee2;
  --sarcelle: #2e7470;
  --sarcelle-fonce: #1f5653;
  --sauge: #9dbfbb;
  --orange: #e07b39;
  --orange-texte: #b05a20;
  --olive: #4b5a2a;
  --feuille: #6e9e34;
  --jaune: #e2c64a;
  --encre: #22302e;
  --encre-douce: #55625f;
  --nuit: #15211f;          /* écran du direct */
  --nuit-2: #1d2d2a;
  --serif: "Lora", Georgia, serif;
  --sans: "Montserrat", "Segoe UI", sans-serif;
  --arabe: "Noto Kufi Arabic", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--creme); color: var(--encre);
  font: 17px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
[lang="ar"] { font-family: var(--arabe); }

/* ---------- Écran code : le dôme de l'affiche ---------- */
.gate {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 22px;
  padding: 32px 20px 48px;
  background: linear-gradient(var(--olive) 0 34%, var(--creme) 34%);
}
/* Grand cercle sauge, comme sur l'affiche du cours */
.gate::after {
  content: ""; position: absolute; z-index: -1; width: 95vmin; aspect-ratio: 1; border-radius: 50%;
  right: -38vmin; bottom: -42vmin; background: var(--sauge); opacity: .55;
}
.gate-title {
  margin: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: 700 .95rem/1 var(--sans); letter-spacing: .32em; text-transform: uppercase; color: var(--creme);
}
.gate-title span { font: 700 2.4rem/1.3 var(--arabe); letter-spacing: 0; color: var(--creme); }
.arch-form { position: relative; width: min(320px, 86vw); aspect-ratio: 200 / 270; }
.arch { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.arch path { fill: var(--creme); stroke: var(--orange); stroke-width: 3; stroke-linejoin: round; }
.arch .arch-inner { fill: none; stroke: var(--orange); stroke-width: 1.2; opacity: .8; }
.arch-content {
  position: absolute; inset: 30% 17% 7%;
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 14px; text-align: center;
}
.arch-content label { font: italic 500 18px/1.3 var(--serif); color: var(--encre); }
#code {
  width: 100%; padding: 10px 0; text-align: center;
  font: 700 26px/1 var(--sans); letter-spacing: .22em; color: var(--sarcelle-fonce);
  background: transparent; border: 0; border-bottom: 2px solid var(--sarcelle); border-radius: 0;
}
#code:focus { outline: none; border-bottom-color: var(--orange); }
.btn-gold {
  padding: 13px 18px; border: 0; border-radius: 999px;
  background: var(--sarcelle); color: var(--creme);
  font: 700 15px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase;
}
.btn-gold:hover { background: var(--sarcelle-fonce); }
.gate-error { margin: 0; min-height: 1.5em; color: #a8321f; font-size: 15px; font-weight: 600; }
/* Les trois traits verts à main levée de l'affiche, au pied de l'arc */
.arch-form::before {
  content: ""; position: absolute; z-index: 1; left: -13%; bottom: -9%; width: 22%; aspect-ratio: 1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 60 60'%3E%3Cg fill='none' stroke='%236e9e34' stroke-width='4.5' stroke-linecap='round'%3E%3Cpath d='M6 22c12-3 24-5 34-6'/%3E%3Cpath d='M12 50c8-8 16-15 26-22'/%3E%3Cpath d='M44 58c1-9 3-18 6-25'/%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
}

/* ---------- Écran caméra (direct) : sombre, accents de l'affiche ---------- */
.cam { position: fixed; inset: 0; display: grid; grid-template-rows: auto auto 1fr auto auto; background: #000; color: var(--creme); }
.cam > .tabs { grid-row: 1; position: relative; background: rgba(21, 33, 31, .94); padding-top: env(safe-area-inset-top); }
.cam:has(> .tabs:not([hidden])) .top { padding-top: 14px; }
#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.top {
  grid-row: 2; position: relative; display: flex; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 14px;
  background: linear-gradient(to bottom, rgba(21, 33, 31, .88), transparent);
}
/* État en pastille, comme « AU PROGRAMME » */
.state {
  margin: 0; display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 11px; border-radius: 999px;
  background: rgba(251, 248, 241, .94); color: var(--encre);
  font: 700 13px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase;
}
.qandil { width: 11px; height: 11px; border-radius: 50%; background: var(--sauge); flex: none; }
.state.live .qandil { background: var(--feuille); box-shadow: 0 0 0 3px rgba(110, 158, 52, .3); }
.state.busy .qandil { background: var(--jaune); }
.state.warn .qandil { background: var(--orange); }
.state.warn { background: #fde9dc; color: #7a3511; }
.timer { margin: 0 0 0 auto; font: 700 18px/1 var(--sans); font-variant-numeric: tabular-nums; }
.icon-btn {
  margin-left: auto; width: 46px; height: 46px; display: grid; place-items: center;
  border: 1px solid rgba(251, 248, 241, .55); border-radius: 50%; background: rgba(21, 33, 31, .55); color: var(--creme);
}
.timer:not([hidden]) + .icon-btn { margin-left: 0; }
.help-btn { font: 700 20px/1 var(--sans); text-decoration: none; }
.help-btn + .icon-btn { margin-left: 0; }
/* Pendant le direct : pas d'onglets ni de lien, quitter la page couperait la diffusion. */
.on-air .tabs, .on-air .help-btn { display: none !important; }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }

/* Aperçu de la traduction (le téléphone seulement ; la vidéo diffusée a son propre bandeau) */
.frieze {
  position: relative; grid-row: 4; margin: 0;
  padding: 18px 18px 14px; text-align: center;
  background: rgba(21, 33, 31, .9); border-top: 3px double var(--orange);
  transition: opacity .35s;
}
.frieze.empty { opacity: 0; }
.frieze p { margin: 0; font: 700 22px/1.35 var(--sans); min-height: 2.7em; white-space: pre-line; }

.actions {
  grid-row: 5; position: relative; display: grid; gap: 10px;
  padding: 12px 16px max(18px, env(safe-area-inset-bottom));
  background: var(--nuit);
}
.hint { margin: 0; text-align: center; color: #c9d3d0; font: italic 15px/1.4 var(--serif); }
.btn-go {
  min-height: 64px; border: 0; border-radius: 999px;
  font: 700 18px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: #2a1406; background: var(--orange);
}
.btn-go:disabled { opacity: .6; }
.btn-go.stop { background: transparent; color: var(--creme); box-shadow: inset 0 0 0 2px var(--creme); }
.btn-go.confirm { background: #c8402a; color: #fff; box-shadow: none; }

/* Ligne « Sous-titres : Français · taille moyenne — Modifier » */
.prefs-line {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 2px; background: none; border: 0; border-bottom: 1px solid #34463f;
  color: #c9d3d0; font-size: 15px; text-align: left;
}
.prefs-line b { color: var(--creme); }
.prefs-edit { color: #f0a56f; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.prefs-line:disabled { opacity: .5; }
.prefs-line:disabled .prefs-edit { display: none; }

/* Panneau de choix : une petite affiche crème */
.prefs {
  width: min(420px, 92vw); padding: 0; border: 0; border-radius: 18px;
  background: var(--creme); color: var(--encre); box-shadow: 0 0 0 3px var(--orange);
}
.prefs::backdrop { background: rgba(21, 33, 31, .72); }
.prefs form { display: grid; gap: 20px; padding: 26px 22px 22px; }
.prefs h2 { margin: 0; font: 700 1.35rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--sarcelle); }
.pf { display: grid; gap: 6px; color: var(--encre-douce); font-size: 15px; font-weight: 600; }
.pf select {
  font: 17px var(--sans); color: var(--encre); background: #fff;
  border: 2px solid var(--sauge); border-radius: 12px; padding: 11px 12px;
}
.sizes { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sizes legend { color: var(--encre-douce); font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.sizes label {
  display: grid; justify-items: center; gap: 4px; padding: 12px 4px; cursor: pointer;
  border: 2px solid var(--sauge); border-radius: 12px; font-size: 15px; background: #fff;
}
.sizes label:has(input:checked) { border-color: var(--orange); background: #fdf0e6; }
.sizes input { position: absolute; opacity: 0; }
.sizes label:has(input:focus-visible) { outline: 3px solid var(--orange); outline-offset: 2px; }
.sz { font-weight: 700; line-height: 1.1; color: var(--sarcelle); }
.sz-s { font-size: 18px; } .sz-m { font-size: 24px; } .sz-l { font-size: 32px; }

/* Aperçu à la taille choisie */
.frieze[data-size="s"] p { font-size: 18px; }
.frieze[data-size="l"] p { font-size: 27px; }

/* Témoin micro : vert = bon son, orange clignotant = problème */
.mic {
  margin: 0 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 6px 11px 6px 8px; border-radius: 999px; font-weight: 700; font-size: 14px;
  background: rgba(21, 33, 31, .7); transition: color .3s;
}
.mic svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.mic.ok { color: #a9d877; }
.mic.bad { color: #ffab7a; animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.mic:not([hidden]) + .timer { margin-left: 0; }

/* Couper / rétablir la traduction (pendant le direct) */
.subs-toggle {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 16px; border-radius: 999px; text-align: left;
  background: transparent; color: var(--creme); font-size: 16px;
  border: 1px solid #4a5f58;
}
.subs-action { font-weight: 700; color: #ffab7a; }
.subs-toggle[aria-pressed="false"] { border-color: var(--orange); background: rgba(224, 123, 57, .16); }
.subs-toggle[aria-pressed="false"] b { color: #ffc9a6; }
.subs-toggle[aria-pressed="false"] .subs-action { color: #a9d877; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .mic.bad { animation: none; } }

/* ---------- Onglets (code responsable) ---------- */
.tabs {
  display: flex; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none;
  padding: 0 clamp(8px, 3vw, 40px); background: #3a4720;
}
.tabs a, .tabs .quit {
  padding: 13px 14px 11px; white-space: nowrap; text-decoration: none;
  font: 700 13px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase;
  color: var(--creme); border-bottom: 3px solid transparent; opacity: .82;
}
.tabs a:hover, .tabs a:focus-visible { opacity: 1; }
.tabs a[aria-current="page"] { opacity: 1; border-bottom-color: var(--orange); }
.tabs .quit {
  margin-left: auto; background: none; border-top: 0; border-left: 0; border-right: 0;
  text-transform: none; letter-spacing: .02em; font-weight: 600; opacity: .7;
}
@media (max-width: 420px) { .tabs { padding: 0 4px; } .tabs a, .tabs .quit { padding: 13px 9px 11px; letter-spacing: .06em; } }
