/**
 * Acordeón Imagen
 * Desktop / tablet: acordeón horizontal.
 * Móvil: acordeón vertical con expansión por altura (1er toque) + 2º toque navega (JS).
 */

/* CONTENEDOR GENERAL (DESKTOP) */
.ai-horizontal-accordion {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 700px;
    max-height: 700px;
    overflow: hidden;
    position: relative;
}

/* CADA PANEL */
.ai-item {
    position: relative;
    flex: 1 1 0;
    min-height: 700px;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    filter: grayscale(100%);
    transition:
        flex 0.45s ease,
        filter 0.45s ease,
        transform 0.45s ease;
    cursor: pointer;
}

/* Capa oscura por defecto */
.ai-item::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    transition: background 0.45s ease;
    z-index: 1;
}

/* Item activo por ACF (estado inicial en color) */
.ai-item.ai-item-active {
    flex: 2.2;
    filter: grayscale(0%);
}

.ai-item.ai-item-active::before {
    background: rgba(0, 0, 0, 0.25);
}

/* Cuando el ratón entra en el contenedor: todos en BN (incluido el activo) */
.ai-horizontal-accordion:hover .ai-item {
    flex: 1 1 0;
    filter: grayscale(100%);
}

/* El panel hover se expande y pasa a color */
.ai-horizontal-accordion .ai-item:hover {
    flex: 3.2;
    filter: grayscale(0%);
}

.ai-horizontal-accordion .ai-item:hover::before {
    background: rgba(0, 0, 0, 0.25);
}

/* ENLACE INTERIOR */
.ai-item-link {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.ai-item-link--nolink {
    cursor: default;
}

/* TITULAR VERTICAL (DESKTOP) */
.ai-item-title {
    color: #ffffff;
    font-family: "Avenir", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;

    writing-mode: vertical-rl;
    text-orientation: mixed;

    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) rotate(180deg);

    font-size: 32px;
    padding: 0;
}

@media (min-width: 768px) {
    .ai-item-title { font-size: 42px; }
}

/* ===========================
   MÓVIL: vertical con expansión por altura
   =========================== */
@media (max-width: 767px) {

    .ai-horizontal-accordion {
        flex-direction: column;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        width: 100%;
        gap: 0;
    }

    /* Estado inicial más estrecho */
    .ai-item {
        flex: none !important;
        width: 100% !important;
        height: 160px !important;
        min-height: 160px !important;
        transition:
            height 0.45s ease,
            filter 0.35s ease;
    }

    /* Activo (solo si NO estamos en modo “touch expand” sobre otro) */
    .ai-item.ai-item-active {
        height: 300px !important;
        min-height: 300px !important;
        filter: grayscale(0%);
    }

    /* Si el acordeón tiene un item tocado (1er tap), el “activo” vuelve a estrecho y BN */
    .ai-horizontal-accordion.ai-has-touch .ai-item.ai-item-active {
        height: 160px !important;
        min-height: 160px !important;
        filter: grayscale(100%);
    }

    /* Expandido por 1er toque (clase puesta por JS) */
    .ai-item.ai-touched {
        height: 300px !important;
        min-height: 300px !important;
        filter: grayscale(0%);
    }

    .ai-item.ai-item-active::before,
    .ai-item.ai-touched::before {
        background: rgba(0, 0, 0, 0.25);
    }

    /* TITULAR horizontal móvil */
    .ai-item-title {
        writing-mode: horizontal-tb;
        text-orientation: initial;
        transform: none;

        font-size: 32px;
        text-align: left;

        left: 25px;
        right: 25px;
        bottom: 25px;
    }
}
