/* ISM TV — immersive cinema viewer */

.ism-tv-body {
  margin: 0;
  height: 100vh;
  height: 100svh;
  background: radial-gradient(ellipse at 50% 0%, #1a1a2e 0%, #0a0a0f 55%, #050508 100%);
  color: #f1f5f9;
  overflow: hidden;
}

html:has(.ism-tv-body) {
  height: 100%;
}

@media (max-width: 1024px) {
  html:has(.ism-tv-body),
  .ism-tv-body {
    height: var(--ism-tv-visible-height, 100svh);
    max-height: var(--ism-tv-visible-height, 100svh);
  }
}

.ism-tv-page {
  height: var(--ism-tv-visible-height, 100svh);
  min-height: 0;
  max-height: var(--ism-tv-visible-height, 100svh);
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow: hidden;
}

.ism-tv-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 100;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: rgba(10, 10, 15, 0.75);
  color: #e2e8f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.15s;
}

.ism-tv-close:hover {
  background: rgba(30, 30, 45, 0.9);
  transform: scale(1.05);
}

.ism-tv-stage {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding-top: 48px;
  min-height: 0;
  overflow: hidden;
}

.ism-tv-frame-slot {
  min-width: 0;
  width: 100%;
}

.ism-tv-side-panel-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ism-tv-side-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0 0 calc(64px + env(safe-area-inset-bottom, 0px) + var(--ism-tv-bottom-inset, 0px));
}

.ism-tv-mode-fab {
  position: relative;
  z-index: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  padding: 8px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #f8fafc;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.15s;
}

.ism-tv-fab-row {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: var(
    --ism-tv-fab-bottom,
    max(12px, calc(12px + env(safe-area-inset-bottom, 0px)))
  );
  z-index: 95;
  display: inline-flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
}

.ism-tv-mode-fab:hover {
  background: rgba(30, 41, 59, 0.96);
  transform: translateY(-1px);
}

.ism-tv-mode-fab__label {
  text-align: center;
  white-space: normal;
  word-break: break-word;
  max-width: 100%;
}

.ism-tv-mode-fab__icon {
  font-size: 1rem;
  line-height: 1;
}

.ism-tv-frame {
  width: 100%;
}

.ism-tv-frame__bezel {
  position: relative;
  background: linear-gradient(145deg, #2a2a35 0%, #15151c 40%, #0d0d12 100%);
  border-radius: 20px;
  padding: 14px 14px 52px;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.06),
    0 24px 60px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ism-tv-screen-area {
  position: relative;
  width: 100%;
  overflow: visible;
}

.ism-tv-frame__brand--overlay {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 9;
  pointer-events: none;
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.ism-tv-frame__logo {
  display: block;
  height: 30px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.ism-tv-screen-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
}

.ism-tv-screen,
.ism-tv-screen iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.ism-tv-empty,
.ism-tv-error,
.ism-tv-video-loader {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: linear-gradient(180deg, #111118 0%, #08080c 100%);
}

.ism-tv-video-loader {
  z-index: 12;
  gap: 14px;
}

.ism-tv-video-loader__spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(148, 163, 184, 0.25);
  border-top-color: #e2e8f0;
  border-radius: 50%;
  animation: ism-tv-spin 0.85s linear infinite;
}

.ism-tv-video-loader__text {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

@keyframes ism-tv-spin {
  to {
    transform: rotate(360deg);
  }
}

.ism-tv-empty__icon {
  font-size: 2.5rem;
  color: #475569;
  margin-bottom: 12px;
}

.ism-tv-empty__title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  color: #cbd5e1;
}

.ism-tv-empty__text {
  margin: 0;
  color: #64748b;
  max-width: 320px;
}

.ism-tv-error {
  color: #fca5a5;
  font-size: 0.95rem;
}

.ism-tv-play-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  border: 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ism-tv-play-overlay:hover {
  background: rgba(0, 0, 0, 0.55);
}

.ism-tv-screen-btn {
  position: absolute;
  bottom: 12px;
  z-index: 9;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #f1f5f9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  transition: background 0.2s, transform 0.15s;
}

.ism-tv-screen-btn:hover {
  background: rgba(30, 30, 45, 0.85);
  transform: scale(1.05);
}

.ism-tv-pip-btn {
  right: 56px;
}

.ism-tv-fullscreen-btn {
  right: 12px;
}

.ism-tv-screen-wrap--pip-placeholder {
  background: #0a0a0f;
  border-radius: 8px;
  min-height: 120px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.8);
}

.ism-tv-screen-wrap.ism-tv-screen-wrap--in-pip {
  width: 100%;
  height: 100%;
  max-height: 100vh;
  aspect-ratio: unset;
  border-radius: 0;
}

/* Program lists (upcoming + past) */
.ism-tv-programs,
.ism-tv-upcoming {
  min-height: 100%;
  box-sizing: border-box;
  background: rgba(15, 15, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 16px 16px;
  backdrop-filter: blur(8px);
}

.ism-tv-programs__title,
.ism-tv-upcoming__title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #e2e8f0;
}

.ism-tv-programs__list,
.ism-tv-upcoming__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ism-tv-programs__item,
.ism-tv-upcoming__item {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ism-tv-programs__item--loading,
.ism-tv-upcoming__item--loading {
  justify-content: center;
  color: #94a3b8;
  font-size: 0.85rem;
}

.ism-tv-programs__main {
  flex: 1 1 auto;
  min-width: 0;
}

.ism-tv-programs__name,
.ism-tv-upcoming__name {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: #f1f5f9;
  line-height: 1.35;
  word-break: break-word;
}

.ism-tv-programs__time,
.ism-tv-upcoming__time {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: #94a3b8;
}

.ism-tv-programs__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ism-tv-programs__action-btn {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #e2e8f0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.ism-tv-programs__action-btn:hover {
  background: rgba(37, 99, 235, 0.35);
  transform: scale(1.05);
}

.ism-tv-programs__action-btn--share:hover {
  background: rgba(22, 163, 74, 0.35);
}

.ism-tv-programs__empty,
.ism-tv-upcoming__empty {
  margin: 0;
  font-size: 0.85rem;
  color: #64748b;
  text-align: center;
  padding: 8px 0 4px;
}

:fullscreen .ism-tv-side-panel-wrap,
:fullscreen .ism-tv-side-panel,
:fullscreen .ism-tv-upcoming,
:fullscreen .ism-tv-programs,
:-webkit-full-screen .ism-tv-side-panel-wrap,
:-webkit-full-screen .ism-tv-side-panel,
:-webkit-full-screen .ism-tv-upcoming,
:-webkit-full-screen .ism-tv-programs {
  display: none !important;
}

:fullscreen .ism-tv-fab-row,
:-webkit-full-screen .ism-tv-fab-row {
  display: none !important;
}

.ism-tv-frame__clock {
  position: absolute;
  left: 22px;
  bottom: 16px;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.ism-tv-info {
  position: absolute;
  right: 22px;
  bottom: 14px;
  max-width: min(55%, 360px);
  text-align: right;
}

.ism-tv-info__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* Upcoming programs (hidden in fullscreen) — legacy aliases above */

/* Native fullscreen on the TV frame element (mobile-safe) */
.ism-tv-frame:fullscreen,
.ism-tv-frame:-webkit-full-screen {
  width: 100%;
  height: 100%;
  max-width: none;
  background: #0a0a0f;
  box-sizing: border-box;
}

.ism-tv-frame:fullscreen .ism-tv-frame__bezel,
.ism-tv-frame:-webkit-full-screen .ism-tv-frame__bezel {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  padding: 8px 8px max(44px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.ism-tv-frame:fullscreen .ism-tv-screen-area,
.ism-tv-frame:-webkit-full-screen .ism-tv-screen-area {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ism-tv-frame:fullscreen .ism-tv-screen-wrap,
.ism-tv-frame:-webkit-full-screen .ism-tv-screen-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  max-height: none;
  aspect-ratio: unset;
}

.ism-tv-frame:fullscreen .ism-tv-screen,
.ism-tv-frame:fullscreen .ism-tv-screen iframe,
.ism-tv-frame:-webkit-full-screen .ism-tv-screen,
.ism-tv-frame:-webkit-full-screen .ism-tv-screen iframe {
  width: 100% !important;
  height: 100% !important;
}

/* CSS fullscreen fallback when Fullscreen API fails on mobile */
body.ism-tv-css-fullscreen {
  overflow: hidden;
}

body.ism-tv-css-fullscreen .ism-tv-page {
  position: fixed;
  inset: 0;
  z-index: 9990;
  padding: 0;
  min-height: 100dvh;
  height: 100dvh;
  background: #0a0a0f;
}

body.ism-tv-css-fullscreen .ism-tv-side-panel-wrap,
body.ism-tv-css-fullscreen .ism-tv-side-panel,
body.ism-tv-css-fullscreen .ism-tv-upcoming,
body.ism-tv-css-fullscreen .ism-tv-programs {
  display: none !important;
}

body.ism-tv-css-fullscreen .ism-tv-fab-row {
  display: none !important;
}

body.ism-tv-css-fullscreen .ism-tv-stage {
  padding-top: 0;
  max-width: none;
  height: 100%;
}

body.ism-tv-css-fullscreen .ism-tv-frame,
body.ism-tv-css-fullscreen .ism-tv-frame__bezel {
  height: 100%;
  min-height: 0;
  border-radius: 0;
}

body.ism-tv-css-fullscreen .ism-tv-frame__bezel {
  display: flex;
  flex-direction: column;
  padding: 8px 8px max(44px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

body.ism-tv-css-fullscreen .ism-tv-screen-area {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body.ism-tv-css-fullscreen .ism-tv-screen-wrap {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  aspect-ratio: unset;
  height: auto;
}

.hidden {
  display: none !important;
}

/* Mobile / tablet immersive landscape */
@media (max-width: 1024px) {
  .ism-tv-body.ism-tv-immersive,
  .ism-tv-body.ism-tv-immersive .ism-tv-page {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .ism-tv-body.ism-tv-immersive .ism-tv-page {
    padding: 0;
  }

  .ism-tv-body.ism-tv-immersive .ism-tv-stage {
    padding-top: 0;
    max-width: none;
    height: 100%;
    justify-content: center;
  }

  .ism-tv-body.ism-tv-immersive .ism-tv-frame__bezel {
    border-radius: 0;
    padding: 8px 8px 44px;
    min-height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .ism-tv-body.ism-tv-immersive .ism-tv-screen-area {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .ism-tv-body.ism-tv-immersive .ism-tv-screen-wrap {
    flex: 1;
    width: 100%;
    max-height: calc(100dvh - 52px);
    aspect-ratio: auto;
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  .ism-tv-page {
    padding: 4px;
  }

  .ism-tv-stage {
    padding-top: 36px;
  }

  .ism-tv-frame__bezel {
    padding: 8px 8px 40px;
    border-radius: 12px;
  }
}

@media (max-width: 640px) {
  .ism-tv-stage {
    padding-top: 40px;
    gap: 10px;
  }

  .ism-tv-side-panel {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + var(--ism-tv-bottom-inset, 0px));
  }

  .ism-tv-mode-fab {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    padding: 7px 5px;
    font-size: 0.58rem;
  }

  .ism-tv-mode-fab__icon {
    font-size: 0.95rem;
  }

  .ism-tv-frame__bezel {
    padding: 10px 10px 48px;
    border-radius: 14px;
  }

  .ism-tv-frame__brand--overlay {
    left: 8px;
    bottom: 8px;
    padding: 4px 7px;
  }

  .ism-tv-frame__logo {
    height: 24px;
    max-width: 88px;
  }

  .ism-tv-info {
    max-width: 50%;
  }

  .ism-tv-info__title {
    font-size: 0.78rem;
  }

  .ism-tv-frame__clock {
    font-size: 0.72rem;
    left: 14px;
  }
}

/* Legacy document-level fullscreen rules removed — frame element is fullscreen target */
