/********************* Historia - escalera continua *********************/

.history-page-section {
    padding: clamp(54px, 7vw, 94px) 0 clamp(70px, 9vw, 120px);
}

.history-section-header {
    margin: 0 auto clamp(38px, 6vw, 70px);
    text-align: center;
}

.history-section-header h2 {
    margin: 0 0 16px;
    color: var(--color-blue-900);
    font-size: clamp(1.85rem, 3.2vw, 2.65rem);
    line-height: 1.1;
    letter-spacing: -0.035em;
}

.history-section-header p {
    margin: 0 auto;
    color: rgba(104, 115, 134, 0.96);
    font-size: 1rem;
    line-height: 1.72;
}

.history-stair-timeline {
    position: relative;
}

.history-stair-scroll {
    position: relative;
    overflow: visible;
}

.history-stair-canvas {
    position: relative;
    width: 100%;
    height: clamp(470px, 40vw, 560px);
    /**** Alto del canva ***/
    overflow: visible;
}

/********************* SVG escalera *********************/

.history-stair-svg {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.history-stair-base-path,
.history-stair-active-path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.history-stair-base-path {
    stroke: rgba(18, 40, 76, 0.22);
    stroke-width: 4;
}

.history-stair-active-path {
    stroke: var(--brand-accent);
    stroke-width: 5;
    stroke-dasharray: 0;
    stroke-dashoffset: 0;
    transition: none;
}

/********************* A帽os debajo de cada escal贸n *********************/

.history-stair-trigger {
    position: absolute;
    left: var(--step-x);
    top: calc(var(--step-y) + 30px);
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0;
    color: rgba(104, 115, 134, 0.9);
    font-size: 0.78rem;
    font-weight: 760;
    line-height: 1;
    border: 0;
    background: transparent;
    transform: translateX(-50%);
    cursor: pointer;
    transition:
        color var(--transition-fast),
        transform var(--transition-fast);
}

.history-stair-trigger span {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.52);
    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        box-shadow var(--transition-fast);
}

.history-stair-trigger:hover,
.history-stair-trigger:focus-visible,
.history-stair-trigger.is-current,
.history-stair-trigger.is-completed {
    color: var(--color-blue-900);
}

.history-stair-trigger.is-current {
    transform: translateX(-50%) translateY(-2px);
}

.history-stair-trigger.is-current span {
    color: #ffffff;
    background: var(--brand-accent);
    box-shadow: 0 10px 22px var(--brand-accent-medium);
}

.history-stair-trigger.is-completed:not(.is-current) span {
    color: var(--brand-accent);
    background: var(--brand-accent-soft);
}

.history-stair-trigger.is-future.is-current span {
    color: #ffffff;
    background: var(--color-blue-900);
}

/********************* Burbuja de informaci贸n *********************/

.history-thought-bubble {
    --bubble-x: 50%;
    --bubble-y: 50%;

    position: absolute;
    left: var(--bubble-x);
    top: calc(var(--bubble-y) - 44px);
    z-index: 6;
    width: min(282px, calc(100% - 28px));
    padding: 15px;
    text-align: center;
    border: 1px solid rgba(18, 40, 76, 0.1);
    border-radius: 24px 24px 24px 10px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
        var(--surface-liquid);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 18px 42px rgba(18, 40, 76, 0.085);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 20px));
    transition:
        opacity 0.26s ease,
        transform 0.26s ease,
        left 0.42s ease,
        top 0.42s ease;
}

.history-thought-bubble.is-visible {
    opacity: 1;
    transform: translate(-50%, calc(-100% - 10px));
}

.history-thought-bubble.is-align-start {
    transform: translate(0, calc(-100% - 20px));
}

.history-thought-bubble.is-align-start.is-visible {
    transform: translate(0, calc(-100% - 10px));
}

.history-thought-bubble.is-align-end {
    transform: translate(-100%, calc(-100% - 20px));
}

.history-thought-bubble.is-align-end.is-visible {
    transform: translate(-100%, calc(-100% - 10px));
}

.history-thought-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -11px;
    width: 22px;
    height: 22px;
    border-right: 1px solid rgba(18, 40, 76, 0.1);
    border-bottom: 1px solid rgba(18, 40, 76, 0.1);
    background: rgba(255, 255, 255, 0.76);
    transform: translateX(-50%) rotate(45deg);
}

.history-thought-bubble.is-align-start::after {
    left: 44px;
}

.history-thought-bubble.is-align-end::after {
    left: calc(100% - 44px);
}

/********************* Imagen flotante historia *********************/

.history-floating-image {
    position: absolute;
    right: clamp(22px, 4vw, 72px);
    bottom: clamp(12px, 2vw, 32px);
    z-index: 2;
    width: min(20vw, 250px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    transition:
        opacity 0.28s ease,
        transform 0.28s ease;
}

.history-floating-image.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.history-floating-image img {
    display: block;
    border-radius: 999px;
    width: 100%;
    object-fit: contain;
}

.history-thought-copy span {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--brand-accent);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.history-thought-copy h3 {
    margin: 0 0 8px;
    color: var(--color-blue-900);
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.18;
    letter-spacing: -0.025em;
}

.history-thought-copy p {
    margin: 0;
    color: rgba(104, 115, 134, 0.98);
    font-size: 0.82rem;
    line-height: 1.48;
}

/********************* Acciones *********************/

.history-stair-actions {
    position: relative;
    left: auto;
    top: auto;
    z-index: 9;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;

    width: 100%;
    max-width: 520px;
    gap: 10px;
    margin: 0 auto 24px;
}

.history-stair-btn.is-hidden {
    display: none;
}

.history-stair-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;

    min-height: 38px;
    gap: 8px;
    padding: 0 14px;

    font-size: 0.8rem;
    font-weight: 760;
    text-decoration: none;

    border-radius: 12px;
    cursor: pointer;

    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast),
        transform var(--transition-fast);
}

.history-stair-btn-primary {
    color: #ffffff;
    border: 1px solid var(--color-blue-900);
    background: var(--color-blue-900);
}

.history-stair-btn-primary:hover {
    color: #ffffff;
    border-color: #0c1d38;
    background: #0c1d38;
    transform: translateY(-1px);
}

.history-stair-btn-secondary {
    color: var(--color-blue-900);
    border: 1px solid rgba(18, 40, 76, 0.12);
    background: rgba(255, 255, 255, 0.5);
}

.history-stair-btn-secondary:hover {
    color: var(--color-blue-900);
    border-color: var(--brand-accent-border);
    background: var(--brand-accent-soft);
    transform: translateY(-1px);
}

.history-stair-btn:focus-visible {
    outline: 3px solid var(--brand-accent-soft);
    outline-offset: 3px;
}

.history-stair-btn:disabled {
    opacity: 0.46;
    cursor: not-allowed;
    transform: none;
}

/********************* Responsive *********************/

@media (max-width: 991.98px) {

    .history-stair-actions {
        position: relative;
        left: auto;
        top: auto;
        z-index: 9;

        justify-content: center;
        flex-wrap: wrap;

        width: 100%;
        max-width: 520px;
        gap: 10px;
        margin: 0 auto 18px;
    }

    .history-stair-scroll {
        box-sizing: border-box;
        overflow-x: auto;
        overflow-y: visible;
        padding: 18px 50% 16px;
    }

    .history-stair-canvas {
        width: 1180px;
        min-width: 1180px;
        height: 600px;
    }

    .history-thought-bubble {
        width: 270px;
    }

    .history-floating-image {
        right: 28px;
        bottom: 28px;
        width: 210px;
    }

    .history-floating-image img {
        max-height: 200px;
    }
}

@media (max-width: 575.98px) {

    .history-page-section {
        padding: 48px 0 70px;
    }

    .history-section-header {
        margin-bottom: 34px;
    }

    /* Controles centrados */

    .history-stair-actions {
        width: 100%;
        max-width: 360px;
        gap: 8px;
        margin: 0 auto 18px;
        padding-inline: 6px;
    }

    .history-stair-btn {
        flex: 0 1 auto;
        width: auto;
        min-height: 36px;
        padding: 0 10px;
        font-size: 0.74rem;
    }

    .history-stair-btn-primary,
    .js-history-restart {
        flex: 0 0 min(230px, 100%);
        width: min(230px, 100%);
    }

    .history-stair-btn-secondary {
        flex: 0 1 auto;
        width: auto;
    }

    /* Escalera horizontal */

    .history-stair-canvas {
        width: 1060px;
        min-width: 1060px;
        height: 560px;
    }

    /* Burbuja */

    .history-thought-bubble {
        width: 250px;
        padding: 13px;
        border-radius: 20px 20px 20px 9px;
    }

    .history-thought-image img {
        width: 52px;
        height: 52px;
    }

    .history-thought-copy h3 {
        font-size: 0.96rem;
    }

    .history-thought-copy p {
        font-size: 0.78rem;
    }

    /* Años */

    .history-stair-trigger {
        font-size: 0.7rem;
    }

    .history-stair-trigger span {
        padding: 6px 8px;
    }

    /* Imagen flotante */

    .history-floating-image {
        right: 18px;
        bottom: 24px;
        width: 150px;
        opacity: 0.92;
    }

    .history-floating-image img {
        max-height: 150px;
    }
}