/* Episode list (/episodes, rendered by functions/episodes.js) */

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

.library-head h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
}

.library-count {
  margin-top: 10px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

/* Topic filters: the app Library's chips. They stay under the top bar while
   the list scrolls */
.topic-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 20;
  margin-top: 28px;
  padding: 12px 0;
  background: var(--creamish);
  box-shadow: 0 1px 0 transparent;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-chip {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 36px;
  text-decoration: none;
  padding: 0 16px;
  border-radius: 20px;
  border: 1px solid rgba(62, 57, 53, 0.16);
  background: var(--surface);
  color: var(--grayish);
  font: 500 0.9rem/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.2s var(--ease),
    border-color 0.2s var(--ease),
    color 0.2s var(--ease);
}

.topic-chip[aria-current="page"] {
  background: var(--orangish);
  border-color: var(--orangish);
  color: #fff;
  font-weight: 600;
}

@media (hover: hover) {
  .topic-chip:not([aria-current]):hover {
    border-color: rgba(62, 57, 53, 0.4);
  }
}

.topic-chip:focus-visible {
  outline: 2px solid var(--orangish);
  outline-offset: 2px;
}

/* The cards: the landing page's episode card */
.library-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 28px 24px;
  margin-top: 20px;
}

.episode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
  color: var(--grayish);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(17, 19, 24, 0.08);
  overflow: hidden;
  text-decoration: none;
  transition:
    transform 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

@media (hover: hover) {
  .episode-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px -12px rgba(17, 19, 24, 0.22);
  }
}

.episode-card:focus-visible {
  outline: 2px solid var(--orangish);
  outline-offset: 3px;
}

.episode-cover {
  position: relative;
  display: block;
  margin: 12px;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--onboarding);
}

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

.category-pill,
.free-pill {
  position: absolute;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.category-pill {
  top: 12px;
  left: 12px;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--orangish);
  color: var(--surface);
}

/* Free sits bottom left, opposite the length */
.free-pill {
  bottom: 12px;
  left: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--grayish);
}

.duration-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(62, 57, 53, 0.5);
  color: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 500;
}

.duration-badge svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.episode-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 2px 16px 18px;
}

.library-date {
  font-size: 0.78rem;
  color: var(--mute);
}

.episode-title {
  margin-top: 4px;
  font-family: var(--episode);
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.25;
  color: var(--grayish);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.episode-sub {
  margin-top: 6px;
  font-size: 0.86rem;
  line-height: 1.45;
  color: rgba(62, 57, 53, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-cta {
  margin-top: 88px;
  padding-top: 48px;
  border-top: 1px solid var(--line);
  max-width: 560px;
}

.library-cta h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

.library-cta > p {
  margin-top: 10px;
  color: var(--mute);
}

.library-cta .store-row,
.library-cta .waitlist-row {
  margin-top: 24px;
}

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

.prelaunch .library-cta .store-row {
  display: flex;
}

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

@media (max-width: 600px) {
  .library-main {
    padding-top: calc(var(--header-h) + 28px);
  }

  /* Phones: one scrolling row of chips, as in the app */
  .topic-bar .wrap {
    width: 100%;
  }

  .topic-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0 18px;
    scroll-padding: 0 18px;
    scrollbar-width: none;
  }

  .topic-chips::-webkit-scrollbar {
    display: none;
  }

  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
  }

  .episode-cover {
    margin: 8px;
    border-radius: 10px;
  }

  .category-pill,
  .free-pill {
    padding: 3px 8px;
    font-size: 10px;
  }

  .category-pill {
    top: 8px;
    left: 8px;
    max-width: calc(100% - 16px);
  }

  .free-pill {
    bottom: 8px;
    left: 8px;
  }

  .duration-badge {
    right: 8px;
    bottom: 8px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .episode-body {
    padding: 0 10px 14px;
  }

  .episode-title {
    font-size: 1rem;
  }

  .episode-sub {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .episode-card,
  .topic-chip {
    transition: none;
  }
}
