/* Portal page — stream grid + player (brand.css required) */

:root {
  --portal-topbar-h: 4.75rem;
}

.portal-body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.portal-main {
  flex: 1 0 auto;
}

.portal-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(
    180deg,
    rgba(12, 10, 20, 0.92) 0%,
    rgba(12, 10, 20, 0.75) 70%,
    rgba(12, 10, 20, 0) 100%
  );
  pointer-events: none;
}

.portal-topbar .home-link,
.portal-topbar .portal-site-title {
  pointer-events: auto;
}

.portal-topbar .home-link {
  margin-bottom: 0;
}

.portal-site-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.1;
  text-align: right;
  color: var(--surface);
  text-shadow:
    3px 3px 0 var(--accent-deep),
    5px 5px 0 rgba(34, 211, 238, 0.3);
}

.page-wide {
  padding-top: calc(var(--portal-topbar-h) + 1.25rem);
}

.browse-tabs {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  margin: 0.5rem 0 1.25rem;
  padding-top: 0.35rem;
  scroll-margin-top: calc(var(--portal-topbar-h) + 0.5rem);
}

.browse-tab {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  border: 3px solid var(--surface);
  background: rgba(240, 242, 252, 0.08);
  color: var(--surface);
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.15s, background 0.15s;
}

.browse-tab:hover {
  transform: translateY(-1px);
}

.browse-tab.active {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--surface);
}

.tv-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: -0.35rem 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.tv-nav.hidden {
  display: none;
}

.tv-nav-back {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: rgba(240, 242, 252, 0.12);
  color: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}

.tv-nav-back:hover {
  background: var(--accent);
}

.tv-nav-trail {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--surface);
  line-height: 1.3;
}

.card-series .card-body h2,
.card-season .card-body h2 {
  font-size: 1.05rem;
}

.card-sub {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted-card);
}

.badge-episode {
  background: rgba(251, 191, 36, 0.25);
  color: #fde68a;
  border-color: #fbbf24;
}

.muted {
  color: var(--muted-card);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(16px);
  }
}

.card:hover {
  transform: translateY(-8px) rotate(-1deg);
  box-shadow: 0 14px 32px rgba(109, 40, 217, 0.35);
}

.card:nth-child(3n + 1) {
  animation-delay: 0.05s;
}

.card:nth-child(3n + 2) {
  animation-delay: 0.12s;
}

.card:nth-child(3n) {
  animation-delay: 0.19s;
}

.card:nth-child(3n + 2):hover {
  box-shadow: 0 14px 32px rgba(155, 93, 229, 0.4);
}

.card:nth-child(3n):hover {
  box-shadow: 0 14px 32px rgba(34, 211, 238, 0.3);
}

.card:nth-child(3n + 1) .card-body .badge:first-child {
  background: #e8e0ff;
  color: var(--accent-deep);
  border-color: var(--accent);
}

.card:nth-child(3n + 2) .card-body .badge:first-child {
  background: #d4f8ff;
  color: #0e7490;
  border-color: var(--cyan);
}

.card:nth-child(3n) .card-body .badge:first-child {
  background: #ede9fe;
  color: var(--accent-deep);
  border-color: var(--violet);
}

.card-poster {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  overflow: hidden;
  position: relative;
}

.card-poster.poster-portrait {
  aspect-ratio: 2 / 3;
  background: #1a1a24;
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-poster.poster-portrait img {
  object-fit: contain;
  object-position: center center;
}

.card:hover .card-poster img {
  transform: scale(1.02);
}

.card-poster.poster-portrait:hover img {
  transform: scale(1.02);
}

.play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 10, 20, 0.35);
  opacity: 0;
  transition: opacity 0.2s;
}

.play-icon::before {
  content: "▶";
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  font-size: 1.5rem;
  color: var(--surface);
  background: var(--accent);
  border: 4px solid var(--surface);
  border-radius: 50%;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
  transform: scale(0.8);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card:hover .play-icon {
  opacity: 1;
}

.card:hover .play-icon::before {
  transform: scale(1.05);
}

.card-body {
  padding: 1rem 1.15rem 1.2rem;
}

.card-body h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
}

.badge {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #ede8ff;
  color: var(--accent-deep);
  border: 2px solid var(--accent);
}

.card-body p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted-card);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.duration {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text);
  background: #c4b5fd;
  border-radius: 6px;
  border: none;
}

/* Player */
.player-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 20, 0.78);
  z-index: 100;
  backdrop-filter: blur(8px);
}

.player-backdrop.hidden,
.player.hidden {
  display: none;
}

.player {
  position: fixed;
  top: calc(var(--portal-topbar-h) + 0.75rem);
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, calc(100vw - 2rem));
  max-height: calc(100vh - var(--portal-topbar-h) - 1.5rem);
  overflow-y: auto;
  z-index: 101;
  background: var(--surface);
  color: var(--text);
  border: none;
  border-radius: calc(var(--radius) + 4px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
  animation: player-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes player-pop {
  from {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
  }
}

.player-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--text);
  background: var(--accent);
  color: var(--surface);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s;
}

.player-close:hover {
  transform: scale(1.1) rotate(90deg);
  background: var(--cyan);
  color: var(--text);
}

.player-video-wrap {
  background: #000;
  aspect-ratio: 16 / 9;
  border-bottom: none;
}

.player-video-wrap video {
  width: 100%;
  height: 100%;
  display: block;
}

.player-meta {
  padding: 1.35rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-meta h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
}

.player-meta .muted {
  white-space: pre-line;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--surface);
  background: rgba(255, 255, 255, 0.06);
  border: 3px dashed rgba(240, 242, 252, 0.3);
  border-radius: var(--radius);
}

.error {
  color: #a5f3fc;
  font-weight: 700;
}

.portal-footer {
  flex-shrink: 0;
  width: 100%;
  margin-top: auto;
  padding: 1.25rem 1.25rem 1.5rem;
  text-align: center;
  background: rgba(12, 10, 20, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.portal-footer-tagline {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted-card);
  opacity: 0.75;
}

.portal-footer-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.68rem;
  opacity: 0.6;
  color: var(--muted-card);
}

.portal-footer-tmdb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.45rem auto 0;
  max-width: 24rem;
  padding: 0.35rem 0 0;
  font-size: 0.62rem;
  line-height: 1.35;
  color: var(--muted-card);
  opacity: 0.6;
}

.portal-footer-tmdb.hidden {
  display: none;
}

/* Legacy class names kept for JS toggle */
.tmdb-attribution.hidden {
  display: none;
}

.tmdb-logo-link {
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
}

.tmdb-logo {
  display: block;
  width: 62px;
  height: auto;
  opacity: 0.85;
}

.tmdb-attribution-text {
  margin: 0;
}

.tmdb-attribution-text a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tmdb-attribution-text a:hover {
  opacity: 1;
}

.player-cast {
  margin-top: 1.25rem;
}

.player-cast.hidden {
  display: none;
}

.player-cast-heading {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-card);
}

.player-cast-list {
  display: flex;
  gap: 0.65rem;
  margin: 0;
  padding: 0 0 0.5rem;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: thin;
}

.cast-member {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 5.75rem;
  text-align: center;
}

.cast-photo {
  width: 72px;
  height: 72px;
  margin-top: 0.35rem;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 42%;
  background: #2a2438;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.cast-photo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--muted-card);
}

.cast-meta {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-top: 0.35rem;
  min-width: 0;
}

.cast-name {
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 5.75rem;
}

.cast-role {
  font-size: 0.6rem;
  line-height: 1.2;
  color: var(--muted-card);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 5.75rem;
}

.player-tmdb-credit {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0 0;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.62rem;
  line-height: 1.3;
  color: var(--muted-card);
  opacity: 0.55;
  flex-shrink: 0;
}

.player-tmdb-credit.hidden {
  display: none;
}

.player-tmdb-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}


@media (max-width: 600px) {
  .player {
    width: 100vw;
    max-height: 100vh;
    top: 0;
    left: 0;
    transform: none;
    border-radius: 0;
    height: 100%;
    border-width: 0;
    box-shadow: none;
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .player {
    animation: none;
  }

  .card:hover {
    transform: translateY(-4px);
  }
}
