/* ==========================================================================
   Componente: At-a-Glance Responsive Timeline con Acordeones
   Inspirado en Grzegorz Rogala (CodePen gOZOExd) adaptado para ISMX IA
   ========================================================================== */

.ismx-tl-container {
    max-width: 1100px;
    margin: 0 auto;
    position: relative;
}

/* Eje central vertical (línea discontinua) */
.ismx-main-timeline {
    position: relative;
    padding: 20px 0;
}

.ismx-main-timeline::after {
    content: "";
    position: absolute;
    width: 2px;
    border-left: 2px dashed #cbd5e1;
    top: 0;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

/* Contenedor del elemento de línea de tiempo */
.ismx-tl-item {
    position: relative;
    width: 50%;
    margin-bottom: 35px;
    z-index: 2;
}

/* Elementos a la izquierda */
.ismx-tl-left {
    left: 0;
    padding-right: 48px;
    padding-left: 10px;
}

/* Elementos a la derecha */
.ismx-tl-right {
    left: 50%;
    padding-left: 48px;
    padding-right: 10px;
}

/* Nodo central con ícono en el eje */
.ismx-tl-node {
    position: absolute;
    top: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid var(--node-accent, #0284c7);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 3;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.ismx-tl-left .ismx-tl-node {
    right: -22px;
}

.ismx-tl-right .ismx-tl-node {
    left: -22px;
}

.ismx-tl-item:hover .ismx-tl-node {
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Tarjeta de contenido */
.ismx-tl-card {
    background: #ffffff;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
}

/* Orígenes de transformación para escalar desde el eje de la línea de tiempo */
.ismx-tl-left .ismx-tl-card {
    transform-origin: 100% 0%;
}

.ismx-tl-right .ismx-tl-card {
    transform-origin: 0% 0%;
}

/* 1. Animaciones Scroll-Driven Nativas (Chrome 115+, Edge) */
@supports (animation-timeline: view()) {
    .ismx-tl-card {
        animation: ismx-tl-fade-scale linear forwards;
        animation-timeline: view();
        animation-range: entry 5% cover 32%;
    }

    .ismx-tl-node {
        animation: ismx-tl-node-pop linear forwards;
        animation-timeline: view();
        animation-range: entry 5% cover 25%;
    }
}

@keyframes ismx-tl-fade-scale {
    from {
        opacity: 0;
        transform: scale(0.65);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes ismx-tl-node-pop {
    from {
        opacity: 0;
        transform: scale(0.3);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 2. Fallback con IntersectionObserver (Safari, Firefox) */
.ismx-tl-no-scroll-timeline .ismx-tl-observe .ismx-tl-card {
    opacity: 0;
    transform: scale(0.75);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ismx-tl-no-scroll-timeline .ismx-tl-observe .ismx-tl-node {
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1), transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.ismx-tl-no-scroll-timeline .ismx-tl-observe.is-visible .ismx-tl-card,
.ismx-tl-no-scroll-timeline .ismx-tl-observe.is-visible .ismx-tl-node {
    opacity: 1;
    transform: scale(1);
}

.ismx-tl-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08) !important;
}

/* Flecha de conexión tarjeta -> nodo */
.ismx-tl-left .ismx-tl-card::before {
    content: "";
    position: absolute;
    top: 36px;
    right: -8px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    border-right: 1px solid rgba(226, 232, 240, 0.8);
    transform: rotate(45deg);
    z-index: 1;
}

.ismx-tl-right .ismx-tl-card::before {
    content: "";
    position: absolute;
    top: 36px;
    left: -8px;
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    border-left: 1px solid rgba(226, 232, 240, 0.8);
    transform: rotate(45deg);
    z-index: 1;
}

/* Acordeón y animaciones */
.ismx-accordion-toggle {
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s ease;
}

.ismx-accordion-toggle .ismx-chevron {
    transition: transform 0.25s ease;
}

.ismx-accordion-toggle[aria-expanded="false"] .ismx-chevron {
    transform: rotate(-90deg);
}

.ismx-accordion-toggle[aria-expanded="false"] .toggle-text-open {
    display: none !important;
}

.ismx-accordion-toggle[aria-expanded="false"] .toggle-text-closed {
    display: inline !important;
}

/* ==========================================================================
   Adaptación Móvil (Responsive < 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* El eje vertical se desplaza hacia la izquierda */
    .ismx-main-timeline::after {
        left: 24px;
        transform: none;
    }

    /* Todos los items abarcan el 100% de ancho */
    .ismx-tl-item {
        width: 100% !important;
        left: 0 !important;
        padding-left: 65px !important;
        padding-right: 15px !important;
        margin-bottom: 28px;
    }

    /* Todos los nodos se alinean al eje izquierdo */
    .ismx-tl-node {
        left: 3px !important;
        right: auto !important;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    /* En móviles el origen de transformación es la esquina superior izquierda (hacia el eje) */
    .ismx-tl-card {
        transform-origin: 0% 0% !important;
    }

    /* Todas las flechas apuntan hacia la izquierda */
    .ismx-tl-left .ismx-tl-card::before,
    .ismx-tl-right .ismx-tl-card::before {
        right: auto !important;
        left: -8px !important;
        border-top: none;
        border-right: none;
        border-bottom: 1px solid rgba(226, 232, 240, 0.8);
        border-left: 1px solid rgba(226, 232, 240, 0.8);
    }
}
