/*
 * Catalog grids, cards, filters, search/archive layouts
 */

.sm-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.sm-section-head__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--sm-border, #e2e8f0);
  border-radius: 10px;
  background: #fff;
  color: var(--sm-primary-hover, #1153c8);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.sm-section-head__link svg {
  width: 16px;
  height: 16px;
}

.sm-section-head__link:hover {
  border-color: color-mix(in srgb, var(--sm-primary, #1a6ef5) 40%, var(--sm-border, #e2e8f0));
  background: #eff6ff;
  color: var(--sm-primary, #1a6ef5);
  text-decoration: none;
}

.sm-section-head .sm-section-title {
  margin: 0;
}

.sm-section-head .sm-section-title::before {
  display: none;
}

.sm-section-title__icon {
  width: 25px;
  height: 25px;
  color: #27477f;
}

.sm-section-title__icon svg {
  width: 100%;
  height: 100%;
}

.sm-filter-bar {
  margin-bottom: 20px;
}

.sm-filter-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  width: 100%;
  margin-inline: auto;
}

.sm-filter-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--sm-text-muted, #64748b);
}

.sm-filter-group label svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--sm-text-main, #0f172a);
}

.sm-filter-group select,
.sm-sfield__input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--sm-border, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

.sm-filter-group--submit {
  min-width: 110px;
}

.sm-filter-group--submit .sm-btn {
  width: auto;
  white-space: nowrap;
  padding: 9px 18px;
}

.sm-grid,
.sm-sgrid,
.sm-agrid {
  display: grid;
  gap: 16px;
}

.sm-grid--home {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 24px;
}

.sm-sgrid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.sm-agrid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Tarjeta de archivo: películas, series y documentales. */
.sm-archive-card {
  display: flex;
  min-width: 0;
  height: 100%;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--sm-border, #e2e8f0);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31, 36, 48, 0.07);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.sm-archive-card:hover {
  border-color: color-mix(in srgb, var(--sm-primary, #1a6ef5) 48%, var(--sm-border, #e2e8f0));
  box-shadow: 0 14px 30px rgba(31, 36, 48, 0.13);
  transform: translateY(-3px);
}

.sm-archive-card__link {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  color: inherit;
}

.sm-archive-card__poster {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: #dfe6ef;
}

.sm-archive-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease;
}

.sm-archive-card:hover .sm-archive-card__img {
  transform: scale(1.035);
}

.sm-archive-card__quality {
  position: absolute;
  top: 8px;
  left: 8px;
  max-width: calc(100% - 16px);
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.sm-archive-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 12px 2px 10px;
}

.sm-archive-card__title {
  display: -webkit-box;
  min-height: 2.6em;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--sm-text-main, #0f172a);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
}

.sm-archive-card__genres {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 5px;
}

.sm-archive-card__genres span {
  max-width: 100%;
  overflow: hidden;
  padding: 3px 7px;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sm-archive-card__meta {
  margin: auto 0 0;
  color: var(--sm-text-muted, #64748b);
  font-size: 0.75rem;
  font-weight: 600;
}

.sm-archive-card__download {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  background: var(--sm-primary, #1a6ef5);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.sm-archive-card__download:hover {
  background: var(--sm-primary-hover, #1153c8);
  box-shadow: 0 8px 18px rgba(26, 110, 245, 0.24);
}

.sm-archive-card__download svg {
  width: 17px;
  height: 17px;
}

.sm-card {
  min-width: 0;
}

.sm-card__link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.sm-card__poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #e2e8f0;
}

.sm-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s ease;
}

.sm-card__link:hover .sm-card__img {
  transform: scale(1.04);
}

.sm-card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
}

.sm-card__body {
  padding: 10px 2px 0;
}

.sm-card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sm-card__meta {
  margin: 4px 0 0;
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--sm-text-muted, #64748b);
}

/* Tarjeta completa exclusiva de "Últimas películas" en la portada. */
.sm-home-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  padding: 0 0 12px;
  border: 1px solid var(--sm-border, #e2e8f0);
  border-radius: 20px;
  background: var(--sm-surface, #fff);
  box-shadow: 0 8px 24px rgba(31, 36, 48, 0.07);
  overflow: hidden;
  transition: transform 240ms ease, border-color 240ms ease, box-shadow 240ms ease;
}

.sm-home-card:hover {
  transform: translateY(-2px);
  border-color: var(--sm-primary, #1a6ef5);
  box-shadow: 0 14px 32px rgba(31, 36, 48, 0.13);
}

.sm-home-card__link {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.sm-home-card__poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 20px 20px 0 0;
  background: linear-gradient(160deg, #dbeafe, #bfdbfe);
  overflow: hidden;
}

.sm-home-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease;
}

.sm-home-card:hover .sm-home-card__img {
  transform: scale(1.04);
}

.sm-home-card__quality {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  max-width: calc(100% - 16px);
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-home-card__info {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px 12px 8px;
}

.sm-home-card__title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.7em;
  margin: 0;
  color: var(--sm-text-main, #0f172a);
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.35;
  overflow: hidden;
  transition: color 240ms ease;
}

.sm-home-card:hover .sm-home-card__title {
  color: var(--sm-primary-hover, #1153c8);
}

.sm-home-card__genres {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.sm-home-card__genre,
.sm-widget-movie__genres span,
.sm-rank-item__genres span {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  background: #2563eb;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  line-height: 1.4;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sm-home-card__meta {
  margin: 0;
  color: var(--sm-text-muted, #64748b);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.sm-home-card__download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: 8px;
  min-height: 40px;
  margin: auto 12px 0;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--sm-primary, #1a6ef5);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: background 240ms ease, box-shadow 240ms ease;
}

.sm-home-card__download svg {
  width: 17px;
  height: 17px;
}

.sm-home-card__download:hover,
.sm-home-card:hover .sm-home-card__download {
  background: var(--sm-primary-hover, #1153c8);
  box-shadow: 0 8px 18px rgba(26, 110, 245, 0.24);
}

.sm-catalog-pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
  justify-content: center;
}

.sm-page-btn {
  box-sizing: border-box;
  min-width: 40px;
  min-height: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--sm-border, #e2e8f0);
  text-decoration: none;
  color: var(--sm-text-muted, #64748b);
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}

.sm-page-btn:hover {
  background: var(--sm-bg, #f1f5f9);
  border-color: var(--sm-primary, #1a6ef5);
  color: var(--sm-primary-hover, #1153c8);
}

.sm-page-btn.is-active {
  background: var(--sm-primary, #1a6ef5);
  border-color: var(--sm-primary, #1a6ef5);
  color: #fff;
}

.sm-page-btn--wide {
  min-width: 88px;
  gap: 7px;
}

.sm-page-btn--wide svg {
  width: 16px;
  height: 16px;
}

.sm-page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 40px;
  color: var(--sm-text-muted, #64748b);
  font-weight: 700;
}

.sm-catalog-pagination-slot:empty {
  display: none;
}

.sm-filter-apply[hidden] {
  display: none;
}

.sm-empty-state {
  grid-column: 1 / -1;
  padding: 40px 16px;
  text-align: center;
  color: var(--sm-text-muted, #64748b);
}

.sm-search__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: start;
}

.sm-sresults-head {
  margin-bottom: 18px;
}

.sm-sresults-head__title,
.sm-arch-head__title {
  margin: 0 0 12px;
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 800;
}

.sm-sfield {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.sm-shelp {
  border: 1px solid var(--sm-border, #e2e8f0);
  border-radius: 12px;
  padding: 16px;
  background: var(--sm-surface, #fff);
}

.sm-shelp__title {
  margin: 0 0 12px;
  font-size: 1rem;
}

.sm-schips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sm-schip {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--sm-text-main, #0f172a);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}

.sm-schip:hover {
  background: var(--sm-primary, #1a6ef5);
  color: #fff;
}

.sm-archive-main {
  padding: 44px 0 64px;
}

.sm-arch-head {
  margin-bottom: 24px;
}

.sm-arch-head__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.sm-arch-head__icon {
  width: 34px;
  height: 34px;
  align-self: center;
  color: #1f3359;
}

.sm-arch-head__icon svg {
  width: 100%;
  height: 100%;
}

.sm-arch-head__title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.sm-arch-head__desc {
  max-width: 75ch;
  margin: 10px 0 0;
  color: var(--sm-text-muted, #64748b);
}

.sm-arch-head__count {
  margin: 0;
  color: var(--sm-text-muted, #64748b);
  font-size: 0.95rem;
  font-weight: 700;
}

body.sm-catalog-busy [data-sm-catalog-grid] {
  opacity: 0.55;
  pointer-events: none;
}

body.sm-catalog-busy [data-sm-catalog-pagination-slot] {
  opacity: 0.55;
  pointer-events: none;
}

.sm-home-card__link:focus-visible,
.sm-home-card__download:focus-visible,
.sm-archive-card__link:focus-visible,
.sm-archive-card__download:focus-visible,
.sm-section-head__link:focus-visible,
.sm-page-btn:focus-visible {
  outline: 2px solid var(--sm-primary, #1a6ef5);
  outline-offset: 2px;
}

@media (max-width: 1023px) {
  .sm-grid--home,
  .sm-sgrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sm-grid--home {
    gap: 24px;
  }
  .sm-agrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sm-search__layout {
    grid-template-columns: 1fr;
  }
  .sm-filter-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .sm-filter-group--submit {
    grid-column: 1 / -1;
  }
  .sm-filter-group--submit .sm-btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .sm-grid--home,
  .sm-sgrid,
  .sm-agrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .sm-grid--home {
    gap: 16px;
  }
  .sm-filter-form {
    grid-template-columns: 1fr 1fr;
  }

  .sm-home-card__title {
    font-size: 0.82rem;
  }

  .sm-home-card__download {
    margin-inline: 10px;
    font-size: 0.78rem;
  }

  .sm-archive-main {
    padding: 28px 0 48px;
  }

  .sm-arch-head__row {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sm-arch-head__icon {
    width: 28px;
    height: 28px;
  }

  .sm-arch-head__title {
    font-size: 1.8rem;
  }

  .sm-arch-head__count {
    width: 100%;
    padding-left: 36px;
  }

  .sm-archive-card {
    padding: 7px;
    border-radius: 14px;
  }

  .sm-archive-card__body {
    padding-top: 10px;
  }

  .sm-archive-card__title {
    font-size: 0.84rem;
  }

  .sm-archive-card__download {
    min-height: 38px;
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sm-home-card,
  .sm-home-card__img,
  .sm-home-card__title,
  .sm-home-card__download {
    transition: none;
  }

  .sm-archive-card,
  .sm-archive-card__img,
  .sm-archive-card__download {
    transition: none;
  }

  .sm-home-card:hover,
  .sm-home-card:hover .sm-home-card__img {
    transform: none;
  }
}
