/* Caméra des danseurs : pensée pour un téléphone porté sur le corps, dans le noir. */

html, body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* ---------- écrans de départ ---------- */

.sheet {
  min-height: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 2rem) 1.5rem calc(env(safe-area-inset-bottom) + 2rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}
.sheet .logo { align-self: flex-start; font-size: 1.2rem; }
/* La bascule de langue, en haut à droite de l'écran de départ, à la hauteur du logo */
.sheet { position: relative; }
.sheet .lang-corner { top: calc(env(safe-area-inset-top) + 1.6rem); right: 1.5rem; }
.sheet h1 { margin: 0.9rem 0 0.25rem; font-size: clamp(1.8rem, 9vw, 2.5rem); color: var(--texte); }
/* Le collectif qui reçoit l'image : le danseur sait pour qui il filme */
.sheet .pour { margin: -0.1rem 0 0.2rem; color: var(--sourdine); font-size: 1rem; }
.sheet .pour b { color: var(--texte); font-weight: 700; }
.lead { margin: 0; color: var(--sourdine); }

form { display: flex; flex-direction: column; gap: 0.75rem; }
.label { font-size: 0.9rem; color: var(--sourdine); }
.field {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid var(--trait-fort);
  border-radius: 0.6rem;
  background: var(--surface);
  font-size: 1.25rem;
  font-weight: 700;
  text-transform: uppercase;
  -webkit-user-select: text; user-select: text;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.field.code { text-align: center; font-family: var(--chasse-fixe); letter-spacing: 0.14em; font-size: 1.6rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--filet);
  border-radius: 0.5rem;
  background: none;
  font-size: 0.9rem;
  font-weight: 700;
}
.chip[aria-pressed="true"] { background: var(--texte); color: var(--fond); border-color: var(--texte); }

.btn {
  margin-top: 0.5rem;
  padding: 1.1rem 1rem 1rem;
  border: 0;
  border-radius: 0.6rem;
  background: var(--accent);
  color: var(--accent-encre);
  font-weight: 800;
  font-size: 1.15rem;
}
.btn:disabled { opacity: 0.5; }

.error { margin: 0; padding: 0.8rem 1rem; border-radius: 0.6rem; background: var(--erreur-fond); color: var(--erreur-encre); }
.error a { color: var(--blanc); }
.notes { margin: auto 0 0; padding: 1rem 0 0 1.1rem; color: var(--sourdine); font-size: 0.9rem; }
.notes li + li { margin-top: 0.35rem; }

/* ---------- en direct ---------- */

.live { position: fixed; inset: 0; background: var(--noir); }
/* L'aperçu montre l'image entière, bandes noires comprises : les repères de cadrage se lisent sur toute l'image envoyée. */
#preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--noir); }
#preview.mirror { transform: scaleX(-1); }
.live.is-paused #preview { opacity: 0.25; filter: grayscale(1); }

/* Repères de cadrage : quatre coins autour de la partie de l'image qui sort à l'écran. Le reste est assombri. */
.crop { position: absolute; pointer-events: none; outline: 1px solid #ffffff66; box-shadow: 0 0 0 200vmax #0000008c; transition: left 160ms, top 160ms, width 160ms, height 160ms; }
.crop i { position: absolute; width: 1.4rem; height: 1.4rem; border: 0 solid #fff; filter: drop-shadow(0 0 2px #000c); }
.crop i:nth-child(1) { left: 0; top: 0; border-width: 3px 0 0 3px; }
.crop i:nth-child(2) { right: 0; top: 0; border-width: 3px 3px 0 0; }
.crop i:nth-child(3) { left: 0; bottom: 0; border-width: 0 0 3px 3px; }
.crop i:nth-child(4) { right: 0; bottom: 0; border-width: 0 3px 3px 0; }
@media (prefers-reduced-motion: reduce) { .crop { transition: none; } }

/* Le cadre rouge : seul signe que l'image est projetée */
.frame { position: absolute; inset: 0; border: 0 solid var(--direct); pointer-events: none; transition: border-width 120ms; }
.live.is-onair .frame { border-width: 10px; }
.live.is-identify .frame { border-width: 10px; border-color: var(--alerte); }

.top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top) + 0.9rem) 1rem 2rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  background: linear-gradient(#000c, #0000);
}
.who { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.slot { font-size: 1.5rem; color: var(--blanc); font-variant-numeric: tabular-nums; }
.who-name { font-weight: 700; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop {
  flex: none;
  padding: 0.55rem 0.9rem;
  border: 1px solid #fff6;
  border-radius: 0.5rem;
  background: #0008;
  font-size: 0.85rem;
  font-weight: 700;
}
.stop.armed { background: var(--blanc); color: var(--noir); border-color: var(--blanc); }

.center {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  padding: 0 1rem; pointer-events: none; text-align: center;
}
/* Badge sous le nom, pour ne pas masquer le cadrage */
.onair-badge {
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 5.4rem); transform: translateX(-50%);
  margin: 0; padding: 0.4em 0.7em;
  background: var(--direct); color: var(--blanc);
  font-size: clamp(1.1rem, 6vw, 1.8rem);
  font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase;
  border-radius: 0.25em;
  white-space: nowrap;
  pointer-events: none;
}
.pausedmark { margin: 0; font-size: clamp(1.4rem, 8vw, 2.4rem); color: var(--blanc); }
.toast { margin: 0; padding: 0.6rem 1rem; border-radius: 0.5rem; background: #000c; font-weight: 700; }

.dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 2.5rem 0.75rem calc(env(safe-area-inset-bottom) + 0.9rem);
  background: linear-gradient(#0000, #000d 45%);
  display: flex; flex-direction: column; gap: 0.35rem;
}
.link { margin: 0; text-align: center; font-weight: 700; font-size: 0.95rem; }
.link::before { content: ''; display: inline-block; width: 0.6em; height: 0.6em; margin-right: 0.5em; border-radius: 50%; background: var(--sourdine); }
.link[data-state="ok"]::before { background: var(--ok); }
.link[data-state="wait"]::before { background: var(--alerte); }
.link[data-state="off"]::before { background: var(--direct); }
.stats { margin: 0; min-height: 1.3em; text-align: center; color: #d0d0d0; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.stats b { font-weight: 700; color: var(--blanc); }
.stats .warn { color: var(--alerte); }
/* Marche à suivre affichée à la place des chiffres : plusieurs lignes, lisibles à bout de bras */
.stats.help { max-width: 34rem; margin-inline: auto; color: var(--blanc); font-size: 0.9rem; line-height: 1.35; text-wrap: balance; }

.buttons { display: flex; justify-content: space-around; align-items: flex-start; gap: 0.25rem; margin-top: 0.5rem; }
.round { flex: 1 1 0; max-width: 6rem; padding: 0; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.disc {
  width: 4.1rem; height: 4.1rem;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #0009;
}
.disc svg { width: 1.7rem; height: 1.7rem; }
.round:active .disc { transform: scale(0.94); }
.round[aria-pressed="true"] .disc { background: var(--accent); border-color: var(--accent); color: var(--accent-encre); }
.cap { font-size: 0.78rem; font-weight: 700; }

/* ---------- verrou ---------- */

.lock {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 0.6rem;
  padding: 0 1.5rem calc(env(safe-area-inset-bottom) + 2.2rem);
  background: linear-gradient(#0000 40%, #000c);
  touch-action: none;
}
.lock-ring {
  --p: 0;
  width: 5.2rem; height: 5.2rem; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1turn), #fff3 0);
}
.lock-ring span { width: 4.5rem; height: 4.5rem; border-radius: 50%; background: #000; display: grid; place-items: center; }
.lock-ring svg { width: 1.7rem; height: 1.7rem; }
.lock-title { margin: 0.3rem 0 0; font-size: 1.15rem; }
.lock-help { margin: 0; color: #d0d0d0; font-size: 0.9rem; text-align: center; }
.live.is-locked .dock, .live.is-locked .stop { visibility: hidden; }

@media (orientation: landscape) and (max-height: 520px) {
  .onair-badge { top: calc(env(safe-area-inset-top) + 0.8rem); font-size: 1.1rem; }
  .dock { padding-top: 1rem; }
  .disc { width: 3.2rem; height: 3.2rem; }
  .buttons { max-width: 32rem; margin-left: auto; margin-right: auto; width: 100%; }
}

/* La ligne d'état devient un bouton quand le navigateur doit reposer sa question "réseau local" */
.link[data-action] { text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; }
