/* css/episodes.css */

/* Main container for the episodes page */
.episodes-page {
  padding: 4rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* Responsive grid of episode tiles */
.episodes-grid {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2rem;
  justify-items: center;
}

/* Square cards */
.episode-card {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0,0,0,0.35);
  cursor: pointer;
}

/* Episode artwork thumbnail */
.episode-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

/* Hover interactions for devices with pointers */
@media (hover: hover) {
  .episode-card:hover img {
    transform: scale(1.05);
  }
}

/* Dark overlay that reveals the episode button */
.episode-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,10,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* Button shown in the overlay */
.episode-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  background: var(--bold);
  color: var(--accent);
  font-family: var(--font-main);
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 6px;
  border: 0;
}

@media (hover: hover) {
  .episode-card:hover .episode-overlay {
    opacity: 1;
  }
}

/* Maintain overlay when card is programmatically activated */
.episode-card.active .episode-overlay {
  opacity: 1;
}

/* ===== Modal ===== */
/* Modal root for SoundCloud player */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;    
  justify-content: center;
  padding: 1rem;    
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

/* Wrapper around iframe to allow overlay */
.player-modal__iframe-wrapper {
  position: relative;
  width: 100%;
  height: 166px;
}

/* The iframe itself */
.player-modal__iframe-wrapper iframe {
  width: 100%;
  height: 166px;
  border: none;
  filter: blur(4px) brightness(0.5); /* blurred & dark while loading */
  transition: filter 0.6s ease;
}

/* Remove blur once content is ready */
.player-modal__iframe-wrapper iframe.is-ready {
  filter: none;
}

/* Loader overlay covers the iframe */
.player-modal__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.7); /* dark overlay */
  transition: opacity 0.6s ease;
  z-index: 2;
}

/* Spinner asset sizing */
.player-modal__loading img {
  width: 170px;
  height: 170px;
  object-fit: contain;
}

/* Fade out when hidden */
.player-modal__loading.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Reveal the modal when toggled */
.player-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* Dimmed background behind the modal */
.player-modal__backdrop {
  position: fixed;      
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5,5,5,0.65);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 220ms ease;
}

/* Fade the backdrop in once the modal opens */
.player-modal.is-open .player-modal__backdrop {
  opacity: 1;
}

/* Modal card layout containing artwork + copy */
.player-modal__card {
  position: relative;
  z-index: 1;
  max-width: 860px;
  max-height: 75vh;
  width: min(92vw, 860px);
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.25rem;
  background: rgba(18,18,18,0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  padding: 1.25rem;
  overflow-y: auto;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform 260ms ease, opacity 260ms ease;
}

/* Animate card into view */
.player-modal.is-open .player-modal__card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Artwork wrapper inside the modal */
.player-modal__media {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(0,0,0,0.35);
  align-self: start;
}

/* Modal artwork */
.player-modal__media img {
  width: 100%;
  display: block;
  aspect-ratio: 1/1;
  object-fit: cover;
}

/* Modal episode title */
.player-modal__content h3 {
  margin: 0 0 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
}

/* Modal description text */
.player-modal__desc {
  margin-top: 1rem;
  color: var(--foreground);
  line-height: 1.5;
}

/* Section heading for each season */
.season-heading {
  font-size: 2rem;
  margin: 2rem auto 1rem;
  color: var(--text-light);
  font-family: 'Orbitron', sans-serif;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 0.5rem;
  text-align: center;
  max-width: max-content;
}

/* Extra gap below the floating season nav */
.episodes-nav {
  margin-bottom: 2rem;
}

/* Responsive adjustments for mobile */
@media (max-width: 800px) {
  .player-modal__card {
    grid-template-columns: 1fr;
    gap: 1rem;
    width: min(94vw, 640px);
  }
  .episode-overlay {
    opacity: 1 !important; /* always visible */
    background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0)); /* fade at bottom */
    align-items: flex-end; /* push text to bottom */
    justify-content: center;
    padding: 0.5rem;
  }

  .episode-button {
    background: transparent;
    color: var(--accent);
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    pointer-events: none; /* so taps still open card instead of button */
  }
}
