/* ===================================================================
   Beitragsseite: Bildansicht (wie bei WhatsApp) und Teilen-Blatt
   Verhalten: beitrag-galerie.js · Markup-Haken: beitrag.php
   =================================================================== */

/* ---------- Fotos im Beitrag antippbar ---------- */

.aufmacher-link {
  position: relative; z-index: 2;
  display: block;
  margin: calc(-1 * clamp(56px, 7vw, 72px)) 0 clamp(26px, 3.5vw, 36px);
  border-radius: var(--radius);
  cursor: zoom-in;
}
.aufmacher-link .beitrag-aufmacher { margin: 0; }
.aufmacher-zahl {
  position: absolute; right: 12px; bottom: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-size: .8rem; font-weight: 700;
}
.aufmacher-zahl svg { width: 15px; height: 15px; }
.bildstrecke .galerie-bild { display: block; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.bildstrecke .galerie-bild img { transition: transform .3s ease; }
.bildstrecke .galerie-bild:hover img { transform: scale(1.03); }

/* ---------- Bildansicht ---------- */

.galerie {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column;
  background: #000;
  color: #fff;
  opacity: 0;
  transition: opacity .22s ease;
  -webkit-user-select: none; user-select: none;
  touch-action: pan-x;
}
.galerie.offen { opacity: 1; }
.galerie[hidden] { display: none; }

.gl-leiste {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 8px 18px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0));
  transition: opacity .2s ease;
}
.gl-zaehler { flex: 1; text-align: center; font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.gl-knopf {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: #fff;
  cursor: pointer;
}
.gl-knopf:hover, .gl-knopf:active { background: rgba(255, 255, 255, .14); }
.gl-knopf svg { width: 24px; height: 24px; }
.gl-knopf[hidden] { display: none; }

.gl-spur {
  flex: 1;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior: contain;
  will-change: transform;
}
.gl-spur::-webkit-scrollbar { display: none; }
.gl-folie {
  flex: 0 0 100%;
  display: grid; place-items: center;
  scroll-snap-align: center; scroll-snap-stop: always;
  padding: calc(env(safe-area-inset-top, 0px) + 60px) 0 calc(env(safe-area-inset-bottom, 0px) + 92px);
}
.gl-folie img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
}

.gl-pfeil {
  position: absolute; top: 50%; z-index: 3;
  display: grid; place-items: center;
  width: 48px; height: 48px; margin-top: -24px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .12); color: #fff;
  cursor: pointer;
}
.gl-pfeil:hover { background: rgba(255, 255, 255, .24); }
.gl-pfeil svg { width: 22px; height: 22px; }
.gl-pfeil.zurueck { left: 18px; }
.gl-pfeil.vor { right: 18px; }
@media (hover: none), (max-width: 820px) { .gl-pfeil { display: none; } }

.gl-unten {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 26px 0 calc(env(safe-area-inset-bottom, 0px) + 12px);
  background: linear-gradient(to top, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0));
  transition: opacity .2s ease;
}
.gl-titel {
  margin: 0 16px 10px;
  font-size: .85rem; line-height: 1.35; color: rgba(255, 255, 255, .85);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}
.gl-daumen {
  display: flex; gap: 6px; justify-content: safe center;
  padding: 0 16px;
  overflow-x: auto; scrollbar-width: none;
}
.gl-daumen::-webkit-scrollbar { display: none; }
.gl-daumen button {
  flex: none; width: 46px; height: 46px; padding: 0;
  border: 0; border-radius: 8px; overflow: hidden;
  background: #222; opacity: .5;
  cursor: pointer;
  transition: opacity .2s ease, transform .2s ease, box-shadow .2s ease;
}
.gl-daumen button.an { opacity: 1; box-shadow: 0 0 0 2px #fff; transform: scale(1.06); }
.gl-daumen img { width: 100%; height: 100%; object-fit: cover; }

/* Antippen blendet die Bedienelemente aus — nur noch das Foto */
.galerie.still .gl-leiste,
.galerie.still .gl-unten,
.galerie.still .gl-pfeil { opacity: 0; pointer-events: none; }

/* ---------- Teilen-Blatt ---------- */

.teilen-blatt { position: fixed; inset: 0; z-index: 310; }
.teilen-blatt[hidden] { display: none; }
.tb-schatten {
  position: absolute; inset: 0;
  background: rgba(0, 18, 8, .5);
  opacity: 0; transition: opacity .25s ease;
}
.tb-blatt {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 18px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-radius: 26px 26px 0 0;
  background: #fff; color: var(--text);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.2, .85, .25, 1);
}
.teilen-blatt.offen .tb-schatten { opacity: 1; }
.teilen-blatt.offen .tb-blatt { transform: none; }
.tb-griff { width: 40px; height: 5px; margin: 4px auto 14px; border-radius: 3px; background: #D9D9D3; }
.tb-blatt h3 { margin: 0 0 4px; font-size: 1.1rem; }
.tb-blatt > p { margin: 0 0 14px; font-size: .85rem; color: var(--grau); }

.tb-vorschau {
  display: flex; gap: 14px; align-items: center;
  padding: 12px; margin-bottom: 14px;
  border-radius: 18px; background: var(--sand);
}
.tb-vorschau .tb-bild {
  flex: none; width: 92px; aspect-ratio: 9 / 16;
  border-radius: 12px; overflow: hidden;
  background: linear-gradient(160deg, #00602f, #003318);
  box-shadow: 0 8px 20px rgba(0, 40, 20, .25);
  display: grid; place-items: center;
}
.tb-vorschau .tb-bild img { width: 100%; height: 100%; object-fit: cover; }
.tb-vorschau .tb-bild .tb-laedt {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .3); border-top-color: #fff;
  animation: tb-dreh .8s linear infinite;
}
@keyframes tb-dreh { to { transform: rotate(360deg); } }
.tb-vorschau b { display: block; font-size: .95rem; color: var(--gruen); }
.tb-vorschau span { display: block; font-size: .8rem; color: var(--grau); line-height: 1.4; margin-bottom: 10px; }
.tb-vorschau .tb-zeile { display: flex; gap: 8px; flex-wrap: wrap; }

.tb-knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border: 0; border-radius: 999px;
  background: var(--gruen); color: #fff;
  font: inherit; font-size: .84rem; font-weight: 700; text-decoration: none;
  cursor: pointer;
}
.tb-knopf.hell { background: #fff; color: var(--gruen); box-shadow: inset 0 0 0 1.5px rgba(0, 72, 36, .2); }
.tb-knopf svg { width: 16px; height: 16px; }
.tb-knopf[disabled] { opacity: .5; cursor: default; }

.tb-raster { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tb-raster button, .tb-raster a {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 2px; border: 0; border-radius: 16px;
  background: none; color: var(--text);
  font: inherit; font-size: .74rem; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer;
}
.tb-raster button:active, .tb-raster a:active { background: var(--sand); }
.tb-raster .tb-rund {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: #EDF6F0; color: var(--gruen);
}
.tb-raster .tb-rund svg { width: 24px; height: 24px; }
.tb-raster .wa .tb-rund { background: #25D366; color: #fff; }
.tb-raster .fb .tb-rund { background: #1877F2; color: #fff; }

/* Kurze Rückmeldung („Link kopiert") */
.tb-meldung {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 90px); z-index: 320;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(20, 20, 20, .9); color: #fff;
  font-size: .86rem; font-weight: 600;
  transform: translate(-50%, 10px); opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.tb-meldung.an { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .galerie, .tb-blatt, .tb-schatten { transition: none; }
}
