/* 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;          /* fills the space above the review text; text stays pinned at the bottom */
    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;       /* natural height, pinned at the bottom (photo fills above) */
    max-height: 45%;
    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-loc { display: inline-flex; align-items: center; gap: 5px; margin: 3px 0 5px; }
.refleczo-lb-flag { border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,0.12); flex: 0 0 auto; opacity: 0.8; }
.refleczo-lb-loc span { font-size: 13px; font-weight: 600; color: #555; }
.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 76px;       /* taller so the active thumb's border isn't clipped top/bottom */
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 9px 10px;
    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; }
/* Active = solid border only (no outline — outline sat OUTSIDE the box and got
   clipped by the strip, which read as the thumb "cut at the top"). */
.refleczo-lb-thumb.is-active { opacity: 1; border-color: #fff; }

/* ---------------------------------------------------------------- photo counter (i/N) */
/* Sits between the thumbnail strip and the Fechar button. Light on the dark
   mobile surround; dark on the white desktop panel (override below). */
.refleczo-lb-counter {
    order: 4;
    flex: 0 0 auto;
    position: relative;       /* anchor the spread-out side arrows */
    display: flex;
    align-items: center;
    justify-content: center;  /* count text dead-center */
    min-height: 30px;
    color: #cfcfcf;           /* light on the dark mobile surround (desktop overrides) */
    padding: 2px 0 0;         /* tight: minimal gap to strip above / Fechar below */
    overflow: visible;        /* side arrows may overflow vertically */
}
.refleczo-lb-counter[hidden] { display: none; }
.refleczo-lb-count-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
}
/* secondary prev/next — pushed OUT to the sides (clear of the centered count text
   AND the centered Fechar pill below), vertically centered on the row. Absolute so
   they can overflow the now-tight row height without nudging anything or colliding. */
.refleczo-lb-cnav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    min-width: 0;             /* beat the theme's button min-width/height (was ovalling these) */
    min-height: 0;
    box-sizing: border-box;
    line-height: 0;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.refleczo-lb-cprev { left: calc(50% - 150px); }
.refleczo-lb-cnext { right: calc(50% - 150px); }
.refleczo-lb-cnav::before {
    content: "";
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}
.refleczo-lb-cprev::before { transform: translateX(2px) rotate(-135deg); }
.refleczo-lb-cnext::before { transform: translateX(-2px) rotate(45deg); }
.refleczo-lb-cnav[disabled] { opacity: 0.3; cursor: default; }

/* ---------------------------------------------------------------- Fechar bar */
.refleczo-lb-fechar-bar {
    order: 5;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;            /* tight gap to the counter above */
    background: transparent;
}
/* Mobile: the bar sits over the dark overlay, so a light pill reads clearly
   (the old dark pill was black-on-black). Desktop bar is white → dark pill (below). */
.refleczo-lb-fechar {
    min-width: 88px;
    height: 40px;
    margin: 0;               /* kill the theme button's 0 14px 14px 0 margin (was shifting it left of center) */
    padding: 0 22px;
    border: none;
    border-radius: 99px;
    background: #fff;
    color: #1a1a1a;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.refleczo-lb-fechar:hover { background: #ececec; }

/* ---------------------------------------------------------------- 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;
}
/* Centered on the photo (vertical middle) rather than anchored to the photo's
   bottom edge — the bottom edge = top of the review text, which shifts per review,
   which is what made the arrows jump. Centered keeps them put. */
.refleczo-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.refleczo-lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.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 auto;
        grid-template-areas:
            "photo content"
            "thumbs thumbs"
            "counter counter"
            "fechar fechar";
    }
    .refleczo-lb-photo {
        grid-area: photo;
        order: 0;
        flex: none;                 /* grid controls sizing here, not flex-basis */
        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: 100px;              /* room so the active border isn't clipped */
        padding: 12px 14px 8px;     /* less bottom → tighter to the counter */
        background: #f3f3f3;
        border-top: 1px solid #e5e5e5;
    }
    .refleczo-lb-thumb { width: 72px; height: 72px; border-radius: 8px; }
    .refleczo-lb-thumb.is-active { border-color: #222; }

    /* counter on the white desktop panel → dark text, blends with the thumb strip */
    .refleczo-lb-counter {
        grid-area: counter;
        color: #666;
        background: #f3f3f3;
        min-height: 26px;
        padding: 0 14px 4px;     /* tight: snug between strip and Fechar */
    }
    /* a bit more spread on the wider desktop panel */
    .refleczo-lb-cprev { left: calc(50% - 175px); }
    .refleczo-lb-cnext { right: calc(50% - 175px); }
    .refleczo-lb-cnav { background: rgba(0, 0, 0, 0.07); }
    .refleczo-lb-cnav:hover { background: rgba(0, 0, 0, 0.13); }

    .refleczo-lb-fechar-bar {
        grid-area: fechar;
        order: 0;
        flex: none;
        height: auto;
        margin: 0;
        padding: 8px 12px;
        background: #fff;
        border-top: 1px solid #e5e5e5;
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
    }
    /* desktop bar is white → dark pill reads best */
    .refleczo-lb-fechar { background: #222; color: #fff; }
    .refleczo-lb-fechar:hover { background: #000; }

    /* 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; }
}
