/*
 * Blog Archive — Efecto Parallax 3D
 * Fiel al CodePen: https://codepen.io/cmlohr/pen/ExNqyXR
 */

/* ─── Cabecera del archivo ───────────────────────────────────── */
.blog-archive-header {
    margin-bottom: 1.6rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.blog-archive-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 48px;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
}

.blog-archive-title {
    font-size: clamp(1.3rem, 2.2vw, 1.9rem);
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    line-height: 1.2;
}

.blog-archive-label {
    font-weight: 400;
    color: #94a3b8;
    font-size: .85em;
    margin-right: .3rem;
}

.blog-archive-description {
    margin: .5rem 0 0;
    color: #475569;
    font-size: .9rem;
}

/* ─── Cuadrícula: 3 columnas ─────────────────────────────────── */
/* Forzar 3 columnas en el contenedor de GeneratePress */
#primary .blog-cards-grid,
.site-main .blog-cards-grid,
.content-area .blog-cards-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px;
    margin-bottom: 2rem;
    width: 100%;
}

@media (max-width: 768px) {
    #primary .blog-cards-grid,
    .site-main .blog-cards-grid,
    .content-area .blog-cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 480px) {
    #primary .blog-cards-grid,
    .site-main .blog-cards-grid,
    .content-area .blog-cards-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ─── .card-wrap: contenedor con perspectiva 3D ──────────────── */
.card-wrap {
    position: relative;
    min-width: 0;
    cursor: pointer;
    transform: perspective(1200px);
    transform-style: preserve-3d;
}

/* ─── Estados hover de card-wrap ────────────────────────────── */

/* imagen: opacity 1 y brillo al hover */
.card-wrap:hover .card-bg {
    opacity: 1;
    filter: brightness(1.05);
    transition: opacity .5s ease,
                filter .5s cubic-bezier(0.23, 1, 0.32, 1),
                transform .5s cubic-bezier(0.23, 1, 0.32, 1);
}

/* hover: mantener solo borde inset */
.card-wrap:hover .card {
    transition: box-shadow .5s cubic-bezier(0.23, 1, 0.32, 1);
    box-shadow:
        inset #333 0 0 0 5px,
        inset rgba(255, 255, 255, 0.4) 0 0 0 6px;
}

/* categoría: aparece en hover */
.card-wrap:hover .card-category {
    opacity: 1;
    transform: translateY(0);
    transition: opacity .35s ease .05s, transform .35s ease .05s;
}

/* extracto: aparece en hover */
.card-wrap:hover .card-excerpt {
    opacity: 1;
    transform: translateY(0);
    max-height: 100px;
    margin-top: 7px;
    transition:
        opacity .4s ease .1s,
        transform .4s ease .1s,
        max-height .45s ease,
        margin-top .3s ease;
}

/* ─── .card: elemento 3D rotante ────────────────────────────── */
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background-color: #111;
    overflow: hidden;
    border-radius: 6px;

    /* Solo borde inset — sin sombra exterior */
    box-shadow:
        inset #333 0 0 0 5px,
        inset rgba(255, 255, 255, 0.4) 0 0 0 6px;

    transition: box-shadow .8s cubic-bezier(0.445, 0.05, 0.55, 0.95);
}

/* ─── Enlace overlay — FUERA del .card 3D, recibe clicks ─────── */
.card-permalink {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    border-radius: 6px;
    color: transparent;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ─── .card-bg: imagen de fondo con parallax ─────────────────── */
.card-bg {
    opacity: 0.88;             /* reposo — hover: 1 */
    position: absolute;
    top: -20px;
    left: -20px;
    width: calc(100% + 40px);
    height: calc(100% + 40px);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    transition:
        opacity .5s ease,
        filter  .8s cubic-bezier(0.445, 0.05, 0.55, 0.95),
        transform .8s cubic-bezier(0.445, 0.05, 0.55, 0.95);
    pointer-events: none;
    will-change: transform;
}

/* Card sin imagen: gradiente de fondo */
.card--no-image .card-bg {
    background-image: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* ─── Gradiente sutil solo en la zona del texto ───────────────── */
/*
 * Mínimo oscurecimiento — solo donde está el título para legibilidad.
 * La imagen se ve clara en el resto de la tarjeta.
 */
.card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 45%;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.25) 60%,
        rgba(0, 0, 0, 0.65) 100%
    );
    z-index: 2;
    pointer-events: none;
    border-radius: 0 0 6px 6px;
}

/* ─── .card-info: panel de texto — translateZ para quedar delante del card 3D ─ */
.card-info {
    padding: 14px 16px 16px;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    color: #fff;
    z-index: 2;
    transform: translateZ(60px);   /* por encima del card rotado */
}

/* ─── Categoría: oculta en reposo, aparece en hover ─────────── */
.card-category {
    display: inline-block;
    padding: 2px 10px;
    background: #000;
    color: #fff;
    border-radius: 50px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-decoration: none;
    margin-bottom: 5px;

    /* Oculta en reposo */
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease;
}

.card-category:hover {
    background: #000 !important;
    color: #fff !important;
}

/* ─── Título: sombra densa para contraste sobre fondos claros ─── */
.card-title {
    font-family: 'Raleway', sans-serif;
    font-size: clamp(.85rem, 1.5vw, 1.15rem);
    font-weight: 700;
    line-height: 1.28;
    text-shadow:
        0 0 2px rgba(0, 0, 0, 1),
        0 0 4px rgba(0, 0, 0, 0.95),
        0 1px 3px rgba(0, 0, 0, 0.9),
        0 2px 6px rgba(0, 0, 0, 0.85),
        0 4px 12px rgba(0, 0, 0, 0.8);
    margin: 0;
    color: #fff;

    /* Máx 2 líneas para mantener proporciones */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-title a {
    color: #fff;
    text-decoration: none;
    transition: opacity .2s ease;
}

.card-title a:hover {
    opacity: 1;
    color: #fff !important;   /* no cambiar color al pasar el mouse */
}

/* ─── Extracto: oculto en reposo, aparece en hover ──────────── */
.card-excerpt {
    font-size: .78rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    margin: 0;

    /* Oculto en reposo */
    opacity: 0;
    transform: translateY(6px);
    max-height: 0;
    overflow: hidden;
    transition:
        opacity .25s ease,
        transform .25s ease,
        max-height .3s ease,
        margin-top .2s ease;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ─── Sin publicaciones ──────────────────────────────────────── */
.blog-no-posts {
    color: #64748b;
    padding: 2rem 0;
    text-align: center;
}

/* ─── Paginación ─────────────────────────────────────────────── */
.blog-archive-pagination {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.blog-archive-pagination .nav-links {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    justify-content: center;
}

.blog-archive-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 .7rem;
    border-radius: 7px;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    transition: background .2s, color .2s, box-shadow .2s, transform .2s;
}

.blog-archive-pagination .page-numbers:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102,126,234,.4);
    transform: translateY(-1px);
}

.blog-archive-pagination .page-numbers.current {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102,126,234,.4);
}

/* ─── Accesibilidad: focus visible ──────────────────────────── */
.card-permalink:focus-visible,
.card-title a:focus-visible,
.card-category:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 3px;
}

/* ─── Responsive: móvil y tablet ───────────────────────────────── */
@media (max-width: 768px) {
    .blog-archive-header {
        margin-bottom: 1.2rem;
        padding-bottom: 0.8rem;
    }

    .blog-cards-grid {
        gap: 12px;
        margin-bottom: 1.5rem;
    }

    .card-wrap {
        transform: none;
        transform-style: flat;
        perspective: none;
    }

    .card-info {
        transform: none;
        padding: 12px 14px 14px;
    }

    /* Mostrar categoría y extracto siempre — sin hover en touch */
    .card-category {
        opacity: 1;
        transform: translateY(0);
    }

    .card-excerpt {
        opacity: 1;
        transform: translateY(0);
        max-height: 80px;
        margin-top: 6px;
    }

    .card-title {
        font-size: clamp(.9rem, 4vw, 1.1rem);
    }

    .card-excerpt {
        font-size: .8rem;
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 480px) {
    .blog-cards-grid {
        gap: 16px;
        margin-bottom: 1.5rem;
    }

    .card-info {
        padding: 14px 16px 16px;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-excerpt {
        font-size: .82rem;
        max-height: 90px;
    }

    /* Área táctil mínima 44px para accesibilidad */
    .card-permalink {
        min-height: 44px;
    }
}

/* Dispositivos sin hover (touch) — mostrar todo el contenido siempre */
@media (hover: none) {
    .card-wrap {
        transform: none;
        transform-style: flat;
        perspective: none;
    }

    .card-info {
        transform: none;
    }

    .card-category {
        opacity: 1;
        transform: translateY(0);
    }

    .card-excerpt {
        opacity: 1;
        transform: translateY(0);
        max-height: 90px;
        margin-top: 6px;
    }

    /* Imagen siempre al 100% en touch */
    .card-bg {
        opacity: 1;
    }
}

/* ─── Sin movimiento ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .card,
    .card-bg,
    .card-info,
    .card-category,
    .card-excerpt {
        transition: none !important;
        animation: none !important;
    }

    .card-wrap:hover .card-category {
        opacity: 1 !important;
        transform: translateY(0) !important;
    }

    .card-wrap:hover .card-excerpt {
        opacity: 1 !important;
        transform: translateY(0) !important;
        max-height: 100px !important;
        margin-top: 7px !important;
    }
}
