/* ============================================================
   HOST PRODUCTION — host.css
   Dark theme, video-hero layout
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d1117;
  --surface:     #161b22;
  --surface-2:   #21262d;
  --border:      rgba(255,255,255,0.08);
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --accent:      #58a6ff;
  --live:        #3fb950;
  --error:       #f85149;
  --radius:      12px;
  --radius-lg:   18px;
  --font-ui:     'Syne', sans-serif;
  --font-mono:   'DM Mono', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* ── OVERLAYS ─────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(13,17,23,0.92);
  backdrop-filter: blur(6px);
}

.overlay__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.overlay__label {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.overlay__sub {
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.overlay__icon {
  width: 52px;
  height: 52px;
  color: var(--error);
}

.overlay--error {
  background: rgba(13,17,23,0.96);
}

.btn-reload {
  margin-top: 8px;
  padding: 10px 28px;
  border: 1.5px solid var(--error);
  border-radius: var(--radius);
  background: transparent;
  color: var(--error);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-reload:hover {
  background: var(--error);
  color: #fff;
}

/* Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── STATE CONTROL ────────────────────────────────────────── */

/* connecting → show connecting overlay */
body.state-connecting #overlayConnecting { display: flex; }

/* error → show error overlay, video blocked */
body.state-error #overlayError   { display: flex; }
body.state-error #player         { pointer-events: none; filter: brightness(0.3); }

/* ready → both overlays hidden (default already hidden) */

/* ── LAYOUT ───────────────────────────────────────────────── */

.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── TOP BAR ──────────────────────────────────────────────── */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s;
}
.topbar__brand:hover { opacity: 0.7; }

.topbar__role {
  color: var(--accent);
  margin-left: 6px;
  font-size: 11px;
  background: rgba(88,166,255,0.12);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.1em;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--font-mono);
}

.status-pill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

/* dot colours per state */
body.state-connecting .status-pill__dot { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
body.state-ready      .status-pill__dot { background: var(--live); }
body.state-error      .status-pill__dot { background: var(--error); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* Icon buttons */
.btn-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon:hover { background: var(--surface); border-color: rgba(255,255,255,0.18); }

.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* ── CONTENT ──────────────────────────────────────────────── */

.content {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 0;
  overflow: hidden;
}

/* ── VIDEO MAIN (left column) ─────────────────────────────── */

.video-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── VIDEO ────────────────────────────────────────────────── */

.video-wrap {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 16px;
  max-height: 58%;
  overflow: hidden;
}

#player {
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-lg);
  background: #000;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  display: none; /* shown by JS on ready */
}

/* ── CONTENT LIST ─────────────────────────────────────────── */

.content-list-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
}

.content-list-wrap__label {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.content-list {
  display: flex;
  flex-direction: row;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.content-list__loading,
.content-list__error {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
  white-space: nowrap;
}

.content-list__error { color: var(--error); }

.content-row {
  flex: 0 0 180px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s, transform 0.12s;
  background: var(--surface-2);
}

.content-row:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.content-row--active {
  border-color: rgba(88,166,255,0.5);
  box-shadow: 0 0 0 1px rgba(88,166,255,0.3);
}

.content-row__art {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface);
}

.content-row__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.content-row__art-placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface);
}

.content-row__info {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.content-row__title {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-row__desc {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content-row__end { display: none; }

/* ── SIDEBAR ──────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

/* ── QR PANEL ─────────────────────────────────────────────── */

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.qr-panel__label {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.qr-panel__canvas-wrap {
  background: #fff;
  padding: 10px;
  border-radius: 10px;
  line-height: 0; /* prevent extra whitespace */
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#qr {
  width: 200px;
  height: 200px;
  display: block;
  image-rendering: pixelated;
}

/* ── SESSION ID (dev-only) ───────────────────────────────── */

.session-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.session-info__label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-info__id {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text);
  word-break: break-all;
}

/* Toggle dev-only elements — set to 'none' for prod */
.dev-only {
  display: none;
}

/* ── RESPONSIVE ───────────────────────────────────────────── */

@media (max-width: 768px) {
  .content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .sidebar {
    flex-direction: row;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 12px;
    overflow-x: auto;
  }

  .qr-panel {
    flex-direction: row;
    gap: 10px;
    padding: 10px 14px;
  }

  .qr-panel__canvas-wrap {
    width: 120px;
    height: 120px;
  }

  #qr {
    width: 100px;
    height: 100px;
  }
}

.btn-mute--active {
  border-color: var(--error);
  color: var(--error);
  background: rgba(248, 81, 73, 0.12);
}

.btn-mute--active:hover {
  background: var(--error);
  color: #fff;
}

.sync-quality {
  position: relative;
  z-index: 200;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e3b341;
  background: rgba(227, 179, 65, 0.15);
  border: 1px solid rgba(227, 179, 65, 0.45);
  padding: 5px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.hidden { display: none; }
