/* Meme-Galerie (template-parts/meme-feed.php): unter dem normalen Seitenkopf, Handy dunkel, Desktop hell als Karte.
   --mf-top ist die Höhe des Seitenkopfs, gemessen in memes.js. */

body.wzf-memes {
  --mf-bg: #16140f;
  --mf-ink: #fff;
  --mf-muted: rgb(255 255 255 / .68);
  --mf-chip: rgb(255 255 255 / .12);
  --mf-bar-h: 48px;
  --mf-h: calc(100dvh - var(--mf-top, 0px));
  margin: 0; height: 100%; overflow: hidden; background: var(--mf-bg); color: var(--mf-ink);
  overscroll-behavior: none;
}
html:has(body.wzf-memes) { height: 100%; overflow: hidden; margin-top: 0 !important; }
/* Theme-Zugaben, die über der Galerie nur stören */
.wzf-memes .trx_addons_scroll_to_top, .wzf-memes .trx_addons_scroll_progress, .wzf-memes #wpadminbar,
.wzf-memes .footer_wrap { display: none !important; }
.wzf-memes .page_content_wrap { padding: 0 !important; }
/* Seitenkopf wie überall hell, auch über dem dunklen Handy-Feed */
.wzf-memes .top_panel { position: relative; z-index: 40; background: #fffcf5; }  /* Untermenüs über der Galerie */

/* Themen-Chips direkt unter dem Seitenkopf */
.mf-bar {
  position: fixed; top: var(--mf-top, 0px); left: 0; right: 0; z-index: 20; height: var(--mf-bar-h); padding: 0 12px;
  display: flex; align-items: center; gap: 12px; background: var(--mf-bg);
}
.mf-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 85%, transparent); padding-right: 24px; }
.mf-chips::-webkit-scrollbar { display: none; }
.mf-chips a {
  flex: none; padding: 6px 12px; border-radius: 999px; background: var(--mf-chip); color: var(--mf-ink);
  font-size: 13px; line-height: 1.2; text-decoration: none; white-space: nowrap;
}
.mf-chips a[aria-current] { background: #009165; }

/* Feed: ein Meme pro Bildschirm, immer genau eins weiter */
.mf-feed {
  position: fixed; top: var(--mf-top, 0px); left: 0; right: 0; bottom: 0; z-index: 10; background: var(--mf-bg);
  overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none; outline: none;
}
.mf-feed::-webkit-scrollbar { display: none; }
.mf-slide {
  height: var(--mf-h); scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; flex-direction: column; box-sizing: border-box;
  padding: var(--mf-bar-h) 0 calc(10px + env(safe-area-inset-bottom));
}
.mf-media { flex: 1; min-height: 0; margin: 0; display: flex; align-items: center; justify-content: center; }
.mf-media img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
/* Handy: kleine Memes auf volle Breite ziehen, Seitenverhältnis bleibt */
@media (max-width: 899px) { .mf-media img { width: 100%; height: 100%; } }
.mf-info { padding: 10px 16px 4px; }
.mf-titel { margin: 0; font-size: 16px; line-height: 1.3; font-weight: 600; color: var(--mf-ink); }
.mf-titel a { color: inherit; text-decoration: none; }
.mf-quelle, .mf-themen { margin: 2px 0 0; font-size: 12px; color: var(--mf-muted); }
.mf-themen a { color: var(--mf-muted); text-decoration: none; margin-right: 6px; }

/* Teilen-Leiste direkt unter dem Bild */
.mf-share { display: flex; justify-content: space-between; gap: 4px; padding: 8px 12px 0; }
.mf-s {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0;
  background: none; color: var(--mf-ink); font: inherit; font-size: 11px; line-height: 1.1; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mf-s svg { box-sizing: border-box; width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: var(--mf-chip); transition: transform .2s; }
.mf-s:active svg { transform: scale(.9); }
.mf-s span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; color: var(--mf-muted); }
.mf-s--instagram svg { background: radial-gradient(circle at 30% 107%, #fdf497 0, #fd5949 45%, #d6249f 60%, #285aeb 90%); }
.mf-s--whatsapp svg { background: #25d366; }
.mf-s--facebook svg { background: #1877f2; }
.mf-s--telegram svg { background: #2aabee; }
.mf-s--x svg { background: #000; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .25); }
.mf-s--teilen svg { background: #009165; }
.mf-s--link, .mf-s--speichern { display: none; }
.mf-s.is-ok svg { background: #009165; }

.mf-leer { align-items: center; justify-content: center; color: var(--mf-muted); }
.mf-more { display: block; padding: 24px; text-align: center; color: var(--mf-ink); }
.js .mf-more { display: none; }

/* Blättern (Desktop) und Hinweis beim ersten Besuch (Handy) */
.mf-nav { display: none; }
.mf-hinweis {
  position: fixed; left: 50%; bottom: 150px; z-index: 15; margin: 0; padding: 8px 14px; transform: translateX(-50%);
  border-radius: 999px; background: rgb(0 0 0 / .6); color: #fff; font-size: 13px; pointer-events: none;
  opacity: 0; transition: opacity .4s;
}
.mf-hinweis.is-an { opacity: 1; animation: mf-wipp 1.4s ease-in-out infinite; }
@keyframes mf-wipp { 50% { transform: translate(-50%, -10px); } }
.mf-toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; max-width: min(90vw, 420px); margin: 0;
  padding: 10px 16px; transform: translate(-50%, 20px); border-radius: 12px; background: #fff; color: #202823;
  font-size: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .3); opacity: 0; pointer-events: none; transition: all .3s;
}
.mf-toast.is-an { opacity: 1; transform: translate(-50%, 0); }

/* Desktop: Creme-Hintergrund, Bild als Karte, Titel und Teilen rechts daneben */
@media (min-width: 900px) {
  body.wzf-memes { --mf-bg: #f3ebdd; --mf-ink: #202823; --mf-muted: #5f5a52; --mf-chip: #fffcf5; --mf-bar-h: 72px; }
  .mf-bar { padding-inline: 28px; gap: 24px; }
  .mf-chips { justify-content: flex-start; }
  .mf-chips a { box-shadow: 0 1px 2px rgb(16 24 20 / .08); font-size: 14px; }
  .mf-chips a[aria-current] { color: #fff; }
  .mf-chips a:hover { color: #009165; }
  .mf-chips a[aria-current]:hover { color: #fff; }

  .mf-slide {
    display: grid; grid-template-columns: minmax(0, 680px) 260px; grid-template-rows: 1fr auto auto 1fr; column-gap: 32px;
    justify-content: center; align-content: center; padding: calc(var(--mf-bar-h) + 8px) 24px 24px;
  }
  /* Einheitlicher Rahmen für alle Memes: gleiche Kartengröße, das Bild liegt vollständig darin (kein Beschnitt) */
  .mf-media {
    grid-row: 1 / 5; box-sizing: border-box; width: 100%; height: min(calc(var(--mf-h) - var(--mf-bar-h) - 40px), 760px);
    padding: 14px; border-radius: 18px; background: #fffcf5;
    box-shadow: 0 2px 4px rgb(16 24 20 / .05), 0 26px 50px -18px rgb(16 24 20 / .3);
  }
  .mf-media img { width: 100%; height: 100%; object-fit: contain; border-radius: 8px; }
  .mf-info { grid-column: 2; grid-row: 2; padding: 0 0 12px; }
  .mf-titel { font-size: 20px; }
  .mf-titel a:hover { color: #009165; }
  .mf-quelle, .mf-themen { font-size: 13px; margin-top: 6px; }
  .mf-themen a:hover { color: #009165; }
  .mf-share { grid-column: 2; grid-row: 3; flex-direction: column; justify-content: flex-start; gap: 8px; padding: 4px 0 0; }
  .mf-s { flex: none; flex-direction: row; gap: 12px; font-size: 14px; padding: 4px 10px 4px 4px; border-radius: 999px; transition: background .2s; }
  .mf-s:hover { background: #fffcf5; }
  .mf-s svg { width: 40px; height: 40px; padding: 9px; color: #fff; }
  .mf-s span { color: var(--mf-ink); }
  .mf-s--x svg { box-shadow: none; }
  .mf-s--link, .mf-s--speichern { display: flex; }
  .mf-s--link svg, .mf-s--speichern svg { background: #fffcf5; color: #202823; box-shadow: 0 1px 2px rgb(16 24 20 / .1); }
  .mf-s--link.is-ok svg { background: #009165; color: #fff; }
  .mf-s--teilen { display: none; }

  .mf-nav { position: fixed; right: 20px; top: 50%; z-index: 20; display: flex; flex-direction: column; gap: 10px; transform: translateY(-50%); }
  /* Elementra gibt Knöpfen Innenabstand und Mindestbreite: hier zurücksetzen, sonst werden es Ovale */
  body.wzf-memes .mf-nav__btn {
    box-sizing: border-box; width: 48px; height: 48px; min-width: 0; min-height: 0; padding: 0; margin: 0; line-height: 1;
    font-size: 0; letter-spacing: 0; text-transform: none; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
    background: #fffcf5; color: #202823; box-shadow: 0 1px 2px rgb(16 24 20 / .08), 0 8px 20px -10px rgb(16 24 20 / .3);
    transition: transform .2s, color .2s;
  }
  .mf-nav__btn svg { display: block; width: 20px; height: 20px; }
  .mf-nav__btn:hover { color: #009165; transform: scale(1.06); }
  .mf-nav__btn:disabled { opacity: .35; cursor: default; transform: none; }
  .mf-nav__btn--runter svg { transform: rotate(180deg); }
  .mf-hinweis { display: none; }
  .mf-leer { display: flex; }
}

/* Blätterknöpfe nur, wenn rechts neben der Teilen-Spalte Platz ist (sonst Tasten und Mausrad) */
@media (min-width: 900px) and (max-width: 1159px) { .mf-nav { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .mf-hinweis.is-an { animation: none; }
}
