/* Viewer page (and the base of the broadcaster page, see broadcast.css).
   Dark, calm, in the visual language of the architecture diagram. */
:root {
  --bg: #1b1b1b;
  --surface: #242424;
  --border: #3a3a3a;
  --text: #f2f2f2;
  --text-muted: #b8b8b8;
  --accent: #6aaef0;
  --live: #e5484d;
  --offline: #8a8a8a;
  --warn: #f0a24b;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
}

.status__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--offline);
}

.status[data-state="live"] { border-color: var(--live); }
.status[data-state="live"] .status__dot { background: var(--live); animation: pulse 2s ease-in-out infinite; }
.status[data-state="connecting"] .status__dot,
.status[data-state="reconnecting"] .status__dot { background: var(--accent); }
.status[data-state="error"] .status__dot { background: var(--warn); }
.status[data-state="ready"] .status__dot { background: var(--live); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .status[data-state="live"] .status__dot { animation: none; }
}

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #000;
}

.video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  background: rgba(16, 16, 16, 0.88);
  text-align: center;
}

.overlay[hidden] { display: none; }

/* "Press play": a banner over the top of the picture that leaves the native
   controls at the bottom clickable. */
.overlay--passive {
  inset: 0 0 auto 0;
  padding: 12px 16px;
  pointer-events: none;
}

.overlay__title {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 600;
}

.overlay__text {
  margin: 0;
  max-width: 36em;
  color: var(--text-muted);
  font-size: clamp(0.875rem, 2.2vw, 1rem);
}

.unmute {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.8);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.unmute[hidden] { display: none; }

.unmute:hover { background: rgba(40, 40, 40, 0.92); border-color: var(--accent); }

.unmute:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* The video fills a container that clips its overflow, so draw the ring inside. */
.video:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.quality {
  min-height: 1.5em;
  margin: 10px 2px 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

@media (max-width: 480px) {
  .page { padding: 16px 12px 32px; }
  .title { font-size: 1.25rem; }
  .stage { border-radius: 8px; }
}
