/* =========================================================
   Close Steps block (wwa/close-steps)
   The base rules are the STACKED layout: every step shows its own photo,
   number and text. That is what the editor preview and no-JS visitors get.
   The PINNED layout sits inside @media (scripting: enabled), and
   .wwa-close-steps--mobile-stack switches back to stacked below 991.8px.
   Type and text colours come from the theme classes in render.php.
   ========================================================= */

.wwa-close-steps {
    position: relative;
    container-type: inline-size;
}

/* ---------- Photo panel (stage and per-step) ---------- */

.wwa-close-steps__media {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.wwa-close-steps__stage {
    display: none;
}

.wwa-close-steps__photos,
.wwa-close-steps__photos::after {
    position: absolute;
    inset: 0;
}

.wwa-close-steps__photos::after {
    content: "";
    background-color: var(--wwa-green-100-50);
}

.wwa-close-steps__photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.07);
    transition: opacity .9s cubic-bezier(.65, 0, .25, 1), transform 1.4s cubic-bezier(.65, 0, .25, 1);
}

.wwa-close-steps__photo.is-active {
    opacity: 1;
    transform: none;
}

/*
 * Figma's strokes sit inside the frame and don't move its content, so the text
 * is 24px from the frame's outer edge. Padding = 24px minus the border.
 */
.wwa-close-steps__frame {
    position: absolute;
    z-index: 1;
    inset: 32px 0 32px 32px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 22px 24px 22px 19px;
    border: 2px solid var(--wwa-light-200);
    border-left-width: 5px;
    border-right: 0;
}

.wwa-close-steps__title {
    margin: 0;
    text-wrap: balance;
}

.wwa-close-steps__count {
    display: flex;
    align-items: flex-end;
    white-space: nowrap;
}

/* Clips top and bottom only, so the outline is never cut at the sides. */
.wwa-close-steps__roll {
    display: block;
    width: 120px;
    height: 86px;
    clip-path: inset(0 -40px);
    font-family: var(--wwa-font-heading);
    font-size: 96px;
    font-weight: 600;
    line-height: 86px;
    text-align: center;
}

.wwa-close-steps__roll-track {
    display: block;
    transition: transform .9s cubic-bezier(.65, 0, .25, 1);
}

.wwa-close-steps__digit {
    display: block;
    color: transparent;
    -webkit-text-stroke: 2px var(--wwa-accent);
}

/* ---------- Steps ---------- */

.wwa-close-steps__steps {
    min-width: 0;
}

.wwa-close-steps__step {
    position: relative;
    padding-bottom: 80px;
}

.wwa-close-steps__step--grey {
    background-color: var(--wwa-green-400);
}

.wwa-close-steps__text {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 12px 0;
}

.wwa-close-steps__content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wwa-close-steps__content > * {
    margin: 0;
}

.wwa-close-steps__content ul,
.wwa-close-steps__content ol {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wwa-close-steps__content strong {
    font-weight: 600;
    color: var(--wwa-accent);
}

/* ---------- Desktop ---------- */

@media screen and (min-width: 991.8px) {
    .wwa-close-steps__step {
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding-bottom: 0;
    }

    .wwa-close-steps__media--step {
        height: auto;
        min-height: 600px;
    }

    /* The left edge sits on the header container; text is 48px / 60px from the outer edge. */
    .wwa-close-steps__frame {
        inset: 48px 0 48px calc((100cqw - 960px) / 2);
        padding: 45px 12px 45px 51px;
        border-width: 3px;
        border-left-width: 9px;
        border-right: 0;
    }

    .wwa-close-steps__roll {
        width: 185px;
        height: 134px;
        font-size: 150px;
        line-height: 134px;
    }

    .wwa-close-steps__digit {
        -webkit-text-stroke-width: 1.5px;
    }

    .wwa-close-steps__text {
        align-self: center;
        gap: 24px;
        padding: 80px calc((100cqw - 960px) / 2 + 12px) 80px 48px;
    }

    /* A <br> in a step heading is a mobile line break (Figma step 1). */
    .wwa-close-steps__heading br {
        display: none;
    }
}

@media screen and (min-width: 1199.8px) {
    .wwa-close-steps__frame {
        left: calc((100cqw - 1140px) / 2);
    }

    .wwa-close-steps__text {
        padding-left: 48px;
    }
}

@media screen and (min-width: 1399.9px) {
    .wwa-close-steps__frame {
        left: calc((100cqw - 1320px) / 2);
    }

    .wwa-close-steps__text {
        padding-right: calc((100cqw - 1320px) / 2 + 12px);
    }
}

/* ---------- Pinned layout (only when JavaScript can run) ---------- */

@media (scripting: enabled) {
    .wwa-close-steps:not(.is-preview) {
        display: grid;
        grid-template-columns: 1fr 1fr;
        transition: background-color .8s cubic-bezier(.65, 0, .25, 1);
    }

    .wwa-close-steps.is-ready.is-grey:not(.is-preview) {
        background-color: var(--wwa-green-400);
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__stage {
        display: block;
        position: sticky;
        top: var(--wwa-header-offset);
        height: calc(100svh - var(--wwa-header-offset));
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__media--step {
        display: none;
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__steps {
        padding-bottom: 20vh;
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__step {
        display: flex;
        align-items: center;
        min-height: calc(100svh - var(--wwa-header-offset));
        padding: 80px 0;
        background-color: transparent;
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__text {
        width: 100%;
        padding-block: 0;
        transition: opacity .8s cubic-bezier(.65, 0, .25, 1), transform .8s cubic-bezier(.65, 0, .25, 1);
    }

    /* The 40px is repeated as RISE in wwa-close-steps.js. */
    .wwa-close-steps.is-ready:not(.is-preview) .wwa-close-steps__step:not(.is-active):not(.is-past) .wwa-close-steps__text {
        opacity: .25;
        transform: translateY(40px);
    }
}

/* ---------- Mobile sticky: stage on top, Figma mobile sizes ---------- */

@media screen and (scripting: enabled) and (max-width: 991.8px) {
    .wwa-close-steps:not(.is-preview) {
        grid-template-columns: minmax(0, 1fr);
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__stage {
        z-index: 2;
        height: 52svh;
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__steps {
        padding-bottom: 30vh;
    }

    .wwa-close-steps:not(.is-preview) .wwa-close-steps__step {
        align-items: flex-start;
        min-height: 70vh;
        padding: 40px 0 0;
        scroll-margin-top: 52svh;
    }
}

/* Landscape phones: the Figma sizes can't fit in a stage this short. */
@media screen and (scripting: enabled) and (max-width: 991.8px) and (max-height: 559.8px) {
    .wwa-close-steps:not(.is-preview):not(.wwa-close-steps--mobile-stack) .wwa-close-steps__frame {
        inset: 10px 0 10px 32px;
        padding: 8px 24px 8px 19px;
    }

    .wwa-close-steps:not(.is-preview):not(.wwa-close-steps--mobile-stack) .wwa-close-steps__title {
        font-size: 20px;
    }

    .wwa-close-steps:not(.is-preview):not(.wwa-close-steps--mobile-stack) .wwa-close-steps__roll {
        width: 56px;
        height: 40px;
        font-size: 44px;
        line-height: 40px;
    }

    .wwa-close-steps:not(.is-preview):not(.wwa-close-steps--mobile-stack) .wwa-close-steps__digit {
        -webkit-text-stroke-width: 1px;
    }

    .wwa-close-steps:not(.is-preview):not(.wwa-close-steps--mobile-stack) .wwa-close-steps__total {
        font-size: 18px;
    }
}

/* ---------- Switch: stacked below 991.8px (Mobile layout = Stacked) ---------- */

@media screen and (max-width: 991.8px) {
    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) {
        display: block;
    }

    .wwa-close-steps__media {
        display: block;
        aspect-ratio: 768 / 960; /* same as 4 / 5 */
        max-width: 100%;
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__stage {
        display: none;
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__media--step {
        display: block;
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__steps {
        padding-bottom: 0;
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__step {
        display: block;
        min-height: 0;
        padding: 0 0 80px;
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__step--grey {
        background-color: var(--wwa-green-400);
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__text {
        padding-block: 24px 0;
    }

    /* Column width: 600px, or the Bootstrap .container content width if smaller */
    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) {
        --wwa-close-col: 600px; /* 768–991: container 720px, content 696px, so 600px wins */
    }

    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__text > * {
        max-width: 100%;
        width: var(--wwa-close-col);
        margin-inline: auto;
    }

    /* Frame lines up with the same column; the border still runs to the right edge. */
    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) .wwa-close-steps__frame {
        left: max(32px, calc((100cqw - var(--wwa-close-col)) / 2));
        padding-right: max(24px, calc((100cqw - var(--wwa-close-col)) / 2));
    }
}

/* 576–767: .container is 540px, so the content area is 516px */
@media screen and (max-width: 767.8px) {
    .wwa-close-steps.wwa-close-steps--mobile-stack:not(.is-preview) {
        --wwa-close-col: 516px;
    }
}

/* ---------- Reduced motion: instant switches, all text at full strength ---------- */
@media (prefers-reduced-motion: reduce) {
    .wwa-close-steps,
    .wwa-close-steps .wwa-close-steps__photo,
    .wwa-close-steps .wwa-close-steps__roll-track,
    .wwa-close-steps:not(.is-preview),
    .wwa-close-steps:not(.is-preview) .wwa-close-steps__text {
        transition: none;
    }

    .wwa-close-steps .wwa-close-steps__photo {
        transform: none;
    }

    .wwa-close-steps.is-ready:not(.is-preview) .wwa-close-steps__step:not(.is-active):not(.is-past) .wwa-close-steps__text {
        opacity: 1;
        transform: none;
    }
}