/**
 * PLGC Gallery Widgets — Shared CSS
 *
 * Covers two widgets:
 *   1. .plgc-filmstrip          — horizontal scroll filmstrip
 *   2. .plgc-content-slideshow  — 50/50 image+text layout with dot nav
 *   3. .plgc-lb                 — shared lightbox (filmstrip only)
 *
 * @package PLGC
 * @since   1.6.7
 */


/* ═══════════════════════════════════════════════════════════════════════════
   1. GALLERY FILMSTRIP
   ═══════════════════════════════════════════════════════════════════════════ */

.plgc-filmstrip {
    position: relative;
    padding-bottom: 3.5rem;
    width: 100%;
    overflow: hidden;
}

.plgc-filmstrip__track {
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    cursor: grab;
    user-select: none;
}
.plgc-filmstrip__track:active { cursor: grabbing; }
.plgc-filmstrip__track::-webkit-scrollbar { display: none; }

.plgc-filmstrip__list {
    display: flex;
    flex-direction: row;
    gap: var(--plgc-fs-gap, 27px);
    list-style: none;
    margin: 0;
    padding: 0;
    width: max-content;
}

.plgc-filmstrip__item {
    width: var(--plgc-fs-width, 309px);
    height: var(--plgc-fs-height, 414px);
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--plgc-medium-grey, #E7E4E4);
}

.plgc-filmstrip__trigger {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
}
.plgc-filmstrip__trigger:focus-visible {
    outline: 3px solid #FFAE40;
    outline-offset: -3px;
}

/* Base image styles — shared between filmstrip and content slideshow.
   SPECIFICITY NOTE: Elementor's global reset (.elementor img { height: auto; })
   has specificity 0,1,1 and loads late in the cascade, overriding our height.
   Using .parent .child selectors (specificity 0,2,0) beats it cleanly. */
.plgc-filmstrip__item .plgc-filmstrip__img,
.plgc-cs-slide .plgc-cs-slide__img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Prevent browser native image drag — critical for mouse swipe to work */
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;  /* Let pointer events fall through to the button/container */
}

.plgc-filmstrip__img {
    transition: transform 250ms ease-in-out;
    /* will-change:transform removed — causes iOS Safari to composit the image
       onto a GPU layer that escapes the overflow:hidden clip on the parent button,
       making it invisible on real iOS devices. The hover scale still works fine. */
}
.plgc-filmstrip__trigger:hover .plgc-filmstrip__img,
.plgc-filmstrip__trigger:focus-visible .plgc-filmstrip__img {
    transform: scale(1.04);
}

.plgc-filmstrip__hover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0);
    transition: background 150ms ease-in-out;
    pointer-events: none;
}
.plgc-filmstrip__hover-overlay svg {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 150ms ease-in-out, transform 150ms ease-in-out;
}
.plgc-filmstrip__trigger:hover .plgc-filmstrip__hover-overlay,
.plgc-filmstrip__trigger:focus-visible .plgc-filmstrip__hover-overlay {
    background: rgba(0,0,0,0.2);
}
.plgc-filmstrip__trigger:hover .plgc-filmstrip__hover-overlay svg,
.plgc-filmstrip__trigger:focus-visible .plgc-filmstrip__hover-overlay svg {
    opacity: 1;
    transform: scale(1);
}

.plgc-filmstrip__nav {
    position: absolute;
    bottom: 0;
    right: 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.25rem;          /* prevent circle button box-shadow / outline clipping */
}

/* Filmstrip pause button — same style as nav buttons but white background */
.plgc-filmstrip__pause {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 2px solid #567915;
    background: #ffffff;
    color: #567915;
    cursor: pointer;
    transition: background 150ms ease-in-out, color 150ms ease-in-out;
}
.plgc-filmstrip__pause:hover { background: #567915; color: #ffffff; }
.plgc-filmstrip__pause:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }
.plgc-filmstrip__nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: none;
    background: #567915;
    color: #fff;
    cursor: pointer;
    transition: background 150ms ease-in-out, transform 150ms ease-in-out;
}
.plgc-filmstrip__nav-btn:hover { background: #233C26; transform: scale(1.08); }
.plgc-filmstrip__nav-btn:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }
.plgc-filmstrip__nav-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

@media (max-width: 767px) {
    .plgc-filmstrip__track { scroll-snap-type: x mandatory; }
    .plgc-filmstrip__item { width: 85vw; height: 65vw; scroll-snap-align: start; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   2. CONTENT SLIDESHOW
   50/50 split: image card + text. Dot nav top-left.
   ═══════════════════════════════════════════════════════════════════════════ */

.plgc-content-slideshow {
    display: flex;
    align-items: center;
    gap: 3rem;
    width: 100%;
    padding: 3rem 0;
}
.plgc-content-slideshow--img-right { flex-direction: row-reverse; }

/* ── Image column ──────────────────────────────────────────────────────── */
.plgc-content-slideshow__img-col {
    position: relative;
    flex: 0 0 calc(50% - 1.5rem);
    max-width: calc(50% - 1.5rem);
    aspect-ratio: 588 / 381;
    border-radius: 5px;
    overflow: hidden;
    background: #E7E4E4;
    cursor: grab;
    user-select: none;
    /* Allow native vertical scroll, capture horizontal for swipe detection.
       Without this, some mobile browsers eat the horizontal pointer events. */
    touch-action: pan-y;
}
.plgc-content-slideshow__img-col:active { cursor: grabbing; }
/* When lightbox is enabled, the lb-trigger button handles its own cursor */
.plgc-content-slideshow__img-col.has-lightbox { cursor: default; }

/* ── Dot row — sits INSIDE the overflow:hidden card ───────────────────── */
.plgc-cs-dots {
    position: absolute;
    /*
     * Figma measurements (node 40007:670):
     *   Dot group: 110px wide × 22px tall, 4 dots
     *   Each dot: 22px diameter
     *   Center-to-center: 110px / 3 gaps ≈ 30px apart
     *   Group top-left: x=19, y=18 inside a 588×381px card
     *
     * WCAG SC 2.5.5: 44×44px minimum touch target.
     * Button = 44×44px hit area. Visible 22px dot drawn by ::before.
     * Center of 22px dot inside 44px button = (44-22)/2 = 11px padding each side.
     * Container offset = 18 - 11 = 7px from card edge so dot centers land at 18px.
     * Adjacent button overlap: 44px button, 30px c-to-c → overlap = (44-30)/2 = 7px each side.
     */
    top: 7px;
    left: 7px;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    z-index: 3; /* must exceed active slide z-index:1 AND lb-trigger inside it */
}

.plgc-cs-dots__sr-live {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
}

.plgc-cs-dots__dot {
    /*
     * 44×44px touch target (WCAG SC 2.5.5).
     * Buttons overlap by 7px each side so visible 22px dots sit 30px apart.
     * Explicit !important beats Elementor/theme button resets.
     */
    pointer-events: auto !important;  /* re-enable — parent img has pointer-events:none */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 -7px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    border-radius: 0 !important;
    outline: none;
}
.plgc-cs-dots__dot:first-child { margin-left: 0 !important; }
.plgc-cs-dots__dot:last-child  { margin-right: 0 !important; }

/* Visible 22px dot — Figma spec, centered inside the 44px button */
.plgc-cs-dots__dot::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #ffffff;
    border: 2.5px solid transparent;
    box-sizing: border-box;
    pointer-events: none;
    transition: background 150ms ease-in-out,
                border-color 150ms ease-in-out,
                transform 150ms ease-in-out;
}

/* Active: dark green fill + white border ring */
.plgc-cs-dots__dot.is-active::before,
.plgc-cs-dots__dot[aria-pressed="true"]::before {
    background: #567915;
    border-color: #ffffff;
}

/* Hover: subtle grow to signal interactivity */
.plgc-cs-dots__dot:hover:not(.is-active)::before {
    background: rgba(255,255,255,0.8);
    transform: scale(1.15);
}

/* Focus ring via box-shadow on the ::before dot — avoids overflow:hidden clipping */
.plgc-cs-dots__dot:focus-visible::before {
    box-shadow: 0 0 0 3px #FFAE40;
}


/* ── Auto-rotation pause button ──────────────────────────────────────────
   WCAG 2.1 AA SC 2.2.2: auto-advancing content must be pausable.
   Pause/play button sits bottom-right of the image card.
   ───────────────────────────────────────────────────────────────────────── */
.plgc-cs-pause {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    z-index: 4;
    pointer-events: auto;  /* re-enable — sits inside img-col which has pointer-events cascading */
    width: 2.75rem;    /* 44px */
    height: 2.75rem;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease-in-out, transform 150ms ease-in-out;
    backdrop-filter: blur(2px);
}
.plgc-cs-pause:hover { background: rgba(0,0,0,0.65); transform: scale(1.08); }
.plgc-cs-pause:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }

/* Progress bar: thin line across bottom of image showing slide duration */
.plgc-cs-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #FFAE40;
    width: 0%;
    z-index: 4;
    transform-origin: left center;
}
.plgc-cs-progress.is-animating {
    transition: width linear;   /* duration set via JS */
}

/* ── Slides ───────────────────────────────────────────────────────────── */
.plgc-cs-slide {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 0;           /* explicit baseline — keeps slide below dots */
    border-radius: 5px;
    overflow: hidden;
}
.plgc-cs-slide.is-active {
    display: block;
    z-index: 1;           /* above inactive slides but below dots (z-index:3) */
    animation: plgc-cs-fade 0.3s ease;
}

/* Lightbox trigger button inside each slide — fills the whole card */
.plgc-cs-slide__lb-trigger {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: zoom-in !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    overflow: hidden;
    pointer-events: auto; /* re-enable — img has pointer-events:none, this button needs it */
}
.plgc-cs-slide__lb-trigger:focus-visible {
    outline: 3px solid #FFAE40 !important;
    outline-offset: -4px !important;
}
/* Hover overlay reuses the filmstrip hover class */
.plgc-cs-slide__lb-trigger .plgc-filmstrip__hover-overlay {
    border-radius: 0;
}
.plgc-cs-slide__lb-trigger:hover .plgc-filmstrip__hover-overlay,
.plgc-cs-slide__lb-trigger:focus-visible .plgc-filmstrip__hover-overlay {
    background: rgba(0,0,0,0.2);
}
.plgc-cs-slide__lb-trigger:hover .plgc-filmstrip__hover-overlay svg,
.plgc-cs-slide__lb-trigger:focus-visible .plgc-filmstrip__hover-overlay svg {
    opacity: 1;
    transform: scale(1);
}

@keyframes plgc-cs-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Slide image — higher specificity to beat .elementor img { height: auto } */
.plgc-cs-slide .plgc-cs-slide__img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* ── Text column ──────────────────────────────────────────────────────── */
.plgc-content-slideshow__text-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: flex-start;
}

.plgc-cs-heading {
    font-family: 'Libre Baskerville', serif;
    font-size: 2.25rem;
    font-weight: 400;
    line-height: 1.333;
    color: #000;
    margin: 0;
}

.plgc-cs-body {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 2;
    color: #000;
    margin: 0;
}
.plgc-cs-body p { margin: 0 0 0.75rem; }
.plgc-cs-body p:last-child { margin-bottom: 0; }

.plgc-cs-cta { margin-top: 0.25rem; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .plgc-content-slideshow,
    .plgc-content-slideshow--img-right {
        flex-direction: column;
        gap: 2rem;
    }
    .plgc-content-slideshow__img-col {
        flex: none;
        width: 100%;
        max-width: 100%;
        aspect-ratio: 588 / 381;
    }
    .plgc-cs-heading { font-size: 1.75rem; }
}

@media (max-width: 480px) {
    .plgc-content-slideshow { padding: 2rem 0; }
    .plgc-cs-heading { font-size: 1.5rem; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   3. SHARED LIGHTBOX
   ═══════════════════════════════════════════════════════════════════════════ */

.plgc-lb {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 250ms ease-in-out;
}
.plgc-lb[aria-hidden="true"]  { opacity: 0; pointer-events: none; }
.plgc-lb[aria-hidden="false"] { opacity: 1; pointer-events: auto; }

.plgc-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.92);
    cursor: pointer;
}
.plgc-lb__inner {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 92vw;
    max-height: 92vh;
}
.plgc-lb__sr-live {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}
.plgc-lb__close {
    position: fixed;
    top: 1rem; right: 1rem;
    width: 2.75rem; height: 2.75rem;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.45);
    background: rgba(0,0,0,0.55);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 2;
    transition: background 150ms ease, border-color 150ms ease;
}
.plgc-lb__close:hover { background: rgba(255,255,255,0.12); border-color: #FFAE40; color: #FFAE40; }
.plgc-lb__close:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }

.plgc-lb__prev,
.plgc-lb__next {
    /* Fixed to viewport edges so arrows stay in the same spot regardless of
       image aspect ratio — no hunting for the button when clicking through
       a mix of portrait and landscape photos. */
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.75rem; height: 2.75rem;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35);
    background: rgba(0,0,0,0.5);
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 150ms ease, border-color 150ms ease;
}
.plgc-lb__prev { left: 1rem; }
.plgc-lb__next { right: 1rem; }
.plgc-lb__prev:hover, .plgc-lb__next:hover { background: rgba(255,255,255,0.1); border-color: #FFAE40; color: #FFAE40; }
.plgc-lb__prev:focus-visible, .plgc-lb__next:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }
.plgc-lb__prev[hidden], .plgc-lb__next[hidden] { display: none; }

.plgc-lb__figure { margin: 0; text-align: center; display: flex; flex-direction: column; align-items: center; }
.plgc-lb__img {
    display: block;
    max-width: 82vw; max-height: 82vh;
    width: auto; height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.55);
}
.plgc-lb__caption {
    margin-top: 0.75rem;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.9rem;
    color: rgba(255,255,255,0.75);
    max-width: 60ch;
    line-height: 1.5;
}
.plgc-lb__caption[hidden] { display: none; }
.plgc-lb__count {
    position: fixed;
    bottom: 1.25rem; left: 50%; transform: translateX(-50%);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.875rem;
    color: rgba(255,255,255,0.55);
    letter-spacing: 0.05em;
}

@media (max-width: 600px) {
    .plgc-lb__inner { gap: 0; max-width: 98vw; }
    .plgc-lb__img   { max-width: 90vw; }
    .plgc-lb__prev  { left: 0.5rem; }
    .plgc-lb__next  { right: 0.5rem; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION — WCAG 2.1 AA SC 2.3.3 / 2.2.2
   All transitions and auto-play disabled for users who request it.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .plgc-lb,
    .plgc-filmstrip__img,
    .plgc-filmstrip__hover-overlay svg,
    .plgc-cs-slide,
    .plgc-cs-dots__dot::before,
    .plgc-cs-progress { transition: none; animation: none; }
    .plgc-filmstrip__trigger:hover .plgc-filmstrip__img { transform: none; }
    .plgc-filmstrip__track { scroll-behavior: auto; }
    /* Auto-rotation is disabled in JS for reduced-motion users */
}
