/* =========================================================
   QWINKY REELS
   Vertical feed — mobile full-screen + desktop centered player
   ========================================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --pink-soft: #ff94d9;

    --icon-menu-height: 102px;
    --account-bar-height: 46px;
    --account-icon-gap: 3px;

    --top-menu-height: var(--icon-menu-height);
    --chrome-shift: 0px;

    --reel-height: 100dvh;
}

html,
body {
    width: 100%;
    height: 100%;
    max-width: 100%;
    background: #000;
    color: #fff;
    font-family: 'Montserrat', sans-serif;
    overflow: hidden;
    overscroll-behavior: none;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.is-guest {
    --top-menu-height:
        calc(
            var(--account-bar-height)
            + var(--account-icon-gap)
            + var(--icon-menu-height)
        );
}

body.is-member {
    --top-menu-height: var(--icon-menu-height);
}


/* =========================================================
   TOP MENU
   Same visual logic as quests.php
   ========================================================= */

.top-shell {
    position: relative;
    z-index: 5000;
}

.top-shell::before {
    content: "";
    position: fixed;
    z-index: 1;
    inset: 0 0 auto 0;
    height: var(--top-menu-height);

    background: rgba(25, 4, 16, .92);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .26);

    pointer-events: none;
}

.join-menu {
    position: fixed;
    z-index: 30;
    top: 0;
    left: 0;
    right: 0;

    width: 100%;
    height: var(--account-bar-height);

    padding: 0 10px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;

    background: rgba(14, 3, 10, .96);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .22);

    isolation: isolate;
    overflow: hidden;
}

body.is-member .join-menu {
    display: none !important;
}

.top-button,
.join-menu .top-button {
    min-width: 80px;
    min-height: 30px;

    padding: 6px 11px;

    display: inline-flex !important;
    align-items: center;
    justify-content: center;

    position: static !important;
    inset: auto !important;
    margin: 0 !important;
    transform: none !important;

    flex: 0 0 auto;

    line-height: 1;

    border: 1px solid rgba(255, 255, 255, .52);
    border-radius: 999px;

    color: #111;
    background: #eae0e0;

    text-align: center;
    text-decoration: none;

    font-size: 10px;
    font-weight: 800;

    visibility: visible !important;
    opacity: 1 !important;
}

.join-menu .login-button {
    color: #fff;
    border-color: #42c86b;
    background: linear-gradient(180deg, #42c86b, #258b45);
}

.join-menu .join-button {
    color: #fff;
    border-color: #ff3b45;
    background: linear-gradient(180deg, #ff3b45, #c41520);
}

.top-icon-menu {
    position: fixed;
    z-index: 20;

    top: 0;
    left: 0;
    right: 0;

    width: 100%;
    height: var(--icon-menu-height);

    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
}

body.is-guest .top-icon-menu {
    top: calc(
        var(--account-bar-height)
        + var(--account-icon-gap)
    );
}

.top-icon-link {
    width: 33.333%;
    min-width: 0;
    height: 100%;

    padding: 6px 2px 7px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;

    color: rgba(255, 255, 255, .68);
    text-decoration: none;

    border-radius: 16px;

    -webkit-tap-highlight-color: transparent;
}

.top-icon-link img {
    width: min(96px, 27vw);
    height: auto;
    max-height: 72px;
    object-fit: contain;

    filter: brightness(.82) saturate(.9);

    user-select: none;
    -webkit-user-drag: none;
}

.top-icon-label {
    display: block;
    margin-top: -1px;

    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.top-icon-link.is-active {
    color: var(--pink-soft);
}

.top-icon-link.is-active img {
    filter:
        brightness(1.12)
        saturate(1.15)
        drop-shadow(0 0 5px rgba(255, 105, 210, .98))
        drop-shadow(0 0 12px rgba(255, 71, 190, .82))
        drop-shadow(0 0 24px rgba(255, 46, 174, .54));
}

.top-shell::before,
.top-icon-menu,
.join-menu {
    transform: translateY(var(--chrome-shift));
    transition: none !important;
    will-change: transform;
}



.mobile-only {
    display: inline;
}

.desktop-only {
    display: none;
}

/* On mobile the real stage still occupies the complete reel. */
.reel-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #000;
}

/* Desktop ambient background; hidden on mobile. */
.reel-backdrop {
    display: none;
}

/* =========================================================
   FEED
   ========================================================= */

.reels-feed {
    position: fixed;
    inset: 0;

    width: 100%;
    height: var(--reel-height);

    overflow-x: hidden;
    overflow-y: auto;

    scroll-snap-type: y mandatory;
    scroll-behavior: auto;

    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;

    background: #000;
}

.reels-feed::-webkit-scrollbar {
    display: none;
}

.reel {
    position: relative;

    width: 100%;
    height: var(--reel-height);
    min-height: 100svh;

    overflow: hidden;

    scroll-snap-align: start;
    scroll-snap-stop: always;

    background: #000;

    cursor: pointer;

    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: pan-y;
}

.reel-video {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;
    object-position: center center;

    background: #000;

    pointer-events: none;
}

.reel-shade {
    position: absolute;
    z-index: 2;
    inset: 0;

    background:
        linear-gradient(
            180deg,
            rgba(0, 0, 0, .14) 0%,
            rgba(0, 0, 0, 0) 28%,
            rgba(0, 0, 0, 0) 62%,
            rgba(0, 0, 0, .56) 100%
        );

    pointer-events: none;
}

.reel-info {
    position: absolute;
    z-index: 3;

    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));

    bottom:
        max(
            28px,
            calc(env(safe-area-inset-bottom) + 18px)
        );

    color: #fff;

    text-shadow: 0 2px 10px rgba(0, 0, 0, .9);

    pointer-events: none;
}

.reel-girl {
    margin-bottom: 5px;

    font-size: 17px;
    font-weight: 900;
    line-height: 1.05;
}

.reel-title {
    max-width: 82%;

    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
}

.reel-play-label {
    margin-top: 7px;

    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;

    opacity: .74;
}

.reel-progress {
    position: absolute;
    z-index: 4;

    left: 10px;
    right: 10px;

    bottom:
        max(
            8px,
            env(safe-area-inset-bottom)
        );

    height: 3px;

    overflow: hidden;

    border-radius: 999px;
    background: rgba(255, 255, 255, .22);

    pointer-events: none;
}

.reel-progress span {
    display: block;

    width: 0%;
    height: 100%;

    border-radius: inherit;
    background: #fff;

    transform-origin: left center;
}

.reel-empty {
    display: grid;
    place-items: center;

    padding: 30px;

    text-align: center;
}

.reel-empty-message {
    font-size: 15px;
    font-weight: 700;
    opacity: .7;
}


/* =========================================================
   DESKTOP REELS
   Vertical 1:2 stage + blurred ambient background
   ========================================================= */

.desktop-reels-block {
    display: none !important;
}

@media (min-width: 901px) {

    :root {
        --icon-menu-height: 110px;
        --account-bar-height: 64px;
        --account-icon-gap: 6px;
    }

    /*
      Restore the compact desktop Qwinky header instead of stretching
      the three icons across the entire monitor.
    */
    .top-icon-menu {
        left: 10px;
        right: auto;
        width: auto;
        justify-content: flex-start;
        gap: 1px;
    }

    .top-icon-link {
        width: 110px;
        min-width: 110px;
        padding: 6px 4px 7px;
        transition:
            transform .16s ease,
            background .16s ease,
            color .16s ease;
    }

    .top-icon-link img {
        width: 108px;
        max-height: 81px;
    }

    .top-icon-label {
        font-size: 10px;
    }

    .top-icon-link:hover {
        transform: translateY(-1px) scale(1.025);
        color: #fff;
        background: rgba(255,255,255,.045);
    }

    .top-icon-link:hover img {
        filter: brightness(1.04) saturate(1.05);
    }

    .join-menu {
        height: var(--account-bar-height);
        padding: 12px 10px;
        gap: 10px;
    }

    .top-button,
    .join-menu .top-button {
        min-width: 104px;
        min-height: 38px;
        padding: 8px 20px;
        font-size: 12px;
    }

    /*
      Feed stays exactly the same scroll-snap system as mobile.
      Wheel/trackpad simply moves from one 100vh reel to the next.
    */
    .reels-feed {
        display: block;
        background: #050505;
    }

    .reel {
        display: flex;
        align-items: center;
        justify-content: center;

        padding:
            calc(var(--top-menu-height) + 14px)
            28px
            18px;

        isolation: isolate;
        background: #050505;
    }

    /*
      The same poster fills the monitor, heavily blurred.
      This avoids decoding the MP4 a second time just for ambience.
    */
    .reel-backdrop {
        display: block;

        position: absolute;
        z-index: 0;

        inset: -8%;

        width: 116%;
        height: 116%;

        object-fit: cover;
        object-position: center;

        filter:
            blur(48px)
            brightness(.28)
            saturate(.9);

        transform: scale(1.06);

        opacity: .92;

        pointer-events: none;
        user-select: none;
    }

    /*
      Dark glass/vignette over the blurred image so the vertical teaser
      always remains the visual focus.
    */
    .reel::before {
        content: "";

        position: absolute;
        z-index: 1;
        inset: 0;

        background:
            radial-gradient(
                ellipse at center,
                rgba(0,0,0,.04) 0%,
                rgba(0,0,0,.22) 52%,
                rgba(0,0,0,.62) 100%
            ),
            linear-gradient(
                180deg,
                rgba(7,3,7,.12),
                rgba(7,3,7,.32)
            );

        pointer-events: none;
    }

    /*
      1:2 vertical player.
      On an ordinary 1440x900 desktop this is ~379 x 758 px.
      On very tall displays it tops out around 470 x 940 px.
    */
    .reel-stage {
        position: relative;
        z-index: 2;
        inset: auto;

        flex: 0 0 auto;

        height: min(
            calc(var(--reel-height) - var(--top-menu-height) - 32px),
            940px
        );

        aspect-ratio: 1 / 2;

        width: auto;
        max-width: 520px;

        overflow: hidden;

        border-radius: 18px;

        background: #000;

        border: 1px solid rgba(255,255,255,.15);

        box-shadow:
            0 30px 90px rgba(0,0,0,.68),
            0 8px 28px rgba(0,0,0,.50),
            0 0 0 1px rgba(0,0,0,.25);
    }

    .reel-video {
        border-radius: inherit;
    }

    .reel-shade {
        border-radius: inherit;

        background:
            linear-gradient(
                180deg,
                rgba(0,0,0,.10) 0%,
                rgba(0,0,0,0) 24%,
                rgba(0,0,0,0) 62%,
                rgba(0,0,0,.64) 100%
            );
    }

    .reel-info {
        left: 20px;
        right: 20px;
        bottom: 30px;
    }

    .reel-girl {
        font-size: 18px;
    }

    .reel-title {
        max-width: 92%;
        font-size: 14px;
    }

    .reel-play-label {
        margin-top: 8px;
        font-size: 10px;
        opacity: .72;
    }

    .reel-progress {
        left: 12px;
        right: 12px;
        bottom: 10px;
    }

    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: inline;
    }

    /*
      The menu still follows --chrome-shift from the existing JS.
      Give the stage a subtle matching upward drift while the header hides,
      so the composition does not feel anchored too low.
    */
    .reel-stage {
        transform: translateY(calc(var(--chrome-shift) * .22));
        will-change: transform;
    }
}


/* =========================================================
   ACCESSIBILITY
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    .reels-feed {
        scroll-behavior: auto;
    }
}
