/*
 * Podcast listing and episode detail.
 */

/* ---------- Listing ---------- */

/* In Figma the title box is 112px tall but holds two 62px lines, so the visible gap is 59px, not 71 */
.podcast-page-head {
  --page-head-gap: 59px;
}

.podcast-page-list {
  padding-bottom: 184px;
}

/*
 * Rows are fixed 707px frames in the mockup (a cover plus 307px), 34px apart,
 * whatever the title length; a row only grows when a card needs more.
 */
.podcast-page-grid {
  --podcast-page-col: calc((min(var(--container), 100vw - 2 * var(--margin)) - 2 * var(--gutter)) / 3);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(calc(var(--podcast-page-col) + 307px), auto);
  gap: 34px var(--gutter);
  margin-top: 34px;
}
.podcast-page-grid__item[hidden] {
  display: none;
}
/* The card texts stop at 396.5px in the Home slider; here they span the 400px column */
.podcast-page-grid .podcast-card__meta,
.podcast-page-grid .podcast-card__text {
  max-width: none;
}
/* The link dot is yellow on the Home, coral on this page */
.podcast-page-grid .podcast-card .dot::before {
  background: var(--c-coral);
}

/* ---------- Episode: intro ---------- */

.episode-page {
  padding-bottom: 179px;
}

.episode-hero__inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gutter);
}
.episode-hero__text {
  flex: 0 1 714px;
  min-width: 0;
  padding-top: 87px;
}
.episode-hero__label {
  font-size: var(--fs-label);
  font-weight: 600;
  line-height: 20px;
  text-transform: uppercase;
}
.episode-hero__title {
  margin-top: 32px;
  font-size: var(--fs-display);
  line-height: 1;
}
.episode-hero__lead {
  margin-top: 29px;
  font-size: var(--fs-body-l);
  line-height: 1.2917;
}
/* Square cover, 500px at 1440: starts under the header and runs to the right page edge */
.episode-hero__cover {
  flex: none;
  width: min(34.723vw, 500px);
  aspect-ratio: 1;
  margin-right: calc(-1 * (100vw - 100%) / 2);
  overflow: hidden;
  background: #ddd;
}
.episode-hero__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Episode: listen ---------- */

.episode-listen {
  margin-top: 75px;
}
/* Fixed 185px frame in the mockup: the player keeps its place under short descriptions */
.episode-listen .section-head__row {
  min-height: 185px;
}
.episode-listen__player {
  margin-top: 34px;
}

/* ---------- Audio player ---------- */

/* 779px in Figma; 780 keeps the centred box on whole pixels */
.player-audio {
  display: flex;
  align-items: flex-start;
  gap: 31px;
  max-width: 780px;
  margin-inline: auto;
  padding: 28px 20px 28px 0;
  border-block: 1px solid var(--c-black);
}

.player-audio__toggle {
  position: relative;
  flex: none;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  background: var(--c-coral);
  color: var(--c-white);
  transition: transform 0.3s var(--ease);
}
.player-audio__toggle:not(:disabled):hover {
  transform: scale(1.06);
}
.player-audio__icon {
  position: absolute;
  top: 26px;
  left: 32px;
}
.player-audio__icon--pause {
  left: 29px;
  display: none;
}
.player-audio.is-playing .player-audio__icon--play {
  display: none;
}
.player-audio.is-playing .player-audio__icon--pause {
  display: block;
}

.player-audio__body {
  flex: 1;
  min-width: 0;
}
.player-audio__heading {
  display: flex;
  align-items: baseline;
  gap: 17px;
  height: 36px;
}
.player-audio__episode {
  flex: none;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  text-transform: uppercase;
}
.player-audio__title {
  overflow: hidden;
  font-size: var(--fs-body-l);
  line-height: 36px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
 * Native range input drawn as a 3px line; the filled part follows --player-progress (set by podcast.js).
 * The box is 19px tall so there are 8px to grab above and below the line.
 */
.player-audio__seek {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 19px;
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: linear-gradient(90deg, var(--c-black) var(--player-progress, 0%), #bbb var(--player-progress, 0%)) center / 100% 3px no-repeat;
  opacity: 1;
  cursor: pointer;
  /* horizontal drags scrub, vertical ones still scroll the page */
  touch-action: pan-y;
}
.player-audio__seek::-webkit-slider-runnable-track {
  height: 19px;
  background: none;
}
.player-audio__seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 0;
  height: 0;
}
.player-audio__seek::-moz-range-track {
  height: 19px;
  background: none;
}
.player-audio__seek::-moz-range-thumb {
  width: 0;
  height: 0;
  border: 0;
  background: none;
}
.player-audio__seek:not(:disabled):hover {
  background-size: 100% 5px;
}
/* The default 3px offset would run into the times below */
.player-audio__seek:focus-visible {
  outline-offset: 0;
}
.player-audio__toggle:disabled,
.player-audio__seek:disabled {
  cursor: default;
}

.player-audio__times {
  display: flex;
  justify-content: space-between;
  height: 17px;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
}

/* ---------- Episode: next episode panel ---------- */

.episode-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 390px;
  margin-top: 115px;
  padding: 80px 32px;
  background: var(--c-sky-tint);
}
.episode-next__label {
  width: 100%;
  max-width: 1024px;
  font-size: var(--fs-meta);
  font-weight: 500;
  line-height: 20px;
  text-transform: uppercase;
}
.episode-next__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 1040px;
}
.episode-next__title {
  font-size: var(--fs-h2);
  line-height: 1.6522;
}
/* The arrow sits 3.5px above the middle of the title line and 5px in from the row end */
.episode-next__arrow {
  flex: none;
  margin: -7px 5px 0 0;
  transition: transform 0.3s var(--ease);
}
.episode-next:hover .episode-next__arrow {
  transform: translateX(8px);
}

/* ---------- Provisional small-screen rules (no mobile mockup yet) ---------- */

@media (max-width: 1000px) {
  .podcast-page-list {
    padding-bottom: 100px;
  }
  .podcast-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
    row-gap: 56px;
  }

  .episode-page {
    padding-bottom: 80px;
  }
  .episode-hero__inner {
    flex-direction: column-reverse;
    gap: 40px;
  }
  .episode-hero__text {
    flex: none;
    padding-top: 0;
  }
  .episode-hero__cover {
    width: 100%;
    margin-right: 0;
  }
  .episode-listen .section-head__row {
    min-height: 0;
  }
  .episode-next {
    min-height: 300px;
    margin-top: 80px;
    padding: 48px 32px;
  }
  .episode-next__title {
    line-height: 1.2;
  }
}

@media (max-width: 760px) {
  .podcast-page-grid {
    grid-template-columns: 1fr;
  }

  .episode-hero__title {
    margin-top: 20px;
  }
  .episode-hero__lead {
    margin-top: 20px;
  }
  .episode-listen {
    margin-top: 56px;
  }
  .player-audio {
    gap: 16px;
    padding-right: 0;
  }
  .episode-next {
    min-height: 240px;
    padding: 32px 24px;
  }
  .episode-next__arrow {
    width: 36px;
    height: auto;
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player-audio__toggle,
  .episode-next__arrow {
    transition: none;
  }
}
