/* The host panel (public/host.js): going live, hand-overs, races. Loaded after viewer.css, whose .host,
   .banner, .self-view, .health, .host-actions and .quality rules this builds on. */

.host {
  padding: 12px;
}

.host-head {
  gap: 6px;
}

.host-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-icon {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.04);
  font-size: 18px;
  line-height: 1;
}

.host-icon:hover,
.host-icon:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.12);
}

.host-icon:focus-visible,
.host-switch input:focus-visible + .host-switch-knob,
.host-settings summary:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.host-icon svg {
  width: 16px;
  height: 16px;
  transition: transform 0.15s ease;
}

.host.is-collapsed .host-icon[aria-expanded="false"] svg {
  transform: rotate(180deg);
}

.host.is-collapsed .host-body {
  display: none;
}

/* The one thing a host must never misread: whether the world can see them. */
.host-air {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--dim);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-align: center;
}

.host-air::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.host-air[data-state="private"] {
  border-color: rgba(255, 181, 71, 0.55);
  color: var(--next);
  background: rgba(255, 181, 71, 0.12);
}

.host-air[data-state="live"] {
  border-color: transparent;
  color: #fff;
  background: var(--grad-warm);
  box-shadow: 0 6px 22px rgba(255, 45, 85, 0.35);
}

.host-air[data-state="live"]::before {
  opacity: 1;
  animation: pulse 1.6s ease-in-out infinite;
}

.host-line {
  margin: 8px 2px 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.host-line:empty {
  display: none;
}

.host-line.is-error {
  color: #ff9fb3;
}

/* A hand-over prompt: a line and a button, never over the host's own controls. */
.host-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 10px;
  padding: 8px 8px 8px 12px;
  border: 1px solid rgba(255, 181, 71, 0.45);
  border-left: 3px solid var(--next);
  border-radius: 12px;
  background: rgba(255, 181, 71, 0.09);
}

.host-notice[data-kind="unlinger"] {
  border-color: var(--line);
  border-left-color: var(--pick);
  background: rgba(62, 230, 168, 0.07);
}

.host-notice p {
  flex: 1 1 150px;
  min-width: 0;
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.35;
}

.host-notice .small {
  padding: 7px 12px;
  font-size: 12.5px;
}

/* The self-view, with the other host small in its corner. */
.host-media {
  position: relative;
}

.host .self-view {
  max-height: 170px;
}

.host-peek {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 38%;
  max-width: 140px;
  margin: 0;
  overflow: hidden;
  border: 2px solid var(--next);
  border-radius: 10px;
  background: #000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.host-peek.is-alone {
  position: relative;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: none;
  margin-top: 10px;
}

.host-peek video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #000;
}

.host-peek figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  padding: 10px 6px 3px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  font-size: 10.5px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-peek-status {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 90%;
  color: var(--dim);
  font-size: 10px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.host-peek-status:empty {
  display: none;
}

.host .host-actions {
  margin-top: 10px;
}

.host .note:empty {
  display: none;
}

/* "Ready to go live": a switch with its reason underneath. */
.host-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.host-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.host-switch-knob {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.15s ease;
}

.host-switch-knob::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.host-switch input:checked + .host-switch-knob {
  background: var(--pick);
}

.host-switch input:checked + .host-switch-knob::after {
  transform: translateX(16px);
}

.host-switch input:disabled + .host-switch-knob {
  opacity: 0.45;
}

.host-switch:has(input:disabled) {
  cursor: default;
}

.host-switch-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: 13.5px;
}

.host-switch-text small {
  color: var(--dim);
  font-size: 11.5px;
}

/* Settings, one tap away: quality and delay, and what happens around a hand-over. */
.host-settings {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.host-settings summary {
  padding: 10px 2px 2px;
  color: var(--dim);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.host-settings summary:hover {
  color: var(--ink);
}

.host-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.host-choice {
  margin: 12px 0 0;
  padding: 0;
  border: 0;
}

.host-choice legend,
.host-keep > span {
  margin-bottom: 4px;
  padding: 0;
  color: var(--dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.host-choice label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13.5px;
  cursor: pointer;
}

.host-choice input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--pick);
}

.host-keep {
  margin-top: 10px;
}

.host-keep select {
  align-self: flex-start;
}

/* The race: the one prompt allowed to cover the stage, for the few seconds a race lasts. */
.host-race {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 12px) var(--safe-right) calc(var(--safe-bottom) + 12px) var(--safe-left);
  background: rgba(7, 6, 13, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: host-race-in 0.18s ease-out both;
}

.host-race-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 20px 20px;
  border: 1px solid transparent;
  border-radius: 24px;
  background:
    linear-gradient(var(--surface-strong), var(--surface-strong)) padding-box,
    var(--grad) border-box;
  box-shadow: var(--shadow);
  text-align: center;
}

.host-race-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--pick);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.host-race h2 {
  margin: 10px 0 0;
  font-size: clamp(20px, 5.4vw, 26px);
  line-height: 1.2;
}

.host-race-self {
  display: block;
  width: 100%;
  max-height: 180px;
  margin-top: 14px;
  border-radius: 14px;
  object-fit: cover;
  background: #000;
  transform: scaleX(-1);
}

.host-race-note {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.host-race-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.host-race-actions .big {
  flex: 1 1 150px;
  min-width: 0;
}

.host-race-actions .ghost {
  flex: 0 1 auto;
}

@keyframes host-race-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 420px) {
  .host .self-view {
    max-height: 140px;
  }

  .host-race-card {
    padding: 18px 14px 14px;
  }
}
