/* ==========================================================================
 * VALORANT — « Protocole »  ·  hud.css
 * Styles du HUD en jeu, partagés par hud.html (avec caméra) et
 * hud-sans-camera.html (sans caméra). Chargé après theme.css.
 * ========================================================================== */
:root { --bar-h: 52px; --gap: 28px; --edge: 40px; }

/* ---------- Cadre webcam ---------- */
.cam {
  position: absolute;
  width: 480px; height: 270px;   /* fenêtre caméra 16:9, entièrement transparente */
}
.cam svg.frame {
  position: absolute; left: -10px; top: -10px;
  width: 500px; height: 290px;
  overflow: visible;
}
.cam .sweep-line { animation: vp-frame 7s var(--ease) infinite; }
@keyframes vp-frame { 0% { stroke-dashoffset: 1000; opacity: 1; } 45% { stroke-dashoffset: 0; opacity: 1; } 46%, 100% { stroke-dashoffset: 0; opacity: 0; } }

.plate {
  position: absolute;
  display: flex; align-items: center; gap: 0;
  height: 46px;
  white-space: nowrap;
}
.plate-key {
  display: grid; place-items: center;
  width: 46px; height: 46px; background: var(--strike);
  --ch: 10px;
}
.plate-key .vp-dia { width: 14px; height: 14px; background: var(--ink); }
.plate-body {
  display: flex; align-items: center; gap: 12px;
  height: 46px; padding: 0 20px 0 16px;
  background: var(--ink-a);
  box-shadow: inset 0 0 0 1px var(--line);
  --ch: 10px;
}
.plate-role { font-family: var(--f-num); font-weight: 700; font-size: 22px; letter-spacing: .2em; text-transform: uppercase; color: var(--strike); }
.plate-sep { font-family: var(--f-num); font-weight: 600; font-size: 20px; color: var(--mist); letter-spacing: -.05em; }
.plate-name { font-family: var(--f-display); font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: .05em; text-transform: uppercase; color: var(--bone); max-width: 400px; overflow: hidden; text-overflow: ellipsis; }

/* Positions (ajustées par la classe sur .stage) */
.cam-br .cam { right: var(--edge); bottom: var(--edge); }
.cam-bl .cam { left: var(--edge); bottom: var(--edge); }
.cam-tr .cam { right: var(--edge); top: var(--edge); }
.cam-tl .cam { left: var(--edge); top: var(--edge); }
.bar-bottom.cam-br .cam, .bar-bottom.cam-bl .cam { bottom: calc(var(--bar-h) + var(--gap)); }
.bar-top.cam-tr .cam, .bar-top.cam-tl .cam { top: calc(var(--bar-h) + var(--gap)); }
.cam-br .plate, .cam-bl .plate { bottom: calc(100% + 18px); }
.cam-tr .plate, .cam-tl .plate { top: calc(100% + 18px); }
.cam-bl .plate, .cam-tl .plate { left: -10px; }
.cam-br .plate, .cam-tr .plate { right: -10px; }
.cam-none .cam { display: none; }

/* ---------- Barre d'infos ---------- */
.bar {
  position: absolute; left: 0; right: 0;
  height: var(--bar-h);
  display: flex; align-items: center;
  background: linear-gradient(180deg, rgba(15, 25, 35, .94), rgba(15, 25, 35, .88));
  font-family: var(--f-num);
}
.bar-bottom .bar { bottom: 0; box-shadow: inset 0 1px 0 var(--line); }
.bar-top .bar { top: 0; box-shadow: inset 0 -1px 0 var(--line); }
.bar-none .bar { display: none; }
.bar::before { /* accent rouge sur le filet */
  content: ''; position: absolute; left: 0; width: 240px; height: 2px; background: var(--strike);
}
.bar-bottom .bar::before { top: 0; }
.bar-top .bar::before { bottom: 0; }

.live {
  display: flex; align-items: center; gap: 12px;
  height: 100%; padding: 0 26px 0 var(--edge);
  flex: none;
  font-weight: 700; font-size: 22px; letter-spacing: .2em; text-transform: uppercase; color: var(--bone); white-space: nowrap;
}
/* Priorité : les réseaux gardent au moins 460px ; pseudo, jeu et titre rétrécissent puis « … » */
.bar-name { flex: 0 1 auto; min-width: 0; max-width: 420px; overflow: hidden; text-overflow: ellipsis; font-family: var(--f-display); font-weight: 800; font-size: 28px; letter-spacing: .05em; text-transform: uppercase; color: var(--bone); white-space: nowrap; }
.bar-game { flex: 0 1 auto; min-width: 0; max-width: 320px; overflow: hidden; text-overflow: ellipsis; margin-left: 16px; font-weight: 600; font-size: 20px; letter-spacing: .18em; text-transform: uppercase; color: var(--mist); white-space: nowrap; }
.bar-game:empty { display: none; }
.bar-sep { width: 1px; height: 24px; background: var(--line); margin: 0 26px; flex: none; }
.bar-soc {
  flex: 1 0 460px; min-width: 460px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  overflow: hidden;
  font-family: var(--f-body); font-weight: 600; font-size: 24px; color: var(--bone);
  white-space: nowrap;
}
.bar-soc .ok-icon { color: var(--strike); font-size: 22px; flex: none; }
.bar-soc .lab { flex: none; font-family: var(--f-num); font-weight: 600; font-size: 18px; letter-spacing: .2em; text-transform: uppercase; color: var(--mist); }
.bar-soc .hdl { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bar-soc.is-tight .lab { display: none; }   /* pas la place : le libellé saute, l'icône suffit */
.bar-right { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 0; padding-right: var(--edge); }
.bar-title { flex: 0 1 auto; min-width: 0; max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-body); font-weight: 600; font-size: 22px; color: var(--bone); }
.bar-clock { flex: none; font-weight: 700; font-size: 26px; font-variant-numeric: tabular-nums; color: var(--bone); letter-spacing: .02em; }
.bar-right .bar-sep { flex: none; }

/* Entrées */
.cam { animation: vp-fade 500ms linear 100ms both; }
.plate { animation: vp-wipe 600ms var(--ease) 400ms both; }
.bar { animation: vp-wipe 700ms var(--ease) 200ms both; }

/* ==========================================================================
 * SANS CAMÉRA (cam=none, et toujours sur hud-sans-camera.html)
 * La plaque « AGENT // PSEUDO » quitte le cadre et devient un indicatif
 * (.callsign) soudé à la barre : une marche chanfreinée qui dépasse de la
 * barre côté gauche. Le balayage rouge du cadre court le long de la barre.
 * Sans barre (bar=none), l'indicatif se pose seul dans le coin bas-gauche
 * et embarque « En direct » + l'heure.
 * ========================================================================== */
.callsign { display: none; }
.cam-none .callsign {
  --ch: 14px;
  position: absolute;
  display: flex; align-items: center;
  height: 46px;
  padding: 0 24px 0 var(--edge);
  background: rgba(15, 25, 35, .94);
  white-space: nowrap;
}
.callsign .plate-key { flex: none; }
.cs-body { display: flex; align-items: center; gap: 12px; min-width: 0; padding-left: 16px; }
.cs-meta { display: none; }

/* Marche au-dessus de la barre du bas (1 px de recouvrement : pas de couture avec le filet) */
.cam-none.bar-bottom .callsign, .cam-none.bar-top .callsign { z-index: 1; height: 47px; }
.cam-none.bar-bottom .callsign {
  left: 0; bottom: calc(var(--bar-h) - 1px);
  padding-bottom: 1px;
  clip-path: polygon(0 0, calc(100% - var(--ch)) 0, 100% var(--ch), 100% 100%, 0 100%);
  box-shadow: inset 0 2px 0 var(--strike);
  animation: hud-cs-up 650ms var(--ease) 500ms both;   /* sort de la barre, chanfrein conservé */
}
/* Marche sous la barre du haut */
.cam-none.bar-top .callsign {
  left: 0; top: calc(var(--bar-h) - 1px);
  padding-top: 1px;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--ch)), calc(100% - var(--ch)) 100%, 0 100%);
  box-shadow: inset 0 -2px 0 var(--strike);
  animation: hud-cs-down 650ms var(--ease) 500ms both;
}
/* La marche porte le pseudo : on ne le répète pas dans la barre, ni l'accent rouge du filet */
.cam-none .bar-name { display: none; }
.cam-none .bar::before { display: none; }

/* Balayage rouge le long du filet de la barre (hérité du cadre caméra) */
.cam-none .bar::after {
  content: ''; position: absolute; left: 0; width: 90px; height: 2px;
  background: linear-gradient(90deg, rgba(255, 70, 85, 0), var(--strike));
  animation: hud-sweep 7s var(--ease) 1.2s infinite both;
}
.cam-none.bar-bottom .bar::after { top: 0; }
.cam-none.bar-top .bar::after { bottom: 0; }
@keyframes hud-sweep {
  0% { transform: translateX(-90px); opacity: 1; }
  45% { transform: translateX(1920px); opacity: 1; }
  46%, 100% { transform: translateX(1920px); opacity: 0; }
}

/* Sans barre : indicatif autonome dans le coin bas-gauche */
.cam-none.bar-none .callsign {
  --ch: 10px;
  left: var(--edge); bottom: var(--edge);
  padding: 0 22px 0 0;
  background: var(--ink-a);
  clip-path: polygon(var(--ch) 0, 100% 0, 100% calc(100% - var(--ch)), calc(100% - var(--ch)) 100%, 0 100%, 0 var(--ch));
  animation: vp-cham-in 650ms var(--ease) 300ms both;
}
.cam-none.bar-none .cs-meta {
  display: flex; align-items: center; gap: 12px;
  flex: none;
  margin-left: 22px; padding-left: 22px;
  box-shadow: inset 1px 0 0 var(--line);
  height: 24px;
  font-family: var(--f-num); font-weight: 700; font-size: 20px; letter-spacing: .2em; text-transform: uppercase; color: var(--bone);
}
.cs-meta .cs-clock { margin-left: 6px; font-size: 24px; letter-spacing: .02em; font-variant-numeric: tabular-nums; }

@keyframes hud-cs-up {
  from { clip-path: polygon(0 100%, calc(100% - var(--ch)) 100%, 100% 100%, 100% 100%, 0 100%); }
  to   { clip-path: polygon(0 0, calc(100% - var(--ch)) 0, 100% var(--ch), 100% 100%, 0 100%); }
}
@keyframes hud-cs-down {
  from { clip-path: polygon(0 0, 100% 0, 100% 0, calc(100% - var(--ch)) 0, 0 0); }
  to   { clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--ch)), calc(100% - var(--ch)) 100%, 0 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .cam-none .bar::after { animation: none; opacity: 0; }
  .cam-none .callsign { animation-name: vp-fade !important; }
}
html.ok-reduced .cam-none .bar::after { animation: none; opacity: 0; }
