/*
 * Galerien im Magazin: Stile für den WordPress-Block „Galerie“.
 * Mosaik (is-style-cm-mosaik), Slideshow (is-style-cm-slideshow), Filmstreifen (is-style-cm-film).
 * Ohne Stil: ordentliches Raster. Die Vorlage „Reportage“ zeigt Galerien ohne Stil als Mosaik.
 * Pfeile, Zähler und Vorschaubilder baut assets/js/galerie.js; ohne Skript lässt sich wischen.
 */

/* Grundlage: dummy.css setzt .spalte figure auf Spalte; Galerien brauchen ihr eigenes Raster */
.spalte .wp-block-gallery{margin:12px 0;gap:8px}
.spalte .wp-block-gallery.has-nested-images{flex-direction:row;flex-wrap:wrap;gap:8px}
.spalte .wp-block-gallery figure{margin:0;gap:0}
.spalte .wp-block-gallery figure img{max-height:none;border-radius:4px}
.spalte .wp-block-gallery figure.wp-block-image figcaption,.cm-buehne .wp-block-gallery figure.wp-block-image figcaption{pointer-events:none}
.spalte .wp-block-gallery .blocks-gallery-caption{flex-basis:100%;margin:4px 0 0;font-size:14px;line-height:20px;color:#4D4D4D;text-align:left}

/* Ohne Stil: Raster mit zwei (oder den gewählten) Spalten, Bilder gleich groß */
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.has-nested-images:not([class*="is-style-"]){display:grid;grid-template-columns:repeat(2,1fr);gap:8px}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-3:not([class*="is-style-"]){grid-template-columns:repeat(3,1fr)}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-4:not([class*="is-style-"]),.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-5:not([class*="is-style-"]),.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-6:not([class*="is-style-"]){grid-template-columns:repeat(4,1fr)}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-1:not([class*="is-style-"]){grid-template-columns:1fr}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery:not([class*="is-style-"])>figure.wp-block-image{width:auto!important;margin:0!important}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.is-cropped:not([class*="is-style-"])>figure img{width:100%!important;aspect-ratio:4/3;height:auto!important;object-fit:cover}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-default:not([class*="is-style-"])>figure:last-of-type:nth-of-type(odd){grid-column:1/-1}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery.columns-default:not([class*="is-style-"])>figure:last-of-type:nth-of-type(odd) img{aspect-ratio:16/9}
.artikel-wrap:not(.cm-reportage) .spalte .wp-block-gallery:not([class*="is-style-"])>.blocks-gallery-caption{grid-column:1/-1}

/* Breiter als die Textspalte: Ausrichtung „Weit“ oder „Volle Breite“, in der Reportage immer */
.spalte>.alignwide,.spalte>.alignfull,.cm-reportage .spalte>.wp-block-gallery,.cm-reportage .spalte>.wp-block-image{align-self:center;width:min(1040px,calc(100vw - 32px));max-width:none}
.spalte>.alignfull{width:min(1180px,calc(100vw - 32px))}

/* Alte Galerien aus dem klassischen Editor ([gallery]) */
.spalte .gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:8px;margin:12px 0}
.spalte .gallery-item{margin:0}
.spalte .gallery-item img{width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:4px}
.spalte .gallery br{display:none}

/* ---------- Mosaik ---------- */
:is(.spalte,.editor-styles-wrapper) .wp-block-gallery.is-style-cm-mosaik,
.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]){display:grid;grid-template-columns:repeat(6,1fr);grid-auto-rows:clamp(110px,14vw,200px);grid-auto-flow:dense;gap:8px}
:is(.spalte,.editor-styles-wrapper) .is-style-cm-mosaik>figure.wp-block-image,
.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"])>figure.wp-block-image{width:auto!important;height:100%;grid-column:span 2;margin:0!important}
:is(.spalte,.editor-styles-wrapper) .is-style-cm-mosaik>figure img,
.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"])>figure img{width:100%!important;height:100%!important;object-fit:cover}
/* Muster aus fünf Bildern: groß links, zwei klein, zwei halb; danach gespiegelt */
:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure:nth-of-type(10n+1){grid-column:1/span 4;grid-row:span 2}
:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure:nth-of-type(10n+7){grid-column:3/span 4;grid-row:span 2}
:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure:is(:nth-of-type(10n+4),:nth-of-type(10n+5),:nth-of-type(10n+9),:nth-of-type(10n+10)){grid-column:span 3}
/* Ein einzelnes letztes Bild in einer halben Reihe nimmt die ganze Breite */
:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure:is(:nth-of-type(5n+4)):last-of-type{grid-column:1/-1}
/* Unterschrift unter dem Raster, nicht als eigene (hohe) Reihe */
:is(.spalte,.editor-styles-wrapper) .wp-block-gallery.is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]){position:relative}
:is(.spalte,.editor-styles-wrapper) .wp-block-gallery.is-style-cm-mosaik:has(>.blocks-gallery-caption),.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]):has(>.blocks-gallery-caption){margin-bottom:40px}
:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>.blocks-gallery-caption{position:absolute;left:0;right:0;top:100%;margin:0;padding-top:8px}
@media (max-width:640px){
	:is(.spalte,.editor-styles-wrapper) .wp-block-gallery.is-style-cm-mosaik,
	.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]){grid-template-columns:1fr 1fr;grid-auto-rows:clamp(120px,36vw,200px);gap:6px}
	:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure.wp-block-image{grid-column:span 1!important;grid-row:span 1!important}
	:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure.wp-block-image:nth-of-type(3n+1){grid-column:1/-1!important;grid-row:span 1!important}
	:is(.spalte .is-style-cm-mosaik,.editor-styles-wrapper .is-style-cm-mosaik,.cm-reportage .spalte .wp-block-gallery:not([class*="is-style-"]))>figure.wp-block-image:nth-of-type(3n+2):last-of-type{grid-column:1/-1!important}
}

/* ---------- Slideshow und Filmstreifen: gemeinsame Spur ---------- */
.wp-block-gallery.is-style-cm-slideshow,.wp-block-gallery.is-style-cm-film{position:relative;display:flex!important;flex-wrap:nowrap!important;gap:8px;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x mandatory;scroll-behavior:smooth;scrollbar-width:none;-webkit-overflow-scrolling:touch}
.wp-block-gallery.is-style-cm-slideshow::-webkit-scrollbar,.wp-block-gallery.is-style-cm-film::-webkit-scrollbar{display:none}
.wp-block-gallery.is-style-cm-slideshow:focus-visible,.wp-block-gallery.is-style-cm-film:focus-visible{outline:2px solid var(--rot);outline-offset:4px}
.wp-block-gallery.is-style-cm-slideshow>.blocks-gallery-caption,.wp-block-gallery.is-style-cm-film>.blocks-gallery-caption{display:none}
@media (prefers-reduced-motion:reduce){.wp-block-gallery.is-style-cm-slideshow,.wp-block-gallery.is-style-cm-film{scroll-behavior:auto}}

/* Slideshow: ein Bild füllt die Bühne */
.wp-block-gallery.is-style-cm-slideshow{gap:0;border-radius:4px;background:#161616}
.wp-block-gallery.is-style-cm-slideshow>figure.wp-block-image{flex:0 0 100%!important;width:100%!important;margin:0!important;scroll-snap-align:start;scroll-snap-stop:always;aspect-ratio:3/2;align-self:stretch}
.wp-block-gallery.is-style-cm-slideshow>figure img{width:100%!important;height:100%!important;object-fit:cover;border-radius:0!important}
.wp-block-gallery.is-style-cm-slideshow>figure figcaption{font-size:15px;line-height:22px;padding:48px 20px 16px!important;text-align:left!important;background:linear-gradient(0deg,rgba(0,0,0,.72),rgba(0,0,0,0))!important}

/* Filmstreifen: Bilder in ihrem Format nebeneinander */
.wp-block-gallery.is-style-cm-film>figure.wp-block-image{flex:0 0 auto!important;width:auto!important;height:clamp(220px,34vw,440px);margin:0!important;scroll-snap-align:start}
.wp-block-gallery.is-style-cm-film>figure img{width:auto!important;height:100%!important;max-width:none;object-fit:cover}
@media (max-width:640px){.wp-block-gallery.is-style-cm-film>figure.wp-block-image{height:clamp(200px,62vw,320px)}.wp-block-gallery.is-style-cm-film>figure img{max-width:84vw}}

/* Leiste unter Slideshow und Filmstreifen */
.cm-leiste{display:flex;align-items:center;gap:12px;margin:-4px 0 4px;font-family:var(--wp--preset--font-family--inter);font-size:14px;line-height:20px;color:#4D4D4D}
.spalte>.cm-leiste{align-self:center;width:100%}
.spalte>.alignwide+.cm-leiste,.spalte>.alignfull+.cm-leiste,.cm-reportage .spalte>.wp-block-gallery+.cm-leiste,.spalte>.alignwide+.cm-leiste+.cm-galerie-text,.cm-reportage .spalte>.wp-block-gallery+.cm-leiste+.cm-galerie-text{width:min(1040px,calc(100vw - 32px))}
.cm-leiste .cm-zaehler{font-variant-numeric:tabular-nums;font-weight:600;color:#000000;min-width:4.5em}
.cm-leiste .cm-text{flex:1;min-width:0}
.cm-galerie-text{margin:-12px 0 4px;font-family:var(--wp--preset--font-family--inter);font-size:14px;line-height:20px;color:#4D4D4D}
.spalte>.cm-galerie-text{align-self:center;width:100%}
.cm-buehne .cm-galerie-text{margin:8px 0 0;color:rgba(255,255,255,.75)}
.hell .cm-buehne .cm-galerie-text{color:#4D4D4D}
.cm-leiste .cm-daumen{flex:1;min-width:0;display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;padding:2px}
.cm-leiste .cm-daumen::-webkit-scrollbar{display:none}
.cm-leiste .cm-daumen button{flex:0 0 auto;width:56px;height:40px;padding:0;border:0;border-radius:3px;overflow:hidden;cursor:pointer;opacity:.55;background:#BDBDBD;outline-offset:2px}
.cm-leiste .cm-daumen button[aria-current="true"]{opacity:1;box-shadow:0 0 0 2px #000000}
.cm-leiste .cm-daumen img{display:block;width:100%!important;height:100%!important;object-fit:cover;border-radius:0!important;max-height:none!important}
.cm-leiste .cm-pfeile{display:flex;gap:8px;margin-left:auto}
.cm-leiste .cm-pfeil{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:999px;background:var(--gelb,#CCCC00);color:#000000;cursor:pointer;font:600 20px/1 var(--wp--preset--font-family--inter)}
.cm-leiste .cm-pfeil:hover{background:#000000;color:var(--gelb,#CCCC00)}
.cm-leiste .cm-pfeil:disabled{opacity:.35;cursor:default;background:var(--gelb,#CCCC00);color:#000000}
.cm-leiste .cm-pfeil:focus-visible,.cm-leiste .cm-daumen button:focus-visible{outline:2px solid var(--rot)}
@media (max-width:640px){.cm-leiste .cm-daumen{display:none}.cm-leiste .cm-pfeil{width:40px;height:40px}}

/* ---------- Vorlage „Reportage“: großes Titelbild ---------- */
.cm-rep-kopf{position:relative;isolation:isolate;min-height:clamp(440px,78svh,860px);display:flex;align-items:flex-end;overflow:hidden;background:#000000;color:#FFFFFF}
.cm-rep-kopf>img{position:absolute;inset:0;z-index:-2;width:100%;height:100%!important;object-fit:cover}
.cm-rep-kopf::after{content:'';position:absolute;inset:0;z-index:-1;background:linear-gradient(180deg,rgba(0,0,0,.35) 0,rgba(0,0,0,0) 30%,rgba(0,0,0,.2) 55%,rgba(0,0,0,.82) 100%)}
.cm-rep-kopf .held{padding-bottom:clamp(28px,5vw,64px)}
.cm-rep-kopf .h1{max-width:20ch;color:#FFFFFF;text-wrap:balance}
.cm-rep-kopf .leise,.cm-rep-kopf .leise strong{color:rgba(255,255,255,.88)!important}
.cm-rep-kopf .cm-unterzeile{max-width:52ch;margin:0;font-size:clamp(18px,1.8vw,22px);line-height:1.45;color:rgba(255,255,255,.92)}
.cm-reportage .spalte .cm-lead{font-size:24px;line-height:36px}

/* ---------- Vorlage „Bildstrecke“: große Slideshow oben ---------- */
.cm-buehne{padding-top:8px}
.cm-buehne .wp-block-gallery.is-style-cm-slideshow{margin:0}
.cm-buehne .wp-block-gallery.is-style-cm-slideshow>figure.wp-block-image{aspect-ratio:16/9;max-height:78svh}
.cm-buehne .cm-leiste{margin:12px 0 0;color:rgba(255,255,255,.75)}
.cm-buehne .cm-leiste .cm-zaehler{color:#FFFFFF}
.cm-buehne .cm-leiste .cm-daumen button[aria-current="true"]{box-shadow:0 0 0 2px #FFFFFF}
.hell .cm-buehne .cm-leiste{color:#4D4D4D}
.hell .cm-buehne .cm-leiste .cm-zaehler{color:#000000}
.hell .cm-buehne .cm-leiste .cm-daumen button[aria-current="true"]{box-shadow:0 0 0 2px #000000}
@media (max-width:640px){.cm-buehne{padding-left:0;padding-right:0}.cm-buehne .wp-block-gallery.is-style-cm-slideshow{border-radius:0}.cm-buehne .wp-block-gallery.is-style-cm-slideshow>figure.wp-block-image{aspect-ratio:4/3}.cm-buehne .cm-leiste,.cm-buehne .cm-galerie-text{padding:0 16px}}

/* Editor: Spuren nicht scrollen lassen, sondern umbrechen, damit man alle Bilder sieht */
.editor-styles-wrapper .wp-block-gallery.is-style-cm-slideshow,.editor-styles-wrapper .wp-block-gallery.is-style-cm-film{flex-wrap:wrap!important;overflow:visible}
.editor-styles-wrapper .wp-block-gallery.is-style-cm-slideshow>figure.wp-block-image{flex:0 0 calc(25% - 6px)!important;aspect-ratio:3/2}
.editor-styles-wrapper .wp-block-gallery.is-style-cm-film>figure.wp-block-image{height:140px}
