/* ============================================
   EPISODES BROWSE PAGE — episodes.css
   ============================================
   Mobile-first approach.
   0px border-radius per Master Shape Rule.
   8-point spacing grid.
   Consistent padding matching hero section.
   UX Laws: Fitts's Law (48px touch targets),
   Hick's Law (categorised filters),
   Law of Proximity (grouped elements),
   Von Restorff (orange accent isolation),
   F-Pattern (left-aligned scanning axis).
   ============================================ */

/* ========== PAGE WRAPPER ========== */
.ep-browse {
  background-color: var(--color-soft-bg);
  padding-top: calc(var(--navbar-height) + var(--space-xl));
  padding-bottom: var(--space-2xl);
  min-height: 100vh;
}

.ep-browse__container {
  max-width: 1440px;
  margin: 0 auto;
  padding-left: var(--page-padding);
  padding-right: var(--page-padding);
}

/* ========== SECTION HEADER ========== */
.ep-browse__header {
  margin-bottom: var(--space-lg);
}

.ep-browse__header-text {
  display: flex;
  flex-direction: column;
}

.ep-browse__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--color-blue);
  margin-bottom: var(--space-xs);
  line-height: 1.0;
}

.ep-browse__eyebrow-line {
  display: inline-block;
  width: 32px;
  height: 2px;
  background-color: var(--color-blue);
  flex-shrink: 0;
}

.ep-browse__heading {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -1px;
  color: var(--color-charcoal);
  margin-bottom: 0;
}

/* ========== TOOLBAR (Filters + Search) ========== */
.ep-browse__toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

/* ---------- Filter Buttons ---------- */
.ep-browse__filters {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-xs);
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  /* Firefox */
  padding-bottom: 4px;
}

.ep-browse__filters::-webkit-scrollbar {
  display: none;
}

.ep-browse__filter-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 var(--space-sm);
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--color-grey-medium);
  background-color: var(--color-white);
  border: 1px solid var(--color-grey-border);
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, transform 0.15s ease;
  line-height: 1;
}

.ep-browse__filter-btn:hover {
  border-color: var(--color-blue);
  color: var(--color-blue);
  background-color: var(--color-blue-light);
}

.ep-browse__filter-btn:active {
  transform: translateY(1px);
}

.ep-browse__filter-btn.is-active {
  background-color: var(--color-blue);
  color: var(--color-white);
  border-color: var(--color-blue);
  font-weight: 700;
}

.ep-browse__filter-btn.is-active:hover {
  background-color: var(--color-blue-dark);
  border-color: var(--color-blue-dark);
  color: var(--color-white);
}

/* ---------- Search ---------- */
.ep-browse__search {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.ep-browse__search-icon {
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--color-grey-medium);
  pointer-events: none;
  transition: color 0.2s ease;
}

.ep-browse__search-input {
  width: 100%;
  height: 48px;
  padding: 0 var(--space-sm) 0 42px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 400;
  color: var(--color-charcoal);
  background-color: var(--color-white);
  border: 1px solid var(--color-grey-border);
  border-radius: 0;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.ep-browse__search-input::placeholder {
  color: var(--color-grey-medium);
  font-weight: 400;
}

.ep-browse__search-input:focus {
  border-color: var(--color-blue);
  border-width: 2px;
  padding-left: 41px;
  /* compensate for 2px border */
}

.ep-browse__search-input:focus+.ep-browse__search-icon,
.ep-browse__search-input:focus~.ep-browse__search-icon {
  color: var(--color-blue);
}

/* Fix: icon color on focus via sibling */
.ep-browse__search:focus-within .ep-browse__search-icon {
  color: var(--color-blue);
}

/* Remove webkit search cancel button styling */
.ep-browse__search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  width: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5568' stroke-width='2.5'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E") center/contain no-repeat;
  cursor: pointer;
}

/* ========== FEATURED EPISODE ========== */
.ep-featured {
  display: flex;
  flex-direction: column;
  background-color: var(--color-white);
  border: 1px solid var(--color-grey-light-bg);
  border-radius: 0;
  overflow: hidden;
  margin-bottom: var(--space-lg);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.ep-featured:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

/* Featured Image */
.ep-featured__image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.ep-featured__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: 0;
  transition: transform 0.4s ease;
}

.ep-featured:hover .ep-featured__image {
  transform: scale(1.03);
}

.ep-featured__badge {
  position: absolute;
  bottom: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 14px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-white);
  background-color: var(--color-blue);
  border-radius: 0;
  line-height: 1.0;
  z-index: 2;
  transform: translateZ(0);
  will-change: transform;
}

/* Featured Content */
.ep-featured__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-md);
}

.ep-featured__category {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-blue);
  margin-bottom: var(--space-xs);
  line-height: 1.0;
}

.ep-featured__title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  color: var(--color-charcoal);
  margin-bottom: var(--space-sm);
}

.ep-featured__description {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--color-grey-medium);
  margin-bottom: var(--space-md);
}

.ep-featured__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.ep-featured__play-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 48px;
  padding: 0 var(--space-lg);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--color-white);
  background-color: var(--color-orange);
  border: 2px solid var(--color-orange);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.ep-featured__play-btn i {
  font-size: 18px;
  line-height: 1;
}

.ep-featured__play-btn:hover {
  background-color: var(--color-orange-hover);
  border-color: var(--color-orange-hover);
  transform: translateY(-1px);
}

.ep-featured__play-btn:active {
  transform: translateY(0);
}

/* ========== EPISODES GRID ========== */
.ep-browse__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
  align-items: stretch;
}

/* Consistent card heights via clamped text */
.ep-browse__grid .episode-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 2.6em; /* Fixed height for exactly 2 lines of text */
  margin-bottom: var(--space-xs);
}

.ep-browse__grid .episode-card__description {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 4.95em; /* Fixed height for exactly 3 lines of text */
  margin-bottom: var(--space-md);
}

/* Episode cards use global styles in styles.css */

/* ========== NO RESULTS ========== */
.ep-browse__no-results {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.ep-browse__no-results i {
  font-size: 48px;
  color: var(--color-grey-border);
  margin-bottom: var(--space-sm);
  display: block;
}

.ep-browse__no-results-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-grey-medium);
  margin-bottom: var(--space-md);
}

.ep-browse__reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 var(--space-lg);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-blue);
  background-color: transparent;
  border: 2px solid var(--color-blue);
  border-radius: 0;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.ep-browse__reset-btn:hover {
  background-color: var(--color-blue);
  color: var(--color-white);
  transform: translateY(-1px);
}

.ep-browse__reset-btn:active {
  transform: translateY(0);
}

/* Featured Description clamping */
.ep-featured__description {
  display: -webkit-box !important;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========== NO RESULTS ========== */
.ep-browse__no-results {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
}

.ep-browse__no-results i {
  font-size: 48px;
  color: var(--color-grey-border);
  margin-bottom: var(--space-sm);
  display: block;
}

.ep-browse__no-results-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-grey-medium);
  margin-bottom: var(--space-md);
}

.ep-browse__reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 var(--space-lg);
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-blue);
  background-color: transparent;
  border: 2px solid var(--color-blue);
  border-radius: 0;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.ep-browse__reset-btn:hover {
  background-color: var(--color-blue);
  color: var(--color-white);
  transform: translateY(-1px);
}

.ep-browse__reset-btn:active {
  transform: translateY(0);
}

/* ========== LOAD MORE ========== */
.ep-browse__load-more {
  text-align: center;
  margin-top: var(--space-xl);
}

.ep-browse__load-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 40px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-charcoal);
  background-color: transparent;
  border: 2px solid var(--color-grey-border);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease,
    border-color 0.2s ease, transform 0.15s ease;
}

.ep-browse__load-btn:hover {
  border-color: var(--color-blue);
  color: var(--color-blue);
  background-color: var(--color-blue-light);
  transform: translateY(-1px);
}

.ep-browse__load-btn:active {
  background-color: var(--color-blue);
  border-color: var(--color-blue);
  color: var(--color-white);
  transform: translateY(0);
}

.ep-browse__load-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--color-grey-border);
  color: var(--color-grey-medium);
  background-color: transparent;
  transform: none;
}

/* ============================================
   RESPONSIVE — TABLET (≥ 600px)
   ============================================ */
@media (min-width: 600px) {

  .ep-browse {
    padding-top: calc(var(--navbar-height) + var(--space-2xl));
    padding-bottom: var(--space-2xl);
  }

  .ep-browse__heading {
    font-size: 36px;
  }

  .ep-browse__toolbar {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .ep-browse__filters {
    flex: 1;
    min-width: 0;
  }

  .ep-browse__search {
    max-width: 260px;
    flex-shrink: 0;
  }

  /* Grid: 2 columns */
  .ep-browse__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
  }

  /* Featured: still stacked but larger */
  .ep-featured__title {
    font-size: 26px;
  }

  .ep-featured__description {
    font-size: 15px;
  }

  .ep-featured__content {
    padding: var(--space-lg);
  }

  .ep-browse__filter-btn {
    height: 42px;
    font-size: 13px;
    flex-shrink: 0;
  }
}

/* ============================================
   RESPONSIVE — TABLET LANDSCAPE (≥ 768px)
   ============================================ */
@media (min-width: 768px) {

  .ep-browse__heading {
    font-size: 40px;
  }

  .ep-browse__toolbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .ep-browse__filters {
    flex: 1;
    min-width: 0;
  }

  .ep-browse__search {
    max-width: 280px;
    flex-shrink: 0;
  }

  /* Featured: horizontal layout */
  .ep-featured {
    flex-direction: row;
  }

  .ep-featured__image-wrapper {
    width: 55%;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    max-height: 360px;
  }

  .ep-featured__content {
    width: 45%;
    padding: var(--space-lg);
  }

  .ep-featured__title {
    font-size: 28px;
  }

  .ep-featured__description {
    font-size: 15px;
  }

  /* Grid: 3 columns */
  .ep-browse__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }

  .ep-browse__filter-btn {
    height: 44px;
    padding: 0 var(--space-md);
    font-size: 14px;
    flex-shrink: 0;
  }
}

/* ============================================
   RESPONSIVE — DESKTOP (≥ 1024px)
   ============================================ */
@media (min-width: 1024px) {

  .ep-browse {
    padding-top: calc(var(--navbar-height) + var(--space-3xl));
    padding-bottom: var(--space-3xl);
  }

  .ep-browse__heading {
    font-size: 44px;
  }

  .ep-browse__eyebrow {
    font-size: 13px;
  }

  .ep-browse__eyebrow-line {
    width: 40px;
  }

  .ep-browse__header {
    margin-bottom: var(--space-xl);
  }

  .ep-browse__toolbar {
    margin-bottom: var(--space-xl);
  }

  .ep-browse__search {
    max-width: 300px;
  }

  .ep-browse__search-input {
    font-size: 15px;
  }

  .ep-browse__filter-btn {
    height: 44px;
    padding: 0 20px;
    font-size: 14px;
    flex-shrink: 0;
  }

  /* Featured card */
  .ep-featured {
    margin-bottom: var(--space-xl);
  }

  .ep-featured__image-wrapper {
    max-height: 420px;
  }

  .ep-featured__content {
    padding: var(--space-xl);
  }

  .ep-featured__category {
    font-size: 12px;
  }

  .ep-featured__title {
    font-size: 32px;
  }

  .ep-featured__description {
    font-size: 16px;
    line-height: 1.75;
  }

  /* Grid: 3 columns */
  .ep-browse__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
  }

  .ep-browse__load-btn {
    font-size: 15px;
    padding: 0 40px;
  }
}

/* ============================================
   RESPONSIVE — LARGE DESKTOP (≥ 1280px)
   ============================================ */
@media (min-width: 1280px) {

  .ep-browse__heading {
    font-size: 48px;
  }

  .ep-featured__title {
    font-size: 36px;
  }

  .ep-featured__description {
    font-size: 17px;
  }

  .ep-featured__content {
    padding: var(--space-2xl);
  }

  .ep-browse__filter-btn {
    height: 48px;
    padding: 0 var(--space-md);
    font-size: 15px;
    flex-shrink: 0;
  }

  .ep-browse__search-input {
    font-size: 16px;
  }
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton {
  background: #E2E8F0;
  background-image: linear-gradient(
    90deg,
    #e2e8f0 0px,
    #cbd5e1 40px,
    #e2e8f0 80px
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite linear;
  border-radius: 0px !important;
}

@keyframes skeletonShimmer {
  0% {
    background-position: -150% 0;
  }
  100% {
    background-position: 150% 0;
  }
}

#pageLoadingState {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.skeleton-card {
  border: 1px solid var(--color-grey-light-bg, #E2E8F0);
  background: var(--color-white, #FFFFFF);
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 0 !important;
}

.skeleton-card__image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.skeleton-card__image {
  width: 100%;
  height: 100%;
}

.skeleton-card__badge {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 26px;
  width: 80px;
  z-index: 1;
}

.skeleton-card__body {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.skeleton-card__title {
  height: 2.6em;
  width: 75%;
  margin-bottom: var(--space-xs);
}

.skeleton-card__description {
  height: 4.95em; /* 3 lines of text in grid */
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-card__text {
  height: 14px;
  width: 100%;
}

.skeleton-card__text--short {
  height: 14px;
  width: 70%;
}

.skeleton-card__actions {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding-top: var(--space-sm);
}

.skeleton-card__button {
  height: 28px;
  width: 120px;
}

.skeleton-featured {
  display: flex;
  flex-direction: column;
  background-color: var(--color-white, #FFFFFF);
  border: 1px solid var(--color-grey-light-bg, #E2E8F0);
  margin-bottom: var(--space-lg, 32px);
  overflow: hidden;
  border-radius: 0 !important;
}

.skeleton-featured__image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
}

.skeleton-featured__image {
  width: 100%;
  height: 100%;
}

.skeleton-featured__badge {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 28px;
  width: 80px;
  z-index: 2;
}

.skeleton-featured__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-md);
}

.skeleton-featured__category {
  height: 11px;
  width: 90px;
  margin-bottom: var(--space-xs);
}

.skeleton-featured__title {
  height: 26px;
  width: 60%;
  margin-bottom: var(--space-sm);
}

.skeleton-featured__description {
  margin-bottom: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-featured__text {
  height: 14px;
  width: 100%;
}

.skeleton-featured__text--short {
  height: 14px;
  width: 70%;
}

.skeleton-featured__actions {
  display: flex;
  align-items: center;
}

.skeleton-featured__button {
  height: 48px;
  width: 160px;
  margin-top: 0;
}

@media (min-width: 768px) {
  .skeleton-featured {
    flex-direction: row;
  }

  .skeleton-featured__image-wrapper {
    width: 55%;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    max-height: 360px;
  }

  .skeleton-featured__content {
    width: 45%;
    padding: var(--space-lg);
  }

  .skeleton-featured__title {
    height: 34px;
  }
}

@media (min-width: 1024px) {
  .skeleton-featured__image-wrapper {
    max-height: 420px;
  }
  .skeleton-featured__content {
    padding: var(--space-xl);
  }
  .skeleton-featured__title {
    height: 38px;
  }
}