/* Fotografa Gallery — front-end styles
 *
 * SPECIFICITY RULE, do not lower it: this stylesheet is enqueued at wp_head(),
 * which the theme calls at header.php:6 — BEFORE it prints style.css (line 14)
 * and mobile.css (line 18). The theme therefore wins every equal-specificity
 * tie. Any rule touching an img must be at least (0,2,1), e.g.
 * ".fgal-main .splide__slide img", to beat:
 *   style.css:457   .single_inside_content img { max-width:100%; height:auto }
 *   mobile.css:126  .single_inside_content img { width:100% }   (<=767px)
 * No !important is needed anywhere if that rule is kept.
 */

.fgal {
    position: relative;      /* local stacking context: arrows can never reach */
    z-index: 0;              /* #header (9999) or the pCloud lightbox (99999)  */
    margin: 0 0 28px;
    scroll-behavior: auto;   /* neutralise the global html{scroll-behavior:smooth} */
}

.fgal .splide__track {
    overflow: hidden;
    scroll-behavior: auto;
}

/* The theme styles bare <li> (style.css:187), which is why the markup uses
   divs; these resets cover the case of Splide markup appearing as a list. */
.fgal .splide__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.fgal .splide__slide {
    margin: 0;
    list-style: none;
}

/* ---- Main stage -------------------------------------------------------- */
/* A fixed stage height is what prevents layout shift, for portrait and
   landscape alike — not the width/height attributes. --fgal-h is set inline
   per gallery, so the box is correct before Splide mounts and before any
   image arrives. */

.fgal-main .splide__slide {
    height: var(--fgal-h, 560px);
    background: #f4f4f4;
}

.fgal-main .splide__slide img {
    width: 100%;
    height: 100%;
    max-width: none;         /* beats .single_inside_content img max-width:100% */
    object-fit: contain;
    display: block;
}

/* Before mount: show only the first slide, already at the right height.
   .fgal-booting is ours, removed by fgal.js — deliberately not Splide's
   own is-initialized, so the no-CLS guarantee does not depend on an
   internal class name. With JS off it simply never gets removed. */
.fgal-booting .splide__list {
    display: block;
}

.fgal-booting .splide__slide + .splide__slide {
    display: none;
}

/* ---- Arrows ------------------------------------------------------------ */
/* 52px circles reuse the visual language of the pCloud lightbox nav. */

/* splide-core.min.css is layout-only and does NOT position the arrows — that
   lives in the full splide.min.css theme, which we deliberately don't ship.
   So position them here, or they stack at the top-left of the stage. */
.fgal .splide__arrows {
    position: static;
}

.fgal .splide__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .85);
    opacity: 1;
}

.fgal .splide__arrow:hover {
    background: #fff;
}

.fgal .splide__arrow svg {
    width: 20px;
    height: 20px;
    fill: #333;
}

.fgal .splide__arrow:disabled {
    opacity: .35;
}

.fgal .splide__arrow--prev {
    left: 8px;
}

.fgal .splide__arrow--next {
    right: 8px;
}

/* ---- Pagination -------------------------------------------------------- */

.fgal .splide__pagination {
    bottom: -1.4em;
}

.fgal .splide__pagination__page {
    background: #ccc;
}

.fgal .splide__pagination__page.is-active {
    background: #3ba1da;
    transform: none;
}

/* ---- Thumbnails -------------------------------------------------------- */

.fgal-thumbs {
    margin-top: 8px;
}

/* Square 1:1, sized here rather than via Splide's fixedWidth so that one
   media query drives both dimensions — see the autoWidth note in
   fotografa_gal_config(). The WP `thumbnail` size is itself a hard-cropped
   square, so a square box shows the stored image with no further cropping. */
.fgal-thumbs .splide__slide {
    width: 84px;
    height: 84px;
    opacity: .55;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: opacity .18s ease;
}

.fgal-thumbs .splide__slide.is-active {
    opacity: 1;
    border-color: #3ba1da;
}

.fgal-thumbs .splide__slide:hover {
    opacity: 1;
}

/* (0,2,1) — without this the <=767px rule .single_inside_content img{width:100%}
   blows every thumbnail up to the full container width. */
.fgal-thumbs .splide__slide img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    display: block;
}

/* ---- Focus ------------------------------------------------------------- */
/* The theme defines no focus styles at all, so these introduce the pattern. */

.fgal .splide__arrow:focus-visible,
.fgal .splide__pagination__page:focus-visible,
.fgal-thumbs .splide__slide:focus-visible {
    outline: 3px solid #3ba1da;
    outline-offset: 2px;
}

/* ---- Responsive -------------------------------------------------------- */

@media (max-width: 767px) {
    .fgal-main .splide__slide {
        height: min(var(--fgal-h, 560px), 68vh);
    }

    .fgal-thumbs .splide__slide {
        width: 64px;
        height: 64px;
    }

    .fgal .splide__arrow {
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .fgal .splide__list,
    .fgal .splide__slide,
    .fgal-thumbs .splide__slide {
        transition: none;
    }
}
