/* ============================================================
   Gallery Stack — frontend CSS (v1.5.36+).
   Replaces the inline 2-col grid that lived in gallery-stack.php.

   Layout strategy:
     - Desktop (>=769px): 2-column CSS grid. Tiles fill LEFT-TO-RIGHT
       in reading order (image 1 top-left, 2 top-right, 3 below-left,
       4 below-right) so the on-screen order matches the sequence set
       in the Story images box. Tiles keep their natural proportions
       (no crop) at a fixed column width, so portrait/landscape
       uploads show in full. (Was a uniform square crop at
       v1.8.13-1.8.14; before that a CSS-column masonry, which
       filled column-by-column and showed images out of reading
       order. The grid keeps reading order; dropping the square
       crop restores the original rectangular look.)
     - Tablet (769-1024px): same grid, tighter gap.
     - Mobile (<=768px): horizontal scroll-snap slider with arrow
       buttons + dot indicator. Same swipe pattern as the
       Routine Builder cards. Images keep their natural proportions
       here (one per view), so no square crop is applied.

   Each image is a <button class="wlpp-story-grid-item"> so
   keyboard + screen-reader users can open the lightbox the same
   way mouse users do. The PhotoSwipe init is in gallery-stack.js.
   ============================================================ */

.wlpp-story-grid-wrap {
    position: relative;
    margin: 30px 0;
}


/* ============================================================
   GRID — desktop 2-column grid, reading order (left-to-right).
   ============================================================ */
.wlpp-story-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.wlpp-story-grid-item {
    /* Reset native button defaults so the wrapper looks like a
       clean tile, not a system button. */
    display: block;
    width: 100%;
    /* Natural height — no fixed aspect ratio, so each image keeps
       its own proportions (rectangular/portrait/landscape) at the
       fixed column width. Reading order is preserved by the grid's
       row-by-row auto-placement; uneven heights may leave a little
       whitespace at the foot of a shorter row, which is expected. */
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    cursor: zoom-in;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wlpp-story-grid-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.wlpp-story-grid-item:focus-visible {
    outline: 3px solid #851625;
    outline-offset: 2px;
}

.wlpp-story-grid-img {
    width: 100%;
    height: auto; /* natural height — show the full image, no crop */
    display: block;
}


/* ============================================================
   ARROWS + DOTS — hidden on desktop (masonry has no concept of
   "next" — there's no scroll). Mobile-only via media query.
   ============================================================ */
.wlpp-story-grid-arrow,
.wlpp-story-grid-dots {
    display: none;
}


/* ============================================================
   TABLET (769-1024px) — same grid, slightly tighter gap.
   ============================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
    .wlpp-story-grid {
        gap: 12px;
    }
}


/* ============================================================
   MOBILE (<=768px) — horizontal scroll-snap slider.
   ============================================================ */
@media (max-width: 768px) {

    /* Slider: switch off the grid, become a flex row with native
       scroll-snap (same pattern as routine-builder.css). */
    .wlpp-story-grid {
        display: flex; /* overrides the desktop grid */
        gap: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 4px;
    }
    .wlpp-story-grid::-webkit-scrollbar {
        display: none;
    }

    .wlpp-story-grid-item {
        flex: 0 0 88%;
        max-width: 88%;
        /* Keep natural image proportions in the slider — no square
           crop here (one image per view). */
        aspect-ratio: auto;
        margin: 0;
        scroll-snap-align: start;
    }
    .wlpp-story-grid-img {
        height: auto; /* natural height to match aspect-ratio:auto */
    }
    .wlpp-story-grid-item:hover {
        transform: none;
        box-shadow: none;
    }

    /* Arrows: visible, sit just outside the slider edge, semi-
       transparent burgundy circles. Hidden when at the start or
       end (JS toggles .is-disabled). */
    .wlpp-story-grid-arrow {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 36px;
        height: 36px;
        border-radius: 50%;
        border: 0;
        background: rgba(255, 255, 255, 0.92);
        color: #1f1f1f;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        cursor: pointer;
        padding: 0;
        z-index: 2;
        transition: opacity 0.2s, transform 0.15s;
    }
    .wlpp-story-grid-arrow-prev { left: -4px; }
    .wlpp-story-grid-arrow-next { right: -4px; }
    .wlpp-story-grid-arrow:disabled,
    .wlpp-story-grid-arrow.is-disabled {
        opacity: 0.35;
        pointer-events: none;
    }

    /* Dots — one per image, current = burgundy + scaled. */
    .wlpp-story-grid-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: 14px;
        padding: 0;
        list-style: none;
    }
    .wlpp-story-grid-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #d6d2cd;
        border: 0;
        padding: 0;
        cursor: pointer;
        transition: background-color 0.2s, transform 0.2s;
    }
    .wlpp-story-grid-dot.is-active {
        background: #851625;
        transform: scale(1.3);
    }
}


/* ============================================================
   PHOTOSWIPE CONTAINER — minor tweak so its close/arrow icons
   pick up brand colour. Otherwise WC's default skin is reused
   as-is.
   ============================================================ */
.pswp__button--close,
.pswp__button--arrow--left,
.pswp__button--arrow--right {
    /* Keep WC defaults; no override needed for now. */
}

/* Hide the lightbox caption (image alt/description). Story images
   are decorative in the lightbox, so we don't show the caption bar
   under the enlarged image. */
.pswp__caption {
    display: none !important;
}
