/* ==========================================================================
   JSFLIX — Series Browse & Chapters Detail Stylesheet
   ========================================================================== */

.series-body {
  background: var(--ink);
  min-height: 100vh;
}

.series-main {
  padding-top: calc(var(--header-height) + 20px);
  padding-bottom: 90px;
}

/* --- App Browse Header (series.html) --- */
.app-browse-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.app-browse-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-browse-dot {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.app-browse-info h1 {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  margin: 0;
}

.app-browse-info p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 3px 0 0;
}

.app-browse-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 16px;
  border-radius: var(--radius-xl);
  background: var(--panel);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s;
}

.app-browse-search:focus-within {
  border-color: rgba(229, 9, 20, 0.6);
}

.app-browse-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

.app-browse-search input::placeholder {
  color: var(--text-muted);
}

/* --- Series Grid (series.html) --- */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.browse-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  transition: transform 0.25s ease;
}

.browse-card:hover {
  transform: translateY(-4px);
}

.browse-poster-wrap {
  position: relative;
  aspect-ratio: 9/13;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
}

.browse-poster-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.browse-card:hover .browse-poster-wrap img {
  transform: scale(1.05);
  filter: brightness(0.85);
}

.browse-play-chip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.browse-card:hover .browse-play-chip {
  opacity: 1;
}

.browse-play-chip span {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.5);
}

.browse-card strong {
  margin-top: 8px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browse-card small {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-dim);
}

/* ==========================================================================
   Chapters & Series Detail Page (chapters.html)
   ========================================================================== */

/* --- Ambient Blurred Backdrop --- */
.ambient-backdrop-wrap {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.ambient-backdrop-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.25;
  filter: blur(40px) saturate(1.2);
  transform: scale(1.15);
  pointer-events: none;
}

.ambient-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10, 10, 12, 0.4) 0%, rgba(10, 10, 12, 0.85) 70%, var(--ink) 100%);
  pointer-events: none;
}

/* --- Series Hero Content --- */
.series-detail-hero {
  position: relative;
  z-index: 2;
  padding: calc(var(--header-height) + 24px) 0 40px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-dim);
  margin-bottom: 20px;
  transition: color 0.2s;
}

.back-link:hover {
  color: #fff;
}

.series-detail-flex {
  display: flex;
  gap: clamp(24px, 4vw, 44px);
  align-items: flex-start;
}

.series-poster-box {
  position: relative;
  width: clamp(160px, 20vw, 220px);
  flex-shrink: 0;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.8);
  aspect-ratio: 9/13;
  background: var(--panel-2);
}

.series-poster-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-info-box {
  flex: 1;
  min-width: 0;
}

.series-info-box h1 {
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  line-height: 1.18;
}

.series-badges-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.series-app-pill {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.series-eps-pill {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.series-desc {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-dim);
  max-width: 680px;
  margin: 0 0 24px;
}

.series-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.series-cta-row .btn {
  padding: 12px 24px;
  font-size: 14.5px;
  font-weight: 600;
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fav-btn:hover {
  border-color: rgba(255, 255, 255, 0.3);
  background: var(--panel-2);
}

.fav-btn.active {
  border-color: var(--brand);
  background: rgba(229, 9, 20, 0.12);
  color: var(--brand);
}

.fav-btn i {
  font-size: 18px;
}

/* --- Episode Section & Pagination --- */
.episodes-section {
  padding: 32px 0 60px;
}

.episodes-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.episodes-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.episode-ranges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.range-tab {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.range-tab:hover {
  background: var(--panel-2);
  color: #fff;
}

.range-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* --- Episode Buttons Grid --- */
.episodes-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 8px;
}

.ep-btn {
  position: relative;
  aspect-ratio: 1/1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
}

.ep-btn:hover {
  border-color: var(--brand);
  color: #fff;
  transform: translateY(-2px);
}

.ep-btn.current {
  border-color: var(--brand);
  background: rgba(229, 9, 20, 0.2);
  color: #fff;
  box-shadow: 0 0 12px rgba(229, 9, 20, 0.4);
}

.ep-btn.current::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 6px var(--brand);
}

.ep-btn.watched {
  background: var(--panel-2);
  color: var(--text-muted);
  border-color: transparent;
}

.ep-btn.locked {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-dim, #71717a);
  border-color: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.ep-btn.locked:hover {
  border-color: #f59e0b;
  color: #fff;
}

.ep-btn .ep-lock-icon {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 10px;
  color: #f59e0b;
}

.ep-btn.free-badge::before {
  content: 'ฟรี';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: #10b981;
  color: #fff;
  line-height: 1;
}

.ep-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
}

.ep-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ep-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* --- Responsive Breakpoints --- */
@media (max-width: 1200px) {
  .browse-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .episodes-grid {
    grid-template-columns: repeat(10, 1fr);
  }
}

@media (max-width: 900px) {
  .browse-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .episodes-grid {
    grid-template-columns: repeat(8, 1fr);
  }
  .series-detail-flex {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .series-badges-bar,
  .series-cta-row {
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .browse-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .episodes-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }
  .app-browse-head {
    flex-direction: column;
    align-items: stretch;
  }
  .app-browse-search {
    max-width: 100%;
  }
}

@media (max-width: 420px) {
  .browse-grid {
    gap: 8px;
  }
  .episodes-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
  .series-cover-wrapper {
    max-width: 180px;
    margin-inline: auto;
  }
  .series-detail-title {
    font-size: 20px;
  }
}
