/* Image Gallery Lightbox – Custom Skin v1.3.0 */

/* ── Thumbnail strip ── */
#igl-thumb-strip {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999999;
    display: flex; gap: 6px; padding: 10px 16px 14px;
    overflow-x: auto; justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,.65) 0%, transparent 100%);
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.35) transparent;
}
#igl-thumb-strip::-webkit-scrollbar       { height: 4px; }
#igl-thumb-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,.35); border-radius: 2px; }
.igl-thumb-btn {
    flex-shrink: 0; width: 68px; height: 52px;
    border: 2px solid transparent; border-radius: 4px;
    overflow: hidden; cursor: pointer; background: none; padding: 0;
    opacity: .6; transition: border-color .2s, opacity .2s, transform .15s;
}
.igl-thumb-btn img        { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.igl-thumb-btn:hover      { opacity: .88; }
.igl-thumb-btn.igl-active { border-color: #fff; opacity: 1; transform: scale(1.07); }
.igl-thumb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Buttons outside the "Max thumbnails" window around the active slide. */
.igl-thumb-btn.igl-thumb-hidden { display: none; }

/* ── Trigger icon ── */
a.igl-trigger {
    display: inline-block; cursor: zoom-in;
    position: relative; overflow: hidden;
    text-decoration: none; vertical-align: middle;
}
a.igl-trigger::after {
    content: "⤢"; position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,.55); color: #fff; font-size: 14px;
    line-height: 1; padding: 4px 6px; border-radius: 3px;
    opacity: 0; transition: opacity .2s; pointer-events: none;
}
a.igl-trigger:hover::after { opacity: 1; }

/* ── Shortcode gallery grid — [igl_gallery] ── */
.igl-shortcode-gallery {
    display: grid;
    grid-template-columns: repeat(var(--igl-columns, 3), minmax(0, 1fr));
    gap: var(--igl-gap, 10px);
}
.igl-shortcode-gallery .igl-trigger { display: block; user-select: none; }
.igl-shortcode-gallery .igl-trigger img {
    width: 100%;
    height: auto;
    aspect-ratio: var(--igl-ratio, 4/3);
    object-fit: cover;
    display: block;
}
/* ratio="auto" keeps each image's natural proportions. */
.igl-shortcode-gallery[style*="--igl-ratio:auto"] .igl-trigger img {
    aspect-ratio: auto;
    object-fit: contain;
}
@media (max-width: 782px) {
    .igl-shortcode-gallery {
        grid-template-columns: repeat(min(var(--igl-columns, 3), 2), minmax(0, 1fr));
    }
}
@media (max-width: 480px) {
    .igl-shortcode-gallery { grid-template-columns: 1fr; }
}

/* ── Elementor gallery grid ── */
.igl-elementor-gallery { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.igl-elementor-gallery .igl-trigger { display: block; user-select: none; }

/* ── Mobile ── */
@media (max-width:600px) {
    .igl-thumb-btn { width: 54px; height: 42px; }
    #igl-thumb-strip { gap: 4px; padding: 8px 10px 12px; }
}

/* ── Hide overlay text on thumbnails — show only inside lightbox ────────────
 *
 * Gated behind .igl-hide-thumb-text, which the init script adds to the content
 * element (1.12.4: parent of .igl-content-marker; :has() covers it before JS)
 * when the "Hide caption text on page thumbnails" setting is on (the default,
 * matching v1.2.7 behaviour). Turning the setting off leaves theme captions
 * exactly as the theme rendered them.
 *
 * Gutenberg Gallery block structure:
 *
 *   <figure class="wp-block-image">
 *     <a class="igl-trigger"><img /></a>
 *     <figcaption>ข้อความ</figcaption>   ← SIBLING of <a>, not inside it
 *   </figure>
 *
 *   <figure class="wp-block-gallery">
 *     <figure>
 *       <a class="igl-trigger"><img /></a>
 *       <figcaption>ข้อความ</figcaption> ← SIBLING
 *     </figure>
 *   </figure>
 *
 * Many themes (Kadence, Astra, OceanWP) and page builders overlay text
 * (titles, captions, category labels) directly on top of gallery thumbnail
 * images. That text makes tapping the image inaccurate on mobile.
 *
 * Strategy:
 *  - Hide figcaption, overlay divs, and text spans that sit inside or next to
 *    an igl-trigger link.
 *  - GLightbox renders its own caption panel inside the modal overlay
 *    (from data-igl-caption), so no information is lost.
 *
 * Scope: only inside .igl-hide-thumb-text (or, before JS runs, the parent of a
 * marker carrying data-igl-hide-thumb), so global page
 * text (menus, headings, sidebars) is never touched.
 * ── */

/* Text INSIDE a trigger link ───────────────────────────────────────────── */

/* figcaption directly inside a trigger link */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger figcaption,

/* wp-block-image caption overlay */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .wp-element-caption,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .wp-block-image__caption,

/* Gutenberg gallery figure caption */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-block-gallery figure.wp-block-image a.igl-trigger figcaption,

/* WooCommerce product image overlay text */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .woocommerce-product-gallery__image--placeholder,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .overlay-text,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .image-overlay,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .caption-overlay,

/* Kadence / theme-generic overlay text spans inside trigger */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger span:not(.screen-reader-text),
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger p,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .kb-gallery-text-inner,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) a.igl-trigger .kt-gallery-item__caption {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity .2s ease;
}

/* Text that is a SIBLING of the trigger (Gutenberg Gallery block) ──────────
 *
 *   <a class="igl-trigger">...</a>
 *   + figcaption          ← direct next sibling
 *   ~ figcaption / p      ← any following sibling, for themes that inject
 *                           extra elements between the <a> and the caption
 */

/* wp-block-image: figcaption sibling */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-block-image a.igl-trigger ~ figcaption,

/* wp-block-gallery nested figure: figcaption sibling */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-block-gallery figure a.igl-trigger ~ figcaption,

/* Generic figure: any figcaption sibling of igl-trigger */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) figure a.igl-trigger ~ figcaption,

/* Theme-injected <p> or caption element sibling of igl-trigger */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) figure a.igl-trigger ~ p,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) figure a.igl-trigger ~ .wp-element-caption,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) figure a.igl-trigger ~ .wp-block-image__caption,

/* Classic Editor — TinyMCE wraps images differently.
 *
 *   <div class="wp-caption aligncenter">
 *     <a class="igl-trigger"><img /></a>
 *     <p class="wp-caption-text">ข้อความ</p>   ← sibling inside .wp-caption
 *   </div>
 */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-caption a.igl-trigger ~ .wp-caption-text,
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-caption a.igl-trigger ~ p,

/* [caption] shortcode rendered by WordPress */
:is(.igl-hide-thumb-text,:has(> .igl-content-marker[data-igl-hide-thumb])) .wp-caption-text {
    opacity: 0 !important;
    pointer-events: none !important;
    user-select: none !important;
    transition: opacity .2s ease;
}

/* ── Trigger tap target ─────────────────────────────────────────────────── */

/* Make the whole trigger a reliable click/tap target */
:is(.igl-content-area,:has(> .igl-content-marker)) a.igl-trigger {
    display: block;     /* full block prevents text from intercepting clicks */
    user-select: none;  /* prevent accidental text selection on long-press */
}

/* Restore cursor so it's obvious the image is clickable.
 *
 * max-width/height:auto rather than width:100%: forcing every content image to
 * fill its container upscaled small images (a 300px logo stretched across an
 * 800px column) and overrode theme alignment classes. */
:is(.igl-content-area,:has(> .igl-content-marker)) a.igl-trigger img {
    cursor: zoom-in;
    display: block;
    max-width: 100%;
    height: auto;
}

/* A gallery of one has nowhere to go, so GLightbox's arrows are hidden.
 * Only reachable when "Open the lightbox on single images too" is on. */
.glightbox-container.igl-single-slide .gnext,
.glightbox-container.igl-single-slide .gprev { display: none !important; }

/* 1.9.0 — another lightbox answered the same click, so this one stood down
   (see standDown() in igl-glightbox-init.js). Hide ours instantly instead of
   letting GLightbox fade out over the top of the other one. */
.igl-stood-down .glightbox-container,
.igl-stood-down #igl-thumb-strip { display: none !important; }

/* ── Arrow and close buttons (1.10.0, redesigned 1.11.0) ────────────────────
 * GLightbox parks the arrows at top:-100% below 769px wide, so phones and
 * tablets in portrait — a Galaxy Tab S9 in Samsung Internet is ~753px — had
 * no arrows at all. They sit at mid-height on every screen.
 *
 * 1.11.0: they are <button>s, and themes style every button. A theme rule
 * such as `button { min-width: 80px }` or `padding: 0 16px` with
 * `box-sizing: content-box` stretched our 48px circles into 80×48 ovals
 * (seen on warehousefactory.net). Every box property a theme might set is
 * pinned here, so the shape is ours on any theme: a true circle.
 */
.glightbox-container .gprev,
.glightbox-container .gnext,
.glightbox-container .gclose,
.glightbox-container .igl-counter {
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 999px !important;
    line-height: 1 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    text-shadow: none !important;
    outline-offset: 3px;
    -webkit-tap-highlight-color: transparent;
}
.glightbox-container .gprev,
.glightbox-container .gnext,
.glightbox-container .gclose {
    position: absolute !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: none !important;
    aspect-ratio: 1 / 1;
    font-size: 0 !important;
    cursor: pointer;
    transform: none !important;
    transition: background-color .15s ease, box-shadow .15s ease, opacity .25s ease, transform .12s ease;
}
.glightbox-container .gprev,
.glightbox-container .gnext {
    top: 50% !important;
    bottom: auto !important;
    width: 52px !important;  min-width: 52px !important;  max-width: 52px !important;
    height: 52px !important; min-height: 52px !important; max-height: 52px !important;
    margin-top: -26px !important;
}
.glightbox-container .gprev { left: max(12px, env(safe-area-inset-left)) !important; right: auto !important; }
.glightbox-container .gnext { right: max(12px, env(safe-area-inset-right)) !important; left: auto !important; }
.glightbox-container .gclose {
    width: 44px !important;  min-width: 44px !important;  max-width: 44px !important;
    height: 44px !important; min-height: 44px !important; max-height: 44px !important;
    top: max(12px, env(safe-area-inset-top)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    left: auto !important;
}

/* Our own icons (1.11.0): stroked chevrons and cross with round ends, set
 * through GLightbox's `svg` option in igl-glightbox-init.js. Older markup
 * with filled paths still gets a sensible size. */
.glightbox-container .gprev svg,
.glightbox-container .gnext svg { width: 24px !important; height: 24px !important; }
.glightbox-container .gclose svg { width: 20px !important; height: 20px !important; }
.glightbox-container .igl-icon { display: block; fill: none !important; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.glightbox-container .igl-icon path { fill: none !important; stroke: inherit !important; }

/* Press feedback: the button gives a little under the finger. */
.glightbox-container .gprev:active,
.glightbox-container .gnext:active,
.glightbox-container .gclose:active { transform: scale(.9) !important; }

.glightbox-container .gprev:focus-visible,
.glightbox-container .gnext:focus-visible,
.glightbox-container .gclose:focus-visible { outline: 3px solid #ffbf00 !important; outline-offset: 3px; }
.glightbox-container .gprev.disabled,
.glightbox-container .gnext.disabled { opacity: .35 !important; }
.glightbox-container.glightbox-closing .gprev,
.glightbox-container.glightbox-closing .gnext,
.glightbox-container.glightbox-closing .gclose,
.glightbox-container.glightbox-closing .igl-counter { opacity: 0 !important; }

/* ── Image counter (1.11.0) ─────────────────────────────────────────────── */
.glightbox-container .igl-counter {
    position: absolute;
    z-index: 99999;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    height: 36px;
    min-width: 64px;
    padding: 0 14px !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 600 15px/1 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", sans-serif !important;
    font-variant-numeric: tabular-nums;
    color: #fff;
    background: rgba(17, 24, 39, .82);
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9), 0 4px 14px rgba(0, 0, 0, .3);
    pointer-events: none;
    user-select: none;
    transition: opacity .25s ease;
}
.glightbox-container.igl-single-slide .igl-counter { display: none; }

/* ── Idle fade (1.11.0) ─────────────────────────────────────────────────── */
/* After 3 s without a touch, mouse move or key the controls fade out so the
 * picture is seen whole; the first tap only brings them back (see
 * bindIdleControls() in igl-glightbox-init.js). A control that has keyboard
 * focus never fades. */
.glightbox-container.igl-idle .gprev:not(:focus-visible),
.glightbox-container.igl-idle .gnext:not(:focus-visible),
.glightbox-container.igl-idle .gclose:not(:focus-visible),
.glightbox-container.igl-idle .igl-counter,
.glightbox-container.igl-idle #igl-thumb-strip { opacity: 0 !important; pointer-events: none !important; }
#igl-thumb-strip { transition: opacity .25s ease; }

/* Automatic colours: a dark chip with a white icon by default (and whenever
 * the picture cannot be read), a light chip with a dark icon where the
 * picture behind the button is light. The ring of the opposite tone keeps
 * the edge visible on busy pictures. Chosen per button by
 * pickControlScheme() in igl-glightbox-init.js. */
.igl-controls-auto .glightbox-container .gprev,
.igl-controls-auto .glightbox-container .gnext,
.igl-controls-auto .glightbox-container .gclose {
    background: rgba(17, 24, 39, .82) !important;
    color: #fff !important;
    box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .9), 0 4px 14px rgba(0, 0, 0, .3) !important;
}
.igl-controls-auto .glightbox-container .gprev svg path,
.igl-controls-auto .glightbox-container .gnext svg path,
.igl-controls-auto .glightbox-container .gclose svg path { fill: #fff; }
.igl-controls-auto .glightbox-container .gprev .igl-icon,
.igl-controls-auto .glightbox-container .gnext .igl-icon,
.igl-controls-auto .glightbox-container .gclose .igl-icon { stroke: #fff !important; }

.igl-controls-auto .glightbox-container .igl-ctl-light {
    background: rgba(255, 255, 255, .95) !important;
    color: #111827 !important;
    box-shadow: 0 0 0 1.5px rgba(17, 24, 39, .85), 0 4px 14px rgba(0, 0, 0, .25) !important;
}
.igl-controls-auto .glightbox-container .igl-ctl-light svg path { fill: #111827; }
.igl-controls-auto .glightbox-container .igl-ctl-light .igl-icon { stroke: #111827 !important; }

@media (prefers-reduced-motion: reduce) {
    .glightbox-container .gprev,
    .glightbox-container .gnext,
    .glightbox-container .gclose,
    .glightbox-container .igl-counter,
    #igl-thumb-strip { transition: none !important; }
    .glightbox-container .gprev:active,
    .glightbox-container .gnext:active,
    .glightbox-container .gclose:active { transform: none !important; }
}

/* 1.12.4: layout-neutral scope marker (replaces the wrapper div). */
.igl-content-marker { display: none !important; }
