/* =====================================================================
   Lava Stream — Page de visionnage
   Visual system extracted from the binding prototype
   (right panel "NAVIGATEUR · CHEZ SON AMI", states offline/connecting/live).
   ===================================================================== */

:root {
  /* Palette */
  --lv-accent:        #7F77DD;   /* light violet */
  --lv-accent-deep:   #534AB7;   /* appuyé violet */
  --lv-accent-soft:   #8079e0;
  --lv-bg-rad-1:      #34324d;
  --lv-bg-rad-2:      #1d1d1a;
  --lv-bg-page:       #1b1b19;

  --lv-text:          #ECEBE7;
  --lv-muted:         #9C9B94;
  --lv-muted-2:       #a7a59c;
  --lv-dim:           #cfcec8;
  --lv-violet-dim:    #b9b5e8;
  --lv-violet-glow:   rgba(127,119,221,.5);

  /* Live overlays */
  --lv-live-pill-bg:  rgba(83,74,183,.92);
  --lv-live-glow:     rgba(127,119,221,.5);
  --lv-glass-bg:      rgba(28,28,26,.66);
  --lv-glass-bg-2:    rgba(28,28,26,.6);
  --lv-glass-border:  rgba(255,255,255,.1);

  /* Fonts */
  --lv-font-display:  'Bricolage Grotesque', system-ui, sans-serif;
  --lv-font-body:     'Space Grotesk', system-ui, sans-serif;
  --lv-font-mono:     'JetBrains Mono', ui-monospace, monospace;

  /* Radial background used by offline & connecting states */
  --lv-radial-bg: radial-gradient(80% 90% at 50% 42%, var(--lv-bg-rad-1) 0%, var(--lv-bg-rad-2) 64%);
}

/* ---------- Reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--lv-bg-page);
  color: var(--lv-text);
  font-family: var(--lv-font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ---------- Keyframes (same names/values as the prototype <style>) ---------- */
@keyframes lvFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes lvLive {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}
@keyframes lvSpin {
  to { transform: rotate(360deg); }
}

/* ---------- Stage / state switching ---------- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.state {
  position: absolute;
  inset: 0;
  display: none;            /* toggled via data-state on .stage */
}

.stage[data-state="offline"]    .state--offline,
.stage[data-state="connecting"] .state--connecting,
.stage[data-state="live"]       .state--live {
  display: block;
  animation: lvFade .35s ease;
}

/* =====================================================================
   OFFLINE
   ===================================================================== */
.state--offline {
  background: var(--lv-radial-bg);
}

/* Centered stack: brand mark + title + subtitle */
.offline__inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

/* Brand mark — 74px outer ring, two concentric rings + dot (offline variant: dim) */
.brandmark {
  display: grid;
  place-items: center;
}
.brandmark--74 {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1.5px solid rgba(127,119,221,.5);
  box-shadow: 0 0 46px rgba(127,119,221,.25);
  margin-bottom: 24px;
}
.brandmark__ring--inner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.2px solid rgba(127,119,221,.4);
  display: grid;
  place-items: center;
}
.brandmark__dot--dim {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(127,119,221,.5);
}

.state__title {
  margin: 0 0 8px;
  font-family: var(--lv-font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--lv-text);
}

.state__subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--lv-muted);
}

/* Brand wordmark, bottom-left, low opacity */
.wordmark--low {
  position: absolute;
  left: 22px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: .65;
}
.wordmark__ring {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.3px solid var(--lv-accent);
  display: grid;
  place-items: center;
}
.wordmark__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lv-accent);
}
.wordmark__text {
  font-family: var(--lv-font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--lv-text);
}
.wordmark__accent {
  color: var(--lv-accent);
}

/* =====================================================================
   CONNECTING
   ===================================================================== */
.state--connecting {
  background: var(--lv-radial-bg);
}
.connecting__inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2.5px solid rgba(127,119,221,.2);
  border-top-color: var(--lv-accent);
  animation: lvSpin .9s linear infinite;
  margin-bottom: 22px;
}
.connecting__label {
  font-family: var(--lv-font-mono);
  font-size: 13px;
  letter-spacing: .14em;
  color: var(--lv-violet-dim);
}

/* =====================================================================
   LIVE
   ===================================================================== */
.state--live {
  background: #000;
}

/* The video fills the area */
.video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  z-index: 1;
}

/* Diagonal-stripe placeholder shown only while the video has no frames yet.
   The JS toggles the `is-hidden` class once the first frame arrives. */
.placeholder {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: repeating-linear-gradient(135deg, #1f1e1c 0 16px, #232220 16px 32px);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.placeholder.is-hidden {
  display: none;
}
.placeholder__text {
  font-family: var(--lv-font-mono);
  font-size: 12px;
  color: #46453f;
  letter-spacing: .1em;
}

/* Overlay container — sits above the video */
.live__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;            /* children re-enable pointer events */
}

/* Top-left: EN DIRECT pill */
.badge-live {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--lv-live-pill-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 7px 15px;
  box-shadow: 0 0 24px var(--lv-live-glow);
}
.badge-live__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: lvLive 1.6s ease-in-out infinite;
}
.badge-live__text {
  font-family: var(--lv-font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  color: #fff;
}

/* Top-right: elapsed time */
.timecode {
  position: absolute;
  top: 18px;
  right: 18px;
  font-family: var(--lv-font-mono);
  font-size: 12px;
  color: var(--lv-dim);
  background: var(--lv-glass-bg-2);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--lv-glass-border);
  border-radius: 8px;
  padding: 6px 12px;
}

/* Bottom: translucent controls bar */
.controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  height: 50px;
  background: var(--lv-glass-bg);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--lv-glass-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: auto;
}
.controls__left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Generic icon button */
.iconbtn {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: #e6e5e0;
  display: grid;
  place-items: center;
}
.iconbtn:focus-visible {
  outline: 2px solid var(--lv-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Volume bars icon (16px wide column of 3 bars) */
.iconbtn--bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
.iconbtn--bars .bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 14px;
}
.bars__bar {
  width: 3px;
  background: #e6e5e0;
  border-radius: 1px;
}
.bars__bar:nth-child(1) { height: 6px; }
.bars__bar:nth-child(2) { height: 11px; }
.bars__bar:nth-child(3) { height: 14px; }

/* When muted, dim the bars */
.iconbtn--bars.is-muted .bars__bar {
  opacity: .35;
}

/* Volume slider */
.volslider {
  -webkit-appearance: none;
  appearance: none;
  width: 96px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255,255,255,.18);
  outline: none;
  cursor: pointer;
  /* The fill is painted via a background gradient driven by JS
     (we set --lv-vol-pct to update the violet fill width). */
  background-image: linear-gradient(
    to right,
    var(--lv-accent) 0%,
    var(--lv-accent) var(--lv-vol-pct, 62%),
    rgba(255,255,255,.18) var(--lv-vol-pct, 62%),
    rgba(255,255,255,.18) 100%
  );
}
.volslider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(127,119,221,.6);
  border: 0;
  cursor: pointer;
}
.volslider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px rgba(127,119,221,.6);
  border: 0;
  cursor: pointer;
}

/* Fullscreen corner-brackets icon (18px square) */
.iconbtn--fs {
  position: relative;
  width: 18px;
  height: 18px;
}
.corners {
  position: absolute;
  inset: 0;
}
.corners__c {
  position: absolute;
  width: 6px;
  height: 6px;
}
.corners__c--tl { top: 0; left: 0; border-top: 1.6px solid #e6e5e0; border-left: 1.6px solid #e6e5e0; }
.corners__c--tr { top: 0; right: 0; border-top: 1.6px solid #e6e5e0; border-right: 1.6px solid #e6e5e0; }
.corners__c--bl { bottom: 0; left: 0; border-bottom: 1.6px solid #e6e5e0; border-left: 1.6px solid #e6e5e0; }
.corners__c--br { bottom: 0; right: 0; border-bottom: 1.6px solid #e6e5e0; border-right: 1.6px solid #e6e5e0; }

/* =====================================================================
   Responsiveness
   The video fills the viewport on any screen size; offline/connecting
   states are centered via fl/grid regardless of dimensions.
   ===================================================================== */
@media (max-width: 540px) {
  .badge-live,
  .timecode { top: 12px; }
  .badge-live { left: 12px; }
  .timecode  { right: 12px; }
  .controls  { left: 12px; right: 12px; bottom: 12px; }
}

/* Honor reduced-motion preference: keep the fade but stop the loops. */
@media (prefers-reduced-motion: reduce) {
  .badge-live__dot,
  .spinner { animation: none; }
  .state   { animation: none; }
}

/* Fullscreen target: when the container goes fullscreen, the video
   already fills it; keep object-fit:contain. */
.state--live:fullscreen { background: #000; }
.state--live:-webkit-full-screen { background: #000; }
