/* ═══════════════════════════════════════════════════════════════════════
   MaHe LIVE Galerie – Frontend CSS
   Autor: Marzahn-Hellersdorf LIVE
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --mahe-accent:   #3a7d12;
    --mahe-dark:     #1a1a1a;
    --mahe-mid:      #555;
    --mahe-light:    #f5f5f5;
    --mahe-border:   #ddd;
    --mahe-radius:   4px;
    --mahe-shadow:   0 2px 8px rgba(0,0,0,.15);
    --mahe-trans:    .25s ease;
}

.mahe-galerie-wrap {
    width: 100%;
    font-family: inherit;
    box-sizing: border-box;
    margin: 0 0 1.6em;
    position: relative;
    z-index: 0;
    isolation: isolate;
    clear: both;
    /* Harte Grenze: nichts von außen kann hineinfließen */
    overflow: clip;          /* CSS overflow:clip – kein Scrollbar, kein Bleed */
}
/* Fallback für Browser ohne overflow:clip */
@supports not (overflow: clip) {
    .mahe-galerie-wrap { overflow: hidden; }
}
.mahe-galerie-wrap *,
.mahe-galerie-wrap *::before,
.mahe-galerie-wrap *::after { box-sizing: border-box; }

.mahe-galerie-title {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 .7em;
    color: var(--mahe-dark);
    border-left: 3px solid var(--mahe-accent);
    padding-left: .6em;
}

.mahe-galerie-error {
    color: #c00;
    font-style: italic;
    font-size: .9em;
}

/* ── CAPTION BOX ──────────────────────────────────────────────────────── */
.mahe-galerie-caption-box {
    background: var(--mahe-light);
    border-left: 3px solid var(--mahe-accent);
    padding: .9em 1.1em;
    font-size: .9em;
    line-height: 1.55;
    color: var(--mahe-mid);
    margin-top: .8em;
    border-radius: 0 var(--mahe-radius) var(--mahe-radius) 0;
}
.mahe-galerie-caption-box p:last-child { margin: 0; }

/* ══════════════════════════════════════════════════════════════════════
   HORIZONTAL FILMSTRIP (Standard)
   ══════════════════════════════════════════════════════════════════════ */
.mahe-hfs {
    width: 100%;
    position: relative;
    z-index: 0;           /* eigener Stacking-Context */
    isolation: isolate;   /* externe Elemente können nicht einbluten */
    overflow: hidden;
}

.mahe-hfs-main {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    background: #000;
    border-radius: var(--mahe-radius) var(--mahe-radius) 0 0;
    overflow: hidden;
    contain: layout style paint;
    clip-path: inset(0);          /* fixed-positioned Elemente werden hart beschnitten */
}

.mahe-hfs-stage {
    flex: 1;
    position: relative;
    min-height: 200px;
    max-height: 520px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    isolation: isolate;
    contain: layout style paint;
    clip-path: inset(0);
    will-change: transform;
}

.mahe-hfs-main-img {
    max-width: 100%;
    max-height: 520px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    transition: opacity .3s ease;
}

.mahe-hfs-img-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    background: linear-gradient(transparent, rgba(0,0,0,.65));
    color: #fff;
    padding: .5em 1em;
    font-size: .82em;
    min-height: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}
.mahe-hfs-img-caption:empty { display: none; }

.mahe-hfs-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(0,0,0,.45);
    color: #fff;
    border: none;
    width: 40px;
    height: 60px;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--mahe-trans);
    padding: 0;
}
.mahe-hfs-arrow:hover { background: rgba(179,0,0,.8); }
.mahe-hfs-prev { left: 0; border-radius: 0 3px 3px 0; }
.mahe-hfs-next { right: 0; border-radius: 3px 0 0 3px; }

.mahe-hfs-strip-wrap {
    overflow-x: auto;
    background: var(--mahe-dark);
    padding: 6px;
    border-radius: 0 0 var(--mahe-radius) var(--mahe-radius);
    scrollbar-width: thin;
    scrollbar-color: var(--mahe-accent) #333;
}
.mahe-hfs-strip-wrap::-webkit-scrollbar { height: 4px; }
.mahe-hfs-strip-wrap::-webkit-scrollbar-thumb { background: var(--mahe-accent); border-radius: 2px; }
.mahe-hfs-strip-wrap::-webkit-scrollbar-track { background: #333; }

.mahe-hfs-strip {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    width: max-content;
}

.mahe-hfs-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 55px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 2px;
    opacity: .65;
    transition: opacity var(--mahe-trans), border-color var(--mahe-trans);
}
.mahe-hfs-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mahe-hfs-thumb:hover { opacity: .9; }
.mahe-hfs-thumb.active { border-color: var(--mahe-accent); opacity: 1; }

.mahe-hfs-counter {
    text-align: right;
    font-size: .78em;
    color: #999;
    padding: 3px 2px 0;
}

@media (max-width: 600px) {
    .mahe-hfs-stage { min-height: 150px; max-height: 280px; }
    .mahe-hfs-thumb { width: 60px; height: 42px; }
    .mahe-hfs-arrow { width: 32px; height: 48px; font-size: 22px; }
}

/* ══════════════════════════════════════════════════════════════════════
   SLIDESHOW
   ══════════════════════════════════════════════════════════════════════ */
.mahe-slideshow {
    position: relative;
    background: #111;
    border-radius: var(--mahe-radius);
    overflow: hidden;
}
.mahe-ss-stage { position: relative; min-height: 200px; }

.mahe-ss-slide {
    display: none;
    position: relative;
}
.mahe-ss-slide.active { display: block; }
.mahe-ss-slide img {
    width: 100%;
    max-height: 520px;
    object-fit: cover;
    display: block;
}
.mahe-ss-caption {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.6);
    color: #fff;
    padding: .5em 1em;
    font-size: .85em;
}
.mahe-ss-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,.4);
    color: #fff;
    border: none;
    width: 40px;
    height: 64px;
    font-size: 30px;
    cursor: pointer;
    z-index: 10;
    transition: background var(--mahe-trans);
}
.mahe-ss-btn:hover { background: rgba(179,0,0,.8); }
.mahe-ss-prev { left: 0; }
.mahe-ss-next { right: 0; }

.mahe-ss-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 6px;
    background: var(--mahe-dark);
}
.mahe-ss-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #555;
    cursor: pointer;
    transition: background var(--mahe-trans);
}
.mahe-ss-dot.active { background: var(--mahe-accent); }

/* ══════════════════════════════════════════════════════════════════════
   THUMBNAILS / THUMBNAIL GRID
   ══════════════════════════════════════════════════════════════════════ */
.mahe-thumbgrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.mahe-mode-thumbnail-grid .mahe-thumbgrid { grid-template-columns: repeat(4, 1fr); }

.mahe-tg-item {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: var(--mahe-radius);
    aspect-ratio: 1;
    background: #eee;
}
.mahe-tg-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--mahe-trans); }
.mahe-tg-item:hover img { transform: scale(1.06); }

.mahe-tg-cap {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .75em;
    padding: .3em .5em;
    transform: translateY(100%);
    transition: transform var(--mahe-trans);
}
.mahe-tg-item:hover .mahe-tg-cap { transform: translateY(0); }

@media (max-width: 500px) {
    .mahe-thumbgrid { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════════════
   MASONRY / MOSAIC
   ══════════════════════════════════════════════════════════════════════ */
.mahe-masonry {
    columns: 3;
    column-gap: 8px;
}
.mahe-ms-item {
    display: block;
    margin-bottom: 8px;
    break-inside: avoid;
    position: relative;
    overflow: hidden;
    border-radius: var(--mahe-radius);
}
.mahe-ms-item img { width: 100%; height: auto; display: block; transition: transform var(--mahe-trans); }
.mahe-ms-item:hover img { transform: scale(1.04); }
.mahe-ms-cap {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: .75em;
    padding: .3em .5em;
    transform: translateY(100%);
    transition: transform var(--mahe-trans);
}
.mahe-ms-item:hover .mahe-ms-cap { transform: translateY(0); }

@media (max-width: 600px) { .mahe-masonry { columns: 2; } }

/* ══════════════════════════════════════════════════════════════════════
   FILM (vertikal)
   ══════════════════════════════════════════════════════════════════════ */
.mahe-film { display: flex; flex-direction: column; gap: 8px; }
.mahe-film-item {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: var(--mahe-radius);
}
.mahe-film-item img { width: 100%; height: auto; display: block; }
.mahe-film-cap {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55); color: #fff; font-size: .8em; padding: .4em .7em;
}

/* ══════════════════════════════════════════════════════════════════════
   BLOG STYLE
   ══════════════════════════════════════════════════════════════════════ */
.mahe-blog-style { display: flex; flex-direction: column; gap: 20px; }
.mahe-bs-item {
    margin: 0;
    border-radius: var(--mahe-radius);
    overflow: hidden;
    box-shadow: var(--mahe-shadow);
}
.mahe-bs-item a { display: block; }
.mahe-bs-item img { width: 100%; height: auto; display: block; }
.mahe-bs-item figcaption {
    padding: .6em .9em;
    font-size: .85em;
    color: var(--mahe-mid);
    background: var(--mahe-light);
    border-top: 1px solid var(--mahe-border);
}

/* ══════════════════════════════════════════════════════════════════════
   SIDESCROLL
   ══════════════════════════════════════════════════════════════════════ */
.mahe-sidescroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--mahe-accent) #ddd;
    -webkit-overflow-scrolling: touch;
}
.mahe-sidescroll::-webkit-scrollbar { height: 4px; }
.mahe-sidescroll::-webkit-scrollbar-thumb { background: var(--mahe-accent); border-radius: 2px; }

.mahe-sc-item {
    flex-shrink: 0;
    display: block;
    height: 220px;
    border-radius: var(--mahe-radius);
    overflow: hidden;
}
.mahe-sc-item img {
    height: 100%;
    width: auto;
    display: block;
    object-fit: cover;
    transition: transform var(--mahe-trans);
}
.mahe-sc-item:hover img { transform: scale(1.05); }

@media (max-width: 500px) { .mahe-sc-item { height: 150px; } }

/* ══════════════════════════════════════════════════════════════════════
   TILE
   ══════════════════════════════════════════════════════════════════════ */
.mahe-tile {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 160px;
    gap: 6px;
}
.mahe-tile-item {
    display: block;
    overflow: hidden;
    border-radius: var(--mahe-radius);
    position: relative;
    background: #eee;
}
.mahe-tile-item.mahe-tile-0 { grid-column: span 2; grid-row: span 2; }
.mahe-tile-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--mahe-trans); }
.mahe-tile-item:hover img { transform: scale(1.06); }
.mahe-tile-cap {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55); color: #fff; font-size: .75em; padding: .3em .5em;
    transform: translateY(100%); transition: transform var(--mahe-trans);
}
.mahe-tile-item:hover .mahe-tile-cap { transform: translateY(0); }

@media (max-width: 500px) {
    .mahe-tile { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 110px; }
    .mahe-tile-item.mahe-tile-0 { grid-column: span 1; grid-row: span 1; }
}

/* ══════════════════════════════════════════════════════════════════════
   LIGHTBOX
   ══════════════════════════════════════════════════════════════════════ */
.mahe-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}
.mahe-lightbox.open { display: flex; }

.mahe-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.88);
    cursor: pointer;
}

.mahe-lb-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0;
    max-width: 95vw;
    max-height: 95vh;
}

.mahe-lb-img {
    max-width: 88vw;
    max-height: 88vh;
    object-fit: contain;
    display: block;
    border-radius: 2px;
    box-shadow: 0 4px 32px rgba(0,0,0,.6);
}

.mahe-lb-close {
    position: absolute;
    top: -38px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: .8;
    transition: opacity var(--mahe-trans);
}
.mahe-lb-close:hover { opacity: 1; color: var(--mahe-accent); }

.mahe-lb-prev,
.mahe-lb-next {
    background: rgba(0,0,0,.4);
    border: none;
    color: #fff;
    font-size: 36px;
    width: 48px;
    height: 80px;
    cursor: pointer;
    transition: background var(--mahe-trans);
    border-radius: var(--mahe-radius);
    padding: 0;
    flex-shrink: 0;
}
.mahe-lb-prev:hover,
.mahe-lb-next:hover { background: rgba(179,0,0,.7); }

.mahe-lb-cap {
    position: absolute;
    bottom: -30px;
    left: 0; right: 0;
    color: #ccc;
    font-size: .82em;
    text-align: center;
}

@media (max-width: 500px) {
    .mahe-lb-prev, .mahe-lb-next { display: none; }
    .mahe-lb-img { max-width: 96vw; max-height: 82vh; }
}

/* ── KOPIERSCHUTZ ─────────────────────────────────────────────────────── */
.mahe-galerie-wrap img {
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;  /* verhindert Drag & normalen Rechtsklick */
}
/* Buttons/Links müssen weiterhin klickbar bleiben */
.mahe-galerie-wrap a,
.mahe-galerie-wrap button,
.mahe-galerie-wrap .mahe-hfs-thumb,
.mahe-galerie-wrap .mahe-lb-prev,
.mahe-galerie-wrap .mahe-lb-next,
.mahe-galerie-wrap .mahe-lb-close,
.mahe-galerie-wrap .mahe-lb-overlay {
    pointer-events: auto;
}
/* Transparentes Overlay über jedem Bild-Container */
.mahe-hfs-stage::after,
.mahe-ss-slide::after,
.mahe-tg-item::after,
.mahe-ms-item::after,
.mahe-film-item::after,
.mahe-bs-item::after,
.mahe-sc-item::after,
.mahe-tile-item::after,
.mahe-lb-content::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 5;
    cursor: default;
}

/* ── SWIPE-TRANSITION ─────────────────────────────────────────────────── */
.mahe-hfs-main-img {
    transition: transform 0.32s cubic-bezier(.4,0,.2,1), opacity 0.18s ease;
    will-change: transform, opacity;
}
.mahe-hfs-main-img.mahe-slide-out-left  { transform: translateX(-60px); opacity: 0; }
.mahe-hfs-main-img.mahe-slide-out-right { transform: translateX(60px);  opacity: 0; }
.mahe-hfs-main-img.mahe-slide-in-left   { transform: translateX(60px);  opacity: 0; }
.mahe-hfs-main-img.mahe-slide-in-right  { transform: translateX(-60px); opacity: 0; }

/* ── TRANSITION PICKER (Admin) ───────────────────────────────────────── */
.mahe-transition-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mahe-trans-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 14px 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    transition: border-color .15s, background .15s;
    min-width: 80px;
    text-align: center;
}
.mahe-trans-tile svg { color: #666; }
.mahe-trans-tile:hover { border-color: #0073aa; background: #f0f7fc; }
.mahe-trans-tile:hover svg { color: #0073aa; }
.mahe-trans-tile.selected { border-color: #3a7d12; background: #f0fff0; color: #1a5c00; }
.mahe-trans-tile.selected svg { color: #3a7d12; }

/* ── TRANSITION ANIMATIONEN (Frontend) ───────────────────────────────── */
/* fade */
.mahe-hfs-main-img.mahe-fade-out { opacity: 0 !important; transition: opacity .3s ease !important; }
.mahe-hfs-main-img.mahe-fade-in  { opacity: 1 !important; transition: opacity .3s ease !important; }

/* zoom */
.mahe-hfs-main-img.mahe-zoom-out { opacity: 0; transform: scale(1.08); transition: opacity .28s ease, transform .28s ease !important; }
.mahe-hfs-main-img.mahe-zoom-in  { opacity: 0; transform: scale(.94); }
.mahe-hfs-main-img.mahe-zoom-active { opacity: 1; transform: scale(1); transition: opacity .28s ease, transform .28s ease !important; }

/* flip */
.mahe-hfs-stage.mahe-flip-stage { perspective: 800px; }
.mahe-hfs-main-img.mahe-flip-out { transform: rotateY(-90deg); opacity: 0; transition: transform .22s ease, opacity .22s ease !important; }
.mahe-hfs-main-img.mahe-flip-in  { transform: rotateY(90deg);  opacity: 0; }
.mahe-hfs-main-img.mahe-flip-active { transform: rotateY(0deg); opacity: 1; transition: transform .22s ease, opacity .22s ease !important; }

/* ── THEMA-ISOLATION ──────────────────────────────────────────────────── */
/* position:fixed Elemente (z.B. "Fehler melden"-Plugins) werden nur im
   root-Stacking-Context gerendert. Wir erzwingen für alle Galerie-Wrapper
   einen eigenen Compositor-Layer mit will-change. Damit werden fixed-Kinder
   von außen NICHT in diese Container hineingerendert. */
.mahe-galerie-wrap {
    transform: translateZ(0);
    will-change: transform;
}
.mahe-hfs,
.mahe-hfs-main,
.mahe-hfs-stage {
    transform: translateZ(0);
    will-change: transform;
}
.mahe-slideshow,
.mahe-thumbgrid,
.mahe-masonry,
.mahe-film,
.mahe-blog-style,
.mahe-sidescroll,
.mahe-tile {
    transform: translateZ(0);
}

/* Alle direkt positionierten Kinder der Stage bleiben innerhalb */
.mahe-hfs-stage > * {
    max-width: 100%;
}

/* Caption-Text darf nicht aus dem Galerie-Rahmen heraus */
.mahe-hfs-img-caption,
.mahe-ss-caption,
.mahe-film-cap,
.mahe-ms-cap,
.mahe-tg-cap,
.mahe-tile-cap {
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3em;
}
