/* style.css
   Mobile-first dark theme for the live streaming site.
   Layout, top to bottom: the host stream full-bleed at the very top,
   a middle region where the viewer cameras fill the space and the
   live chat floats over them with a transparent background, and the
   message input pinned at the bottom. No top bar, no viewer count,
   no status line. Room controls are slash commands, not buttons.
   The page fills the screen (100dvh) with no whole-page scrolling.
   Safe-area insets keep content clear of notches and the home indicator.
   Every colour is a named variable at the top so the theme is easy to change.
*/

:root {
  /* Page background and panels */
  --bg: #0d0f14;
  --panel: #161a23;
  --panel-border: #262c3a;
  /* Text */
  --text: #eef1f6;
  --muted: #9aa3b2;
  /* Accent and live red */
  --accent: #4f8cff;
  --live: #e5484d;
  /* Buttons */
  --button-bg: #232936;
  --button-text: #eef1f6;
  --danger: #e5484d;
  /* Inputs */
  --input-bg: #0d0f14;
  --input-border: #333b4d;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* App shell: full screen, no page scroll. The chat list scrolls inside. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* The screen: one column filling the page. */
.screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* Player area: the host stream, full-bleed at the very top, edge to
   edge with no margins. */
.player-area {
  flex-shrink: 0;
  padding: 0;
}

.player-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 55dvh;
  background: #000;
  overflow: hidden;
}

#player {
  width: 100%;
  height: 100%;
}

/* The stream is 16:9 inside a 4:3 box, so the video letterboxes
   with black bars top and bottom. Cover fills the box edge to edge
   instead, keeping the box big. OvenPlayer never sets object-fit
   itself, so this rule wins. */
#player video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Never show OvenPlayer's own error text ("Error initializing HLS."
   and friends) or its warning icon. Only our offline box speaks to
   the viewer. */
#player .op-message-box {
  display: none !important;
}

/* Plain <video> fallback (see js/player.js). Fills the box like the
   OvenPlayer video. */
.native-fallback-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

/* Red LIVE pill, overlaid at the video's bottom-right corner. Shown
   only while the stream is up. */
.live-badge {
  display: none;
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 6;
  background: var(--live);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 999px;
}

.live-badge.on {
  display: inline-block;
}

/* Offline message shown over the player when nothing is streaming. */
.offline-box {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #000;
  color: var(--text);
  text-align: center;
  padding: 16px;
}

.offline-box.on {
  display: flex;
}

.offline-box strong {
  font-size: 18px;
}

.offline-box span {
  color: var(--muted);
  font-size: 14px;
}

/* Paywall lock shown over the player when the paywall is on. */
.paywall-box {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(13, 15, 20, 0.94);
  color: var(--text);
  text-align: center;
  padding: 16px;
  z-index: 5;
}

.paywall-box.on {
  display: flex;
}

.paywall-box strong {
  font-size: 18px;
}

.paywall-box span {
  color: var(--muted);
  font-size: 14px;
}

/* In-page note shown when Subscribe is tapped but not open yet. */
.paywall-note {
  color: var(--muted);
  font-size: 14px;
}

/* Buttons. Big enough to tap on a phone. */
button {
  font: inherit;
  color: var(--button-text);
  background: var(--button-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  min-height: 44px;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button.active {
  border-color: var(--accent);
  color: var(--accent);
}

/* Inputs. */
input[type="text"],
input[type="password"] {
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* Middle region: one container holding both the cameras and the
   chat. It takes the free space between the video and the input.
   The cameras fill it as the background layer; the chat floats
   over them. */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* Chat text over the cameras: white fill, black stroke outline,
   about 60% opaque so the cameras show through underneath. The
   -webkit-text-stroke draws the outline; the text-shadow stack is
   the fallback for browsers without stroke support. The stroke and
   shadows are inherited by the name, time, and message spans inside
   each row. The Moderation button under the chat gets the same
   treatment, since it sits over the cameras too. */
.chat-message,
.chat-whisper,
.chat-system,
.chat-action,
.pin-bar,
.poll-box .poll-question,
.poll-box .poll-results,
#modToggleButton {
  color: #fff;
  opacity: 0.6;
  -webkit-text-stroke: 1px #000;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 rgba(0, 0, 0, 0.9),
    1px -1px 0 rgba(0, 0, 0, 0.9),
    -1px 1px 0 rgba(0, 0, 0, 0.9),
    1px 1px 0 rgba(0, 0, 0, 0.9),
    0 0 4px rgba(0, 0, 0, 0.9);
}

/* Chat section, floating over the cameras. Completely transparent:
   no background anywhere, so the cameras show through. The list
   scrolls inside it. */
.chat-section {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: transparent;
  padding: 12px 12px 0;
}

/* Moderation toggle, shown only to the host. A plain text button
   under the chat list. */
#modToggleButton {
  align-self: flex-start;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 4px 0;
  font-size: 14px;
  cursor: pointer;
}

/* The list scrolls on its own. Up and down swipes scroll the chat.
   Sideways swipes are handed to the camera strip by the touch
   handler in chat.js, since the list covers the strip. */
.chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 2px;
  background: transparent;
}

/* One message is a single line: the message text, then @username,
   then the relative time. No bubble, no background. The spans sit
   inline and wrap together. */
.chat-message {
  padding: 2px 0;
  overflow-wrap: anywhere;
}

.chat-message .chat-text {
  font-size: 15px;
}

.chat-message .chat-name {
  font-weight: 700;
  color: var(--accent);
}

.chat-message .chat-time {
  color: var(--muted);
  flex-shrink: 0;
}

/* Private messages. Only the sender, the recipient, and the host ever
   see one. Same line shape as public chat, with an accent border on
   the left and a small Whisper marker, and no background either. */
.chat-whisper {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 8px;
  overflow-wrap: anywhere;
}

.chat-whisper .chat-whisper-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

.chat-whisper .chat-whisper-text {
  font-size: 15px;
}

.chat-whisper .chat-name {
  font-weight: 700;
  color: var(--accent);
}

.chat-whisper .chat-time {
  color: var(--muted);
}

.chat-system {
  font-size: 13px;
  text-align: center;
  padding: 2px 0;
}

.chat-system .chat-time {
  color: var(--muted);
}

/* Action lines: /me, /hug, /lurk, /dice, /coin, /8ball. One line
   that reads as "name does something", in italics, in the sender's
   own color when it is mine. Same shape as a chat message. */
.chat-action {
  font-style: italic;
  padding: 2px 0;
  overflow-wrap: anywhere;
}

.chat-action .chat-text {
  font-size: 15px;
}

.chat-action .chat-time {
  color: var(--muted);
}

/* Pinned message from the host, at the top of the chat. An accent
   border on the left, like a whisper, and no background, so the
   cameras still show through. */
.pin-bar {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 8px;
  margin-bottom: 6px;
  font-size: 14px;
  flex-shrink: 0;
  overflow-wrap: anywhere;
}

.pin-bar .pin-label {
  font-weight: 700;
  color: var(--accent);
  margin-right: 6px;
}

/* Active poll from the host, above the chat list. The question and
   the results use the same outlined text as the chat. The vote
   buttons are solid controls, so their text is plain. */
.poll-box {
  flex-shrink: 0;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.poll-box .poll-question {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.poll-box .poll-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.poll-box button {
  -webkit-text-stroke: 0;
  text-shadow: none;
  opacity: 1;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 14px;
}

.poll-box .poll-results {
  font-size: 14px;
}

.poll-box .poll-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* /size: when a chat text size is chosen, every line of chat text
   on this screen uses it. Without the class, the default sizes
   above show. */
.chat-section.sized .chat-text,
.chat-section.sized .chat-name,
.chat-section.sized .chat-time,
.chat-section.sized .chat-whisper-tag,
.chat-section.sized .chat-whisper-text,
.chat-section.sized .chat-system,
.chat-section.sized .chat-action,
.chat-section.sized .pin-bar,
.chat-section.sized .poll-question,
.chat-section.sized .poll-results {
  font-size: var(--chat-size);
}

/* Camera section, filling the whole middle region behind the chat.
   When nobody is on camera the strip is empty and the dark page
   background shows through the chat instead. */
.cam-section {
  position: absolute;
  inset: 0;
  width: 100%;
}

/* The camera strip, filling the region. The tiles stay full size,
   so overflow cameras are a swipe away instead of being squeezed
   smaller. Scroll snapping lands each swipe on a tile. Sideways
   swipes belong to this strip; up and down swipes are left alone
   for the chat. Tiles size by height, so they fill the region. */
.cam-grid {
  display: flex;
  flex-direction: row;
  gap: 8px;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding: 0;
  scrollbar-width: none;
  padding: 0;
  align-items: stretch;
}

.cam-grid::-webkit-scrollbar {
  display: none;
}

.cam-tile {
  flex: 0 0 auto;
  height: 100%;
  width: auto;
  aspect-ratio: 4 / 3;
  scroll-snap-align: start;
  position: relative;
  background: #000;
  overflow: hidden;
}

.cam-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cam-tile .cam-label {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 999px;
  max-width: calc(100% - 12px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cam-tile.local {
  outline: 2px solid var(--accent);
}

/* Spotlight: the host picked this camera to show big. A wider tile
   with a strong accent outline, so it stands out in the strip. */
.cam-tile.spotlight {
  aspect-ratio: 16 / 9;
  outline: 3px solid var(--accent);
}

/* Message and command input, pinned at the very bottom. */
.chat-form {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
}

.chat-form input {
  flex: 1;
  min-width: 0;
}

.chat-form button {
  flex-shrink: 0;
}

/* Command suggestions, above the input like a search bar's
   autocomplete. The input is pinned at the bottom, so the list
   opens upward. Hidden until typing "/" narrows it down. */
.suggest-box {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 100%;
  margin-bottom: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 10;
}

.suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 10px 12px;
  min-height: 0;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.suggest-item.active {
  background: var(--accent);
  color: #fff;
}

/* A panel is one card: player, cameras, chat, moderation. */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 12px;
}

.panel h2 {
  font-size: 16px;
  margin: 0 0 10px;
}

.panel p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

/* Moderation panel. Hidden unless the user is the host; shown as a
   bottom sheet over the page. */
.mod-panel {
  display: none;
}

.mod-panel.on {
  display: block;
}

.mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--panel-border);
}

.mod-row:first-of-type {
  border-top: none;
}

.mod-row .mod-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mod-row .mod-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.mod-row .mod-buttons button {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 14px;
}

.mod-empty {
  color: var(--muted);
  font-size: 14px;
}

/* Small note text under a panel. */
.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

.note a {
  color: var(--accent);
}

/* Error line shown when joining the room fails. */
.error-line {
  display: none;
  color: var(--danger);
  font-size: 14px;
  flex-shrink: 0;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 6px 12px 0;
}

.error-line.on {
  display: block;
}

/* Bottom sheets: host sign-in, moderation, and the camera prompt.
   Slide up from the bottom. */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.sheet-backdrop.on {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-width: 560px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform 0.25s ease-out;
}

.sheet.on {
  transform: translateY(0);
}

.sheet h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

.sheet p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

/* Join prompt. Full-screen overlay; blocks the app until the visitor
   joins with a name. Shown whenever the page loads and the user is
   not joined yet. */
.welcome-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.welcome-sheet.on {
  display: flex;
}

.welcome-sheet h2 {
  font-size: 22px;
  margin: 0;
}

.welcome-sheet p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.welcome-sheet input {
  max-width: 320px;
}

/* First-visit guided tour. A dim overlay plus one small popup anchored
   to the part of the page it describes. Shown once, on a first visit,
   right after the camera prompt sheet is dismissed. The popup is
   placed by js/tour.js, next to its anchor element. */
.tour-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.tour-backdrop.on {
  opacity: 1;
  pointer-events: auto;
}

.tour-popup {
  position: fixed;
  left: 16px;
  right: 16px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 32;
  display: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.tour-popup.on {
  display: block;
}

.tour-text {
  margin: 0 0 12px;
  font-size: 15px;
}

.tour-text a {
  color: var(--accent);
}

.tour-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Skip looks like a quiet link next to the main button. */
.tour-skip {
  background: transparent;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  min-height: 44px;
  padding: 10px 4px;
}

/* The part of the page a tour step describes, lifted above the dim
   overlay and outlined so it stands out. */
.tour-highlight {
  position: relative;
  z-index: 31;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Wide screens: wider video. Camera tiles size by height, so they
   fill the middle region at any width. */
@media (min-width: 900px) {
  .player-wrap {
    aspect-ratio: 16 / 9;
    max-height: 60dvh;
  }
}
