/* ─── MODAL ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  overflow-y: auto;
  padding: 40px 0;
  animation: overlayFadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; align-items: flex-start; justify-content: center; }

@keyframes overlayFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  position: relative;
  background: var(--dark-card);
  border-radius: 6px;
  width: 100%;
  max-width: 850px;
  margin: auto;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  animation: modalSlideIn 0.3s ease;
  overflow: hidden;
}
@keyframes modalSlideIn {
  from { transform: scale(0.94) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal__close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--dark-card);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  color: #fff;
}
.modal__close:hover { background: #333; }
.modal__close svg { width: 20px; height: 20px; }

/* Modal hero (backdrop area) */
.modal__hero {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  overflow: hidden;
  background: #000;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  background-color: #181818;
}
.modal__backdrop-grad {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to top, var(--dark-card), transparent);
}
.modal__hero-content {
  position: absolute;
  bottom: 36px; left: 40px;
  z-index: 5;
}
.modal__title {
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 900;
  margin-bottom: 20px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
  max-width: 500px;
}
.modal__hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal__trailer-btn { font-size: 14px; padding: 8px 20px; }
.modal__trailer-btn svg { width: 20px; height: 20px; }
.modal__add-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(42,42,42,0.8);
  border: 2px solid rgba(255,255,255,0.5);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.modal__add-btn:hover { border-color: #fff; }
.modal__add-btn svg { width: 20px; height: 20px; }

/* Body */
.modal__body {
  display: flex;
  gap: 30px;
  padding: 0 40px 24px;
}
.modal__body-left { flex: 2; }
.modal__body-right { flex: 1; }

.modal__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 14px;
}
.modal__match { color: var(--green); font-weight: 700; }
.modal__year { color: #e5e5e5; }
.modal__seasons { color: #e5e5e5; }
.modal__hd {
  border: 1px solid rgba(255,255,255,0.4);
  padding: 1px 6px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}
.modal__maturity {
  border: 1px solid rgba(255,255,255,0.4);
  padding: 2px 6px;
  font-size: 11px;
}
.modal__desc {
  font-size: 14px;
  line-height: 1.65;
  color: #e5e5e5;
}

.modal__cast, .modal__genres {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.modal__cast span, .modal__genres span { color: #e5e5e5; }

/* Player section */
.modal__player-section {
  padding: 0 0 0;
}
.modal__player-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.modal__player-label strong { color: #fff; font-size: 15px; }
.modal__retry-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #e5e5e5;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.modal__retry-btn:hover { background: rgba(255,255,255,0.18); }
.modal__retry-btn svg { width: 14px; height: 14px; }

.modal__player-wrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  overflow: hidden;
}
.modal__player-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Loading overlay shown OVER the iframe while it initialises */
.modal__player-loading {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.modal__player-loading.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal__player-loading .spinner {
  width: 44px; height: 44px;
  border-width: 3px;
}
.modal__player-loading p {
  font-size: 13px;
  color: var(--text-muted);
}

.modal__player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}
.modal__player-placeholder:hover { background: rgba(255,255,255,0.05); }
.modal__play-icon {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
}
.modal__play-icon svg { width: 32px; height: 32px; }

/* Episodes */
.modal__episodes-section {
  padding: 0 40px 24px;
}
.modal__episodes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal__episodes-header h3 {
  font-size: 20px;
  font-weight: 700;
}
.modal__season-select {
  background: rgba(42,42,42,0.9);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 20px;
}

.modal__episodes-list { display: flex; flex-direction: column; gap: 2px; }

.episode-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.episode-item:hover { background: rgba(255,255,255,0.08); }
.episode-item.active { background: rgba(255,255,255,0.12); }
.episode-item__num {
  font-size: 20px;
  color: var(--text-muted);
  min-width: 32px;
  text-align: center;
}
.episode-item__thumb {
  width: 130px;
  flex-shrink: 0;
  aspect-ratio: 16/9;
  background: #333;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.episode-item__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.episode-item__thumb-play {
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.episode-item:hover .episode-item__thumb-play { opacity: 1; }
.episode-item__thumb-play svg { width: 30px; height: 30px; }

.episode-item__info { flex: 1; }
.episode-item__title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.episode-item__name { font-size: 15px; font-weight: 700; }
.episode-item__duration { font-size: 13px; color: var(--text-muted); }
.episode-item__desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* More Like This */
.modal__more-section { padding: 0 40px 40px; }
.modal__section-title { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.modal__more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.more-card {
  background: #2f2f2f;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}
.more-card:hover { opacity: 0.85; }
.more-card__thumb {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #333;
}
.more-card__body { padding: 10px 12px 12px; }
.more-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.more-card__title { font-size: 14px; font-weight: 700; }
.more-card__match { color: var(--green); font-size: 13px; font-weight: 700; }
.more-card__desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Loading state */
.modal-loading {
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 760px) {
  .modal { border-radius: 0; }
  .modal-overlay { padding: 0; }
  .modal__hero-content { left: 20px; bottom: 20px; }
  .modal__body { flex-direction: column; padding: 0 20px 20px; }
  .modal__player-section { padding: 0 20px 20px; }
  .modal__episodes-section { padding: 0 20px 20px; }
  .modal__more-section { padding: 0 20px 30px; }
  .modal__more-grid { grid-template-columns: repeat(2, 1fr); }
  .episode-item__thumb { width: 90px; }
}
