/* Galerie Play – Kacheln + Lightbox. Präfix pg-. */
.pg {
    --pg-gap: 10px;
    --pg-radius: 14px;
    --pg-tile-bg: rgba(20, 9, 31, .08);
    --pg-ink: #14091f;
    --pg-paper: #f3f1f7;
    --pg-accent: #d9ccff;
    width: 100%;
    margin: 0 0 30px;
}

/* Ohne JS: einfaches Raster, Bilder vollständig sichtbar */
.pg .pg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 45%), 1fr));
    gap: var(--pg-gap);
    align-items: start;
}

.pg .pg-tile {
    appearance: none;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--pg-radius);
    background: var(--pg-tile-bg);
    overflow: hidden;
    cursor: pointer;
    line-height: 0;
    box-shadow: none;
    -webkit-tap-highlight-color: transparent;
}

.pg .pg-tile img {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    border-radius: 0;
    transition: transform .8s cubic-bezier(.2, .8, .2, 1);
    user-select: none;
}

.pg .pg-tile:focus-visible {
    outline: 3px solid var(--pg-ink);
    outline-offset: 3px;
}

.pg:not(.pg--js) .pg-tile { background: transparent; }

/* Mit JS: absolute Positionierung, berechnet in play-galerie.js */
.pg.pg--js .pg-grid {
    display: block;
    position: relative;
}

.pg.pg--js .pg-tile {
    position: absolute;
    left: 0;
    top: 0;
}

.pg.pg--js .pg-tile img {
    height: 100%;
    object-fit: cover;
}

@media (hover: hover) {
    .pg .pg-tile:hover img { transform: scale(1.04); }
}

@media (max-width: 599px) {
    .pg { --pg-radius: 10px; }
}

/* ---------- Lightbox ---------- */
html.pg-lb-open,
html.pg-lb-open body { overflow: hidden; }

.pg-lb[hidden],
.pg-lb .pg-lb-btn[hidden],
.pg-lb .pg-lb-thumbs[hidden] { display: none !important; }

.pg-lb {
    --pg-paper: #f3f1f7;
    --pg-accent: #d9ccff;
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    color: var(--pg-paper);
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    opacity: 0;
    transition: opacity .38s ease;
}

.pg-lb.is-on { opacity: 1; }

.pg-lb .pg-lb-bg {
    position: absolute;
    inset: 0;
    background: rgba(14, 6, 24, .9);
    -webkit-backdrop-filter: blur(22px);
    backdrop-filter: blur(22px);
}

.pg-lb .pg-lb-top {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 68px;
    padding: 0 clamp(14px, 3vw, 32px);
}

.pg-lb .pg-lb-count {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 15px;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
    color: var(--pg-paper);
}

.pg-lb .pg-lb-count b { font-weight: 500; color: var(--pg-accent); }

.pg-lb .pg-lb-stage {
    position: relative;
    z-index: 1;
    flex: 1;
    min-height: 0;
    touch-action: pan-y;
}

.pg-lb .pg-lb-img {
    position: absolute;
    left: 0;
    top: 0;
    max-width: none;
    margin: 0;
    border-radius: 14px;
    object-fit: contain;
    user-select: none;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}

.pg-lb .pg-lb-btn {
    appearance: none;
    cursor: pointer;
    z-index: 3;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: 1.5px solid rgba(243, 241, 247, .35);
    border-radius: 50%;
    background: rgba(243, 241, 247, .08);
    color: var(--pg-paper);
    display: grid;
    place-items: center;
    box-shadow: none;
    transition: background .25s, border-color .25s, transform .25s;
}

.pg-lb .pg-lb-btn:hover { background: rgba(243, 241, 247, .22); border-color: var(--pg-paper); }

.pg-lb .pg-lb-btn:focus-visible,
.pg-lb .pg-lb-th:focus-visible { outline: 3px solid var(--pg-accent); outline-offset: 3px; }

.pg-lb .pg-lb-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.pg-lb .pg-lb-prev,
.pg-lb .pg-lb-next { position: absolute; top: 50%; margin-top: -24px; }
.pg-lb .pg-lb-prev { left: clamp(10px, 2.5vw, 28px); }
.pg-lb .pg-lb-next { right: clamp(10px, 2.5vw, 28px); }

.pg-lb .pg-lb-thumbs {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 92px;
    padding: 10px clamp(14px, 3vw, 32px) 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.pg-lb .pg-lb-thumbs::-webkit-scrollbar { display: none; }

.pg-lb .pg-lb-th {
    appearance: none;
    flex: none;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 9px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(243, 241, 247, .1);
    opacity: .5;
    transition: opacity .25s;
}

.pg-lb .pg-lb-th img { display: block; height: 100%; width: 100%; object-fit: cover; margin: 0; }
.pg-lb .pg-lb-th:hover { opacity: .85; }
.pg-lb .pg-lb-th[aria-current="true"] { opacity: 1; outline: 2px solid var(--pg-accent); outline-offset: 2px; }

@media (max-width: 520px), (max-height: 560px) {
    .pg-lb .pg-lb-thumbs { display: none; }
    .pg-lb .pg-lb-btn { width: 44px; height: 44px; }
    .pg-lb .pg-lb-prev,
    .pg-lb .pg-lb-next { margin-top: -22px; }
}

@media (prefers-reduced-motion: reduce) {
    .pg .pg-tile img,
    .pg-lb,
    .pg-lb .pg-lb-btn,
    .pg-lb .pg-lb-th { transition: none !important; }
    .pg .pg-tile:hover img { transform: none; }
}

/* Abstand zwischen Titel/Intro und Galerie */
.play-galerie-row { margin-top: 32px; }
@media (max-width: 690px) { .play-galerie-row { margin-top: 24px; } }

/* Gleicher Abstand ueber und unter dem Laufband (Galerie -> Band -> Footer) */
#ajax-content-wrap .play-galerie-row { margin-bottom: 30px !important; }
/* Nur die Play-Seite (Masonry mit 2 Handy-Spalten); Identity/Communication (1 Spalte) bleiben unveraendert. Ohne Seiten-ID. */
#ajax-content-wrap .container.main-content:has(.play-galerie-row .pg[data-pg-mobile-cols="2"]) { padding-bottom: 33px !important; }
@media (max-width: 690px) { #ajax-content-wrap .container.main-content:has(.play-galerie-row .pg[data-pg-mobile-cols="2"]) { padding-bottom: 0 !important; } }
@media (max-width: 690px) { .play-galerie-row .wpb_column { padding-left: 0 !important; padding-right: 0 !important; } }
/* Handy: schmalere Seitenraender, Galerie laeuft fast bis zum Rand (10px) */
@media (max-width: 690px) {
    .play-galerie-row { margin-left: -12px !important; margin-right: -12px !important; }
}
