/* ============================================
   Guide Product Display – Media v2.5
   ============================================ */

.gpd-media, .gpd-media * { box-sizing: border-box; margin: 0; padding: 0; }

/* Prevent horizontal overflow from breakout */
html:has(.gpd-media),
body:has(.gpd-media) { overflow-x: hidden; }

/* ---- Full Width Breakout (no horizontal overflow) ---- */
.gpd-media {
    width: calc(100vw - var(--wp-admin--admin-bar--height, 0px));
    max-width: 100%;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    padding: 0 24px;
    margin-bottom: 32px;
    overflow: hidden;
}

/* ============================================
   PAGE GRID
   ============================================ */

.gpd-grid {
    display: grid;
    gap: 8px;
    max-width: 1400px;
    margin: 0 auto;
}

.gpd-grid--2x3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; aspect-ratio: 3/1; }
.gpd-grid--2x2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr 1fr; aspect-ratio: 2/1; }
.gpd-grid--1x2 { grid-template-columns: repeat(2, 1fr); grid-template-rows: 1fr; aspect-ratio: 3/1; }

.gpd-grid--video {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 200px 200px;
    direction: ltr; /* Video always on left side */
}

.gpd-grid--video .gpd-grid__item--span { grid-row: 1 / 3; }

.gpd-grid__item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    cursor: pointer;
}

.gpd-grid__item img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    transition: transform 0.3s ease;
}

.gpd-grid__item:hover img { transform: scale(1.05); }
.gpd-grid__item:focus-visible { outline: 3px solid #e8930c; outline-offset: 2px; }

/* Video Play */
.gpd-grid__play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 68px; height: 68px; border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(4px);
    transition: background 0.2s, transform 0.2s;
}

.gpd-grid__play svg { margin-left: 3px; }

.gpd-grid__item--video:hover .gpd-grid__play {
    background: rgba(220,38,38,0.85);
    transform: translate(-50%,-50%) scale(1.1);
}

/* Show All Overlay */
.gpd-grid__overlay {
    position: absolute; inset: 0;
    background: rgba(26,26,46,0.55);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}

.gpd-grid__item--more:hover .gpd-grid__overlay { background: rgba(26,26,46,0.72); }

.gpd-grid__overlay span {
    color: #fff; font-size: 18px; font-weight: 700;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-shadow: 0 2px 8px rgba(0,0,0,0.4);
    text-align: center; line-height: 1.4;
}

/* ============================================
   LIGHTBOX — SHARED
   ============================================ */

.gpd-lb { position: fixed; inset: 0; z-index: 999999; display: none; }
.gpd-lb[aria-hidden="false"] { display: block; }

/* Hide Tidio when lightbox is open */
.gpd-lb[aria-hidden="false"] ~ #tidio-chat-iframe,
body.gpd-lb-open #tidio-chat,
body.gpd-lb-open #tidio-chat-iframe { display: none !important; }

/* Hide Elementor lightbox & navigation overlaps */
body.gpd-lb-open .elementor-lightbox,
body.gpd-lb-open .elementor-slideshow,
body.gpd-lb-open .swiper-button-prev,
body.gpd-lb-open .swiper-button-next,
body.gpd-lb-open .elementor-swiper-button,
body.gpd-lb-open .elementor-swiper-button-prev,
body.gpd-lb-open .elementor-swiper-button-next { display: none !important; }

/* Close — override Elementor */
.gpd-lb__close, .gpd-lb .gpd-lb__close {
    position: fixed !important; top: 16px !important; right: 20px !important;
    z-index: 10000000 !important; width: 48px !important; height: 48px !important;
    border: none !important; border-radius: 50% !important;
    background: rgba(0,0,0,0.65) !important; color: #fff !important;
    font-size: 22px !important; cursor: pointer !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    padding: 0 !important; margin: 0 !important; line-height: 1 !important;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important;
    transition: background 0.2s !important;
}

.gpd-lb__close:hover { background: rgba(0,0,0,0.85) !important; }

/* ============================================
   LIGHTBOX — GRID VIEW (Layer 1)
   ============================================ */

.gpd-lb__grid-view {
    position: fixed; inset: 0; z-index: 9999999;
    background: #fff;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 72px 24px 24px;
}

.gpd-lb__grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 8px; max-width: 1200px; margin: 0 auto;
}

.gpd-lb__grid-item {
    position: relative; aspect-ratio: 4/3;
    overflow: hidden; border-radius: 10px;
    cursor: pointer; transition: transform 0.2s;
}

.gpd-lb__grid-item:hover { transform: scale(1.02); }

.gpd-lb__grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gpd-lb__grid-play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; backdrop-filter: blur(4px);
}

.gpd-lb__grid-play svg { margin-left: 2px; }
.gpd-lb__grid-item--video:hover .gpd-lb__grid-play { background: rgba(220,38,38,0.85); }

/* ============================================
   LIGHTBOX — SINGLE VIEW (Layer 2)
   Split: image left, side grid right
   ============================================ */

.gpd-lb__single-view {
    position: fixed; inset: 0; z-index: 9999999;
    background: #000; display: none;
    flex-direction: column;
}

.gpd-lb__single-view.gpd-lb__single--active { display: flex; }

/* Counter — LTR force */
.gpd-lb__counter {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 10000000;
    color: rgba(255,255,255,0.75); font-size: 15px; font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    direction: ltr; unicode-bidi: bidi-override;
}

/* Split container */
.gpd-lb__split {
    display: flex;
    direction: ltr;
    flex: 1;
    min-height: 0;
    padding: 56px 0 0;
    overflow: hidden;
    width: 100%;
}

/* Left: main image */
.gpd-lb__left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
    padding: 16px;
    overflow: hidden;
}

.gpd-lb__content-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    max-height: calc(100vh - 100px) !important;
    overflow: hidden !important;
}

/* Image — override Elementor's img { height: auto; max-width: 100% } */
.gpd-lb__img,
.gpd-lb .gpd-lb__img,
#gpd-lightbox .gpd-lb__img,
#gpd-single-view .gpd-lb__img,
.gpd-lb__single-view .gpd-lb__img,
.elementor .gpd-lb__img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    border-radius: 8px !important;
    animation: gpdImgIn 0.15s ease;
    display: block !important;
    margin: auto !important;
}

@keyframes gpdImgIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

.gpd-lb__video-embed {
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    border-radius: 8px;
    overflow: hidden;
}

.gpd-lb__video-embed iframe { width: 100%; height: 100%; border: 0; }

/* Nav arrows — ultra-override Elementor */
.gpd-lb__nav,
.gpd-lb__nav.gpd-lb__nav,
.gpd-lb .gpd-lb__nav,
#gpd-lightbox .gpd-lb__nav,
#gpd-single-view .gpd-lb__nav {
    all: unset !important;
    position: absolute !important;
    top: 50% !important; transform: translateY(-50%) !important;
    z-index: 10000000 !important;
    width: 48px !important; height: 48px !important;
    border: none !important; border-radius: 50% !important;
    background: rgba(255,255,255,0.15) !important; color: #fff !important;
    font-size: 28px !important; cursor: pointer !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
    line-height: 1 !important;
    backdrop-filter: blur(4px) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
    transition: background 0.2s !important;
    box-sizing: border-box !important;
}

.gpd-lb__prev, .gpd-lb .gpd-lb__prev, #gpd-lightbox .gpd-lb__prev,
#gpd-single-view .gpd-lb__prev { left: 16px !important; right: auto !important; }
.gpd-lb__next, .gpd-lb .gpd-lb__next, #gpd-lightbox .gpd-lb__next,
#gpd-single-view .gpd-lb__next { right: 16px !important; left: auto !important; }

.gpd-lb__nav:hover {
    background: rgba(255,255,255,0.3) !important;
    transform: translateY(-50%) scale(1.08) !important;
}

/* Right: side grid */
.gpd-lb__right {
    flex: 0 0 280px;
    width: 280px;
    max-width: 280px;
    display: flex;
    flex-direction: column;
    background: rgba(255,255,255,0.06);
    border-left: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    height: calc(100vh - 56px);
}

/* Toggle / "All photos" button at top of side grid */
.gpd-lb__toggle, .gpd-lb .gpd-lb__toggle {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 14px 16px !important;
    margin: 0 !important;
    border: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    border-radius: 0 !important;
    background: rgba(255,255,255,0.08) !important;
    color: rgba(255,255,255,0.8) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
    width: 100% !important;
    height: auto !important;
    position: static !important;
    z-index: auto !important;
    box-shadow: none !important;
}

.gpd-lb__toggle:hover { background: rgba(255,255,255,0.14) !important; }

.gpd-lb__toggle svg { opacity: 0.7; flex-shrink: 0; }

/* Side grid — scrollable */
.gpd-lb__side-grid {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    align-content: start;
}

.gpd-lb__side-item {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.15s;
    border: 2px solid transparent;
}

.gpd-lb__side-item:hover { opacity: 0.85; transform: scale(1.02); }

.gpd-lb__side-item--active {
    opacity: 1;
    border-color: #fff;
}

.gpd-lb__side-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gpd-lb__side-play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    pointer-events: none;
}

.gpd-lb__side-play svg { margin-left: 1px; }

.gpd-lb__side-grid::-webkit-scrollbar { width: 4px; }
.gpd-lb__side-grid::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
.gpd-lb__side-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Mobile thumbnail strip — hidden on desktop */
.gpd-lb__thumbs {
    display: none;
    gap: 6px; padding: 10px 16px 20px;
    overflow-x: auto; justify-content: center;
    flex-shrink: 0; -webkit-overflow-scrolling: touch;
    background: rgba(0,0,0,0.6);
}

.gpd-lb__thumb {
    position: relative; flex-shrink: 0;
    width: 60px; height: 44px;
    border-radius: 5px; overflow: hidden;
    cursor: pointer; opacity: 0.45;
    transition: opacity 0.2s, transform 0.2s;
    border: 2px solid transparent;
}

.gpd-lb__thumb:hover { opacity: 0.75; }
.gpd-lb__thumb--active { opacity: 1; border-color: #fff; transform: scale(1.08); }
.gpd-lb__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gpd-lb__thumb-play {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    pointer-events: none;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .gpd-media { padding: 0 12px; margin-left: 0; margin-right: 0; width: 100%; }

    .gpd-grid--2x3, .gpd-grid--video {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto; aspect-ratio: auto;
    }

    .gpd-grid--video .gpd-grid__item--span { grid-row: auto; grid-column: 1 / -1; }
    .gpd-grid--2x2, .gpd-grid--1x2 { aspect-ratio: auto; }

    .gpd-lb__grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }

    /* Single view: stack vertically, hide side grid, show thumbs */
    .gpd-lb__split { flex-direction: column; padding-top: 48px; }
    .gpd-lb__left { flex: 1; padding: 8px; }
    .gpd-lb__right { display: none; }
    .gpd-lb__thumbs { display: flex; }

    .gpd-lb__nav, .gpd-lb .gpd-lb__nav, #gpd-lightbox .gpd-lb__nav,
    #gpd-single-view .gpd-lb__nav { width: 40px !important; height: 40px !important; font-size: 24px !important; }
    .gpd-lb__prev, .gpd-lb .gpd-lb__prev, #gpd-single-view .gpd-lb__prev { left: 8px !important; }
    .gpd-lb__next, .gpd-lb .gpd-lb__next, #gpd-single-view .gpd-lb__next { right: 8px !important; }

    .gpd-grid__play { width: 52px; height: 52px; }
    .gpd-grid__play svg { width: 22px; height: 22px; }
}

@media (max-width: 480px) {
    .gpd-media { padding: 0 8px; width: 100%; }
    .gpd-grid { gap: 6px; }
    .gpd-grid__overlay span { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
    .gpd-grid__item img, .gpd-lb__img {
        animation: none !important; transition: none !important;
    }
}
