/* =============================================================================
   ESTILOS COMPARTIDOS DE GRID PARA LOS 8 ARCHIVOS DE CONTENIDO
   (peliculas, series, animes, doramas, telenovelas, estrenos, 4k, proximamente)
   =============================================================================
   Antes archive-peliculas.css, archive-series.css, archive-animes.css,
   archive-doramas.css, archive-telenovelas.css, archive-estrenos.css,
   archive-4k.css y archive-proximamente.css eran funcionalmente identicos
   (828 lineas cada uno), solo cambiaba el ID del contenedor del grid.
   Verificado regla por regla con un parser CSS real.
   ============================================================================= */

/* ============================================
   FRONT PAGE - ESTILO YOUTUBE CON TRAILER LIGERO
============================================ */

/* ============================================
   SECCIONES
============================================ */
.sp-posts-section {
    padding: 16px 0;
    max-width: 100%;
}

/* ============================================
   CABECERA DE SECCIÓN
============================================ */
.sp-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.sp-section-title-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.sp-section-title-link {
    text-decoration: none !important;
    color: inherit !important;
    border: none !important;
    display: inline-block;
    box-shadow: none !important;
    outline: none !important;
}

.sp-section-title-link:active,
.sp-section-title-link:focus,
.sp-section-title-link:hover {
    text-decoration: none !important;
    color: inherit !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.sp-section-title-link .sp-section-title {
    text-decoration: none !important;
    color: var(--sp-text-color) !important;
    border: none !important;
    transition: opacity 0.2s;
}

.sp-section-title-link:hover .sp-section-title {
    opacity: 0.8;
}

.sp-section-title {
    color: var(--sp-text-color);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.sp-section-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: var(--sp-primary-color);
    border-radius: 50%;
    flex-shrink: 0;
    padding: 5px;
    box-sizing: border-box;
    min-width: 28px;
    min-height: 28px;
}

.sp-section-emoji .sp-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    filter: brightness(0) invert(1);
}

.sp-section-emoji img {
    max-width: 18px;
    max-height: 18px;
    object-fit: contain;
}

.sp-section-title-text {
    position: relative;
    display: inline-block;
}

.sp-section-hover-text {
    display: none;
}

/* ============================================
   GRID DE POSTS - 3 COLUMNAS EN ORDENADOR / 1 EN MÓVIL
============================================ */
.sp-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 0;
    width: 100%;
    min-width: 0;
}

/* Cada artículo ocupa todo el espacio de su celda */
.sp-posts-grid article {
    width: 100%;
    min-width: 0;
}

/* Imágenes dentro del grid que ocupen todo el ancho */
.sp-posts-grid .sp-thumbnail-wrapper {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    position: relative;
}

.sp-posts-grid .sp-thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   TARJETAS DE CONTENIDO
============================================ */
.sp-movie-item,
.sp-series-item,
.sp-anime-item,
.sp-dorama-item,
.sp-telenovela-item {
    background-color: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
    transition: none;
    cursor: pointer;
    min-width: 0;
}

.sp-movie-item a,
.sp-series-item a,
.sp-anime-item a,
.sp-dorama-item a,
.sp-telenovela-item a {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ============================================
   THUMBNAIL WRAPPER - 16:9
============================================ */
.sp-thumbnail-wrapper {
    position: relative;
    overflow: hidden;
    padding-top: 56.25%;
    border-radius: 12px;
    background: linear-gradient(100deg, var(--sp-card-bg) 30%, #262626 50%, var(--sp-card-bg) 70%);
    background-size: 200% 100%;
    animation: sp-shimmer 1.6s ease-in-out infinite;
    transition: border-radius 0.3s ease, box-shadow 0.3s var(--sp-ease, ease);
}

/* La imagen (z-index superior) cubre el shimmer en cuanto termina de cargar;
   no requiere JS porque el fondo del wrapper queda debajo del <img>. */
@keyframes sp-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sp-thumbnail-wrapper {
        animation: none;
        background: var(--sp-card-bg);
    }
}

.sp-movie-item:hover .sp-thumbnail-wrapper,
.sp-series-item:hover .sp-thumbnail-wrapper,
.sp-anime-item:hover .sp-thumbnail-wrapper,
.sp-dorama-item:hover .sp-thumbnail-wrapper,
.sp-telenovela-item:hover .sp-thumbnail-wrapper {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* Imagen del poster */
.sp-thumbnail-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    transition: opacity 0.4s ease, transform 0.4s ease;
    border-radius: 12px;
    z-index: 1;
}

/* En hover, la imagen se oscurece */
.sp-movie-item:hover .sp-thumbnail-image,
.sp-series-item:hover .sp-thumbnail-image,
.sp-anime-item:hover .sp-thumbnail-image,
.sp-dorama-item:hover .sp-thumbnail-image,
.sp-telenovela-item:hover .sp-thumbnail-image {
    opacity: 0.4;
    transform: scale(1.05);
}

/* Solo los que tienen trailer: la imagen se oculta completamente */
.sp-movie-item[data-has-trailer="true"]:hover .sp-thumbnail-image,
.sp-series-item[data-has-trailer="true"]:hover .sp-thumbnail-image,
.sp-anime-item[data-has-trailer="true"]:hover .sp-thumbnail-image,
.sp-dorama-item[data-has-trailer="true"]:hover .sp-thumbnail-image,
.sp-telenovela-item[data-has-trailer="true"]:hover .sp-thumbnail-image {
    opacity: 0;
}

/* ============================================
   TRAILER CONTAINER - REPRODUCTOR LIGERO SIN CONTROLES
============================================ */
.sp-trailer-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
}

/* En hover, el trailer se muestra */
.sp-movie-item[data-has-trailer="true"]:hover .sp-trailer-container,
.sp-series-item[data-has-trailer="true"]:hover .sp-trailer-container,
.sp-anime-item[data-has-trailer="true"]:hover .sp-trailer-container,
.sp-dorama-item[data-has-trailer="true"]:hover .sp-trailer-container,
.sp-telenovela-item[data-has-trailer="true"]:hover .sp-trailer-container {
    opacity: 1;
    visibility: visible;
}

/* El iframe del trailer - SIN CONTROLES */
.sp-trailer-iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

/* Estilo para cuando el trailer está cargando */
.sp-trailer-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sp-spin 0.8s linear infinite;
    z-index: 5;
}

@keyframes sp-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ============================================
   DURACIÓN BADGE (siempre visible)
============================================ */
.sp-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    font-weight: 500;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: 0.3px;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   INFORMACIÓN DEL CONTENIDO
============================================ */
.sp-content-info {
    padding: 10px 4px 0 4px;
}

.sp-content-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--sp-text-color);
    margin: 0 0 4px 0;
    line-height: 1.4;
    display: -webkit-box;
    display: box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 40px;
}

.sp-content-meta {
    margin-bottom: 3px;
}

.sp-content-original-title {
    font-size: 13px;
    color: var(--sp-text-dark);
    font-weight: 400;
    transition: color 0.2s;
}

.sp-movie-item:hover .sp-content-original-title,
.sp-series-item:hover .sp-content-original-title,
.sp-anime-item:hover .sp-content-original-title,
.sp-dorama-item:hover .sp-content-original-title,
.sp-telenovela-item:hover .sp-content-original-title {
    color: var(--sp-text-light);
}

.sp-content-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--sp-text-dark);
    flex-wrap: wrap;
}

.sp-content-views,
.sp-content-rating,
.sp-content-year {
    font-size: 13px;
    color: var(--sp-text-dark);
}

.sp-content-rating {
    color: #ffd700;
    font-weight: 500;
}

.sp-content-year {
    color: var(--sp-text-dark);
}

/* ============================================
   SEPARADOR
============================================ */
.sp-hr {
    border: none;
    height: 1px;
    width: 100%;
    margin: 8px 0 16px 0;
    background: var(--sp-border-color);
    border-radius: 0;
}

/* ============================================
   MENSAJE DE SIN CONTENIDO
============================================ */
.sp-no-content-message {
    color: var(--sp-text-dark);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
============================================ */

/* TABLET - 2 columnas */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .sp-posts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

/* MÓVIL - 1 columna */
@media screen and (max-width: 768px) {
    .sp-posts-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    
    .sp-section-title {
        font-size: 17px;
    }
    
    .sp-section-emoji {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
        padding: 4px;
    }
    
    .sp-section-emoji img {
        max-width: 14px;
        max-height: 14px;
    }
    
    .sp-thumbnail-wrapper {
        border-radius: 8px;
    }
    
    .sp-thumbnail-image {
        border-radius: 8px;
    }
    
    .sp-content-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: 36px;
    }
    
    .sp-content-original-title,
    .sp-content-views,
    .sp-content-rating,
    .sp-content-year {
        font-size: 12px;
    }
    
    .sp-duration-badge {
        font-size: 11px;
        padding: 1px 6px;
        bottom: 6px;
        right: 6px;
    }
}

/* En dispositivos táctiles, desactivar el hover del trailer */
@media (hover: none) {
    .sp-trailer-container {
        display: none !important;
    }
    
    .sp-thumbnail-image {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* MÓVIL PEQUEÑO - 1 columna */
@media screen and (max-width: 480px) {
    .sp-posts-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .sp-posts-section {
        padding: 12px 0;
    }
    
    .sp-section-title {
        font-size: 15px;
        gap: 6px;
    }
    
    .sp-section-emoji {
        width: 22px;
        height: 22px;
        min-width: 22px;
        min-height: 22px;
        padding: 3px;
    }
    
    .sp-section-emoji img {
        max-width: 12px;
        max-height: 12px;
    }
    
    .sp-content-info {
        padding: 8px 2px 0 2px;
    }
    
    .sp-content-title {
        font-size: 12px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: 34px;
    }
    
    .sp-content-original-title {
        font-size: 11px;
    }
    
    .sp-content-stats {
        font-size: 11px;
        gap: 4px;
    }
    
    .sp-content-views,
    .sp-content-rating,
    .sp-content-year {
        font-size: 11px;
    }
    
    .sp-duration-badge {
        font-size: 10px;
        padding: 1px 5px;
        bottom: 4px;
        right: 4px;
        border-radius: 3px;
    }
}

/* MÓVIL MUY PEQUEÑO - 1 columna */
@media screen and (max-width: 360px) {
    .sp-posts-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .sp-content-title {
        font-size: 11px;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: 30px;
    }
    
    .sp-content-original-title,
    .sp-content-views,
    .sp-content-rating,
    .sp-content-year {
        font-size: 10px;
    }
}

/* ============================================
   ANIMACIONES
============================================ */
.sp-movie-item,
.sp-series-item,
.sp-anime-item,
.sp-dorama-item,
.sp-telenovela-item {
    animation: fadeInUp 0.5s ease forwards;
    opacity: 0;
}

.sp-movie-item:nth-child(1),
.sp-series-item:nth-child(1),
.sp-anime-item:nth-child(1),
.sp-dorama-item:nth-child(1),
.sp-telenovela-item:nth-child(1) { animation-delay: 0.02s; }
.sp-movie-item:nth-child(2),
.sp-series-item:nth-child(2),
.sp-anime-item:nth-child(2),
.sp-dorama-item:nth-child(2),
.sp-telenovela-item:nth-child(2) { animation-delay: 0.04s; }
.sp-movie-item:nth-child(3),
.sp-series-item:nth-child(3),
.sp-anime-item:nth-child(3),
.sp-dorama-item:nth-child(3),
.sp-telenovela-item:nth-child(3) { animation-delay: 0.06s; }
.sp-movie-item:nth-child(4),
.sp-series-item:nth-child(4),
.sp-anime-item:nth-child(4),
.sp-dorama-item:nth-child(4),
.sp-telenovela-item:nth-child(4) { animation-delay: 0.08s; }
.sp-movie-item:nth-child(5),
.sp-series-item:nth-child(5),
.sp-anime-item:nth-child(5),
.sp-dorama-item:nth-child(5),
.sp-telenovela-item:nth-child(5) { animation-delay: 0.10s; }
.sp-movie-item:nth-child(6),
.sp-series-item:nth-child(6),
.sp-anime-item:nth-child(6),
.sp-dorama-item:nth-child(6),
.sp-telenovela-item:nth-child(6) { animation-delay: 0.12s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   BOTÓN DE FAVORITO (corazón) - overlay sobre cada tarjeta
   Se inyecta vía JS en cualquier .sp-movie-item / .sp-series-item / etc.
============================================================ */
.sp-movie-item,
.sp-series-item,
.sp-anime-item,
.sp-dorama-item,
.sp-telenovela-item,
.sp-list-card {
    position: relative;
}

.sp-fav-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 15;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 15, 15, 0.6);
    backdrop-filter: blur(2px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.2s var(--sp-ease), transform 0.15s var(--sp-ease), background 0.15s;
}

.sp-movie-item:hover .sp-fav-btn,
.sp-series-item:hover .sp-fav-btn,
.sp-anime-item:hover .sp-fav-btn,
.sp-dorama-item:hover .sp-fav-btn,
.sp-telenovela-item:hover .sp-fav-btn,
.sp-list-card:hover .sp-fav-btn,
.sp-fav-btn.active {
    opacity: 1;
}

.sp-fav-btn:hover {
    background: rgba(15, 15, 15, 0.85);
    transform: scale(1.08);
}

.sp-fav-btn.active {
    color: var(--sp-primary-color);
}

/* En táctil no hay hover: siempre visible pero discreto */
@media (hover: none) {
    .sp-fav-btn {
        opacity: 1;
        background: rgba(15, 15, 15, 0.5);
    }
}

/* Botón de quitar (X) - usado en Continuar viendo */
.sp-remove-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 15;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 15, 15, 0.6);
    backdrop-filter: blur(2px);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s var(--sp-ease), background 0.15s;
}

.sp-list-card:hover .sp-remove-btn {
    opacity: 1;
}

.sp-remove-btn:hover {
    background: rgba(220, 30, 30, 0.85);
}

@media (hover: none) {
    .sp-remove-btn {
        opacity: 1;
    }
}

/* Barra de progreso (Continuar viendo) */
.sp-progress-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.25);
    z-index: 12;
}

.sp-progress-fill {
    height: 100%;
    background: var(--sp-primary-color);
}

/* ============================================================
   SECCIONES DINÁMICAS (Continuar viendo / Mi Lista)
============================================================ */
.sp-clear-continue-btn {
    background: none;
    border: none;
    color: var(--sp-text-dark);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.sp-clear-continue-btn:hover {
    background: var(--sp-sidebar-hover);
    color: var(--sp-text-color);
}

.sp-empty-list-message {
    color: var(--sp-text-dark);
    font-size: 13px;
    padding: 20px 4px;
}

/* ============================================================
   TOAST - Notificación breve ("Añadido a Mi Lista", etc.)
============================================================ */
.sp-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translate(-50%, 16px);
    background: #fff;
    color: #0f0f0f;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--sp-ease), transform 0.2s var(--sp-ease);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 768px) {
    .sp-toast {
        bottom: 16px;
        font-size: 13px;
        padding: 10px 16px;
        max-width: 90%;
        text-align: center;
    }
}


/* ============================================================
   FORZAR 3 COLUMNAS COMO EN FRONT-PAGE
   (el grid genérico .sp-posts-grid puede estar siendo sobrescrito
   por otra regla del tema con más especificidad -p.ej. 6 columnas-,
   así que aquí se apunta directo al ID del contenedor de esta
   página para asegurar el mismo layout que en el front-page: 3
   columnas en escritorio, 2 en tablet y 1 en móvil)
============================================================ */
#movie-posts-container.sp-posts-grid,
#series-posts-container.sp-posts-grid,
#anime-posts-container.sp-posts-grid,
#dorama-posts-container.sp-posts-grid,
#telenovela-posts-container.sp-posts-grid,
#estrenos-posts-container.sp-posts-grid,
#k4-posts-container.sp-posts-grid,
#proximamente-posts-container.sp-posts-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 20px !important;
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    #movie-posts-container.sp-posts-grid,
    #series-posts-container.sp-posts-grid,
    #anime-posts-container.sp-posts-grid,
    #dorama-posts-container.sp-posts-grid,
    #telenovela-posts-container.sp-posts-grid,
    #estrenos-posts-container.sp-posts-grid,
    #k4-posts-container.sp-posts-grid,
    #proximamente-posts-container.sp-posts-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
}

@media screen and (max-width: 768px) {
    #movie-posts-container.sp-posts-grid,
    #series-posts-container.sp-posts-grid,
    #anime-posts-container.sp-posts-grid,
    #dorama-posts-container.sp-posts-grid,
    #telenovela-posts-container.sp-posts-grid,
    #estrenos-posts-container.sp-posts-grid,
    #k4-posts-container.sp-posts-grid,
    #proximamente-posts-container.sp-posts-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
}