/* Salle — style unique. Aucune ressource externe : rien ne sort du navigateur. */

:root {
  --ink-900: #131a24;
  --ink-850: #172130;
  --ink-800: #1c2734;
  --ink-700: #26333f;
  --ink-600: #33424f;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e6ecf2;
  --muted: #90a1b4;
  --amber: #f0a64b;
  --amber-soft: rgba(240, 166, 75, 0.16);
  --alert: #e4626f;
  --good: #57c4a6;
  --r: 14px;
  --r-sm: 9px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* L'attribut hidden doit l'emporter sur toute règle d'affichage. Sans cette
   ligne, un élément portant display:grid ou display:flex reste visible malgré
   hidden : c'est la feuille du navigateur qui perd, et l'interface affiche des
   éléments censés être masqués. */
[hidden] { display: none !important; }

/* Textes pédagogiques : utiles pour découvrir l'outil en simulation, inutiles
   au quotidien. Ils n'apparaissent donc que dans le fichier de démonstration. */
.aide { display: none; }
body.mode-simulation .aide { display: block; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--ink-900);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.015em; }

.ico {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ico.big { width: 42px; height: 42px; stroke-width: 1.3; color: var(--amber); }

.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.push { margin-left: auto; }
.wide { width: 100%; }

.note, .hint {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────────── Salon */

.lobby {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 460px);
  gap: 48px;
  align-items: center;
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 28px;
  overflow-y: auto;
}

.lobby__preview {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
}

.lobby__preview video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.preview__fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); background: var(--ink-850);
}

.preview__meter {
  position: absolute; left: 18px; right: 18px; bottom: 74px;
  height: 3px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.12); overflow: hidden;
}
.preview__meter span {
  display: block; height: 100%; width: 0;
  background: var(--good); transition: width 90ms linear;
}

.preview__toggles {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
}
.preview__toggles .round { width: 46px; padding: 10px 4px; background: rgba(10, 14, 20, 0.66); }
.preview__toggles .round span { display: none; }

.brand { display: block; height: auto; margin: 0 0 10px; }

/* Signature sous le logo */
.baseline {
  margin: 0 0 26px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.center .baseline { margin: -8px 0 4px; font-size: 12.5px; }
.lobby__form .brand { width: 188px; }
.center .brand { width: 160px; margin: 0 0 6px; opacity: 0.9; }

.mark { width: 104px; height: auto; opacity: 0.85; flex: 0 0 auto; }
.mark-sep { width: 1px; height: 16px; background: var(--line); flex: 0 0 auto; }
.lobby__form h1 { margin: 0 0 12px; font-size: clamp(24px, 3vw, 34px); line-height: 1.12; }
.lede { margin: 0 0 22px; max-width: 46ch; color: var(--muted); }

/* Le formulaire défile si la fenêtre est courte ; le bouton reste atteignable. */
.lobby__form { max-height: 100%; overflow-y: auto; padding-right: 4px; }

label { display: block; margin: 0 0 6px; font-size: 13px; color: var(--muted); }

input[type="text"], input[type="password"], input:not([type]), select {
  width: 100%;
  padding: 11px 13px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color 120ms;
}
input:focus, select:focus { border-color: var(--amber); }
#joinForm label:not(:first-of-type) { margin-top: 16px; }

/* Appareils : visibles dès l'arrivée, pour se voir et s'entendre avant
   d'entrer en réunion. */
.devices {
  margin: 18px 0 0;
  padding: 14px 0 4px;
  border-top: 1px solid var(--line);
}
.devices h2 { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.04em; color: var(--amber); }
.devices label { margin-top: 12px; }
.devices label:first-of-type { margin-top: 0; }

.level {
  height: 6px;
  margin: 8px 0 0;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.level span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--good);
  transition: width 90ms linear;
}
#micHint { margin-top: 6px; }
#micHint.ok { color: var(--good); }
#spkTest { margin-top: 12px; }

/* Le bouton d'entrée reste atteignable quelle que soit la hauteur d'écran. */
#joinBtn {
  position: sticky;
  bottom: 0;
  margin-top: 6px;
}

.primary {
  padding: 12px 20px;
  background: var(--amber);
  color: #1a1206;
  font-weight: 600;
  border-radius: var(--r-sm);
  transition: filter 120ms, transform 120ms;
}
.primary:hover { filter: brightness(1.07); }
.primary:active { transform: translateY(1px); }
.primary.small { padding: 9px 12px; display: grid; place-items: center; }

.ghost {
  padding: 11px 13px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
}
.ghost:hover { color: var(--text); }
.ghost.small { padding: 6px 8px; }

.link { padding: 0; margin-top: 18px; color: var(--amber); font-size: 13.5px; text-decoration: underline; }

.invite-note {
  margin: 16px 0 0;
  padding: 10px 12px;
  background: var(--amber-soft);
  border-left: 2px solid var(--amber);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text);
}

.error {
  margin: 14px 0 0; padding: 10px 12px;
  background: rgba(228, 98, 111, 0.12);
  border-left: 2px solid var(--alert);
  border-radius: 4px;
  color: #f4b9c0; font-size: 14px;
}

.checks { list-style: none; margin: 14px 0 0; padding: 0; font-size: 13.5px; }
.checks li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.checks .mark { flex: 0 0 auto; width: 18px; text-align: center; }
.checks .ok { color: var(--good); }
.checks .ko { color: var(--alert); }
.checks .wait { color: var(--muted); }
.checks b { display: block; font-weight: 600; }
.checks span.detail { color: var(--muted); }

/* ─────────────────────────────────────────────────────────────────── Salle */

.call {
  display: grid;
  grid-template-columns: 1fr 0;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "top top" "stage panel" "ctrl ctrl";
  height: 100%;
  transition: grid-template-columns 180ms ease;
}
.call--panel { grid-template-columns: 1fr 336px; }

.topbar {
  grid-area: top;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 18px;
}

.room-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-name--locked::after { content: " · verrouillée"; color: var(--amber); font-weight: 400; font-size: 12.5px; }

.badge {
  padding: 4px 10px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.badge--lock { color: var(--good); border-color: rgba(87, 196, 166, 0.3); }
.badge--host { color: var(--amber); border-color: rgba(240, 166, 75, 0.4); }
.badge--warn { color: var(--amber); border-color: rgba(240, 166, 75, 0.35); }
.badge--bad { color: var(--alert); border-color: rgba(228, 98, 111, 0.35); }

.stage {
  grid-area: stage;
  display: grid; gap: 10px;
  padding: 0 14px 4px;
  min-height: 0;
  min-width: 0;
}

/* Occupation maximale : les vignettes s'étirent pour remplir la surface, le
   découpage en rangées étant calculé selon la place réellement disponible. */
.stage--fill { display: flex; flex-direction: column; }
.rang {
  display: flex;
  gap: 10px;
  flex: 1;
  min-height: 0;
  justify-content: center;   /* une rangée incomplète reste centrée */
}
.rang .tile {
  aspect-ratio: auto;
  height: 100%;
  min-width: 0;
  flex: 0 1 calc((100% - (var(--par-rangee) - 1) * 10px) / var(--par-rangee));
}
.stage--stack { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; align-content: stretch; }
.stage--stack .strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.stage--stack .strip .tile { flex: 0 0 auto; width: min(24vw, 190px); }

.tile {
  transition: border-color 400ms ease, box-shadow 400ms ease;
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.tile--main { aspect-ratio: auto; width: 100%; height: 100%; background: #0d1218; }
/* L'indicateur de parole apparaît vite et s'efface lentement : la transition
   de base gouverne l'extinction, celle de la classe gouverne l'allumage. */
.tile--speaking {
  border-color: var(--good);
  box-shadow: 0 0 0 1px var(--good);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.tile--hand { border-color: var(--amber); }
.tile video { width: 100%; height: 100%; object-fit: cover; background: var(--ink-850); }
.tile--main video, .tile--screen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }

.avatar { position: absolute; inset: 0; display: grid; place-items: center; background: var(--ink-850); }
.initials {
  display: grid; place-items: center;
  width: 74px; height: 74px;
  border-radius: 50%;
  background: var(--ink-700);
  font-size: 25px; font-weight: 600; color: var(--muted);
}
.initials.mini { width: 28px; height: 28px; font-size: 12px; }

.tile__bar {
  /* Le bandeau épouse le texte qu'il contient : ancré à gauche seulement, il
     ne s'étire pas jusqu'au bord opposé. Il se borne toutefois à la largeur
     de la vignette, un nom très long étant alors coupé proprement. */
  position: absolute; left: 8px; bottom: 8px; right: auto;
  display: inline-flex; align-items: center; gap: 7px;
  width: fit-content;
  max-width: calc(100% - 16px);
  padding: 5px 9px;
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  font-size: 12.5px;
}
.tile__bar .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile__bar .ico { width: 15px; height: 15px; flex: 0 0 auto; }

.tile__state {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 9px;
  background: rgba(10, 14, 20, 0.72);
  border-radius: 999px;
  font-size: 11.5px; color: var(--muted);
}

.tile__pin {
  position: absolute; top: 6px; right: 6px;
  padding: 6px; border-radius: 8px;
  background: rgba(10, 14, 20, 0.6);
  color: var(--muted); opacity: 0;
  transition: opacity 120ms;
}
.tile:hover .tile__pin, .tile__pin:focus-visible { opacity: 1; }
.tile__pin--on { opacity: 1; color: var(--amber); }

.muted { color: var(--alert); }
.raised { color: var(--amber); }

.controls {
  grid-area: ctrl;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 14px;
}
.sep { width: 1px; height: 30px; margin: 0 8px; background: var(--line); }

.round {
  position: relative;
  display: grid; place-items: center; gap: 3px;
  width: 62px; padding: 8px 4px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.round:hover { background: var(--ink-700); }
.round span { font-size: 11px; color: var(--muted); }
.round[aria-pressed="false"] { background: var(--ink-850); color: var(--alert); }
.round[aria-pressed="false"] span { color: rgba(228, 98, 111, 0.8); }
.round--on { background: var(--amber-soft); border-color: rgba(240, 166, 75, 0.45); color: var(--amber); }
.round--on span { color: var(--amber); }
.round--leave { background: rgba(228, 98, 111, 0.14); border-color: rgba(228, 98, 111, 0.4); color: #f19aa4; }
.round--leave:hover { background: var(--alert); color: #fff; }

.pill {
  position: absolute; top: 2px; right: 6px;
  min-width: 17px; padding: 0 4px;
  background: var(--ink-600);
  border-radius: 999px;
  font: 10.5px/17px inherit; font-style: normal;
  color: var(--text);
}
.pill--alert { background: var(--alert); color: #fff; }

.panel {
  grid-area: panel;
  display: flex; flex-direction: column; min-height: 0;
  margin-right: 14px;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.panel__tabs { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.tab { padding: 7px 12px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.tab[aria-selected="true"] { background: var(--ink-700); color: var(--text); }

.pane { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 12px; overflow-y: auto; }

.people { list-style: none; margin: 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 9px; padding: 8px 6px; border-radius: 8px; }
.people li + li { border-top: 1px solid var(--line); }
.people .who { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people .ico { width: 16px; height: 16px; color: var(--muted); }
.tagself { font-size: 11px; color: var(--muted); }
.taghost { font-size: 11px; color: var(--amber); }
.tagguest { font-size: 11px; color: var(--muted); }

.fp {
  padding: 2px 6px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--good);
  cursor: help;
}

.actions { display: flex; gap: 2px; opacity: 0; transition: opacity 120ms; }
.people li:hover .actions, .actions:focus-within { opacity: 1; }
.act { padding: 4px; border-radius: 6px; color: var(--muted); }
.act:hover { background: var(--ink-700); color: var(--text); }
.act--danger:hover { background: rgba(228, 98, 111, 0.18); color: var(--alert); }
.act .ico { width: 15px; height: 15px; }

.knocks {
  margin-bottom: 12px; padding: 10px;
  background: var(--amber-soft);
  border: 1px solid rgba(240, 166, 75, 0.35);
  border-radius: var(--r-sm);
}
.knocks__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.knocks h3, .host-tools h3 { margin: 0; font-size: 12px; letter-spacing: 0.04em; color: var(--amber); }
.knocks .link { margin: 0; }
.knock-list { list-style: none; margin: 0; padding: 0; }
.knock-list li { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.knock-list .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.yes { padding: 5px 11px; background: var(--amber); color: #1a1206; font-size: 12.5px; font-weight: 600; border-radius: 7px; }
.no { padding: 5px 9px; background: var(--ink-700); border-radius: 7px; color: var(--muted); }
.no:hover { color: var(--alert); }

.host-tools { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.check { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--text); font-size: 13px; }
.check input { width: auto; }

.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg { font-size: 14px; }
.msg__head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 2px; }
.msg__who { font-weight: 600; font-size: 12.5px; }
.msg__time { font-size: 11px; color: var(--muted); }
.msg__body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg--self .msg__who { color: var(--amber); }
.msg--sys { color: var(--muted); font-size: 13px; font-style: italic; }
#chatForm { margin-top: 10px; }
#chatInput { flex: 1; }

.popover {
  position: absolute; right: 18px; bottom: 92px;
  width: 290px; padding: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  z-index: 20;
}
.popover label:not(:first-child) { margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 104px;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--ink-700);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13.5px;
  z-index: 30;
}

.center { height: 100%; display: grid; place-content: center; justify-items: center; gap: 18px; text-align: center; padding: 24px; }
.center h2 { margin: 0; }
.center .lede { margin: 0; max-width: 42ch; }

@media (max-width: 900px) {
  .lobby { grid-template-columns: 1fr; gap: 22px; align-content: start; }
  .lobby__preview { aspect-ratio: 16 / 10; }
  .lobby__form h1 { font-size: 26px; }
  .call--panel { grid-template-columns: 1fr; }
  .call--panel .stage { display: none; }
  .panel { grid-area: stage; margin: 0 14px; }
  .controls { flex-wrap: wrap; gap: 4px; }
  .round { width: 54px; }
  .actions { opacity: 1; }
  .topbar .badge:nth-child(4) { display: none; }
  .mark, .mark-sep { display: none; }
}

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

/* Génération des liens d'invitation, dans le panneau organisateur */
.invite { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.invite .row { margin-bottom: 6px; }
.invite select { flex: 1; }
#inviteUrl { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }

/* Diagnostic des périphériques, dans le salon d'entrée */
.media-note {
  margin: 12px 0 8px;
  padding: 10px 12px;
  background: var(--ink-800);
  border-left: 2px solid var(--amber);
  border-radius: 4px;
  font-size: 13px;
  color: var(--muted);
}

.preview__tag {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 3px 9px;
  background: rgba(10, 14, 20, 0.75);
  border-radius: 999px;
  font-size: 11.5px;
  color: var(--muted);
}

.build-tag { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); letter-spacing: 0.04em; }
.sim__version { padding: 2px 8px; background: var(--amber); color: #1a1206; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; }
