/* ── Root vars ── */
.eb-stacking {
    --eb-stk-height: 380px;
    --eb-stk-peek: 1em;
    --eb-stk-top: 80px;
    --eb-stk-gap: 48px;
    --eb-stk-n: 4;

    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(var(--eb-stk-n), var(--eb-stk-height));
    gap: var(--eb-stk-gap);
    padding-bottom: calc(100vh - var(--eb-stk-height, 380px));
}

/* ── Sticky card wrapper ── */
.eb-stk-card {
    position: sticky;
    top: var(--eb-stk-top);
    z-index: calc(var(--i) + 1);
    height: var(--eb-stk-height);
    padding-top: calc(var(--i) * var(--eb-stk-peek));
    perspective: 1000px;
    box-sizing: border-box;
}

/* ── Animated inner surface ── */
.eb-stk-inner {
    width: 100%;
    height: 100%;
    border-radius: 1.5rem;
    overflow: hidden;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    transform-origin: 50% 0%;
    will-change: transform, filter;

    animation: eb-stk-scale linear forwards;
    animation-timeline: view();
    animation-range: exit-crossing 0% exit-crossing 100%;
}

/* ── Card content fills full area ── */
.eb-stk-inner > * {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes eb-stk-scale {
    from {
        transform: none;
        filter: brightness(1);
    }
    to {
        transform: scale(0.85) translateY(-8vh) rotateX(-15deg);
        filter: brightness(0.85);
    }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .eb-stk-inner {
        animation: none;
    }
}
