/* ===== Viewer: film fills the screen, chat on the right ===== */
:root {
  --nav-h: 56px;
  --chat-w: 20%; /* default; the viewer can drag the chat edge (saved per browser) */
}

html, body { height: 100%; }
body {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--nav-h) minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  background: #000;
}

/* ---- Navigation ---- */
.nav {
  position: relative; z-index: 30; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 clamp(10px, 2vw, 20px);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav .spacer { flex: 1; }

.account { display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 3px 3px 3px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px; font-weight: 600; font-size: 14px;
}
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #111; }

.chat-toggle[aria-pressed='true'] { background: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---- Genre dropdown ---- */
.genre-menu { position: relative; min-width: 0; }
#genre-current { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.genre-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 12px 0 14px;
  border-radius: 999px; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); font-weight: 700; font-size: 15px;
}
.genre-btn:hover { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.genre-btn .chev { width: 16px; height: 16px; transition: transform 0.2s var(--ease); }
.genre-btn[aria-expanded='true'] .chev { transform: rotate(180deg); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 0 var(--live); animation: live-pulse 1.8s infinite; flex: none; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.6); } 70% { box-shadow: 0 0 0 7px rgba(255, 59, 59, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0); } }

.genre-pop {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 260px; max-height: min(70vh, 480px); overflow-y: auto;
  padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: pop-in 0.16s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.genre-pop-title { font-size: 11px; font-weight: 800; color: var(--muted); padding: 6px 10px 8px; }
.genre-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.genre-opt {
  --c: var(--accent);
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; font-weight: 600;
}
.genre-opt:hover, .genre-opt:focus-visible { background: var(--surface-2); outline: none; }
.genre-opt[aria-selected='true'] { background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); }
.genre-opt .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: color-mix(in srgb, var(--c) 22%, transparent); }
.genre-opt .count { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.genre-opt .count::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.genre-empty { padding: 10px; color: var(--muted); font-size: 14px; }

/* ---- Watch area ---- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) clamp(200px, var(--chat-w), 60%); min-height: 0; }

/* Drag handle on the chat's left edge */
.chat-resizer {
  position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; z-index: 6;
  cursor: col-resize; touch-action: none; outline: none;
}
.chat-resizer::after {
  content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px;
  background: transparent; transition: background 0.15s;
}
.chat-resizer:hover::after, .chat-resizer:focus-visible::after, body.resizing .chat-resizer::after { background: var(--accent); }
.chat-resizer::before {
  content: ''; position: absolute; left: 2px; top: 50%; width: 6px; height: 36px; margin-top: -18px;
  border-radius: 3px; background: var(--line-strong); transition: background 0.15s;
}
.chat-resizer:hover::before, .chat-resizer:focus-visible::before, body.resizing .chat-resizer::before { background: var(--accent); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .screen { pointer-events: none; }
.watch.chat-off { grid-template-columns: minmax(0, 1fr); }
.watch.chat-off .chat { display: none; }

.screen { position: relative; min-width: 0; min-height: 0; background: #000; overflow: hidden; }
.screen video, .vdb-host { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; z-index: 1; }
.vdb-host .videodb-player, .vdb-host iframe, .vdb-host video { width: 100% !important; height: 100% !important; border: 0 !important; object-fit: contain !important; }
.screen.idle { cursor: none; }
/* Once a VideoDB film plays, this covers its own controls: no pause, no seeking. */
.vdb-shield { display: none !important; pointer-events: none !important; }
.screen.vdb-locked .vdb-shield { display: none !important; pointer-events: none !important; }
.vdb-loading { display: none !important; pointer-events: none !important; }

.controls {
  position: absolute; right: 16px; bottom: 16px; z-index: 3;
  display: flex; align-items: center; gap: 6px; padding: 6px 10px 6px 6px; border-radius: 999px;
  background: rgba(10, 10, 14, 0.62); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1);
  transition: opacity 0.35s, transform 0.35s var(--ease);
}
.screen.idle .controls { opacity: 0; transform: translateY(8px); pointer-events: none; }
.ctl { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: #fff; display: grid; place-items: center; }
.ctl:hover { background: rgba(255, 255, 255, 0.14); }
.ctl svg { width: 21px; height: 21px; }
#btn-mute .ic-off, #btn-fs .ic-exit { display: none; }
#btn-mute[aria-pressed='true'] .ic-on { display: none; }
#btn-mute[aria-pressed='true'] .ic-off { display: block; }
.screen:fullscreen #btn-fs .ic-enter { display: none; }
.screen:fullscreen #btn-fs .ic-exit { display: block; }
.volume { width: 110px; accent-color: var(--accent); }

.unmute-pill {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px;
  border: 0; background: #fff; color: #111; font-weight: 700; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: bob 2.4s var(--ease) infinite;
}
.unmute-pill svg { width: 18px; height: 18px; }
@keyframes bob { 50% { transform: translate(-50%, -3px); } }

.overlay { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; text-align: center; padding: 20px; }
.overlay.info { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px); }
.overlay.start { background: radial-gradient(circle, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.7)); }
.ov-card { max-width: 420px; display: grid; gap: 6px; justify-items: center; }
.ov-card p { margin: 0; }
.ov-icon { font-size: 36px; }
.ov-title { font-size: 18px; font-weight: 700; }
.big-play {
  display: inline-flex; align-items: center; gap: 12px; padding: 16px 28px 16px 22px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700;
  box-shadow: 0 16px 50px -10px var(--accent); transition: transform 0.15s;
}
.big-play:hover { transform: scale(1.04); }
.big-play svg { width: 26px; height: 26px; }

.spinner {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px; z-index: 2;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.15); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Channel-switch "static" transition */
.switcher { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #050507; animation: switch-out 0.7s var(--ease) forwards; }
.switcher-noise {
  position: absolute; inset: -50%;
  background-image: repeating-radial-gradient(circle at 17% 32%, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 73% 61%, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 2px);
  animation: noise 0.18s steps(3) infinite;
}
.switcher-label { position: relative; font-family: var(--font-display); font-size: clamp(22px, 4vw, 40px); font-weight: 700; color: var(--accent); text-shadow: 0 0 30px var(--accent); }
@keyframes noise { 33% { transform: translate(-3%, 2%); } 66% { transform: translate(2%, -3%); } }
@keyframes switch-out { 0%, 55% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---- Chat ---- */
.chat {
  position: relative; min-width: 0; min-height: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--surface); border-left: 1px solid var(--line);
  overflow: visible;
}
.chat > :not(.chat-resizer) { min-width: 0; overflow-x: clip; }
.chat-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-head h2::before { content: ''; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.chat-viewers { font-size: 12px; color: var(--muted); }
.chat-scroller { overflow-y: auto; overscroll-behavior: contain; padding: 6px 0; }
.chat-list { list-style: none; margin: 0; padding: 0; }
.msg { position: relative; padding: 5px 12px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.msg:hover { background: rgba(255, 255, 255, 0.03); }
.msg .who { font-weight: 700; margin-right: 6px; }
.msg .badge { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: var(--accent); color: var(--accent-ink); margin-right: 6px; vertical-align: 1px; }
.msg time { color: var(--muted); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
.msg .body a { color: #8ab4ff; }
.msg-tools { position: absolute; right: 8px; top: 2px; display: none; gap: 4px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { display: flex; }
.msg-tools button { border: 1px solid var(--line-strong); background: var(--surface-3); border-radius: 6px; font-size: 11px; padding: 2px 6px; min-height: 24px; }
.sys { padding: 8px 14px; font-size: 12.5px; color: var(--text-2); }
.new-pill {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  border: 0; border-radius: 999px; padding: 6px 14px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap;
}
.composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.composer .input { border-radius: 999px; padding-left: 14px; min-width: 0; }
.chat-guest { padding: 12px 14px 14px; border-top: 1px solid var(--line); text-align: center; color: var(--text-2); font-size: 13.5px; }
.chat-guest p { margin: 0 0 10px; }
.chat-guest .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chat-guest .row .btn { flex: 1 1 auto; min-width: 0; }

/* ---- Small screens: film on top, chat below ---- */
@media (max-width: 800px) {
  :root { --nav-h: 52px; }
  .watch { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .watch.chat-off { grid-template-rows: minmax(0, 1fr); }
  .screen { aspect-ratio: 16 / 9; }
  .watch.chat-off .screen { aspect-ratio: auto; }
  .chat { border-left: 0; border-top: 1px solid var(--line); }
  .chat-resizer { display: none; }
  .volume { display: none; }
  .chat-toggle .label, .user-chip .name { display: none; }
  .nav { gap: 6px; }
  .nav > * { flex-shrink: 0; }
  .nav .genre-menu { flex-shrink: 1; }
  .genre-btn { max-width: 100%; min-width: 0; padding: 0 8px 0 10px; font-size: 14px; }
  .account .register-btn { display: none; }
  .brand-mark { width: 36px; height: 36px; }
  .genre-pop { position: fixed; left: 10px; right: 10px; top: calc(var(--nav-h) + 6px); min-width: 0; }
}
@media (max-width: 420px) {
  .lang-switch button { min-width: 32px; }
  .account .btn-sm { padding: 0 10px; }
}
