/* =====================================================================
   GALERIE – editoriales Mosaik mit Vorhang-Reveal, Fokus-Hover,
   animiertem Filter und Kino-Lightbox. Nur auf galerie.html geladen.
   Kachelgroessen: P (hoch), PL (hoch gross), L (quer), LL (quer gross), Q (Zitat)
   ===================================================================== */

.bg-gallery-section { padding: clamp(60px, 8vw, 110px) 0 clamp(70px, 9vw, 130px); }

/* --- Filter --- */
.bg-filters { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 30px; margin: 0 0 clamp(30px, 4vw, 52px); padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.bg-filter { position: relative; padding: 6px 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-family: var(--serif); font-size: clamp(1.15rem, 1.8vw, 1.5rem); font-style: italic; letter-spacing: -.01em; transition: color .35s ease; }
.bg-filter sup { margin-left: 4px; color: var(--mint); font-family: var(--sans); font-size: 9px; font-style: normal; font-weight: 700; letter-spacing: .08em; vertical-align: super; }
.bg-filter::after { position: absolute; right: 0; bottom: -19px; left: 0; height: 2px; background: var(--mint); content: ''; transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease-cinema); }
.bg-filter:hover, .bg-filter[aria-pressed="true"] { color: var(--ink); }
.bg-filter[aria-pressed="true"]::after { transform: scaleX(1); }

/* --- Mosaik (Masonry) ---
   Jedes Bild behaelt sein echtes Seitenverhaeltnis; galerie.js berechnet aus
   data-ratio, wie viele 2-px-Zeilen eine Kachel belegt. "--wide" = doppelte Breite. */
.bg-gal {
  --gap: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 2px;
  grid-auto-flow: row dense;
  column-gap: var(--gap);
  align-items: start;
}
.bg-tile { position: relative; margin: 0; overflow: hidden; aspect-ratio: var(--ratio, 1); }
.bg-tile--wide { grid-column: span 2; }
.bg-tile.is-hidden { display: none; }

.bg-tile__btn { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: var(--tile-color, var(--light)); cursor: zoom-in; }
.bg-tile__btn img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 1.6s var(--ease-cinema), filter .7s ease; }

/* Bildunterschrift: gleitet beim Hover von unten herein */
.bg-tile__cap { position: absolute; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; gap: 4px; padding: 46px 20px 18px; background: linear-gradient(to top, rgba(20,16,13,.72), rgba(20,16,13,0)); color: var(--white); opacity: 0; pointer-events: none; transform: translateY(14px); transition: opacity .5s ease, transform .7s var(--ease-cinema); }
.bg-tile__cat { color: #A9DCD5; font-size: 9px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; }
.bg-tile__title { font-family: var(--serif); font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-style: italic; line-height: 1.2; }

@media (hover: hover) {
  .bg-tile:hover .bg-tile__btn img { transform: scale(1.06); }
  .bg-tile:hover .bg-tile__cap, .bg-tile:focus-within .bg-tile__cap { opacity: 1; transform: translateY(0); }
  /* Fokus-Effekt: die anderen Bilder treten leicht zurueck */
  .bg-gal:has(.bg-tile__btn:hover) .bg-tile:not(:hover) .bg-tile__btn img { filter: saturate(.55) brightness(.82); }
}
.bg-tile__btn:focus-visible { outline: 2px solid var(--mint); outline-offset: -2px; }

/* Zitat-Kacheln */
.bg-tile--Q { --ratio: 1.1; display: flex; flex-direction: column; justify-content: center; padding: clamp(20px, 3vw, 40px); background: var(--ink); color: var(--white); }
.bg-tile--Q blockquote { margin: 0 0 16px; font-family: var(--serif); font-size: clamp(1.35rem, 2.3vw, 2.1rem); font-style: italic; line-height: 1.25; }
.bg-tile--Q blockquote::before { display: block; margin-bottom: 6px; color: var(--mint); font-size: 2.6em; font-style: normal; line-height: .6; content: '\201C'; }
.bg-tile--Q figcaption { color: #A9DCD5; font-size: 9px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; }

/* --- Vorhang-Reveal beim Scrollen (nur mit JS, siehe .bg-js) --- */
/* Der Vorhang liegt auf dem Button, nicht auf der Kachel: ein clip-path auf der
   beobachteten Kachel selbst verhindert in Chrome, dass sie als sichtbar erkannt wird. */
.bg-js .bg-tile .bg-tile__btn { clip-path: inset(100% 0 0 0); transition: clip-path 1.25s var(--ease-cinema) var(--d, 0s); }
.bg-js .bg-tile .bg-tile__btn img { transform: scale(1.22); }
.bg-js .bg-tile.is-in .bg-tile__btn { clip-path: inset(0 0 0 0); }
.bg-js .bg-tile--Q { opacity: 0; transform: translateY(40px); transition: opacity 1s ease var(--d, 0s), transform 1.25s var(--ease-cinema) var(--d, 0s); }
.bg-js .bg-tile--Q.is-in { opacity: 1; transform: none; }
.bg-js .bg-tile.is-in .bg-tile__btn img { transform: scale(1); transition: transform 1.8s var(--ease-cinema) var(--d, 0s), filter .7s ease; }
@media (hover: hover) {
  .bg-js .bg-tile.is-in:hover .bg-tile__btn img { transform: scale(1.06); transition-delay: 0s; }
}

/* Filterwechsel: weiche Ueberblendung, falls View Transitions fehlen */
.bg-gal { transition: opacity .35s ease; }
.bg-gal.is-filtering { opacity: 0; }
::view-transition-group(*) { animation-duration: .7s; animation-timing-function: cubic-bezier(.16, 1, .3, 1); }

.bg-gallery-count { margin-top: 34px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .2em; text-align: center; text-transform: uppercase; }

/* --- Lightbox --- */
.bg-lb { position: fixed; z-index: 200; inset: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; padding: 70px clamp(16px, 7vw, 110px) 26px; background: rgba(14,12,11,.985); color: var(--white); opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s linear .45s; }
.bg-lb.is-open { opacity: 1; visibility: visible; transition: opacity .45s ease; }
.bg-lb__stage { position: relative; display: grid; width: 100%; height: 100%; min-height: 0; place-items: center; overflow: hidden; }
.bg-lb__img { max-width: 100%; max-height: calc(100svh - 190px); object-fit: contain; box-shadow: 0 30px 90px rgba(0,0,0,.45); opacity: 0; transform: scale(.96); transition: opacity .55s ease, transform .9s var(--ease-cinema); user-select: none; -webkit-user-drag: none; }
.bg-lb__img.is-ready { opacity: 1; transform: scale(1); animation: bgKenBurns 14s ease-out .4s both; }
@keyframes bgKenBurns { from { transform: scale(1); } to { transform: scale(1.035); } }
.bg-lb__meta { display: flex; width: 100%; max-width: 900px; align-items: flex-end; justify-content: space-between; gap: 20px; padding-top: 20px; }
.bg-lb__cat { display: block; margin-bottom: 6px; color: #A9DCD5; font-size: 9px; font-weight: 700; letter-spacing: .24em; text-transform: uppercase; }
.bg-lb__title { margin: 0; font-family: var(--serif); font-size: clamp(1.3rem, 2.4vw, 2rem); font-style: italic; line-height: 1.15; }
.bg-lb__count { flex: 0 0 auto; color: rgba(249,249,247,.55); font-family: var(--serif); font-size: 15px; letter-spacing: .04em; }
.bg-lb__count b { color: var(--white); font-weight: 400; }
.bg-lb__btn { position: absolute; z-index: 2; display: grid; width: 52px; height: 52px; place-items: center; border: 1px solid rgba(249,249,247,.3); border-radius: 50%; background: rgba(14,12,11,.35); color: var(--white); cursor: pointer; font-size: 20px; line-height: 1; transition: background .3s ease, border-color .3s ease, transform .3s var(--ease-cinema); }
.bg-lb__btn:hover { border-color: var(--white); background: var(--white); color: var(--ink); }
.bg-lb__close { top: 16px; right: 18px; font-size: 26px; }
.bg-lb__prev { top: 50%; left: clamp(10px, 2.5vw, 34px); transform: translateY(-50%); }
.bg-lb__next { top: 50%; right: clamp(10px, 2.5vw, 34px); transform: translateY(-50%); }
.bg-lb__prev:hover { transform: translateY(-50%) translateX(-3px); }
.bg-lb__next:hover { transform: translateY(-50%) translateX(3px); }

/* --- Tablet --- */
@media (max-width: 980px) {
  .bg-gal { --gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --- Handy --- */
@media (max-width: 680px) {
  .bg-filters { gap: 2px 20px; padding-bottom: 12px; }
  .bg-filter { font-size: 1.05rem; }
  .bg-filter::after { bottom: -13px; }
  .bg-gal { --gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bg-tile--Q { --ratio: 1.6; grid-column: span 2; }
  .bg-tile__cap { display: none; }
  .bg-lb { padding: 64px 10px 18px; }
  .bg-lb__btn { width: 42px; height: 42px; font-size: 17px; }
  .bg-lb__prev, .bg-lb__next { top: auto; bottom: 18px; transform: none; }
  .bg-lb__prev:hover, .bg-lb__next:hover { transform: none; }
  .bg-lb__prev { left: auto; right: 64px; }
  .bg-lb__next { right: 14px; }
  .bg-lb__meta { padding-right: 110px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-js .bg-tile .bg-tile__btn { clip-path: none; }
  .bg-js .bg-tile--Q { opacity: 1; transform: none; }
  .bg-js .bg-tile .bg-tile__btn img { transform: none; }
  .bg-lb__img.is-ready { animation: none; }
}
