/* ===================================================================
   Grandes Historias - Layout Especial
   Post 1: Grande izquierda
   Posts 2-3: Abajo del post 1 (horizontal)
   Post 4: Pequeño arriba derecha
   Post 5: Grande abajo derecha
   =================================================================== */

/* Contenedor principal */
.kal-mx-grandes-historias {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 40px 0;
    box-sizing: border-box;
    --gm-grandes-historias-primary-color: #d32f2f;
    --gm-grandes-historias-secondary-color: #f5f5f5;
    --gm-grandes-historias-text-color: #333333;
    --border-radius: 12px;
    --gap: 16px;
}

.kal-mx-grandes-historias.no-posts {
    text-align: center;
    padding: 60px 20px;
    color: var(--gm-grandes-historias-text-color);
}

/* Grid principal: 2 columnas */
.historias-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--gap);
    width: 100%;
}

/* COLUMNA IZQUIERDA */
.historias-left-column {
    display: grid;
    grid-template-rows: 2fr 1fr;
    gap: var(--gap);
}

/* Post 1 - Historia principal grande */
.historia-main {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--gm-grandes-historias-secondary-color);
    min-height: 572px;
}

/* Posts 2 y 3 - Grid horizontal inferior */
.historias-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap);
}

.historia-bottom {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--gm-grandes-historias-secondary-color);
    min-height: 200px;
}

/* COLUMNA DERECHA */
.historias-right-column {
    display: grid;
    grid-template-rows: 1fr 2fr;
    gap: var(--gap);
}

/* Post 4 - Pequeño arriba */
.historia-small-right {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--gm-grandes-historias-secondary-color);
    min-height: 200px;
}

/* Post 5 - Grande abajo */
.historia-large-right {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius);
    background: var(--gm-grandes-historias-secondary-color);
    min-height: 450px;
}

/* Estilos comunes para todos los items */
.historia-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.historia-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.historia-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

/* Imagen de historia */
.historia-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: var(--border-radius);
}

.historia-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.historia-item:hover .historia-image img {
    transform: scale(1.08);
}

/* Overlay con gradiente */
.historia-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 50%, transparent 100%);
    transition: background 0.3s ease;
    border-radius: var(--border-radius);
}

.historia-item:hover .historia-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 60%, transparent 100%);
}

/* Contenido sobre la imagen */
.historia-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 24px;
    z-index: 2;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Tags */
.historia-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.historia-tag {
    font-family: var(--fuente-raleway);
    background: var(--gm-grandes-historias-primary-color);
    color: white;
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Títulos */
.historia-title {
    font-family: var(--fuente-raleway);
    font-weight: 700;
    line-height: 1.3;
    color: white;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.historia-date {
    font-family: var(--fuente-raleway);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-size: 12px;
}

.historia-date-extra {
    font-family: var(--fuente-raleway);
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
    font-size: 11px;
    font-style: italic;
    display: block;
    margin-top: 4px;
}

/* Post 1 - Historia principal */
.historia-main .historia-content {
    padding: 32px;
}

.historia-main .historia-title {
    font-size: 20px;
    -webkit-line-clamp: 3;
    max-height: calc(20px * 1.3 * 3);
}

.historia-main .historia-date {
    font-size: 12px;
}

/* Posts 2 y 3 - Inferior izquierda */
.historia-bottom .historia-content {
    padding: 20px;
}

.historia-bottom .historia-title {
    font-size: 14px;
    -webkit-line-clamp: 2;
    max-height: calc(14px * 1.3 * 2);
}

/* Post 4 - Pequeño derecha */
.historia-small-right .historia-content {
    padding: 20px;
}

.historia-small-right .historia-title {
    font-size: 14px;
    -webkit-line-clamp: 2;
    max-height: calc(14px * 1.3 * 2);
}

/* Post 5 - Grande derecha */
.historia-large-right .historia-content {
    padding: 28px;
}

.historia-large-right .historia-title {
    font-size: 16px;
    -webkit-line-clamp: 3;
    max-height: calc(16px * 1.3 * 3);
}

/* Paginación */
.historias-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 40px;
    padding-top: 0;
    border-top: none;
}

.pagination-button {
    font-family: var(--fuente-raleway);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0;
    border: 1px solid #d0d0d0 !important;
    background: #e8e8e8 !important;
    color: #666 !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
}

.pagination-button:hover {
    background: #d5d5d5 !important;
    border-color: #b0b0b0 !important;
    color: #333 !important;
    transform: none;
}

.pagination-button.active {
    background: white !important;
    background-color: white !important;
    color: #333 !important;
    border-color: #d0d0d0 !important;
}

.pagination-button svg {
    width: 14px;
    height: 14px;
}

/* Botones Anterior/Siguiente */
.prev-button,
.next-button {
    font-size: 14px;
    font-weight: 600;
    padding: 0 18px;
    width: auto;
    min-width: auto;
    gap: 6px;
    background: #e8e8e8;
    color: #666;
    border: 1px solid #d0d0d0;
}

.prev-button:hover,
.next-button:hover {
    background: #d5d5d5;
    border-color: #b0b0b0;
    color: #333;
}

.pagination-numbers {
    display: flex;
    gap: 6px;
}

/* Responsive Design */

/* Tablet (hasta 1024px) */
@media (max-width: 1024px) {
    .kal-mx-grandes-historias {
        padding: 30px 0;
        --gap: 12px;
    }

    .historia-main {
        min-height: 350px;
    }

    .historia-main .historia-content {
        padding: 24px;
    }

    .historia-main .historia-title {
        font-size: 18px;
        -webkit-line-clamp: 3;
        max-height: calc(18px * 1.3 * 3);
    }

    .historia-bottom {
        min-height: 160px;
    }

    .historia-bottom .historia-content {
        padding: 16px;
    }

    .historia-bottom .historia-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        max-height: calc(13px * 1.3 * 2);
    }

    .historia-small-right {
        min-height: 160px;
    }

    .historia-small-right .historia-content {
        padding: 16px;
    }

    .historia-small-right .historia-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        max-height: calc(13px * 1.3 * 2);
    }

    .historia-large-right {
        min-height: 350px;
    }

    .historia-large-right .historia-content {
        padding: 24px;
    }

    .historia-large-right .historia-title {
        font-size: 15px;
        -webkit-line-clamp: 3;
        max-height: calc(15px * 1.3 * 3);
    }
}

/* Mobile (hasta 768px) - Stack vertical */
@media (max-width: 768px) {
    .kal-mx-grandes-historias {
        padding: 20px 0;
        --gap: 12px;
    }

    .historias-grid {
        grid-template-columns: 1fr;
    }

    .historias-left-column {
        grid-template-rows: auto;
    }

    .historia-main {
        min-height: 320px;
    }

    .historia-main .historia-content {
        padding: 20px;
    }

    .historia-main .historia-title {
        font-size: 18px;
        -webkit-line-clamp: 3;
        max-height: calc(18px * 1.3 * 3);
    }

    .historias-bottom-grid {
        grid-template-columns: 1fr;
    }

    .historia-bottom {
        min-height: 220px;
    }

    .historias-right-column {
        grid-template-rows: auto;
    }

    .historia-small-right {
        min-height: 220px;
    }

    .historia-large-right {
        min-height: 280px;
    }

    .historia-large-right .historia-title {
        font-size: 16px;
        -webkit-line-clamp: 3;
        max-height: calc(16px * 1.3 * 3);
    }

    .historias-pagination {
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 40px;
    }

    .pagination-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .pagination-numbers {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    .prev-button,
    .next-button {
        flex: 1;
    }
}

/* Mobile pequeño (hasta 480px) */
@media (max-width: 480px) {
    .kal-mx-grandes-historias {
        --border-radius: 8px;
    }

    .historia-main {
        min-height: 280px;
    }

    .historia-main .historia-content {
        padding: 16px;
    }

    .historia-main .historia-title {
        font-size: 16px;
        -webkit-line-clamp: 3;
        max-height: calc(16px * 1.3 * 3);
    }

    .historia-bottom {
        min-height: 200px;
    }

    .historia-bottom .historia-content,
    .historia-small-right .historia-content {
        padding: 14px;
    }

    .historia-bottom .historia-title,
    .historia-small-right .historia-title {
        font-size: 13px;
        -webkit-line-clamp: 2;
        max-height: calc(13px * 1.3 * 2);
    }

    .historia-large-right {
        min-height: 240px;
    }

    .historia-large-right .historia-content {
        padding: 16px;
    }

    .historia-large-right .historia-title {
        font-size: 14px;
        -webkit-line-clamp: 2;
        max-height: calc(14px * 1.3 * 2);
    }

    .historia-tag {
        font-size: 10px;
        padding: 4px 10px;
    }

    .historia-date {
        font-size: 11px;
    }

    .historia-date-extra {
        font-size: 10px;
        margin-top: 3px;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.historia-item {
    animation: fadeIn 0.6s ease-out forwards;
    opacity: 0;
}

.historia-main {
    animation-delay: 0.1s;
}

.historias-bottom-grid .historia-bottom:nth-child(1) {
    animation-delay: 0.2s;
}

.historias-bottom-grid .historia-bottom:nth-child(2) {
    animation-delay: 0.3s;
}

.historia-small-right {
    animation-delay: 0.2s;
}

.historia-large-right {
    animation-delay: 0.3s;
}