/* =====================================================================
   CineBusca — Estilos
   Tema oscuro tipo cine, responsive.
   ===================================================================== */

:root {
  --bg: #0b0e14;
  --bg-soft: #141925;
  --bg-card: #1a2030;
  --line: #2a3245;
  --text: #e8ecf4;
  --text-dim: #9aa4b8;
  --accent: #ffb02e;
  --accent-2: #e50914;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* El atributo HTML "hidden" debe ganarle a display:flex/grid de las clases. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "logo search"
    "tabs tabs";
  gap: 12px 20px;
  align-items: center;
}

.logo {
  grid-area: logo;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}
.logo:hover {
  text-decoration: none;
}
.logo__icon {
  font-size: 1.5rem;
}
.logo__text strong {
  color: var(--accent);
}

/* Buscador */
.search {
  grid-area: search;
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 4px 4px 18px;
  max-width: 520px;
  width: 100%;
  margin-left: auto;
  transition: border-color 0.2s;
}
.search:focus-within {
  border-color: var(--accent);
}
.search__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  padding: 8px 0;
}
.search__input::placeholder {
  color: var(--text-dim);
}
.search__btn {
  border: none;
  background: var(--accent);
  color: #1a1200;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, filter 0.2s;
}
.search__btn:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

/* Pestañas */
.tabs {
  grid-area: tabs;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.18s;
}
.tab:hover {
  color: var(--text);
  border-color: var(--text-dim);
}
.tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1200;
  font-weight: 600;
}

/* ===== Main ===== */
.main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Selector de género/categoría */
.genre-select {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.genre-select:hover,
.genre-select:focus {
  border-color: var(--accent);
}

/* Panel de filtros (Explorar) */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}
.filter {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}
.filter .genre-select {
  min-width: 150px;
}

/* Botón "Cargar más" */
.load-more {
  display: flex;
  justify-content: center;
  margin-top: 36px;
}
.load-more__btn {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 32px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.load-more__btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1200;
}
.load-more__btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===== Grid de tarjetas ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  outline: none;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-6px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.card__poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--bg-soft);
}
.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card__img--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 2rem;
}
.card__img--empty span {
  font-size: 0.8rem;
}

.card__type {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
}

.card__fav {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.15s, color 0.2s, background 0.2s;
}
.card__fav:hover {
  transform: scale(1.15);
  background: rgba(0, 0, 0, 0.85);
}
.card__fav.is-active {
  color: var(--accent);
}

.card__body {
  padding: 12px 14px 14px;
}
.card__title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.card__rating {
  color: var(--accent);
  font-weight: 600;
}

/* ===== Estados (loader / mensajes) ===== */
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}
.modal__box {
  position: relative;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 880px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: pop 0.2s ease;
}
@keyframes pop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}
.modal__close:hover {
  background: var(--accent-2);
}
.modal__backdrop {
  height: 320px;
  background-size: cover;
  background-position: center;
  position: relative;
}
.modal__backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--bg-soft), transparent 70%);
}
.modal__content {
  padding: 0 0 28px;
}
/* Hero del detalle: póster + info al lado */
.modal__hero {
  display: flex;
  gap: 22px;
  padding: 0 28px;
  align-items: flex-end;
  margin-top: -90px;
  position: relative;
  z-index: 2;
}
/* Si NO hay backdrop, el hero es el primer hijo -> sin margen negativo */
.modal__content > .modal__hero:first-child {
  margin-top: 26px;
}
.modal__poster {
  width: 165px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 3px solid var(--bg-soft);
  box-shadow: var(--shadow);
  display: block;
}
.modal__info {
  flex: 1;
  min-width: 0;
  padding-bottom: 6px;
}
.modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.modal__title {
  font-size: 1.85rem;
  font-weight: 800;
  line-height: 1.15;
}
.modal__title span {
  color: var(--text-dim);
  font-weight: 400;
}
.btn-fav {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.18s;
}
.btn-fav:hover {
  border-color: var(--accent);
}
.btn-fav.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1200;
  font-weight: 600;
}
.modal__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.btn-share {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.18s;
}
.btn-share:hover {
  border-color: var(--accent);
}
.modal__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0 0;
}
.tag {
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.modal__overview {
  padding: 18px 24px 0;
  line-height: 1.6;
  color: var(--text);
}
.modal__cast {
  padding: 14px 24px 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Botón de play sobre el backdrop */
.trailer-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: rgba(229, 9, 20, 0.92);
  color: #fff;
  font-size: 1.5rem;
  padding-left: 4px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s, background 0.2s;
}
.trailer-btn:hover {
  transform: translate(-50%, -50%) scale(1.12);
  background: var(--accent-2);
}

/* Cuando se carga el reproductor, el backdrop pasa a 16:9 */
.modal__backdrop.has-frame {
  height: 0;
  padding-bottom: 56.25%;
  background: #000;
}
.modal__backdrop.has-frame::after {
  content: none;
}
.trailer-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ¿Dónde verla? (plataformas + cines) */
.watch {
  padding: 18px 24px 0;
}
.watch__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.watch__group {
  margin-bottom: 14px;
}
.watch__label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}
.providers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.provider {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
  display: block;
}
.provider-link {
  display: inline-block;
  line-height: 0;
  transition: transform 0.15s;
}
.provider-link[href] {
  cursor: pointer;
}
.provider-link[href]:hover {
  transform: scale(1.1);
}
.provider-link[href]:hover .provider {
  border-color: var(--accent);
}
.cines-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cines-links a {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
  transition: all 0.18s;
}
.cines-links a:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}
.watch__more {
  display: inline-block;
  font-size: 0.85rem;
  margin-top: 4px;
}
.watch__empty {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Críticas */
.reviews {
  padding: 18px 24px 24px;
}
.reviews__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.review {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.review:last-child {
  margin-bottom: 0;
}
.review__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.review__rating {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
}
.review__text {
  color: var(--text-dim);
  line-height: 1.55;
  font-size: 0.9rem;
  white-space: pre-line;
}

/* Reparto con fotos (carrusel) */
.cast {
  padding: 20px 24px 0;
}
.cast__title,
.recs__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 14px;
}
.cast__row,
.recs__row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.cast-card {
  flex: 0 0 96px;
  width: 96px;
  text-align: center;
}
.cast-card img {
  width: 96px;
  height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}
.cast-card__noimg {
  width: 96px;
  height: 120px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.cast-card__name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 6px;
  line-height: 1.2;
}
.cast-card__char {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.2;
  margin-top: 2px;
}

/* Recomendados (carrusel) */
.recs {
  padding: 20px 24px 0;
}
.rec-card {
  flex: 0 0 110px;
  width: 110px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
}
.rec-card img {
  width: 110px;
  height: 165px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: transform 0.15s, border-color 0.2s;
  display: block;
}
.rec-card:hover img {
  transform: translateY(-4px);
  border-color: var(--accent);
}
.rec-card__name {
  font-size: 0.78rem;
  margin-top: 6px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--line);
  padding: 22px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header__inner {
    grid-template-columns: 1fr;
    grid-template-areas:
      "logo"
      "search"
      "tabs";
  }
  .search {
    max-width: none;
    margin-left: 0;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
  }
  .section-title {
    font-size: 1.25rem;
  }
  /* Detalle en móvil: póster más chico, título más pequeño */
  .modal__backdrop {
    height: 200px;
  }
  .modal__hero {
    gap: 14px;
    padding: 0 16px;
    margin-top: -56px;
  }
  .modal__poster {
    width: 100px;
    border-width: 2px;
  }
  .modal__title {
    font-size: 1.3rem;
  }
  .modal__tags,
  .modal__overview,
  .modal__cast,
  .watch,
  .reviews {
    padding-left: 16px;
    padding-right: 16px;
  }
  .modal__tags {
    padding-left: 0;
    padding-right: 0;
  }
  .filter .genre-select {
    min-width: 130px;
  }
}
