/* ═══════════════════════════════════════════════════════════════
   KP Markets Stack — v8 (Wipe-effect for Left & Right + Fix)

   WIPE-EFFECT:
   • .left en .right zijn position:fixed (vaste viewport-positie) op desktop
   • .slide heeft clip-path:inset(0) → clipt fixed children
   • Volgende slide scrollt erover → content wordt netjes "gewiped"

   EERSTE SLIDE FIX:
   • Slide 0 start met class .is-initial → fixed content is tijdelijk absolute
   • Zodra slide 0 gepind wordt (top:0), verwijdert JS .is-initial
     → content wordt fixed → klaar voor wipe naar slide 1
   ═══════════════════════════════════════════════════════════════ */

/* ── Container ── */
.kp-markets-stack {
    position: relative;
    width: 100%;
}

/* ── Slide ── */
.kp-markets-stack__slide {
    position: relative;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    overflow: hidden;
    background: #0D1C38;
    clip-path: inset(0);
    /* CRUCIAAL: Voorkomt dat ScrollTrigger inline transformaties toevoegt die de 'fixed' positionering breken op page load */
    transform: none !important; 
}

/* ── FIX: clip-path op de pin-spacer ── */
.kp-markets-stack > .pin-spacer {
    clip-path: inset(0) !important;
    overflow: visible !important;
}

.kp-markets-stack__right,
.kp-markets-stack__left {
    will-change: position;
}

.kp-markets-stack__grid {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Z-index */
.kp-markets-stack__slide[data-slide="0"],
.kp-markets-stack .pin-spacer:nth-child(1) { z-index: 1; }
.kp-markets-stack__slide[data-slide="1"],
.kp-markets-stack .pin-spacer:nth-child(2) { z-index: 2; }
.kp-markets-stack__slide[data-slide="2"],
.kp-markets-stack .pin-spacer:nth-child(3) { z-index: 3; }
.kp-markets-stack__slide[data-slide="3"],
.kp-markets-stack .pin-spacer:nth-child(4) { z-index: 4; }
.kp-markets-stack__slide[data-slide="4"],
.kp-markets-stack .pin-spacer:nth-child(5) { z-index: 5; }
.kp-markets-stack__slide[data-slide="5"],
.kp-markets-stack .pin-spacer:nth-child(6) { z-index: 6; }


/* ══════════════════════════════════════════════════════════════
   COVER
   ══════════════════════════════════════════════════════════════ */
.kp-markets-stack__cover {
    position: absolute;
    inset: 0;
    z-index: 1;
    will-change: transform;
}

.kp-markets-stack__cover::before {
    content: none;
}

.kp-markets-stack__cover-img {
    width: 100%;
    height: 120%;
    object-fit: cover;
    object-position: center bottom;
    display: block;
}

.kp-markets-stack__overlay {
    display: none;
}

.kp-markets-stack__slide:last-child .kp-markets-stack__cover::before {
    content: none;
}


/* ══════════════════════════════════════════════════════════════
   CONTENT + STICKY
   ══════════════════════════════════════════════════════════════ */
.kp-markets-stack__content {
    position: relative;
    height: 100%;
    z-index: 3;
}

.kp-markets-stack__sticky {
    position: relative;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: row;
    align-items: center;
}


/* ══════════════════════════════════════════════════════════════
   SIDEBAR — fixed, blijft staan bij slide-wisseling
   ══════════════════════════════════════════════════════════════ */

/* Mobile sidebar: verborgen op desktop */
.kp-markets-stack__sidebar--mobile {
    display: none;
}

.kp-markets-stack__sidebar--global {
    position: fixed;
    left: 0;
    top: 0;
    width: 123px;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    z-index: 10;
    pointer-events: none;
    overflow: hidden;
    /* Start verborgen — JS toont/verbergt op basis van container scroll boundaries */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.kp-markets-stack__sidebar-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 48px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    transform-origin: 0 0;
    transform: rotate(-90deg);
    width: 100vh;
    height: 123px;
    white-space: nowrap;
    position: absolute;
    top: 100%;
    left: 0;
}

.kp-markets-stack__sidebar-text {
    color: #fff;
    font-family: "acumin-pro", "AcuminPro-Regular", sans-serif;
    font-size: 18px;
    line-height: 150%;
    font-weight: 400;
}

.kp-markets-stack__sidebar .kp-section-label__arrow {
    color: #fff;
}


/* ══════════════════════════════════════════════════════════════
   MAIN
   ══════════════════════════════════════════════════════════════ */
.kp-markets-stack__main {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    max-width: 88.75rem;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
    padding: 0 clamp(24px, 3vw, 48px);
}


/* ══════════════════════════════════════════════════════════════
   LEFT (Text Content)
   ══════════════════════════════════════════════════════════════ */
.kp-markets-stack__left {
    flex: 1;
    min-width: 0;
    max-width: 710px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-right: clamp(40px, 5vw, 80px);
}

/* Market items with chevron icon */
.kp-markets-stack__items {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.kp-markets-stack__item {
    display: flex;
    flex-direction: row;
    gap: 16px;
    align-items: flex-start;
}
.kp-markets-stack__item-icon {
    flex-shrink: 0;
    width: 12px;
    height: 27px;
    margin-top: 4px;
}
.kp-markets-stack__item-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kp-markets-stack__item-title {
    font-family: "sofia-pro", "SofiaPro-Regular", sans-serif;
    font-size: 24px;
    font-weight: 400;
    line-height: 140%;
    color: #ffffff;
}
.kp-markets-stack__item-text {
    font-family: "acumin-pro", "AcuminPro-Regular", sans-serif;
    font-size: 20px;
    font-weight: 400;
    line-height: 150%;
    color: #ffffff;
}

.kp-markets-stack__title {
    color: #fff;
    font-family: "sofia-pro", "SofiaPro-Regular", sans-serif;
    font-size: clamp(40px, 5.2vw, 100px);
    line-height: 120%;
    font-weight: 400;
    margin: 0;
    will-change: transform, opacity;
}

.kp-markets-stack__text {
    color: #fff;
    font-family: "acumin-pro", "AcuminPro-Regular", sans-serif;
    font-size: clamp(16px, 1.25vw, 24px);
    line-height: 140%;
    font-weight: 400;
    margin: 0;
    max-width: 100%;
    will-change: transform, opacity;
}

/* Default: alle content fixed voor het wipe-effect */
@media (min-width: 1025px) {
    .kp-markets-stack__left {
        position: fixed;
        /* Identieke centrering logica als de rechterkant, maar dan vanaf links (inclusief sidebar width 123px) */
        --main-max: 88.75rem;
        left: calc(max(0px, (100vw - var(--main-max)) / 2) + clamp(24px, 3vw, 48px));
        top: 50%;
        transform: translateY(-50%);
        z-index: 4;
        width: 100%;
    }
}


/* ══════════════════════════════════════════════════════════════
   RIGHT — THUMBNAIL
   ══════════════════════════════════════════════════════════════ */
.kp-markets-stack__right {
    flex-shrink: 0;
}

@media (min-width: 1025px) {
    .kp-markets-stack__right {
        position: fixed;
        /* Rechterrand = marge van main + padding. */
        --main-max: 88.75rem;
        right: calc(max(0px, (100vw - 123px - var(--main-max)) / 2) + clamp(24px, 3vw, 48px));
        top: 50%;
        transform: translateY(-50%);
        z-index: 4;
    }

    /* ── EERSTE SLIDE: start als "in-flow" ── */
    .kp-markets-stack__slide.is-initial .kp-markets-stack__right,
    .kp-markets-stack__slide.is-initial .kp-markets-stack__left {
        position: absolute;
    }
}

.kp-markets-stack__grid {
    width: clamp(280px, 31.25vw, 600px);
    aspect-ratio: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    overflow: hidden;
    will-change: transform, opacity;
}

/* KP chevron shapes in grid corners (fallback when no hoek_iconen) */
.kp-markets-stack__shape {
    position: absolute;
    pointer-events: none;
}
.kp-markets-stack__shape--tl { top: 0; left: 0; }
.kp-markets-stack__shape--tr { top: 0; right: 0; }
.kp-markets-stack__shape--bl { bottom: 0; left: 0; }
.kp-markets-stack__shape--br { bottom: 0; right: 0; }

.kp-markets-stack__grid-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    align-self: stretch;
    flex-shrink: 0;
}

.kp-markets-stack__grid-row--top {
    transform-origin: center center;
}

.kp-markets-stack__icon {
    flex-shrink: 0;
    width: clamp(50px, 5.2vw, 100px);
    height: clamp(50px, 5.2vw, 100px);
    aspect-ratio: 1;
    object-fit: contain;
    display: block;
    pointer-events: none;
    user-select: none;
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Medium desktop (1025px – 1543px)
   ══════════════════════════════════════════════════════════════ */
@media (min-width: 1025px) and (max-width: 96.4375rem) {
    .kp-markets-stack__main {
        max-width: 69.8125rem;
    }

    .kp-markets-stack__left {
        --main-max: 69.8125rem;
        left: calc(max(0px, (100vw - var(--main-max)) / 2) + clamp(24px, 3vw, 48px));
        max-width: 560px;
    }

    .kp-markets-stack__right {
        --main-max: 69.8125rem;
    }

    .kp-markets-stack__grid {
        width: clamp(220px, 28vw, 450px);
    }

    .kp-markets-stack__title {
        font-size: clamp(36px, 4.5vw, 80px);
    }

    .kp-markets-stack__text {
        max-width: 420px;
    }
}

/* ── Kleine desktop ── */
@media (min-width: 1025px) and (max-width: 1260px) {
    .kp-markets-stack__main {
        max-width: calc(100vw - 123px - 48px);
        padding: 0 24px;
    }

    .kp-markets-stack__left {
        left: 24px;
        max-width: 450px;
    }

    .kp-markets-stack__right {
        --main-max: calc(100vw - 123px - 48px);
        right: 24px;
    }

    .kp-markets-stack__grid {
        width: clamp(200px, 25vw, 350px);
    }

    .kp-markets-stack__title {
        font-size: clamp(32px, 3.8vw, 60px);
    }

    .kp-markets-stack__text {
        max-width: 380px;
        font-size: 16px;
    }
}


/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile (≤ 1024px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    .kp-markets-stack__slide {
        clip-path: none;
        height: auto;
        min-height: 0;
        overflow: visible;
        position: relative;
    }

    .kp-markets-stack__cover {
        position: absolute;
        inset: 0;
        overflow: hidden;
    }

    .kp-markets-stack__cover-img {
        width: 100%;
        height: 130%;
        object-fit: cover;
        object-position: center;
        display: block;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }

    .kp-markets-stack__content {
        position: relative;
        z-index: 3;
    }

    .kp-markets-stack__sidebar--global {
        display: none;
    }

    .kp-markets-stack__sidebar--mobile {
        display: block;
        position: relative;
        left: auto;
        top: auto;
        width: 100%;
        height: auto;
        z-index: 5;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto;
    }

    .kp-markets-stack__sidebar-inner {
        transform: none;
        width: 100%;
        height: auto;
        position: relative;
        top: auto;
        left: auto;
        padding: 24px 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    }

    .kp-markets-stack__sticky {
        height: auto;
        flex-direction: column;
        padding: 0 16px 32px 16px;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 80px;
    }

    .kp-markets-stack__main {
        flex-direction: column;
        gap: 80px;
        align-items: flex-start;
        width: 100%;
        padding-top: 5rem;
    }

    .kp-markets-stack__left {
        max-width: 100%;
        margin-right: 0;
        gap: 24px;
    }

    .kp-markets-stack__title {
        font-size: 48px;
        line-height: 120%;
    }

    .kp-markets-stack__text {
        font-size: 18px;
        line-height: 140%;
        max-width: 100%;
    }

    .kp-markets-stack__grid {
        width: 100%;
        max-width: 357px;
        height: auto;
        aspect-ratio: 1;
    }
    
    .kp-markets-stack__right {
        width: 100%;
    }

    .kp-markets-stack__icon {
        width: 64px;
        height: 64px;
    }
}

@media (max-width: 600px) {
    .kp-markets-stack__grid { max-width: 100%; }
}