/* =============================================
   IPS Beta 3 — Publicaciones / Biblioteca Digital
   Diseño "Digital Library"
   ============================================= */

/* === NAV ACTIVO === */
.main-nav a.nav-current {
    color: var(--primary);
    background: var(--primary-50);
}

.main-nav a.nav-current::after {
    transform: translateX(-50%) scaleX(1);
}

/* ================================================================
   VARIABLES DE TIPO DE ARCHIVO
   ================================================================ */
:root {
    --pdf-color: #dc2626;
    --pdf-bg: #fef2f2;
    --word-color: #2563eb;
    --word-bg: #eff6ff;
    --excel-color: #16a34a;
    --excel-bg: #f0fdf4;
    --link-color: #7c3aed;
    --link-bg: #f5f3ff;
}

/* ================================================================
   HERO
   ================================================================ */
.pub-hero {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    margin-top: var(--header-height);
    overflow: hidden;
    background: linear-gradient(150deg, #0d1f0b 0%, #1a3318 35%, #243f21 70%, #2d5a27 100%);
    padding: 80px 24px 110px;
}

/* Patrón de líneas diagonal */
.pub-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(-45deg,
            transparent,
            transparent 40px,
            rgba(255, 255, 255, 0.015) 40px,
            rgba(255, 255, 255, 0.015) 41px);
}

.pub-hero-glow {
    position: absolute;
    bottom: -80px;
    right: -60px;
    width: 460px;
    height: 460px;
    background: radial-gradient(circle, rgba(74, 158, 63, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.pub-hero-content {
    position: relative;
    z-index: 2;
    max-width: var(--max-width);
    margin: 0 auto;
    width: 100%;
}

.pub-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 22px;
    font-size: 0.8rem;
}

.pub-breadcrumb a {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
    transition: var(--transition);
}

.pub-breadcrumb a:hover {
    color: #fff;
}

.pub-breadcrumb span {
    color: rgba(255, 255, 255, 0.4);
}

.pub-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 5px 14px 5px 10px;
    border-radius: 50px;
    margin-bottom: 18px;
    backdrop-filter: blur(10px);
}

.pub-hero-eyebrow svg {
    opacity: 0.8;
}

.pub-hero-title {
    font-family: var(--font-serif);
    font-size: clamp(2.2rem, 5vw, 3.4rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.12;
    margin-bottom: 16px;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.pub-hero-desc {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.75;
    max-width: 580px;
    font-weight: 300;
    margin-bottom: 36px;
}

/* Stats inline */
.pub-hero-stats {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}

.pub-stat {
    display: flex;
    flex-direction: column;
    padding: 0 28px;
}

.pub-stat:first-child {
    padding-left: 0;
}

.pub-stat strong {
    font-family: var(--font-serif);
    font-size: 1.9rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}

.pub-stat span {
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 3px;
}

.pub-stat-sep {
    width: 1px;
    height: 36px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 4px;
}

/* Wave */
.pub-hero-wave {
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 80px;
    z-index: 2;
}

.pub-hero-wave svg {
    width: 100%;
    height: 100%;
}

/* ================================================================
   TOOLBAR: BÚSQUEDA + FILTROS
   ================================================================ */
.pub-toolbar {
    background: var(--white);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 20px 24px;
    position: sticky;
    top: var(--header-height);
    z-index: 40;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}

.pub-toolbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Búsqueda */
.pub-search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
    max-width: 380px;
}

.pub-search-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    pointer-events: none;
}

.pub-search-input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border: 1.5px solid var(--gray-200);
    border-radius: 50px;
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text-primary);
    background: var(--gray-50);
    transition: var(--transition);
}

.pub-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Conteo de resultados */
.pub-count {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.pub-count strong {
    color: var(--text-primary);
}

/* Filtros por tipo/categoría */
.pub-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-left: auto;
}

.pub-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: 50px;
    background: var(--white);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.pub-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.pub-filter-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pub-filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* ================================================================
   LISTADO DE PUBLICACIONES
   ================================================================ */
.pub-section {
    background: var(--off-white);
    padding: 48px 24px 80px;
    min-height: 400px;
}

.pub-section-inner {
    max-width: var(--max-width);
    margin: 0 auto;
}

/* Estado vacío / sin resultados */
.pub-empty {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
    display: none;
}

.pub-empty svg {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    opacity: 0.35;
}

.pub-empty p {
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ================================================================
   TARJETA DE PUBLICACIÓN
   ================================================================ */
.pub-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: stretch;
    overflow: hidden;
    transition: var(--transition);
    margin-bottom: 16px;
    position: relative;
}

.pub-card:last-child {
    margin-bottom: 0;
}

.pub-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: transparent;
}

/* Strip + Icon de tipo */
.pub-card-type {
    width: 80px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.pub-card-type::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.pub-card.type-pdf .pub-card-type {
    background: var(--pdf-bg);
    color: var(--pdf-color);
}

.pub-card.type-word .pub-card-type {
    background: var(--word-bg);
    color: var(--word-color);
}

.pub-card.type-excel .pub-card-type {
    background: var(--excel-bg);
    color: var(--excel-color);
}

.pub-card.type-link .pub-card-type {
    background: var(--link-bg);
    color: var(--link-color);
}

.pub-card.type-pdf::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--pdf-color);
}

.pub-card.type-word::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--word-color);
}

.pub-card.type-excel::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--excel-color);
}

.pub-card.type-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--link-color);
}

.pub-type-icon {
    width: 36px;
    height: 36px;
}

.pub-type-badge {
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
}

/* Cuerpo */
.pub-card-body {
    flex: 1;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pub-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pub-card-year {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 50px;
}

.pub-card-cat {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 0.3px;
}

.pub-card-title {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pub-card-desc {
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Acción de descarga */
.pub-card-action {
    width: 140px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px;
    border-left: 1px solid rgba(0, 0, 0, 0.05);
}

.pub-download-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
    border: 2px solid transparent;
    text-align: center;
    cursor: pointer;
    text-decoration: none;
    min-width: 90px;
}

.pub-download-btn svg {
    width: 22px;
    height: 22px;
    transition: var(--transition);
}

.pub-download-btn:hover svg {
    transform: translateY(2px);
}

.pub-download-btn:hover {
    transform: scale(1.04);
}

.type-pdf .pub-download-btn {
    background: var(--pdf-bg);
    color: var(--pdf-color);
    border-color: rgba(220, 38, 38, 0.2);
}

.type-word .pub-download-btn {
    background: var(--word-bg);
    color: var(--word-color);
    border-color: rgba(37, 99, 235, 0.2);
}

.type-excel .pub-download-btn {
    background: var(--excel-bg);
    color: var(--excel-color);
    border-color: rgba(22, 163, 74, 0.2);
}

.type-link .pub-download-btn {
    background: var(--link-bg);
    color: var(--link-color);
    border-color: rgba(124, 58, 237, 0.2);
}

.type-pdf .pub-download-btn:hover {
    background: var(--pdf-color);
    color: #fff;
}

.type-word .pub-download-btn:hover {
    background: var(--word-color);
    color: #fff;
}

.type-excel .pub-download-btn:hover {
    background: var(--excel-color);
    color: #fff;
}

.type-link .pub-download-btn:hover {
    background: var(--link-color);
    color: #fff;
}

/* Sin archivo → badge desactivado */
.pub-download-btn.no-file {
    opacity: 0.4;
    pointer-events: none;
    cursor: default;
    background: var(--gray-100);
    color: var(--text-muted);
    border-color: transparent;
}

/* ================================================================
   CTA
   ================================================================ */
.pub-cta {
    background: linear-gradient(135deg, #0d2b0a 0%, #2d5a27 55%, #3a7a33 100%);
    padding: 72px 24px;
    position: relative;
    overflow: hidden;
}

.pub-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 70% 50%, rgba(143, 214, 133, 0.1) 0%, transparent 60%);
}

.pub-cta-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.pub-cta-text h2 {
    font-family: var(--font-serif);
    font-size: clamp(1.4rem, 3vw, 1.9rem);
    font-weight: 600;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.3;
}

.pub-cta-text p {
    font-size: 0.93rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.7;
    max-width: 460px;
}

.pub-cta-actions {
    display: flex;
    gap: 14px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.pub-cta-btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 30px;
    background: #fff;
    color: var(--primary);
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: 0.9rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.pub-cta-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.pub-cta-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 26px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius-xl);
    font-weight: 600;
    font-size: 0.86rem;
    transition: var(--transition);
}

.pub-cta-btn-secondary:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
    .pub-tool-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .pub-search-wrap {
        max-width: 100%;
    }

    .pub-filters {
        margin-left: 0;
    }

    .pub-card {
        flex-direction: column;
    }

    .pub-card-type {
        flex-direction: row;
        width: auto;
        padding: 14px 18px;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        gap: 10px;
    }

    .pub-card::before {
        width: 100% !important;
        height: 4px !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: auto !important;
    }

    .pub-card-action {
        width: auto;
        border-left: none;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        padding: 14px 18px;
        justify-content: flex-start;
    }

    .pub-download-btn {
        flex-direction: row;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .pub-hero {
        padding: 60px 18px 90px;
    }

    .pub-hero-stats {
        flex-wrap: wrap;
        gap: 6px;
    }

    .pub-stat {
        padding: 0 14px;
    }

    .pub-cta-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .pub-cta-actions {
        flex-direction: column;
        width: 100%;
    }

    .pub-cta-btn-primary,
    .pub-cta-btn-secondary {
        width: 100%;
        justify-content: center;
    }
}