/* ============================================================
   Support Store — Jornada cinematográfica (scroll 2.5D)
   Baseado no "cinematic-scroll-prompt-kit" (MIT).
   O JS escreve só variáveis CSS (--s1-o, --s2-scale, ...);
   toda a transformação final fica aqui.

   Faixas de z-index dentro do palco:
     0–9   mundo (backdrops + molduras)
     10–19 tint / vinheta
     20–29 textos narrativos
     30–39 catálogo e controles
   ============================================================ */

.cinematic-scroll {
    position: relative;
    /* distância virtual de rolagem; ajustada por breakpoint abaixo */
    height: var(--cs-length, 4200px);
    --px: 0;
    --py: 0;
    --cs-pad: max(5vw, 24px);
}

.cinematic-stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    min-height: 520px;
    overflow: clip;
    isolation: isolate;
    background: #05070a;
    color: var(--text-primary);
}

/* ---------- mundo ---------- */
.cs-world { position: absolute; inset: 0; z-index: 0; }

/* backdrop: a mesma foto desfocada e escurecida, com sangria de 12% */
.cs-bd {
    position: absolute;
    inset: -12%;
    width: 124%;
    height: 124%;
    object-fit: cover;
    filter: blur(30px) brightness(.38) saturate(1.15);
    will-change: transform, opacity;
    opacity: var(--s1-o, 1);
    transform: translate3d(calc(var(--px) * -6px), calc(var(--py) * -4px), 0) scale(var(--bd-scale, 1.04));
    pointer-events: none;
}
.cs-bd[data-scene="2"] { opacity: var(--s2-o, 0); }
.cs-bd[data-scene="3"] { opacity: var(--s3-o, 0); }

/* moldura com a foto nítida */
.cs-frame {
    position: absolute;
    top: 50%;
    left: 70%;
    width: var(--fw, min(34vw, calc(78svh * .75)));
    aspect-ratio: 3 / 4;
    margin: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 40px 120px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .1);
    will-change: transform, opacity;
    transform-origin: 50% 55%;
    opacity: var(--s1-o, 1);
    transform:
        translate3d(calc(-50% + var(--px) * 10px), calc(-50% + var(--py) * 7px), 0)
        scale(var(--s1-scale, 1));
}
.cs-frame[data-scene="2"] {
    opacity: var(--s2-o, 0);
    transform:
        translate3d(calc(-50% + var(--px) * 10px), calc(-50% + var(--py) * 7px), 0)
        scale(var(--s2-scale, .82));
}
.cs-frame[data-scene="3"] {
    opacity: var(--s3-o, 0);
    filter: brightness(var(--s3-bright, 1));
    transform:
        translate3d(calc(-50% + var(--px) * 10px), calc(-50% + var(--py) * 7px + var(--s3-y, 0px)), 0)
        scale(var(--s3-scale, .82));
}
.cs-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* tint / vinheta para legibilidade do texto */
.cs-shade {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(5, 7, 10, .82) 0%, rgba(5, 7, 10, .45) 38%, rgba(5, 7, 10, 0) 62%),
        radial-gradient(120% 90% at 50% 50%, transparent 55%, rgba(5, 7, 10, .55) 100%);
}

/* ---------- textos ---------- */
.cs-copy {
    position: absolute;
    z-index: 20;
    left: var(--cs-pad);
    top: 50%;
    width: min(460px, 44vw);
    opacity: var(--o, 0);
    transform: translate3d(0, calc(-50% + var(--y, 0px)), 0);
    pointer-events: none;
    will-change: transform, opacity;
}
.cs-copy[data-active="true"] { pointer-events: auto; }
#cs-intro { --o: var(--t0-o, 1); --y: var(--t0-y, 0px); }
#cs-a { --o: var(--ta-o, 0); --y: var(--ta-y, 24px); }
#cs-b { --o: var(--tb-o, 0); --y: var(--tb-y, 24px); }

.cs-eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 16px;
}
.cs-copy h2,
.cs-copy h3 {
    font-family: var(--font-headline);
    font-weight: 700;
    line-height: 1.08;
    letter-spacing: -.02em;
    font-size: clamp(32px, 4.2vw, 60px);
    margin-bottom: 20px;
    color: #fff;
}
.cs-copy p {
    font-size: clamp(16px, 1.25vw, 19px);
    line-height: 1.65;
    color: #c9ccd2;
    max-width: 38ch;
}
.cs-facts {
    list-style: none;
    margin-top: 24px;
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: #c9ccd2;
}
.cs-facts li::before { content: "\2014\00a0"; color: var(--accent); }
.cs-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    padding: 14px 24px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}
.cs-cta:hover { filter: brightness(1.1); }
.cs-hint {
    margin-top: 32px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- catálogo ---------- */
.cs-catalog {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: max(4svh, 24px);
    opacity: var(--cat-o, 0);
    transform: translate3d(0, calc((1 - var(--cat-o, 0)) * 24px), 0);
    pointer-events: none;
}
.cs-catalog[data-active="true"] { pointer-events: auto; }
.cs-catalog-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    padding: 0 var(--cs-pad);
    margin-bottom: 16px;
}
.cs-catalog-head h3 {
    font-family: var(--font-headline);
    font-size: clamp(24px, 2.6vw, 36px);
    color: #fff;
    letter-spacing: -.01em;
}
.cs-ctl {
    display: flex;
    gap: 8px;
    opacity: var(--ctl-o, 0);
}
.cs-ctl button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(13, 20, 29, .7);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}
.cs-ctl button:hover { background: rgba(255, 255, 255, .15); }
.cs-ctl button:disabled { opacity: .35; cursor: default; }

.cs-rail {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px var(--cs-pad) 12px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--cs-pad);
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    cursor: grab;
    list-style: none;
    transform: translate3d(var(--cat-x, 0px), 0, 0);
    -webkit-overflow-scrolling: touch;
}
.cs-rail::-webkit-scrollbar { display: none; }
.cs-rail.dragging { cursor: grabbing; scroll-snap-type: none; }
.cs-rail li { flex: 0 0 auto; scroll-snap-align: start; }

.cs-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 250px;
    min-height: 150px;
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(13, 20, 29, .78);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #fff;
    text-decoration: none;
    transition: transform .25s, border-color .25s, background .25s;
}
.cs-card:hover { transform: translateY(-4px); border-color: var(--primary); background: rgba(20, 30, 44, .9); }
.cs-card i { font-size: 20px; color: var(--accent); margin-bottom: 4px; }
.cs-card strong { font-family: var(--font-headline); font-size: 18px; line-height: 1.2; }
.cs-card span { font-size: 13px; line-height: 1.5; color: #aeb2ba; }
.cs-card.is-new::after {
    content: "Novo";
    align-self: flex-start;
    margin-top: auto;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--primary);
}

.cinematic-scroll a:focus-visible,
.cinematic-scroll button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.cs-skip {
    position: absolute;
    left: 8px;
    top: -60px;
    z-index: 60;
    background: #fff;
    color: #000;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
}
.cs-skip:focus { top: 8px; }

/* ---------- tablet / mobile ---------- */
@media (max-width: 1024px) {
    .cinematic-scroll { --cs-length: 3800px; }
    .cs-frame { left: 74%; --fw: min(38vw, calc(70svh * .75)); }
    .cs-copy { width: min(400px, 52vw); }
}

@media (max-width: 768px) {
    .cinematic-scroll { --cs-length: 3200px; --cs-pad: 20px; }
    .cs-bd { filter: blur(18px) brightness(.4) saturate(1.1); }
    .cs-frame {
        left: 50%;
        top: 34%;
        --fw: min(76vw, calc(50svh * .75));
        border-radius: var(--radius-md);
    }
    .cs-shade {
        background: linear-gradient(0deg, rgba(5, 7, 10, .92) 0%, rgba(5, 7, 10, .75) 34%, rgba(5, 7, 10, 0) 58%);
    }
    .cs-copy {
        left: 0;
        right: 0;
        top: auto;
        bottom: max(24px, env(safe-area-inset-bottom));
        width: auto;
        padding: 0 var(--cs-pad);
        transform: translate3d(0, var(--y, 0px), 0);
    }
    .cs-copy h2, .cs-copy h3 { font-size: clamp(28px, 8vw, 36px); margin-bottom: 12px; }
    .cs-copy p { font-size: 15px; max-width: none; }
    .cs-facts { margin-top: 14px; }
    #cs-b .cs-facts { display: none; }
    .cs-cta { margin-top: 18px; padding: 12px 22px; }
    .cs-hint { display: none; }
    .cs-card { width: 224px; min-height: 132px; padding: 16px; }
    .cs-catalog { bottom: max(16px, env(safe-area-inset-bottom)); }
}

/* ---------- movimento reduzido: sem pin, tudo em fluxo normal ---------- */
@media (prefers-reduced-motion: reduce) {
    .cinematic-scroll { height: auto; }
    .cinematic-stage {
        position: relative;
        height: auto;
        min-height: 0;
        overflow: visible;
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 56px;
        padding: 72px var(--cs-pad);
    }
    .cs-world { position: static; display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
    .cs-bd, .cs-shade { display: none; }
    .cs-frame, .cs-frame[data-scene] {
        position: relative; top: auto; left: auto; width: 100%; opacity: 1; transform: none; filter: none;
    }
    .cs-copy {
        position: static; width: auto; opacity: 1; transform: none; pointer-events: auto; padding: 0;
    }
    .cs-hint { display: none; }
    .cs-catalog { position: static; opacity: 1; transform: none; pointer-events: auto; min-width: 0; }
    .cs-catalog-head, .cs-rail { padding-inline: 0; }
    .cs-ctl { opacity: 1; }
    .cs-rail { transform: none; }
}
