﻿:root {
  --episodes-bg: #000000;
  --episodes-text: #f8fafc;
  --episodes-muted: rgba(248, 250, 252, 0.76);
  --episodes-border: rgba(255, 255, 255, 0.08);
  --episodes-accent: #E30613;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--episodes-bg);
  color: var(--episodes-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body[data-page="episodios.html"] {
  background: #000 !important;
  overflow: hidden;
  height: 100vh;
}

body[data-page="episodios.html"] #site-header {
  position: absolute !important;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
}

body[data-page="episodios.html"] .topbar,
body[data-page="episodios.html"] .navbar.topbar {
  background: rgba(8, 8, 10, 0.18) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
  box-shadow: none !important;
}

body[data-page="episodios.html"] main {
  min-height: 100vh;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.preview-section {
  position: relative;
  min-height: 92vh;
  height: calc(100vh - 8px);
  overflow: hidden;
  background: #000;
}

.preview-bg {
  opacity: 1;
  transition: opacity 0.22s ease;
  position: absolute;
  inset: 0;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.08);
  transform-origin: center center;
  filter: brightness(0.42);
}

.preview-section::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.14) 40%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 1;
}

.preview-section::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28vh;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.88) 72%, #000 100%);
  pointer-events: none;
  z-index: 3;
}

.preview-player-shell,
#preview-player-passive,
#preview-player-active {
  position: absolute;
  inset: 0;
}

#preview-player-passive,
#preview-player-active {
  z-index: 0;
  opacity: 0;
  transition: opacity 0.32s ease;
}

#preview-player-passive iframe,
#preview-player-active iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(100vw + 6px);
  height: calc(56.25vw + 6px);
  min-width: calc(177.78vh + 6px);
  min-height: calc(100vh + 14px);
  border: 0;
  background: #000;
  transform: translate(-50%, -50%) scale(1.12);
  transform-origin: center center;
  backface-visibility: hidden;
  will-change: transform;
}

.passive-preview-frame,
.passive-preview-frame.is-current,
#preview-player-passive > div,
#preview-player-active > iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-player-shell {
  overflow: hidden;
}

.preview-section.is-live-preview-ready .preview-bg,
.preview-section.is-playing .preview-bg {
  opacity: 0;
}


.preview-section.is-live-preview-ready #preview-player-passive,
.preview-section.is-playing #preview-player-active {
  z-index: 2;
  opacity: 1;
}

.preview-section.is-live-preview-ready #preview-player-passive iframe,
.preview-section.is-playing #preview-player-active iframe {
  display: block;
}


.preview-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.preview-section.is-loading .preview-loading,
.preview-section.is-passive-loading .preview-loading {
  opacity: 1;
  visibility: visible;
}

.preview-loading-ring {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: #ffffff;
  animation: preview-spin 0.8s linear infinite;
}

@keyframes preview-spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-fallback {
  position: absolute;
  left: 24px;
  bottom: 210px;
  z-index: 6;
  display: none;
  width: min(360px, calc(100% - 48px));
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(8, 8, 10, 0.76);
  border: 1px solid var(--episodes-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.preview-section.show-fallback .preview-fallback {
  display: block;
}

.preview-fallback-title {
  margin: 0 0 10px;
  color: #ffffff;
  font-size: 0.98rem;
  line-height: 1.45;
}

.preview-fallback-link {
  color: #ffffff;
  font-weight: 700;
  text-decoration: none;
}

.preview-fallback-link:hover {
  text-decoration: underline;
}

.preview-content {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: calc(var(--header-offset, 92px) + 28px) 32px 250px;
}

.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preview-meta-left {
  max-width: 350px;
}

.preview-meta-right {
  align-items: flex-end;
  text-align: right;
}

.preview-meta-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-meta-label {
  color: var(--episodes-muted);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.preview-meta-value {
  margin: 0;
  color: #ffffff;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.44);
}

.preview-guests {
  font-size: clamp(2rem, 3.2vw, 3.1rem);
  line-height: 0.98;
  font-weight: 800;
}

.preview-duration,
.preview-episode-number {
  font-size: clamp(1.3rem, 2vw, 2.15rem);
  font-weight: 800;
}

.video-player {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: calc(var(--header-offset, 92px) + 12px) 16px 24px;
  background: rgba(0, 0, 0, 0.96);
  z-index: 80;
}

.video-player iframe {
  width: min(1180px, 92vw);
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  border-radius: 18px;
  background: #000;
}

.close-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--episodes-accent);
  color: #ffffff;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
}

.episodes-library {
  position: relative;
  background: transparent;
  margin-top: -336px;
  padding: 56px 0 140px;
  transition: margin-top 0.32s ease, padding-top 0.32s ease;
  z-index: 5;
}

.preview-section.is-playing + .episodes-library {
  margin-top: 28px;
  padding-top: 52px;
}

.episodes-library-inner {
  width: min(1360px, calc(100% - 120px));
  margin: 0 auto;
}

.episodes-tunnel {
  position: relative;
  height: min(82vh, 900px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 2px 140px;
  touch-action: pan-y;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
  mask-image: none;
  -webkit-mask-image: none;
}

.episodes-tunnel::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(230px, 320px));
  justify-content: center;
  gap: 20px;
  align-content: start;
  padding: 0 0 170px;
}

.episodes-grid > .library-episode:last-child:nth-child(3n + 1) {
  grid-column: 2;
}

.episodes-library.is-compact .episodes-tunnel {
  height: auto !important;
  overflow: visible;
  padding: 0;
}

.episodes-library.is-compact .episodes-grid {
  padding: 0;
}

.library-episode {
  background: transparent;
}

.episode-media {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.episode-media img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.episode-link-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.episode-youtube-only .episode-media::after {
  content: "Abrir no YouTube";
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(227, 6, 19, 0.88);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.episodes-empty {
  grid-column: 1 / -1;
  color: #cbd5e1;
  text-align: center;
  padding: 28px 0;
}

@media (max-width: 1100px) {
  .episodes-library-inner {
    width: min(1120px, calc(100% - 64px));
  }

  .episodes-grid {
    grid-template-columns: repeat(3, minmax(205px, 270px));
  }
}

@media (max-width: 700px) {
  body[data-page="episodios.html"] {
    overflow: auto;
    height: auto;
  }

  body[data-page="episodios.html"] main {
    height: auto;
    overflow: visible;
  }

  .preview-section {
    min-height: 100vh;
    height: auto;
  }

  .preview-content {
    width: 100%;
    padding: calc(var(--header-offset, 92px) + 14px) 8px 20px;
    min-height: calc(100vh - var(--header-offset, 92px) - 180px);
    gap: 18px;
    align-items: flex-end;
  }

  .preview-meta-left {
    max-width: 210px;
  }

  .preview-meta-label {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
  }

  .preview-guests {
    font-size: 1rem;
  }

  .preview-duration,
  .preview-episode-number {
    font-size: 0.92rem;
  }

  .episodes-library {
    margin-top: -180px;
    padding-top: 70px;
  }

  .episodes-library-inner {
    width: calc(100% - 18px);
  }

  .episodes-tunnel {
    height: min(64vh, 540px);
  }

  .episodes-grid {
    grid-template-columns: repeat(2, minmax(146px, 1fr));
    gap: 12px;
    padding-bottom: 32px;
  }

  .episodes-grid > .library-episode:last-child:nth-child(3n + 1) {
    grid-column: auto;
  }

  .preview-fallback {
    left: 12px;
    right: 12px;
    bottom: 210px;
    width: auto;
  }
}

@media (max-width: 420px) {
  .episodes-library-inner {
    width: calc(100% - 14px);
  }

  .episodes-tunnel {
    height: min(60vh, 460px);
    padding-bottom: 16px;
  }

  .episodes-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-content {
    gap: 12px;
  }

  .preview-guests {
    font-size: 0.92rem;
    max-width: 10ch;
  }

  .preview-duration,
  .preview-episode-number {
    font-size: 0.84rem;
  }
}


.preview-section:not(.is-playing) #preview-player-passive,
.preview-section:not(.is-playing) #preview-player-passive *,
.preview-section:not(.is-playing) #preview-player-passive iframe {
  pointer-events: none !important;
}
#preview-player-active {
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  padding: calc(var(--header-offset, 92px) + 6px) 16px 10px;
  pointer-events: none;
}

#preview-player-active iframe {
  position: relative;
  inset: auto;
  display: block;
  width: min(1440px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - var(--header-offset, 92px) - 18px);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 18px;
  background: #000;
  transform: none;
  box-shadow: 0 26px 90px rgba(0, 0, 0, 0.52);
  pointer-events: auto;
}

.preview-section.is-playing #preview-player-active {
  display: flex;
}

.preview-section.is-playing .preview-content {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preview-section.is-playing::before,
.preview-section.is-playing::after {
  opacity: 0;
}

.preview-section.is-playing {
  min-height: 100vh;
  height: 100vh;
}















body[data-page="episodios.html"].episode-playing {
  overflow: auto;
  height: auto;
}

body[data-page="episodios.html"].episode-playing main {
  min-height: 100vh;
  height: auto;
  overflow: visible;
}

body[data-page="episodios.html"].episode-playing .preview-section {
  min-height: 100vh;
  height: 100vh;
}

body[data-page="episodios.html"].episode-playing .episodes-library {
  margin-top: 0;
  padding-top: 34px;
}

body[data-page="episodios.html"].episode-playing .episodes-tunnel {
  height: auto;
  max-height: none;
  overflow: visible;
  padding-bottom: 160px;
}


/* ------------------------------------------------------------------
   Telemóvel e tablet ao alto: o vídeo da pré-visualização (16:9) era
   esticado para encher o ecrã todo em altura e só se via uma faixa do
   meio, com o título por cima numa coluna estreita. Aqui o vídeo
   aparece inteiro numa caixa 16:9 logo abaixo do cabeçalho, com o
   título, a duração e o número do episódio por baixo, e a lista de
   episódios segue a seguir na própria página.
   ------------------------------------------------------------------ */
@media (max-width: 700px), (max-width: 1100px) and (orientation: portrait) {
  body[data-page="episodios.html"],
  body[data-page="episodios.html"].episode-playing {
    overflow: auto;
    height: auto;
  }

  body[data-page="episodios.html"] main,
  body[data-page="episodios.html"].episode-playing main {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .preview-section,
  .preview-section.is-playing,
  body[data-page="episodios.html"].episode-playing .preview-section {
    height: auto;
    min-height: 0;
    padding-top: var(--episodes-header-height, 110px);
  }

  .preview-section::before,
  .preview-section::after {
    display: none;
  }

  .preview-bg,
  .preview-player-shell {
    top: var(--episodes-header-height, 110px);
    bottom: auto;
    height: 56.25vw;
  }

  .preview-bg {
    transform: none;
    filter: brightness(0.7);
  }

  #preview-player-passive iframe {
    width: calc(100vw + 4px);
    height: calc(56.25vw + 4px);
    min-width: 0;
    min-height: 0;
    transform: translate(-50%, -50%) scale(1.02);
  }

  #preview-player-active {
    padding: 0;
  }

  #preview-player-active iframe {
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }

  .preview-fallback {
    bottom: 12px;
  }

  .preview-content,
  .preview-section.is-playing .preview-content {
    margin-top: 56.25vw;
    min-height: 0;
    padding: 16px 16px 4px;
    align-items: flex-start;
    gap: 16px;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .preview-meta-left {
    flex: 1;
    max-width: none;
    gap: 8px;
  }

  .preview-guests {
    max-width: none;
    font-size: clamp(1.05rem, 4.4vw, 1.9rem);
    line-height: 1.18;
  }

  .preview-meta-right {
    flex-shrink: 0;
    gap: 8px;
  }

  .preview-meta-block {
    gap: 2px;
  }

  .preview-meta-label {
    font-size: clamp(0.62rem, 1.8vw, 0.8rem);
  }

  .preview-duration,
  .preview-episode-number {
    font-size: clamp(0.9rem, 2.8vw, 1.3rem);
  }

  .episodes-library,
  .preview-section.is-playing + .episodes-library,
  body[data-page="episodios.html"].episode-playing .episodes-library {
    margin-top: 0;
    padding-top: 20px;
    padding-bottom: 60px;
  }

  .episodes-library .episodes-tunnel,
  body[data-page="episodios.html"].episode-playing .episodes-tunnel {
    height: auto !important;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  .episodes-grid,
  .episodes-library.is-compact .episodes-grid {
    padding-bottom: 0;
  }
}

@media (min-width: 701px) and (max-width: 1100px) and (orientation: portrait) {
  .episodes-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .episodes-grid > .library-episode:last-child:nth-child(3n + 1) {
    grid-column: auto;
  }
}
