/* H-Donghua V2 Single Page Episode List Stylesheet */
/* 6. FUTURISTIC EPISODE SYSTEM */
.hd-episodes-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--hd-spacing-lg);
}

.hd-episodes-search-box {
  position: relative;
  background-color: var(--hd-surface);
  border: 1px solid var(--hd-border-glass);
  border-radius: var(--hd-radius-md);
  padding: 2px 10px;
  display: flex;
  align-items: center;
  transition: var(--hd-transition-all);
  margin-top: var(--hd-spacing-xs);
  margin-bottom: var(--hd-spacing-md);
}

.hd-episodes-search-box:focus-within {
  border-color: var(--hd-primary);
  box-shadow: var(--hd-glow-primary);
}

.hd-episodes-search-box input {
  background: none;
  border: none;
  outline: none;
  padding: 6px var(--hd-spacing-lg) 6px 6px;
  font-size: 12px;
  color: #fff;
  width: 140px;
  -moz-appearance: textfield;
}

.hd-episodes-search-box input::-webkit-outer-spin-button,
.hd-episodes-search-box input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hd-episodes-search-box svg {
  position: absolute;
  right: 10px;
  color: var(--hd-text-dim);
}

/* Episode Grid Buttons */
.hd-episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--hd-spacing-sm);
}

.nextjs-ep-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: var(--hd-surface);
  border: 1px solid var(--hd-border-glass);
  padding: var(--hd-spacing-sm) 0;
  border-radius: var(--hd-radius-md);
  transition: var(--hd-transition-all);
}

.nextjs-ep-card:hover {
  background-color: var(--hd-primary);
  border-color: var(--hd-primary);
  box-shadow: var(--hd-glow-primary);
  transform: translateY(-3px);
}

.nextjs-ep-card .num {
  font-family: var(--hd-font-display);
  font-size: var(--hd-text-base);
  font-weight: 800;
  color: #fff;
}

.nextjs-ep-card .label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--hd-text-dim);
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: 0.05em;
}

.nextjs-ep-card:hover .label {
  color: rgba(255,255,255,0.7);
}

/* 8. RELATED SUBJECTS HORIZONTAL SCROLL (Bangumi) */
.hd-related-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: var(--hd-spacing-md);
  margin-bottom: var(--hd-spacing-xl);
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: var(--hd-spacing-sm);
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.hd-related-grid::-webkit-scrollbar {
  display: none;
}

.hd-related-card {
  background-color: var(--hd-surface-glass);
  border: 1px solid var(--hd-border-glass);
  border-radius: var(--hd-radius-lg);
  overflow: hidden;
  transition: var(--hd-transition-all);
  cursor: default;
  flex: 0 0 140px;
  min-width: 140px;
  scroll-snap-align: start;
}

.hd-related-card:hover {
  border-color: var(--hd-primary);
  box-shadow: var(--hd-shadow-md);
}

.hd-related-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2/3;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.02);
}

.hd-related-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s var(--hd-ease-out);
}

.hd-related-card:hover .hd-related-cover-img {
  transform: scale(1.05);
}

.hd-related-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hd-text-dim);
  background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.05) 100%);
}

.hd-related-type-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background-color: var(--hd-primary);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--hd-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.hd-related-info {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hd-related-title {
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hd-related-subtitle {
  font-size: 10px;
  color: var(--hd-text-dim);
  font-weight: 500;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==========================================================================
   10. SIDEBAR EPISODE GRID & ANIME SHORT INFO CARD
   ========================================================================== */

/* Episode Sidebar Grid Layout */
.hd-ep-grid-scroll {
  max-height: 320px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 4px 6px 4px 4px; /* Padding on all sides to prevent border/glow clipping on hover and active states */
  margin-top: var(--hd-spacing-xs);
}

@media (max-width: 1200px) and (min-width: 1025px) {
  .hd-ep-grid-scroll {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1024px) {
  .hd-ep-grid-scroll {
    grid-template-columns: repeat(12, 1fr);
  }
}

@media (max-width: 768px) {
  .hd-ep-grid-scroll {
    grid-template-columns: repeat(8, 1fr);
  }
}

@media (max-width: 480px) {
  .hd-ep-grid-scroll {
    grid-template-columns: repeat(5, 1fr);
  }
}

.hd-ep-grid-scroll::-webkit-scrollbar {
  width: 6px;
}
.hd-ep-grid-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--hd-radius-full);
}
.hd-ep-grid-scroll::-webkit-scrollbar-thumb {
  background: var(--hd-border-glass);
  border-radius: var(--hd-radius-full);
}
.hd-ep-grid-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--hd-text-dim);
}

.hd-ep-grid-link {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  background: var(--hd-surface);
  border: 1px solid var(--hd-border-glass);
  border-radius: var(--hd-radius-md);
  font-family: var(--hd-font-display);
  font-size: var(--hd-text-sm);
  font-weight: 700;
  color: var(--hd-text-muted);
  transition: var(--hd-transition-all);
  text-decoration: none;
}

.hd-ep-grid-link:hover {
  border-color: var(--hd-primary);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.hd-ep-grid-link.active {
  background: var(--hd-primary);
  border-color: var(--hd-primary);
  color: #fff;
  box-shadow: var(--hd-glow-primary);
}

.hd-ep-grid-link.active:hover {
  background: var(--hd-primary);
  transform: none;
}

/* Performance Optimization: Content Visibility for Episode & Related Grids */
.hd-ep-grid-scroll {
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

.hd-related-grid {
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
}

/* ==========================================================================
   ─── Episode Progress Indicators ───
   ========================================================================== */

/* Ensure ep-grid-link can contain absolute progress bars */
.hd-ep-grid-link {
  position: relative;
}

/* Progress bar — absolute bottom of episode grid button */
.hd-ep-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  background: linear-gradient(90deg, var(--hd-primary), var(--hd-accent));
  border-radius: 0 0 var(--hd-radius-md) var(--hd-radius-md);
  z-index: 2;
  transition: width 0.4s var(--hd-ease-out);
  pointer-events: none;
}

/* Watched state — completed episode */
.hd-ep-grid-link.watched {
  border-color: rgba(46, 125, 50, 0.35);
  background: rgba(46, 125, 50, 0.08);
  opacity: 0.75;
}

.hd-ep-grid-link.watched:hover {
  opacity: 1;
  border-color: rgba(46, 125, 50, 0.5);
  background: rgba(46, 125, 50, 0.12);
}

/* ✓ Checkmark overlay — top-right of watched episode */
.hd-ep-grid-link.watched::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 9px;
  font-weight: 800;
  color: rgba(46, 125, 50, 0.9);
  line-height: 1;
  z-index: 3;
  pointer-events: none;
}

/* Watching state — currently in progress */
.hd-ep-grid-link.watching {
  border-color: var(--hd-primary);
  box-shadow: 0 0 10px var(--hd-primary-glow);
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
}

.hd-ep-grid-link.watching:hover {
  box-shadow: 0 0 18px var(--hd-primary-glow);
}

/* ─── Episode Card Progress (Single Anime Detail Page) ─── */
.nextjs-ep-card {
  position: relative;
  overflow: hidden;
}

.nextjs-ep-card .hd-ep-card-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2.5px;
  background: linear-gradient(90deg, var(--hd-primary), var(--hd-accent));
  border-radius: 0 0 var(--hd-radius-md) var(--hd-radius-md);
  z-index: 2;
  transition: width 0.4s var(--hd-ease-out);
  pointer-events: none;
}

/* Responsive overrides */
@media (max-width: 768px) {
  /* 5. Episode List Filter grid and sidebar */
  .hd-sidebar-episodes-filter {
    padding: var(--hd-spacing-md);
    margin-top: var(--hd-spacing-md);
  }

  .hd-episodes-search-box,
  .hd-episodes-search-box:focus-within {
    width: 100%;
    margin-bottom: var(--hd-spacing-md);
    outline: none;
  }

  .hd-episodes-search-box input,
  .hd-episodes-search-box input:focus,
  .hd-episodes-search-box input:active,
  .hd-episodes-search-box input:-webkit-autofill {
    width: 100%;
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    border: none;
    background: transparent;
    box-shadow: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
  }

  .hd-ep-grid-scroll {
    max-height: 280px; /* Limit height of episode grid */
  }

  /* Make the number cells easier to tap on mobile */
  .hd-ep-grid-link {
    height: 42px;
    font-size: 12px;
    border-radius: var(--hd-radius-sm);
  }

  /* 6. Tabs Navigation capsule horizontal scroll fix */
  .hd-tabs-nav-capsule {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  
  .hd-tabs-nav-capsule::-webkit-scrollbar {
    display: none;
  }
  
  .hd-tabs-nav-capsule .hd-tab-btn {
    flex-shrink: 0;
    padding: 10px 16px; /* Slightly reduced horizontal padding on mobile */
  }

}