/* Refleczo Reviews — owned UGC photo lightbox (Task B7).
 * Replaces Stamped's .stamped-ugc-modal. Ported from the battle-tested
 * stamped-polish.md Part 2 design onto our own .refleczo-lb-* markup.
 *
 * Hard-won lessons baked in:
 *  - Viewport-locked (position:fixed; inset:0; overflow:hidden) — NEVER 100vh.
 *  - Horizontal-pan lock: overflow-x:hidden + max-width:100% + overscroll-behavior:contain
 *    on EVERY layer so iOS Safari has nowhere to pan during swipe.
 *  - NO touch-action:pan-y on the text container.
 *  - No backdrop-tap close (deliberate). Two explicit closes: top-right X + Fechar.
 */

/* ---------------------------------------------------------------- modal shell */
#refleczo-lb {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100%;
    overscroll-behavior: contain;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
#refleczo-lb[hidden] { display: none; }

.refleczo-lb-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100%;
    overscroll-behavior: contain;
}

/* ---------------------------------------------------------------- photo area */
.refleczo-lb-photo {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100%;
    overscroll-behavior: contain;
    order: 1;
}
.refleczo-lb-photo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* ---------------------------------------------------------------- review text */
.refleczo-lb-content {
    order: 2;
    flex: 0 0 auto;
    max-height: 50%;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding: 12px 14px;
    background: #fff;
    color: #222;
}
.refleczo-lb-stars { display: inline-flex; gap: 2px; line-height: 1; margin: 0 0 2px; }
.refleczo-lb-stars svg { width: 16px; height: 16px; display: block; fill: #fbbc04; }
.refleczo-lb-author { font-size: 13px; font-weight: 600; color: #444; margin: 2px 0; }
.refleczo-lb-title { font-size: 15px; font-weight: 600; color: #222; margin: 2px 0 4px; line-height: 1.25; }
.refleczo-lb-body { font-size: 13px; line-height: 1.45; color: #333; margin: 2px 0 4px; }

/* ---------------------------------------------------------------- thumb strip */
.refleczo-lb-thumbs {
    order: 3;
    flex: 0 0 64px;
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 4px 8px;
    background: #1a1a1a;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}
.refleczo-lb-thumb {
    flex: 0 0 auto;
    width: 55px;
    height: 55px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.7;
    border: 2px solid transparent;
    box-sizing: border-box;
    padding: 0;
    background: #000;
}
.refleczo-lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.refleczo-lb-thumb.is-active { opacity: 1; border-color: #fff; outline: 1px solid rgba(255,255,255,0.4); }

/* ---------------------------------------------------------------- Fechar bar */
.refleczo-lb-fechar-bar {
    order: 4;
    flex: 0 0 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    background: transparent;
}
.refleczo-lb-fechar {
    min-width: 88px;
    height: 40px;
    padding: 0 22px;
    border: none;
    border-radius: 99px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.refleczo-lb-fechar:hover { background: rgba(0, 0, 0, 0.95); }

/* ---------------------------------------------------------------- close X (top-right) */
.refleczo-lb-x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    cursor: pointer;
    z-index: 20;
    padding: 0;
}
.refleczo-lb-x::before,
.refleczo-lb-x::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}
.refleczo-lb-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.refleczo-lb-x::after  { transform: translate(-50%, -50%) rotate(-45deg); }

/* ---------------------------------------------------------------- prev/next arrows */
.refleczo-lb-nav {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    cursor: pointer;
    z-index: 15;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.refleczo-lb-nav::before {
    content: "";
    width: 12px;
    height: 12px;
    border-top: 2px solid #fff;
    border-right: 2px solid #fff;
}
.refleczo-lb-prev { left: 14px; bottom: 14px; }
.refleczo-lb-next { right: 14px; bottom: 14px; }
.refleczo-lb-prev::before { transform: translateX(3px) rotate(-135deg); }
.refleczo-lb-next::before { transform: translateX(-3px) rotate(45deg); }
.refleczo-lb-nav[disabled] { opacity: 0.3; cursor: default; }

/* ================================================================ DESKTOP (≥850px) */
@media (min-width: 850px) {
    .refleczo-lb-wrap {
        position: absolute;
        inset: auto;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: calc(100% - 64px);
        height: calc(100% - 64px);
        max-width: 1160px;
        max-height: 760px;
        background: #fff;
        border-radius: 12px;
        overflow: hidden;
        /* two-pane (photo + content) on top row, strip + fechar full width below */
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
        grid-template-rows: minmax(0, 1fr) auto auto;
        grid-template-areas:
            "photo content"
            "thumbs thumbs"
            "fechar fechar";
    }
    .refleczo-lb-photo {
        grid-area: photo;
        order: 0;
        background: #111;
        border-top-left-radius: 12px;
    }
    .refleczo-lb-content {
        grid-area: content;
        order: 0;
        max-height: none;
        height: 100%;
        overflow-y: auto;
        padding: 28px 26px;
        background: #fff;
    }
    .refleczo-lb-author { font-size: 14px; }
    .refleczo-lb-title { font-size: 18px; }
    .refleczo-lb-body { font-size: 14px; line-height: 1.5; }

    .refleczo-lb-thumbs {
        grid-area: thumbs;
        order: 0;
        flex: none;
        height: 96px;
        padding: 10px 14px;
        background: #f3f3f3;
        border-top: 1px solid #e5e5e5;
    }
    .refleczo-lb-thumb { width: 75px; height: 75px; border-radius: 8px; }
    .refleczo-lb-thumb.is-active { border-color: #222; outline-color: rgba(0,0,0,0.25); }

    .refleczo-lb-fechar-bar {
        grid-area: fechar;
        order: 0;
        flex: none;
        height: auto;
        margin: 0;
        padding: 12px;
        background: #fff;
        border-top: 1px solid #e5e5e5;
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
    }

    /* X sits on the modal, top-right of the whole modal */
    .refleczo-lb-x { top: 14px; right: 14px; }

    /* arrows vertically centered over the photo pane (they live inside .refleczo-lb-photo) */
    .refleczo-lb-prev,
    .refleczo-lb-next { bottom: auto; top: 50%; transform: translateY(-50%); }
    .refleczo-lb-prev { left: 16px; }
    .refleczo-lb-next { right: 16px; }
}
