/*
 * ============================================================
 *  Simplest Theme — Most Viewed Widget + Sticky Sidebar
 *  Archivo: /wp-content/themes/simplest/most-viewed.css
 * ============================================================
 */

/* ──────────────────────────────────────────────────────────
   STICKY SIDEBAR — hace que el sidebar se quede fijo
   al hacer scroll
   ────────────────────────────────────────────────────────── */
.sp-sidebar {
    align-self: flex-start;
    position: relative; /* JS se encarga del sticky */
}

/* Clase que JS aplica cuando el widget debe quedar fijo */
.sp-mv-widget--fixed {
    position: fixed !important;
    top: 20px !important;  /* pequeño margen desde el borde superior */
    width: 280px !important;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #e52a32 #f0f0f0;
    z-index: 50;
}

/* Clase que JS aplica cuando el widget llega al final del contenido */
.sp-mv-widget--bottom {
    position: absolute !important;
    bottom: 0;
    top: auto !important;
}

/* Webkit scrollbar fino */
.sp-sidebar::-webkit-scrollbar       { width: 3px; }
.sp-sidebar::-webkit-scrollbar-track { background: #f0f0f0; border-radius: 2px; }
.sp-sidebar::-webkit-scrollbar-thumb { background: #e52a32; border-radius: 2px; }

/* ──────────────────────────────────────────────────────────
   WIDGET CONTAINER
   ────────────────────────────────────────────────────────── */
.sp-mv-widget {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06), 0 8px 28px rgba(0,0,0,.08);
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
}

/* ──────────────────────────────────────────────────────────
   HEADER
   ────────────────────────────────────────────────────────── */
.sp-mv-widget__header {
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.sp-mv-widget__accent {
    display: inline-block;
    width: 4px;
    height: 20px;
    background: #e52a32;
    border-radius: 2px;
    flex-shrink: 0;
}

.sp-mv-widget__title {
    font-size: .82rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #0d0d0d;
    margin: 0;
}

/* ──────────────────────────────────────────────────────────
   LIST
   ────────────────────────────────────────────────────────── */
.sp-mv-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

/* ──────────────────────────────────────────────────────────
   ITEM
   ────────────────────────────────────────────────────────── */
.sp-mv-item {
    border-bottom: 1px solid #f5f5f5;
}

.sp-mv-item:last-child {
    border-bottom: none;
}

.sp-mv-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    transition: background .18s ease;
    position: relative;
}

.sp-mv-link:hover {
    background: #fafafa;
}

/* Línea roja de hover a la izquierda */
.sp-mv-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: #e52a32;
    border-radius: 0 2px 2px 0;
    transform: scaleY(0);
    transform-origin: center;
    transition: transform .22s cubic-bezier(.4,0,.2,1);
}

.sp-mv-link:hover::before {
    transform: scaleY(1);
}

/* ──────────────────────────────────────────────────────────
   RANKING NUMBER
   ────────────────────────────────────────────────────────── */
.sp-mv-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: -.02em;
    flex-shrink: 0;
    background: #f5f5f5;
    color: #aaa;
    transition: background .18s, color .18s;
}

/* Top 3 — destacados en rojo */
.sp-mv-rank--top {
    background: rgba(229,42,50,.10);
    color: #e52a32;
}

.sp-mv-item:nth-child(1) .sp-mv-rank--top {
    background: #e52a32;
    color: #ffffff;
}

.sp-mv-link:hover .sp-mv-rank {
    background: #e52a32;
    color: #ffffff;
}

/* ──────────────────────────────────────────────────────────
   THUMBNAIL
   ────────────────────────────────────────────────────────── */
.sp-mv-thumb {
    width: 58px;
    height: 52px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f0f0f0;
}

.sp-mv-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .4s cubic-bezier(.4,0,.2,1);
}

.sp-mv-link:hover .sp-mv-img {
    transform: scale(1.08);
}

/* Placeholder sin imagen */
.sp-mv-thumb--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
}

/* ──────────────────────────────────────────────────────────
   TEXT META
   ────────────────────────────────────────────────────────── */
.sp-mv-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;         /* evita overflow del texto */
    flex: 1;
}

.sp-mv-post-title {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.35;
    color: #0d0d0d;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .18s;
}

.sp-mv-link:hover .sp-mv-post-title {
    color: #e52a32;
}

.sp-mv-date {
    font-size: .68rem;
    color: #aaa;
    white-space: nowrap;
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVE
   ────────────────────────────────────────────────────────── */

/* En tablet: sidebar pasa abajo, sticky se desactiva */
@media (max-width: 1023px) {
    .sp-sidebar {
        position: static;
        max-height: none;
        overflow: visible;
    }

    .sp-mv-widget {
        border-radius: 14px;
    }

    /* Lista horizontal en tablet */
    .sp-mv-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0;
        padding: 4px 0;
    }

    .sp-mv-item {
        border-bottom: 1px solid #f5f5f5;
        border-right: 1px solid #f5f5f5;
    }

    .sp-mv-item:nth-child(even) {
        border-right: none;
    }
}

/* En móvil: una columna */
@media (max-width: 640px) {
    .sp-mv-list {
        grid-template-columns: 1fr;
    }

    .sp-mv-item {
        border-right: none;
    }
}

/* ──────────────────────────────────────────────────────────
   ANIMACIÓN DE ENTRADA
   ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
    .sp-mv-item {
        animation: mvFadeIn .4s cubic-bezier(.4,0,.2,1) both;
    }

    .sp-mv-item:nth-child(1) { animation-delay: .05s; }
    .sp-mv-item:nth-child(2) { animation-delay: .10s; }
    .sp-mv-item:nth-child(3) { animation-delay: .15s; }
    .sp-mv-item:nth-child(4) { animation-delay: .20s; }
    .sp-mv-item:nth-child(5) { animation-delay: .25s; }
    .sp-mv-item:nth-child(6) { animation-delay: .30s; }

    @keyframes mvFadeIn {
        from { opacity: 0; transform: translateX(10px); }
        to   { opacity: 1; transform: translateX(0); }
    }
}




/*
 * ── PATCH: Agregar al final de most-viewed.css ──────────────────
 * Corrige los estilos de ranking (top 1 vs top 2-3)
 */

/* Rank base */
.sp-mv-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: -.02em;
    flex-shrink: 0;
    background: #f5f5f5;
    color: #bbb;
    transition: background .18s, color .18s;
}

/* Puesto 1 — rojo sólido */
.sp-mv-rank--top1 {
    background: #e52a32 !important;
    color: #ffffff !important;
}

/* Puestos 2 y 3 — rojo claro */
.sp-mv-rank--top {
    background: rgba(229,42,50,.10);
    color: #e52a32;
}

/* Hover sobre cualquier rank */
.sp-mv-link:hover .sp-mv-rank {
    background: #e52a32 !important;
    color: #ffffff !important;
}