/* Live streaming (SPEC 24): Home's "Live now" row, the live page and Studio's Go live page.
   The ring, the LIVE pill and the channel badge are in style.css (they show on every page). */

/* Home: Live now ----------------------------------------------------------- */

.live-row { margin-bottom: 28px; }
.live-row-title { display: flex; align-items: center; gap: 10px; }
/* position: relative keeps absolutely placed bits (screen-reader text) inside the scrolling row, not the page */
.live-row-list {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 340px); gap: 18px;
  overflow-x: auto; margin: -4px; padding: 4px 4px 8px; scrollbar-width: thin;
}
.live-card { min-width: 0; }
.live-card-screen {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.10), transparent 60%),
    linear-gradient(135deg, hsl(var(--hue) 50% 28%), hsl(calc(var(--hue) + 50) 55% 12%));
  box-shadow: inset 0 0 0 2px var(--accent);
}
.live-card-screen .avatar { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 0 0 6px var(--accent); }
.live-card-pill { position: absolute; left: 10px; top: 10px; }
.live-card-watching {
  position: absolute; right: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.78); color: #fff; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.live-card:hover .live-card-screen { box-shadow: inset 0 0 0 3px var(--accent); }

/* The live page ------------------------------------------------------------- */

.live-page { align-items: start; }
.live-page:has(.live-chat-slot:empty) { grid-template-columns: minmax(0, 1fr); max-width: 1280px; }
.live-chat-slot:empty { display: none; }
.live-player .live-video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.live-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.45); color: #fff; text-align: center; pointer-events: none;
}
.live-overlay-text { font-weight: 600; font-size: 16px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.live-unmute { position: absolute; left: 12px; top: 12px; z-index: 2; background: rgba(0, 0, 0, 0.72); color: #fff; }
.live-unmute:hover { background: rgba(0, 0, 0, 0.88); }
.live-ended-screen {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 16px;
  background:
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(135deg, #1d1d22, #0b0b0d);
  color: #fff; text-align: center;
}
.live-ended-title { font-size: 20px; font-weight: 700; }
.live-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: -2px 0 12px; font-size: 14px; }
.live-ended {
  display: grid; gap: 8px; justify-items: start; margin-top: 16px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
}
.live-ended-head { font-weight: 700; }
.live-replay { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.live-replay:not(:has(> :not([hidden]))) { display: none; }

/* Studio: Go live ------------------------------------------------------------ */

.golive { padding: 18px; display: grid; gap: 16px; }
.golive-tabs {
  display: inline-flex; gap: 2px; justify-self: start; max-width: 100%; overflow-x: auto;
  padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line);
}
.golive-tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px;
  background: none; color: var(--text-2); font-weight: 600; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.golive-tabs [role="tab"]:hover { color: var(--text); background: var(--surface-2); }
.golive-tabs [role="tab"][aria-selected="true"] { background: var(--text); color: var(--bg); }
.golive-tabs [role="tab"]:disabled { opacity: 0.5; cursor: default; }

.golive-device { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(250px, 1fr); gap: 18px; align-items: start; }
.golive-stage {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius);
  background: #000; color: #fff; scroll-margin-top: 84px; /* under the sticky header when going live scrolls to it */
}
.golive-stage.is-live { box-shadow: 0 0 0 3px var(--accent); }
/* The connection dropped while live: the LIVE pill greys out and a warning chip says viewers can't see the creator */
.golive-stage.is-live.is-reconnecting { box-shadow: 0 0 0 3px #f5a524; }
.golive-stage.is-reconnecting .live-pill { background: #52525b; }
.golive-stage.is-reconnecting .live-dot { animation: none; }
.golive-preview { width: 100%; height: 100%; object-fit: contain; background: #000; }
.golive-preview.is-mirrored { transform: scaleX(-1); }
.golive-placeholder {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 16px;
  text-align: center; background: linear-gradient(135deg, #1d1d22, #0b0b0d);
}
.golive-placeholder p { max-width: 360px; color: #e4e4e7; font-size: 14px; }
.golive-placeholder .btn { background: #fff; color: #111; }
.golive-hud {
  position: absolute; left: 10px; right: 10px; top: 10px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  pointer-events: none;
}
.golive-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.golive-chip-warn { background: #fbbf24; color: #111; }
.golive-flip {
  position: absolute; right: 10px; bottom: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.66); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.golive-flip:hover { background: rgba(0, 0, 0, 0.85); }
.golive-meter {
  position: absolute; left: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.66); color: #fff;
}
.golive-meter-track { position: relative; width: 84px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.golive-meter-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: #4ade80; transition: width 0.08s linear; }

.golive-form { display: grid; gap: 14px; align-content: start; }
.golive-form .field { margin: 0; }
.golive-count { justify-self: end; margin-top: 4px; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.golive-go { width: 100%; height: 54px; font-size: 17px; }
.golive-end, .golive-cancel { width: 100%; }
.golive-status { min-height: 1.45em; }
.golive-status:focus { outline: none; }
.golive-status.is-warn { color: var(--danger-text); font-weight: 600; }
.golive-note { font-size: 13px; color: var(--text-2); }
.golive-done { display: grid; gap: 10px; justify-items: start; }

.golive-app { display: grid; gap: 18px; max-width: 760px; }
.golive-copy { display: flex; gap: 8px; min-width: 0; }
.golive-copy input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }
.golive-copy .btn { flex: none; }
.golive-title-row { display: flex; gap: 8px; align-items: flex-end; }
.golive-title-row .field { flex: 1 1 auto; min-width: 0; }
.golive-steps { display: grid; gap: 10px; }
.golive-steps h3 { font-size: 16px; }
.golive-steps ol { margin: 0; padding-left: 22px; display: grid; gap: 4px; color: var(--text-2); font-size: 14px; }
.golive-steps ol strong { color: var(--text); }
.golive-steps details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--bg); }
.golive-steps summary { cursor: pointer; font-weight: 600; }
.golive-steps details[open] summary { margin-bottom: 8px; }

.live-table-title { display: grid; gap: 2px; min-width: 200px; max-width: 420px; }
.live-table-title a { font-weight: 600; overflow-wrap: anywhere; }
.live-table-title a:hover { text-decoration: underline; }
.live-replay-error { display: block; max-width: 320px; margin-top: 4px; }

@media (max-width: 1100px) {
  .golive-device { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .golive-stage { scroll-margin-top: 124px; }
  .live-page .watch-info { padding: 0 16px; }
  .live-chat-slot { padding: 0 16px; }
  .live-ended-title { font-size: 17px; }
  .live-ended-screen .avatar { --size: 56px !important; }
  .live-row-list { grid-auto-columns: minmax(240px, 78%); }
}

@media (max-width: 520px) {
  .golive { padding: 12px; gap: 12px; }
  .golive-stage { aspect-ratio: 3 / 4; max-height: 62svh; }
  /* The one button stays on screen on a phone: the form's parts join the preview's column, so Go live (and End stream
     while live) can stick to the bottom of the screen while any of it is in view */
  .golive-form { display: contents; }
  .golive-go, .golive-end, .golive-cancel {
    position: sticky; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 3;
    box-shadow: 0 0 0 4px var(--surface), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
  .golive-end, .golive-cancel { background: var(--surface); } /* opaque: they can float over the preview */
  [data-golive][data-phase="starting"] .golive-go { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); } /* Cancel under it */
  .golive-tabs { justify-self: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .golive-tabs [role="tab"] { justify-content: center; padding: 0 8px; }
  .golive-copy { flex-wrap: wrap; }
  .golive-copy input { flex-basis: 100%; }
  .golive-title-row { flex-wrap: wrap; }
  .golive-title-row .btn { width: 100%; }
}

@media (max-width: 380px) {
  .golive-tabs [role="tab"] .icon { display: none; }
  .golive-tabs [role="tab"] { font-size: 13.5px; }
}

@media (forced-colors: active) {
  .live-pill, .live-badge { border: 1px solid CanvasText; }
  .golive-meter-fill { background: CanvasText; }
}

/* Rewind (the owner, 2026-10-21): the LIVE button over a stream from an app, top left; red at the live edge, grey behind
   it, and it takes the viewer back to live */
.live-edge {
  position: absolute; top: 10px; left: 10px; z-index: 4; display: inline-flex; align-items: center; gap: 6px; height: 30px;
  padding: 0 12px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font: inherit; font-size: 13px;
  font-weight: 800; letter-spacing: 0.04em; cursor: pointer;
}
.live-edge[hidden] { display: none; }
.live-edge .live-dot { color: #fff; }
.live-edge.is-behind { background: rgba(0, 0, 0, 0.6); color: #ddd; }
.live-edge.is-behind .live-dot { color: #9a9a9a; }
.live-edge:hover { filter: brightness(1.1); }
