/* ==========================================================================
 * Widget: Timeline
 * BEM naming: .wb-timeline, .wb-timeline__element, .wb-timeline__element--modifier
 * All colours use CSS variables from Elementor global tokens or geniova.css.
 * ========================================================================== */

/* ---------- Custom properties (overridable via Elementor style controls) -- */
.wb-timeline {
    --wb-timeline-line-color: var(--e-global-color-37c837c, #0B0006);
    --wb-timeline-fill-color: var(--e-global-color-416b38f, #DF006E);
    --wb-timeline-circle-color: var(--e-global-color-416b38f, #DF006E);
    --wb-timeline-card-bg: var(--e-global-color-eabd2c9, #F2F2F2);
    --wb-timeline-card-border: var(--_primitives---opacity--neutral-darkest-15, rgba(11, 0, 6, 0.15));
    /* Swap handle/divider — overridable via Elementor style controls */
    --wb-timeline-swap-line-color: var(--e-global-color-a4f8eaa, #FFFFFF);
    --wb-timeline-swap-handle-bg: var(--e-global-color-a4f8eaa, #FFFFFF);
    --wb-timeline-swap-handle-border: var(--e-global-color-82c53d5, #DAD8D9);
    --wb-timeline-swap-handle-shadow: var(--e-global-color-82c53d5, #DAD8D9);
    --wb-timeline-swap-handle-icon-color: var(--e-global-color-37c837c, #0B0006);
    /* Image area background strip (top + bottom padding around image) */
    --wb-timeline-image-bg: var(--wb-timeline-card-bg);
    --wb-timeline-image-padding: 48px;
}

/* ---------- Main container ------------------------------------------------ */
.wb-timeline {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* ---------- Header -------------------------------------------------------- */
.wb-timeline__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 768px;
    width: 100%;
    text-align: center;
    margin-bottom: 80px;
}

/* Spacing via global: [class*="__tagline"] mb 8x, [class*="__title"] mb 12x, .button-group mt 16x */
.wb-timeline__header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Tagline */
.wb-timeline .wb-timeline__tagline {
    font-size: var(--e-global-typography-bceafde-font-size, 1rem);
    font-weight: 600;
    line-height: 1.5;
    color: var(--color-scheme-3--text, var(--e-global-color-37c837c, #0B0006));
}

/* Title */
.wb-timeline .wb-timeline__title {
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -1px;
    color: var(--color-scheme-3--accent, var(--e-global-color-416b38f, #DF006E));
}

/* Description */
.wb-timeline .wb-timeline__description {
    color: var(--color-scheme-3--text, var(--e-global-color-37c837c, #0B0006));
    line-height: 1.5;
    margin-bottom: 0;
}

/* ---------- Timeline content ---------------------------------------------- */
.wb-timeline__content {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

/* ---------- Timeline row (CSS Grid: 3 columns desktop) -------------------- */
.wb-timeline__row {
    display: grid;
    grid-template-columns: 1fr 32px 1fr;
    gap: 0 48px; /* Mantener gap: CSS Grid estándar */
}

/* Progress always in column 2 */
.wb-timeline__progress {
    grid-column: 2;
    grid-row: 1;
}

/* Card wrapper defaults to column 3 (right side) */
.wb-timeline__card-wrapper {
    grid-row: 1;
}

/* Odd rows: card on the right (column 3) */
.wb-timeline__row:nth-child(odd) .wb-timeline__card-wrapper {
    grid-column: 3;
}

/* Even rows: card on the left (column 1) */
.wb-timeline__row:nth-child(even) .wb-timeline__card-wrapper {
    grid-column: 1;
}

/* Card wrapper: top padding to offset card below the circle position */
.wb-timeline__card-wrapper {
    padding-top: 16px;
}

/* ---------- Timeline progress (line + circle) ----------------------------- */
.wb-timeline__progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    align-self: stretch;
}

.wb-timeline__line {
    width: 3px;
    background-color: var(--wb-timeline-line-color);
    transition: background-color 0.1s linear;
}

.wb-timeline__line--top {
    height: 40px;
    flex-shrink: 0;
}

/* First row's top line: permanent fade from transparent to solid.
   Uses mask so the JS fill colour changes apply underneath. */
.wb-timeline__row:first-child .wb-timeline__line--top {
    -webkit-mask-image: linear-gradient(to bottom, transparent, black);
    mask-image: linear-gradient(to bottom, transparent, black);
}

.wb-timeline__line--bottom {
    flex: 1 0 0;
    min-height: 8px;
}

.wb-timeline__circle {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--wb-timeline-circle-color);
    border: 3px solid var(--wb-timeline-circle-color);
    flex-shrink: 0;
    margin: 8px 0;
}

/* ---------- Card ---------------------------------------------------------- */
.wb-timeline__card {
    background-color: var(--wb-timeline-card-bg);
    border: var(--_ui-styles---stroke--border-width, 0px) solid var(--wb-timeline-card-border);
    border-radius: var(--radius-small);
    overflow: hidden;
    width: 100%;
}

/* Spacing via global: __card-title mb 12x, .button-group mt 16x; __card-tagline mb 8x */
.wb-timeline__card-content {
    display: flex;
    flex-direction: column;
    padding: 32px;
}

.wb-timeline__card-titles {
    display: flex;
    flex-direction: column;
}

/* Card tagline — spacing consistent with global tagline */
.wb-timeline .wb-timeline__card-tagline {
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -1px;
    color: var(--color-scheme-3--text, var(--e-global-color-37c837c, #0B0006));
    /* margin-bottom via wb-global-styles.css (--spacing-8x) */
}

/* Card title */
.wb-timeline .wb-timeline__card-title {
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: -1px;
    color: var(--color-scheme-3--accent, var(--e-global-color-416b38f, #DF006E));
}

/* Card description */
.wb-timeline .wb-timeline__card-description {
    color: var(--color-scheme-3--text, var(--e-global-color-37c837c, #0B0006));
    line-height: 1.5;
    margin-bottom: 0;
}

/* ---------- Single image -------------------------------------------------- */
.wb-timeline__card-image {
    width: 100%;
    padding-top: var(--wb-timeline-image-padding);
    padding-bottom: var(--wb-timeline-image-padding);
    background-color: var(--wb-timeline-image-bg);
}

.wb-timeline__card-image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 1 / 1;
}

/* ---------- Swap (Before/After) ------------------------------------------- */
.wb-timeline__swap {
    position: relative;
    width: 100%;
}

/* Swap container: includes the top/bottom padding strips + the image area.
   overflow:hidden clips both images AND the labels inside the "after" layer. */
.wb-timeline__swap-container {
    position: relative;
    width: 100%;
    /* padding strips create the coloured band above and below the image */
    padding-top: var(--wb-timeline-image-padding);
    padding-bottom: var(--wb-timeline-image-padding);
    background-color: var(--wb-timeline-image-bg);
    /* aspect-ratio applies to the inner image area: account for both padding strips */
    /* Use a wrapper trick: the image itself uses aspect-ratio 1/1 inside */
    overflow: hidden;
    cursor: col-resize;
}

/* Labels — positioned in the top padding strip, vertically centred */
.wb-timeline__swap-label {
    position: absolute;
    top: 0;
    height: var(--wb-timeline-image-padding);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-weight: 600;
    font-size: var(--e-global-typography-bceafde-font-size, 1rem);
    line-height: 1.5;
    color: var(--e-global-color-a4f8eaa, #FFFFFF);
    z-index: 3;
    pointer-events: none;
    white-space: nowrap;
}

.wb-timeline__swap-label--before {
    left: 0;
    /* Always visible — lives in the base layer */
    z-index: 3;
}

.wb-timeline__swap-label--after {
    right: 0;
    /* Lives inside .wb-timeline__swap-after which is clipped by clip-path,
       so it disappears when the handle moves fully to the right */
    z-index: 3;
    /* Offset left edge to fill from the right edge of the container */
    left: 0;
    justify-content: flex-end;
}

/* Both images fill the image area (container minus padding strips) */
.wb-timeline__swap-img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    pointer-events: none;
    user-select: none;
}

.wb-timeline__swap-img--before {
    position: relative;
    z-index: 1;
}

/* After image: absolute, overlay exactly on top of the before image.
   Offset by the padding strip height so both images align perfectly.
   aspect-ratio is reset because height is computed from the container. */
.wb-timeline__swap-after .wb-timeline__swap-img--after {
    position: absolute;
    top: var(--wb-timeline-image-padding);
    left: 0;
    width: 100%;
    height: calc(100% - var(--wb-timeline-image-padding) * 2);
    aspect-ratio: auto;
}

/* After wrapper overlays on top, clipped from the left.
   Covers the full container including padding strips. */
.wb-timeline__swap-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    clip-path: inset(0 0 0 50%);
}

/* Divider line + handle — spans full container height (padding strips + image) */
.wb-timeline__swap-divider {
    position: absolute;
    top: 0;
    left: 50%;
    height: 100%;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateX(-50%);
    pointer-events: none;
}

.wb-timeline__swap-line {
    width: 3px;
    flex: 1;
    background-color: var(--wb-timeline-swap-line-color);
}

.wb-timeline__swap-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 10px;
    border-radius: 100px;
    background-color: var(--wb-timeline-swap-handle-bg);
    border: 1px solid var(--wb-timeline-swap-handle-border);
    box-shadow: inset 0px -4px 0px 0px var(--wb-timeline-swap-handle-shadow);
    cursor: grab;
    pointer-events: auto;
    flex-shrink: 0;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.wb-timeline__swap-handle:hover {
    box-shadow:
        inset 0px -4px 0px 0px var(--wb-timeline-swap-handle-shadow),
        0 4px 12px var(--_primitives---opacity--neutral-darkest-20, rgba(11, 0, 6, 0.2));
    transform: scale(1.05);
}

.wb-timeline__swap-handle:active {
    cursor: grabbing;
    transform: scale(0.95);
    box-shadow: inset 0px -2px 0px 0px var(--wb-timeline-swap-handle-shadow);
}

.wb-timeline__swap-handle .material-symbols-outlined {
    font-size: 24px;
    line-height: 1;
    /* !important needed: WB_Controls_Helper applies html body {{WRAPPER}} span.material-symbols-outlined
       with !important for button icon colors, which would otherwise override this variable */
    color: var(--wb-timeline-swap-handle-icon-color) !important;
}

/* ---------- Responsive: Tablet -------------------------------------------- */
@media (max-width: 991px) {
    .wb-timeline__header {
        margin-bottom: 48px;
    }
}

/* ---------- Responsive: Mobile -------------------------------------------- */
@media (max-width: 767px) {
    .wb-timeline__header {
        margin-bottom: 48px;
    }

    /* Mobile: 2-column layout — timeline on the left, cards on the right */
    .wb-timeline__row {
        grid-template-columns: 20px 1fr;
        gap: 0 16px; /* Mantener gap: CSS Grid estándar */
    }

    /* All cards go to column 2 on mobile regardless of odd/even */
    .wb-timeline__row:nth-child(odd) .wb-timeline__card-wrapper,
    .wb-timeline__row:nth-child(even) .wb-timeline__card-wrapper {
        grid-column: 2;
    }

    /* Progress always column 1 on mobile */
    .wb-timeline__progress {
        grid-column: 1;
    }

}
