/* ============================================================
   AF Recent Gallery Widget — style.css
   ============================================================ */

/* ── Section wrapper ────────────────────────────────────────── */
.af-gallery-section {
    width: 100%;
    box-sizing: border-box;
    background: #fff;
}

/* ── Heading block ──────────────────────────────────────────── */
.af-gallery-heading-wrap {
    text-align: center;
    margin-bottom: 40px;
}

.af-gallery-script-heading {
    font-family: 'Dancing Script', 'Pacifico', cursive;
    font-size: 1.5rem;
    font-style: italic;
    color: #4a4a4a;
    margin: 0 0 6px;
    display: block;
    line-height: 1.3;
}

.af-gallery-main-heading {
    font-size: 2.6rem;
    font-weight: 700;
    color: #1a2e3b;
    margin: 0;
    line-height: 1.15;
}

/* ── Grid layout ────────────────────────────────────────────── */
/*
   STAGGERED GALLERY LAYOUT — pyramid/mountain shape
   ═══════════════════════════════════════════════════
   Studied from reference image:

   Col 3 (center tall)  = 380px  ← tallest, peaks above everything
   Col 2 & 4 (doubles)  = 340px  ← mid height, two stacked squares
   Col 1 & 5 (outer)    = 280px  ← shortest, squarish, sit centered

   All columns are align-self:center so they all share the same
   vertical midpoint — producing the pyramid silhouette.
   Grid height = tallest col (380px). overflow:visible lets nothing clip.

   Visual result:
        ___
       |   |
   ___ |   | ___
  |   ||   ||   |
  | 2 || 3 || 4 |
  |___||   ||___|
   ___ |   | ___
  |   ||___||   |
  | 1 |     | 5 |
  |___|     |___|

   Wait — re-reading reference more carefully:
   Col 1 & 5: tall single, vertically CENTERED → they protrude above AND below col 2/4
   Col 2 & 4: two stacked images, combined height shorter than col 1/5
   Col 3: tallest of all

   Correct heights:
   Col 3  = 400px  (tallest)
   Col 1,5 = 370px  (second tallest — tall portrait, centered)
   Col 2,4 = 320px  (shortest combined — two small stacked squares)
*/
.af-gallery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    gap: 12px;
    /* Grid height = tallest element */
    height: 400px;
    width: 100%;
    overflow: visible;
    /* All cols share the same vertical center */
    align-items: center;
}

.af-gallery-col {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-self: center;
}

/* Col 1 & 5 — tall outer singles, second tallest */
.af-gallery-col:nth-child(1),
.af-gallery-col:nth-child(5) {
    height: 370px;
}

/* Col 2 & 4 — double stacked, shortest combined */
.af-gallery-col:nth-child(2),
.af-gallery-col:nth-child(4) {
    height: 320px;
}

/* Col 3 — center single, tallest */
.af-gallery-col:nth-child(3) {
    height: 400px;
}

.af-gallery-col-double {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
}

.af-gallery-col-single .af-gallery-img-wrap {
    height: 100%;
    flex: 1;
}

.af-gallery-col-double .af-gallery-img-wrap {
    flex: 1;
    min-height: 0;
}

/* ── Image wrapper / card ───────────────────────────────────── */
.af-gallery-img-wrap {
    position: relative;
    overflow: hidden;
    border-radius: 14px;
    display: block;
    cursor: pointer;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Background-image div (full bleed crop) ─────────────────── */
.af-gallery-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(1);
    transition: transform 450ms ease;
    will-change: transform;
}

/* ── Dark overlay on hover ──────────────────────────────────── */
.af-gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 450ms ease;
    pointer-events: none;
    z-index: 1;
}

/* ── Light sweep — full top-to-bottom, reverses on mouse-leave ─ */
/*
   Strategy: the sweep band sits above the card (translateY(-105%))
   by default. On hover it transitions to translateY(105%) — fully
   below. On mouse-leave the transition runs in reverse automatically
   because it's a CSS transition, not an animation.
   The band covers 110% of the card height so it fills edge-to-edge.
*/
.af-gallery-sweep {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    /* Cover the full card height + a little extra to guarantee full fill */
    height: 110%;
    /* Bright centre band, feathered top & bottom edges */
    background: linear-gradient(
        to bottom,
        transparent              0%,
        rgba(255,255,255,0.0)    8%,
        rgba(255,255,255,0.45)  35%,
        rgba(255,255,255,0.65)  50%,
        rgba(255,255,255,0.45)  65%,
        rgba(255,255,255,0.0)   92%,
        transparent             100%
    );
    pointer-events: none;
    z-index: 2;
    /* Start: band fully above the card */
    transform: translateY(-110%);
    /* Transition drives both the forward sweep and the reverse */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

/* Hover-in: sweep downward through the card and exit below */
.af-gallery-img-wrap:hover .af-gallery-sweep {
    transform: translateY(110%);
}

/* Zoom in on hover */
.af-gallery-img-wrap:hover .af-gallery-img {
    transform: scale(1.08);
}

/* Overlay tint on hover */
.af-gallery-img-wrap:hover .af-gallery-overlay {
    opacity: 1;
}

/* ── Dot indicators ─────────────────────────────────────────── */
.af-gallery-dots-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 18px;
}

.af-gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #cdd6dd;
    display: inline-block;
    flex-shrink: 0;
}

.af-gallery-dot.active {
    background: #2d6a9f;
}

/* ── Lightbox ───────────────────────────────────────────────── */
.af-gallery-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.88);
    animation: afLightboxIn 0.25s ease;
}

.af-gallery-lightbox.af-lb-open {
    display: flex;
}

@keyframes afLightboxIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.af-lightbox-inner {
    position: relative;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: grab;
    user-select: none;
}

.af-lightbox-img {
    max-width: 90vw;
    max-height: 88vh;
    border-radius: 10px;
    display: block;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: afImgIn 0.3s ease;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none; /* let mousedown/up pass through to .af-lightbox-inner / lightbox */
}

@keyframes afImgIn {
    from { transform: scale(0.92); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

.af-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 2.4rem;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    padding: 4px 8px;
    transition: opacity 0.2s;
    opacity: 0.85;
}

.af-lightbox-close:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE LAYOUT
   ═══════════════════════════════════════════════════════════════ */

/* ── Tablet (768px – 1024px): 3-column, drop outer tall cols ── */
@media (max-width: 1024px) and (min-width: 769px) {
    .af-gallery-grid {
        grid-template-columns: 1fr 1fr 1fr;
        height: 340px;
        overflow: visible;
    }

    /* Hide outer tall columns */
    .af-gallery-col:nth-child(1),
    .af-gallery-col:nth-child(5) {
        display: none;
    }

    /* Reset stagger — all 3 remaining cols equal height on tablet */
    .af-gallery-col:nth-child(2),
    .af-gallery-col:nth-child(3),
    .af-gallery-col:nth-child(4) {
        height: 340px;
        align-self: center;
    }

    .af-gallery-col-double {
        height: 340px;
    }
}

/* ── Mobile (≤ 768px): completely different flat grid layout ─── */
/*
   We hide the desktop column-based grid entirely and show
   .af-gallery-mobile — a flat 2-column CSS grid with all 7 images
   placed explicitly via grid-area.

   Layout on mobile:
   ┌──────────┬──────────┐
   │  img-1   │  img-2   │  row 1 — equal halves
   ├──────────┼──────────┤
   │  img-3   │  img-4   │  row 2 — equal halves
   ├──────────┴──────────┤
   │       img-7         │  row 3 — full-width hero
   ├──────────┬──────────┤
   │  img-5   │  img-6   │  row 4 — equal halves
   └──────────┴──────────┘
*/
@media (max-width: 768px) {

    .af-gallery-main-heading {
        font-size: 1.75rem;
    }

    .af-gallery-script-heading {
        font-size: 1.15rem;
    }

    /* Hide desktop grid */
    .af-gallery-grid {
        display: none !important;
    }

    /* Show mobile grid */
    .af-gallery-mobile {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 160px 160px 200px 160px;
        gap: 10px;
        width: 100%;
    }

    .af-gallery-mobile .af-mob-full {
        grid-column: 1 / -1;
    }

    /* All image wraps fill their cell */
    .af-gallery-mobile .af-gallery-img-wrap {
        width: 100%;
        height: 100%;
        display: block;
    }
}

/* ── Very small phones (≤ 400px) ───────────────────────────────── */
@media (max-width: 400px) {
    .af-gallery-mobile {
        grid-template-rows: 130px 130px 170px 130px !important;
        gap: 8px !important;
    }
}

/* ── Mobile grid base (hidden on desktop, shown via media query) */
.af-gallery-mobile {
    display: none;
}

/* Inside mobile grid each wrap needs to be a sizing context */
.af-gallery-mobile .af-gallery-img-wrap {
    position: relative;  /* needed for absolute .af-gallery-img child */
    overflow: hidden;
    display: block;
}

/* af-mob-full wrapper passes height down to its image wrap child */
.af-mob-full {
    display: contents; /* lets the inner .af-gallery-img-wrap sit directly in the grid cell */
}

@media (max-width: 768px) {
    /* Override display:contents on mobile full-width row so height works */
    .af-mob-full {
        display: block;
        width: 100%;
        height: 100%;
        grid-column: 1 / -1;
    }
    .af-mob-full .af-gallery-img-wrap {
        height: 100%;
        width: 100%;
    }
}

/* ── Minimal arrow navigation (desktop only) ───────────────────
   Simple circular outline buttons. No hard color, no red hover —
   just a gentle opacity/scale lift on hover. Hidden entirely on
   touch devices since swipe already covers navigation there. */
.af-lightbox-arrow {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #ffffff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.af-lightbox-arrow:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.06);
}

.af-lightbox-arrow:active {
    transform: scale(0.96);
}

/* Sit inline beside the image on desktop */
.af-lightbox-inner {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
}

.af-lb-counter {
    width: 100%;
    order: 10;
}

/* Hide arrows on touch / narrow viewports — swipe handles it there */
@media (max-width: 1024px) {
    .af-lightbox-arrow {
        display: none !important;
    }
    .af-lightbox-inner {
        flex-direction: column;
    }
}
