/* =============================================================
   KM STREAM STYLES — page-specific only
   Shared components (buttons, header, nav, footer) come from
   km-core/km-global.css.
   ============================================================= */

/* ── Page base ─────────────────────────────────────────────── */

/* No overflow:hidden or height:100vh on body — those fight with
   WP's admin bar margin-top on html. The viewport handles itself. */
body.km-page--stream {
  overflow: hidden;
}

/* ── Header: stream page uses a shorter header ─────────────── */

.km-header--stream .km-header__inner {
  height: 56px;
  gap: var(--km-space-md);
}

.km-header--stream .km-header__logo-img {
  height: 26px;
}

.km-header--stream .km-nav__link {
  font-size: var(--km-size-xs);
  padding: 0.3rem 0.65rem;
}

.km-header--stream .km-header__auth {
  margin-left: 0; /* controls sit to the right of auth, not auth to the right of nav */
}


/* ── Stream control buttons ────────────────────────────────── */

.km-stream__controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  flex-shrink: 0;
}

.km-stream__ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--km-radius-sm);
  cursor: pointer;
  color: var(--km-text-muted);
  transition: all var(--km-transition);
  text-decoration: none;
  flex-shrink: 0;
}

.km-stream__ctrl-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  pointer-events: none;
}

.km-stream__ctrl-btn:hover {
  color: var(--km-gold-bright);
  border-color: var(--km-border-subtle);
  background: rgba(138, 91, 24, 0.08);
}

.km-stream__ctrl-btn.is-active {
  color: var(--km-gold-mid);
  border-color: var(--km-border-mid);
  background: rgba(138, 91, 24, 0.12);
}


/* ════════════════════════════════════════════════════════════
   STREAM VIEWPORT
   ════════════════════════════════════════════════════════════ */

.km-stream__viewport {
  position: fixed;
  top: 88px;   /* 56px stream header + 32px permanent top padding */
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: #000;
  overflow: hidden;
  z-index: 1;
}


/* ── Video panel ───────────────────────────────────────────── */

.km-stream__video-panel {
  flex: 1;
  min-width: 0;
  position: relative;
  background: #000;
  display: flex;
  align-items: stretch;
}

.km-stream__embed-wrap {
  width: 100%;
  height: 100%;
  position: relative;
  pointer-events: auto; /* explicitly allow clicks through to Twitch iframe */
}

/* Twitch injects an iframe into this div */
#km-twitch-embed {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

/* Ensure Twitch's injected iframe never gets blocked */
#km-twitch-embed iframe {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  pointer-events: auto !important;
  position: relative;
  z-index: 1;
}


/* ── Offline state ─────────────────────────────────────────── */

.km-stream__offline {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--km-bg-base);
  z-index: 2;
  pointer-events: none; /* let clicks pass through even when shown */
}

.km-stream__offline[hidden] {
  display: none;
}

.km-stream__offline-inner {
  text-align: center;
  padding: var(--km-space-xl);
  pointer-events: auto;
}

.km-stream__offline-mascot {
  height: 120px;
  width: auto;
  margin: 0 auto var(--km-space-lg);
  filter: grayscale(60%) opacity(0.5);
  animation: km-float 6s ease-in-out infinite;
}

.km-stream__offline-title {
  font-family: var(--km-font-display);
  font-size: var(--km-size-2xl);
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--km-text-muted);
  margin-bottom: var(--km-space-sm);
}

.km-stream__offline-sub {
  font-size: var(--km-size-sm);
  color: var(--km-text-dim);
  margin: 0;
}

.km-stream__offline-sub a {
  color: var(--km-gold-bright);
}


/* ── Chat panel ────────────────────────────────────────────── */

.km-stream__chat-panel {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--km-bg-surface);
  border-left: 1px solid var(--km-border-subtle);
  transition: width 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.km-stream__chat-panel.is-hidden {
  width: 0;
  opacity: 0;
  border-left: none;
}

.km-stream__chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem var(--km-space-md);
  border-bottom: 1px solid var(--km-border-subtle);
  background: var(--km-bg-base);
  flex-shrink: 0;
}

.km-stream__chat-label {
  font-size: var(--km-size-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--km-text-muted);
}

.km-stream__chat-popout {
  display: flex;
  align-items: center;
  color: var(--km-text-dim);
  transition: color var(--km-transition);
}
.km-stream__chat-popout:hover {
  color: var(--km-gold-bright);
}
.km-stream__chat-popout svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.km-stream__chat-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
}


/* ════════════════════════════════════════════════════════════
   THEATRE MODE
   ════════════════════════════════════════════════════════════ */

body.km-theatre .km-stream__chat-panel {
  width: 0;
  opacity: 0;
  border-left: none;
  pointer-events: none;
}

body.km-theatre #km-theatre-toggle {
  color: var(--km-gold-mid);
  border-color: var(--km-border-mid);
  background: rgba(138, 91, 24, 0.12);
}


/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .km-stream__chat-panel { width: 300px; }
}

@media (max-width: 768px) {

  body.km-page--stream {
    overflow: auto;
  }

  .km-stream__viewport {
    position: static; /* back to normal flow on mobile — stacked layout */
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    margin-top: 80px; /* approx mobile header height */
  }

  .admin-bar .km-stream__viewport {
    margin-top: calc(80px + 46px);
    top: auto;
  }

  .km-stream__video-panel {
    width: 100%;
    flex: none;
    aspect-ratio: 16 / 9;
  }

  .km-stream__embed-wrap {
    aspect-ratio: 16 / 9;
    position: relative;
    height: auto;
  }

  #km-twitch-embed {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .km-stream__chat-panel {
    width: 100%;
    height: 500px;
    border-left: none;
    border-top: 1px solid var(--km-border-subtle);
  }

  .km-stream__chat-panel.is-hidden {
    height: 0;
    width: 100%;
    opacity: 0;
  }

  body.km-theatre .km-stream__chat-panel {
    width: 100%;
    height: 0;
  }

  .km-stream__controls {
    display: none;
  }

}




