/* Episode page (/episode/{code}, rendered by functions/episode/[ref].js) */

.episode-main {
  padding: calc(var(--header-h) + 56px) 0 0;
  background: var(--creamish);
}

.episode-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  gap: 64px;
  align-items: start;
  padding-bottom: 88px;
}

.episode-art {
  position: sticky;
  top: calc(var(--header-h) + 32px);
  border-radius: 20px;
  overflow: hidden;
  aspect-ratio: 1080 / 608;
  background: var(--onboarding);
  box-shadow: 0 24px 48px -28px rgba(42, 35, 32, 0.45);
}

.episode-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.episode-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-bottom: 18px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--mute);
}

/* The category pill of the app's and the site's episode cards */
.episode-category {
  border-radius: 12px;
  padding: 4px 12px;
  background: var(--orangish);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.episode-title {
  font-family: var(--episode);
  letter-spacing: -0.01em;
}

.episode-hook {
  display: block;
  font-size: clamp(2.3rem, 4.4vw, 3.5rem);
  line-height: 1.06;
  font-weight: 700;
}

.episode-rest {
  display: block;
  margin-top: 14px;
  font-size: clamp(1.2rem, 1.9vw, 1.5rem);
  line-height: 1.32;
  font-weight: 500;
  color: rgba(62, 57, 53, 0.8);
  letter-spacing: 0;
}

.episode-subtitle {
  margin-top: 20px;
  max-width: 46ch;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--mute);
}

/* The opening's player */
.preview {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 32px;
  padding: 16px 22px 16px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 28px -18px rgba(42, 35, 32, 0.4);
}

.preview-button {
  flex-shrink: 0;
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--orangish);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    transform 0.22s var(--ease),
    background-color 0.22s var(--ease);
}

.preview-button svg {
  grid-area: 1 / 1;
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition:
    opacity 0.18s var(--ease),
    transform 0.18s var(--ease);
}

.preview-button .icon-pause,
.preview.is-playing .icon-play {
  opacity: 0;
  transform: scale(0.7);
}

.preview.is-playing .icon-pause {
  opacity: 1;
  transform: none;
}

/* Waiting for audio: the button breathes */
.preview.is-loading .preview-button {
  animation: preview-wait 1.1s var(--ease) infinite alternate;
}

@keyframes preview-wait {
  to {
    background-color: #d9773f;
    transform: scale(0.94);
  }
}

@media (hover: hover) {
  .preview-button:hover {
    transform: scale(1.04);
  }
}

.preview-button:active {
  transform: scale(0.96);
}

.preview-button:focus-visible,
.preview-track:focus-visible {
  outline: 2px solid var(--orangish);
  outline-offset: 3px;
}

.preview-button:disabled {
  background: var(--line);
  cursor: default;
  animation: none;
}

.preview-body {
  flex: 1;
  min-width: 0;
}

.preview-label {
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--grayish);
}

.preview-track {
  position: relative;
  margin-top: 10px;
  height: 6px;
  border-radius: 3px;
  background: rgba(62, 57, 53, 0.12);
  cursor: pointer;
  touch-action: none;
}

/* A taller invisible hit area, so the bar is easy to catch on a phone */
.preview-track::before {
  content: "";
  position: absolute;
  inset: -12px 0;
}

.preview-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--orangish);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s linear;
}

.preview.is-seeking .preview-fill {
  transition: none;
}

.preview-time {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--mute);
}

.preview.is-unavailable .preview-track,
.preview.is-unavailable .preview-time {
  opacity: 0.4;
}

.episode-meta {
  margin-top: 22px;
  font-size: 0.92rem;
  color: var(--mute);
}

.episode-free {
  display: block;
  margin-top: 4px;
  font-weight: 600;
  color: var(--grayish);
}

.episode-cta {
  margin-top: 28px;
}

/* The page shows store buttons only once the server says the app is live
   (STORES_LIVE), whatever the rest of the site's pre-launch state */
.prelaunch .episode-cta .store-row {
  display: flex;
}

.episode-cta .waitlist-row {
  display: block;
  max-width: 440px;
}

.episode-cta .waitlist-kicker {
  color: var(--grayish);
}

.episode-ios-note {
  margin-top: 14px;
  max-width: 44ch;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--mute);
}

/* About the episode: what it covers beside (phones: above) the opening */
.episode-read {
  padding: 64px 0 80px;
  background: var(--surface);
}

.episode-read-inner.has-contents {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 680px);
  gap: 64px;
  align-items: start;
}

.episode-read-inner:not(.has-contents) .episode-opening-block {
  max-width: 680px;
}

.episode-contents-block {
  position: sticky;
  top: calc(var(--header-h) + 32px);
}

.episode-read-heading {
  margin-bottom: 16px;
  font-family: var(--sans);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--orangish);
}

.episode-contents {
  list-style: none;
  counter-reset: part;
  display: grid;
  gap: 10px;
}

.episode-contents li {
  counter-increment: part;
  display: grid;
  grid-template-columns: 1.6em 1fr;
  align-items: baseline;
  font-family: var(--episode);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--grayish);
}

.episode-contents li::before {
  content: counter(part);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--orangish);
}

.episode-text p {
  font-family: var(--episode);
  font-size: clamp(1.06rem, 1.4vw, 1.16rem);
  line-height: 1.7;
  color: var(--grayish);
}

.episode-text p + p {
  margin-top: 0.9em;
}

.episode-continue {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 0.95rem;
  color: var(--mute);
}

.episode-read + footer,
.episode-main + footer {
  background: var(--surface);
}

@media (max-width: 900px) {
  .episode-main {
    padding-top: calc(var(--header-h) + 24px);
  }

  .episode-hero {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-bottom: 64px;
  }

  .episode-art {
    position: static;
    border-radius: 16px;
  }

  /* On phones the player comes right under the title, within the first screen */
  .episode-info {
    display: flex;
    flex-direction: column;
  }

  .episode-info .preview {
    order: 1;
    margin-top: 24px;
  }

  .episode-subtitle {
    order: 2;
    margin-top: 24px;
  }

  .episode-meta,
  .episode-cta {
    order: 3;
  }

  .episode-read {
    padding: 40px 0 56px;
  }

  .episode-read-inner.has-contents {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .episode-contents-block {
    position: static;
  }
}

@media (max-width: 420px) {
  .preview {
    gap: 14px;
    padding: 14px 18px 14px 14px;
  }

  .preview-button {
    width: 52px;
    height: 52px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-fill,
  .preview-button,
  .preview-button svg {
    transition: none;
  }

  .preview.is-loading .preview-button {
    animation: none;
  }
}
