* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #0a0a0a;
    color: #f6f6f6;
    font-family: 'JetBrains Mono', monospace;
}

/* Hide scrollbar */
html {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html::-webkit-scrollbar {
    display: none;
}

.posters-app {
    width: 100%;
    position: relative;
}

/* Header - Hidden */
.header {
    display: none;
}

/* Scroll hint */
/* Gallery View */
.gallery {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 1800px;
    perspective-origin: 50% 50%;
    overflow: hidden;
}

.gallery-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Poster Wrapper - handles positioning */
.poster-wrapper {
    position: absolute;
    width: 320px;
    cursor: pointer;
    will-change: transform;
}

/* Poster Card - handles skew and hover animation via CSS */
.poster-card {
    width: 100%;
    will-change: transform;
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    --skew-x: 0deg;
    --skew-y: 19deg;
    /* Continuous lift driven by proximity to the active point on mobile,
       or by the :hover rule on desktop. Default 0% = sits in the stack. */
    --lift-x: 0%;
    transform: skewX(var(--skew-x)) skewY(var(--skew-y)) translateX(var(--lift-x));
}

/* Desktop lift is driven by JS (scroll-driven, mobile-style 2-card
   handoff). See applyLifts() + desktopScrollTick() in posters.js. */

/* While a scroll loop (desktop wheel or mobile touch) is driving --lift-x
   and the transform every frame, suppress the CSS transition — otherwise
   it would smear over the JS-interpolated values. Restored on scroll end
   so the initial-load lift and any one-shot setters still animate. */
body.posters-scrolling .poster-card {
    transition: none;
}

.poster-card img {
    width: 100%;
    height: auto;
    border-radius: 2px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    user-select: none;
}


/* Gallery Navigation - hidden on scroll version */
.gallery-nav {
    display: none;
}

/* Detail View */
.detail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #202020;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.detail.visible {
    opacity: 1;
    visibility: visible;
}

/* Back Button */
.back-btn {
    position: fixed;
    top: 115px;
    left: 58px;
    width: 32px;
    height: 32px;
    padding: 4px;
    background: transparent;
    border: 0.8px solid #2D2D2D;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    z-index: 250;
    transition: color 0.2s;
    box-sizing: border-box;
}

.back-btn:hover {
    color: #fff;
}

/* Marquee Background */
.marquee-bg {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.marquee-track {
    display: flex;
    white-space: nowrap;
    animation: marquee 20s linear infinite;
}

.marquee-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 120px;
    font-weight: 500;
    line-height: 100%;
    color: #F6F6F6;
    text-transform: uppercase;
    letter-spacing: -0.12em;
}

/* Separator between repeats — e.g. "TITLE | TITLE | TITLE" */
.marquee-text::after {
    content: "|";
    margin: 0 40px;
    font-weight: 400;
    color: #FFFFFF;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-25%); }
}

/* Detail Content */
.detail-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 60px;
    padding: 80px 60px 80px 120px;
    z-index: 10;
}

.detail-image {
    position: absolute;
    top: 115px;
    left: 120px;
    height: calc(100vh - 197px);
    aspect-ratio: 561 / 698;
    flex: 0 0 auto;
    border-radius: 4px;
    /* box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5); */
}

.detail-image canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 4px;
}

.detail-info {
    position: absolute;
    top: calc(50% + 140px);
    left: calc(170px + 0.8037 * (100vh - 197px));
    width: min(500px, calc(100vw - 170px - 0.8037 * (100vh - 197px) - 80px));
    flex: 0 0 auto;
    max-width: none;
    z-index: 11;
    text-align: left;
}

.detail-desc {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 20px;
    line-height: 32px;
    letter-spacing: 0;
    color: #7B7B7B;
    text-transform: uppercase;
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    .header {
        padding: 16px;
    }

    .gallery {
        perspective: 800px;
        align-items: flex-end;
        padding-bottom: 100px;
    }

    .gallery-wrapper {
        justify-content: center;
    }

    .poster-wrapper {
        width: 190px;
    }

    /* Mobile: slight skew */
    .poster-card {
        --skew-x: 0deg;
        --skew-y: 12deg;
    }

    /* Show navigation on mobile */
    .gallery-nav {
        display: contents;
    }

    .nav-btn {
        position: fixed;
        bottom: 135px;
        box-sizing: content-box;
        width: 20px;
        height: 20px;
        padding: 8px;
        background: transparent;
        border: 0.8px solid #2D2D2D;
        color: rgba(255, 255, 255, 0.6);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        z-index: 100;
    }

    .nav-btn.prev { left: 30px; }
    .nav-btn.next { right: 30px; }

    .nav-btn img {
        display: block;
        width: 20px;
        height: 20px;
    }

    .nav-btn:active {
        background: rgba(255, 255, 255, 0.1);
        color: #fff;
    }

    .nav-btn.disabled {
        opacity: 0.05;
        pointer-events: none;
    }

    .poster-card {
        transition-duration: 0.2s;
    }

    /* (Touch-drag transition suppression now lives at the top level so the
       same posters-scrolling class also covers the desktop wheel loop.) */

    /* Lighter shadows on mobile — the desktop 50px-blur shadow on 32+
       layers is expensive enough on phone GPUs to cause scroll jank. */
    .poster-card img {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    }

    .poster-wrapper.active .poster-card img {
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
    }

    /* Detail mobile — stack marquee + card + desc, centered vertically.
       `safe center` falls back to flex-start when content overflows, so the
       marquee + back button stay reachable on short viewports (e.g. iPhone
       14 Pro) instead of overflowing above the scroll origin. */
    .detail {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: safe center;
        /* Top gap clears the fixed navbar + its (now shorter) progressive
           blur (~92px) so the back arrow isn't hidden behind it. */
        padding: 100px 0 100px;
        overflow-y: auto;
    }

    .detail-content {
        position: static;
        flex: 0 0 auto;
        flex-direction: column;
        width: 100%;
        height: auto;
        padding: 28px 30px 0;
        gap: 28px;
        overflow-y: visible;
        align-items: center;
        justify-content: flex-start;
    }

    /* Scrolling title above the card, now part of the flow.
       flex-shrink:0 — .marquee-bg has overflow:hidden so its min-content
       height collapses to ~0, and the parent flex column would otherwise
       squash it (DevTools showed it shrunk to 18px on short viewports). */
    .marquee-bg {
        position: static;
        top: auto;
        transform: none;
        width: 100%;
        order: -1;
        flex-shrink: 0;
    }

    .marquee-track {
        animation-duration: 18s;
    }

    .marquee-text {
        font-family: 'JetBrains Mono', monospace;
        font-weight: 500;
        font-size: 40px;
        /* line-height >= 1.2 so descenders (y/g/comma) sit inside the
           line box — otherwise .marquee-bg's overflow:hidden clips them,
           which is what made "Markey B. G." look cropped on short phones. */
        line-height: 1.2;
        letter-spacing: -0.12em;
        color: #F6F6F6;
        text-transform: uppercase;
    }

    .marquee-text::after {
        margin: 0 16px;
    }

    .detail-image {
        position: static;
        top: auto;
        left: auto;
        height: auto;
        max-width: none;
        flex: 0 0 auto;
        width: min(370px, 86vw);
        aspect-ratio: 370 / 460;
    }

    .detail-image canvas {
        max-height: none;
        width: 100%;
        height: 100%;
        display: block;
    }

    .detail-info {
        position: static;
        top: auto;
        left: auto;
        max-width: 100%;
        width: 100%;
        text-align: center;
    }

    .detail-desc {
        font-family: 'JetBrains Mono', monospace;
        font-weight: 300;
        font-size: 16px;
        line-height: 26px;
        letter-spacing: -0.04em;
        color: #7B7B7B;
        text-transform: uppercase;
        /* No internal scroll — on short viewports the outer .detail
           (overflow-y:auto + safe center) handles scrolling, so marquee +
           poster + full description all stay reachable as one flow. */
    }

    .back-btn {
        position: static;
        order: -2;
        top: auto;
        left: auto;
        width: auto;
        height: auto;
        box-sizing: content-box;
        align-self: flex-start;
        margin: 0 0 30px 30px;
        padding: 8px;
        border: 0.8px solid #2D2D2D;
        flex-shrink: 0;
    }
}
