/* ============================================================================
   aicam-viewfinder.css — "broadcast viewfinder" reskin for aicam.html.

   Injected only by js/aicam-viewfinder.js (which adds body.fx-viewfinder). Every
   selector is scoped under body.fx-viewfinder, so this file is inert unless the
   mode is on. Concept mirrors fxcam-viewfinder.css: the phone becomes a director's
   monitor — corner crop marks, a tally light, a running timecode and a
   jumbotron-style lower-third reframe the preview as "go on air".

   State colours are FIXED broadcast semantics (amber = standby, red = on air) and
   never theme per game. Brand chrome (lower-third accent, fonts) themes from the
   per-game JSON, exactly like the rest of the platform. Tokens reuse aicam-modern's
   --fx-* where present and fall back so this stands alone.
   ============================================================================ */

body.fx-viewfinder {
  --aiv-tally: #ff2d2d;    /* ON AIR — semantic, not themeable */
  --aiv-standby: #ffb020;  /* STANDBY — semantic, not themeable */
  --aiv-text: var(--fx-text, var(--primary-color, #e8eaed));
  --aiv-muted: color-mix(in srgb, var(--aiv-text) 55%, transparent);
  --aiv-line: var(--fx-line, rgba(232, 234, 237, 0.14));
  --aiv-brand: var(--secondary-color, var(--fx-amber, #ffb02e));
  --aiv-sans: var(--font-family, "Archivo", system-ui, -apple-system, sans-serif);
  --aiv-mono: var(--secondary-font-family, "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace);
}

/* The app's own state chip is replaced by the HUD tally in this mode. */
body.fx-viewfinder .cam .badge { display: none !important; }

/* ---- Crop-mark frame (injected into each monitor) ------------------------- */
body.fx-viewfinder .aiv-cropframe {
  position: absolute;
  inset: 14px 12px;
  pointer-events: none;
  z-index: 6;
}
body.fx-viewfinder .aiv-cropframe span {
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--aiv-standby);
  opacity: 0.85;
  transition: border-color 0.35s ease;
}
body.fx-viewfinder .aiv-cropframe .tl { top: 0; left: 0; border-right: 0; border-bottom: 0; }
body.fx-viewfinder .aiv-cropframe .tr { top: 0; right: 0; border-left: 0; border-bottom: 0; }
body.fx-viewfinder .aiv-cropframe .bl { bottom: 0; left: 0; border-right: 0; border-top: 0; }
body.fx-viewfinder .aiv-cropframe .br { bottom: 0; right: 0; border-left: 0; border-top: 0; }
body.fx-viewfinder.aiv-onair .aiv-cropframe span { border-color: var(--aiv-tally); }

/* ---- Status HUD: tally + timecode (injected) ------------------------------ */
body.fx-viewfinder .aiv-hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 0;
  pointer-events: none;
}
body.fx-viewfinder .aiv-tally {
  font-family: var(--aiv-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 176, 32, 0.5);
  color: var(--aiv-standby);
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
body.fx-viewfinder .aiv-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--aiv-standby);
  animation: aivBreathe 2.2s ease-in-out infinite;
}
body.fx-viewfinder.aiv-onair .aiv-tally {
  color: #fff;
  border-color: rgba(255, 45, 45, 0.65);
  background: rgba(255, 45, 45, 0.16);
}
body.fx-viewfinder.aiv-onair .aiv-dot {
  background: var(--aiv-tally);
  animation: aivPulse 1.5s ease-out infinite;
}
body.fx-viewfinder .aiv-tc {
  font-family: var(--aiv-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--aiv-muted);
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--aiv-line);
}
body.fx-viewfinder.aiv-onair .aiv-tc { color: var(--aiv-tally); }

/* ---- Lower-third: the fan's name as it hits the jumbotron (injected) ------- */
body.fx-viewfinder .aiv-lowerthird {
  position: absolute;
  left: 12px; right: 12px;
  bottom: 14px;
  z-index: 7;
  display: flex;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
body.fx-viewfinder .aiv-lowerthird.is-empty { opacity: 0; transform: translateY(6px); }
body.fx-viewfinder .aiv-lt-bar {
  max-width: 82%;
  background: linear-gradient(90deg, rgba(6, 8, 12, 0.92), rgba(6, 8, 12, 0.5));
  border-left: 3px solid var(--aiv-brand);
  padding: 8px 13px;
  border-radius: 3px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
body.fx-viewfinder .aiv-lt-name {
  font-family: var(--aiv-sans);
  font-weight: 800;
  font-size: 16px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--aiv-text);
}

/* ---- On-air monitor: wrapper around #selfView (built by the JS) -----------
   Shrinks to the self-view's own width so crop marks hug the picture, and its
   overlays stay hidden until the mirror is live and visible. */
body.fx-viewfinder .aiv-monitor {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 18px auto 0;
}
body.fx-viewfinder .aiv-monitor > video { margin: 0 !important; }
body.fx-viewfinder .aiv-monitor .aiv-cropframe,
body.fx-viewfinder .aiv-monitor .aiv-hud,
body.fx-viewfinder .aiv-monitor .aiv-lowerthird { display: none; }
body.fx-viewfinder .aiv-monitor.is-live .aiv-cropframe { display: block; }
body.fx-viewfinder .aiv-monitor.is-live .aiv-hud { display: flex; }
body.fx-viewfinder .aiv-monitor.is-live .aiv-lowerthird { display: flex; }

/* ---- Motion ---------------------------------------------------------------- */
@keyframes aivBreathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@keyframes aivPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 45, 45, 0.6); }
  100% { box-shadow: 0 0 0 9px rgba(255, 45, 45, 0); }
}
@media (prefers-reduced-motion: reduce) {
  body.fx-viewfinder .aiv-dot { animation: none; }
}
