/*
Theme Name: FF Admannshagen-Bargeshagen
Description: Theme der Freiwilligen Feuerwehr Admannshagen-Bargeshagen – angelehnt an das bisherige Contao-Design, mobilfähig.
Version: 1.0.0
Requires at least: 6.5
Requires PHP: 8.1
Text Domain: ffab
*/

:root {
  --red: #d40000;
  --red-dark: #a30000;
  --red-tint: #fdecec;
  --ink: #1f1f1f;
  --muted: #616161;
  --line: #e2e2e2;
  --bg: #f1f1f1;
  --paper: #ffffff;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 18px rgba(0, 0, 0, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-w: 220px;
  --side-w: 250px;
  --gap: 28px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg) url("assets/img/background.png") no-repeat center 420px fixed;
  background-size: min(1500px, 120vw) auto;
  color: var(--ink);
  font: 16px/1.6 var(--font);
}

img { max-width: 100%; height: auto; }

a { color: var(--red); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--red-dark); }

:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }

.screen-reader-text {
  border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%);
  height: 1px; width: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute !important;
  word-wrap: normal !important;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--paper); padding: 8px 14px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }

/* ---------------------------------------------------------------- */
/* Rahmen                                                            */
/* ---------------------------------------------------------------- */

.site {
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .03), 0 0 24px rgba(0, 0, 0, .10);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Kopf: Foto mit rotem Rahmen wie bisher, darunter Leiste mit Namen */
.site-header {
  background: var(--red);
  border-top: 8px solid var(--red);
}

.site-header__photo { display: block; line-height: 0; }
.site-header__photo img {
  width: 100%;
  aspect-ratio: 999 / 374;
  max-height: 380px;
  object-fit: cover;
  object-position: center 45%;
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { color: #fff; }
.brand__logo { display: none; width: 64px; height: auto; background: #fff; border-radius: 4px; padding: 2px; }
.brand__text { display: flex; flex-wrap: wrap; column-gap: .4em; line-height: 1.2; }
.brand__name, .brand__place { font-weight: 700; font-style: italic; font-size: 1.25rem; letter-spacing: .01em; }

.nav-toggle {
  display: none;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, .7);
  color: #fff;
  border-radius: var(--radius);
  width: 46px; height: 42px;
  padding: 0;
  cursor: pointer;
}
.nav-toggle svg { width: 26px; height: 26px; display: block; margin: auto; }
.nav-toggle__close { display: none; }
.nav-open .nav-toggle__open { display: none; }
.nav-open .nav-toggle__close { display: block; }

/* Drei Spalten */
.site-body {
  flex: 1;
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--side-w);
  gap: var(--gap);
  padding: var(--gap) 20px;
  align-items: start;
}

/* ---------------------------------------------------------------- */
/* Navigation links (roter Kasten wie bisher)                        */
/* ---------------------------------------------------------------- */

.site-nav { position: sticky; top: 16px; }

.site-nav .menu,
.site-nav .menu ul,
.site-nav > div > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav > .menu,
.site-nav > div > ul {
  background: var(--red);
  border-radius: var(--radius);
  padding: 8px 0;
  box-shadow: var(--shadow);
}

.site-nav .menu > li > a {
  display: block;
  padding: 7px 16px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.3;
}
.site-nav .menu > li > a:hover { background: rgba(255, 255, 255, .14); }
.site-nav .menu > li.current-menu-item > a,
.site-nav .menu > li.current-menu-ancestor > a,
.site-nav .menu > li.current-menu-parent > a { background: rgba(0, 0, 0, .14); }

/* Unterpunkte: weiß hinterlegt, rote Schrift – nur im aktiven Bereich */
.site-nav .sub-menu { display: none; background: #fff; margin: 2px 6px 6px; border-radius: 4px; padding: 4px 0; }
.site-nav li.is-open > .sub-menu { display: block; }
.site-nav .sub-menu a {
  display: block;
  padding: 4px 12px;
  color: var(--red);
  font-size: .94rem;
  text-decoration: none;
  line-height: 1.35;
}
.site-nav .sub-menu a:hover { background: var(--red-tint); }
.site-nav .sub-menu .current-menu-item > a { font-weight: 700; }
.site-nav .sub-menu .sub-menu { margin: 0 0 0 10px; padding: 0; }

.member-box {
  display: block;
  margin-top: 24px;
  padding: 22px 12px;
  background: var(--red);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  font-style: italic;
  font-size: 1.6rem;
  line-height: 1.1;
  transition: transform .15s ease, background .15s ease;
}
.member-box:hover { color: #fff; background: var(--red-dark); transform: translateY(-2px); }

/* ---------------------------------------------------------------- */
/* Seitenleiste rechts                                               */
/* ---------------------------------------------------------------- */

.site-sidebar { display: grid; gap: 22px; }

.infobox { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; font-size: .94rem; }
.infobox > :not(.infobox__title) { margin-left: 14px; margin-right: 14px; }
.infobox > :last-child { margin-bottom: 14px; }
.infobox__title,
.infobox .wp-block-heading:first-child {
  margin: 0 0 10px;
  padding: 7px 14px;
  background: var(--red);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}
.infobox p { margin: 0 0 .7em; }
.infobox img { display: block; margin: 0 auto; }

.ffab-social { display: flex; gap: 18px; justify-content: center; padding-top: 4px; }
.ffab-social a { display: inline-flex; width: 46px; height: 46px; }
.ffab-social svg { width: 100%; height: 100%; }
.ffab-social__fb { color: #1877f2; }
.ffab-social__ig { color: #d62976; }

/* ---------------------------------------------------------------- */
/* Inhalt                                                            */
/* ---------------------------------------------------------------- */

.site-main { min-width: 0; }

h1, h2, h3, h4, h5, h6 { line-height: 1.25; margin: 1.4em 0 .5em; }
.entry-title, .page-title, .entry-content h1 {
  color: var(--red);
  font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem);
  margin: 0 0 .4em;
}
.entry-content h2 { font-size: 1.35rem; color: var(--red); }
.entry-content h3 { font-size: 1.15rem; }
.entry-content h4, .entry-content h5, .entry-content h6 { font-size: 1rem; }
.entry-content > :first-child { margin-top: 0; }

.entry-kicker { margin: 0; color: var(--muted); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.entry-meta, .card__meta { color: var(--muted); font-size: .9rem; margin: 0 0 1em; }
.is-style-subheadline, .front-content h2 + p em:only-child {
  color: var(--muted); font-weight: 700; font-style: italic; font-size: 1.1rem;
}

.entry-content table, .einsatz-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.entry-content td, .entry-content th, .einsatz-table td, .einsatz-table th {
  border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top;
}
.wp-block-table { overflow-x: auto; margin: 1em 0; }

.entry-content ul, .entry-content ol { padding-left: 1.4em; }

.wp-block-image img { border-radius: 4px; }
.wp-block-gallery.has-nested-images { gap: 8px; }
.wp-block-gallery.has-nested-images figure.wp-block-image img { border-radius: 4px; }

.wp-block-file { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: #fafafa; border: 1px solid var(--line); border-radius: var(--radius); }
.wp-block-file .wp-block-file__button { background: var(--red); color: #fff; border-radius: 4px; padding: 4px 12px; font-size: .85rem; text-decoration: none; }

.back-link { margin-top: 2em; }

/* Abschnitts-Überschriften mit rotem Balken (wie die alten h6-/Infobox-Titel) */
.is-style-bar,
.entry-content h2.is-style-bar {
  margin: 1.8em 0 .8em;
  padding: 6px 12px;
  background: var(--red);
  color: #fff;
  font-size: 1.05rem;
  border-radius: 4px;
}
.front-content > .wp-block-heading:first-child { margin-top: 0; font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem); }
.front-content > .is-style-subheadline { margin-top: -.3em; }

/* Gruppenfoto auf dem Handy in der Startseite statt im Kopf */
.front-photo { display: none; }

/* Listen: letzte Einsätze / Termine */
.ffab-einsaetze, .ffab-termine, .termin-list { list-style: none; margin: 0; padding: 0 !important; }
.ffab-einsaetze li, .termin-list li {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
}
.ffab-einsaetze li:last-child { border-bottom: 0; }
.ffab-date, .termin-list__date { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ffab-einsaetze a { text-decoration: none; }
.ffab-einsaetze a:hover { text-decoration: underline; }
.ffab-nr { font-weight: 700; }
.ffab-termine li { padding: 0 0 8px; }
.ffab-termine .ffab-date { display: block; font-size: .85rem; }
.termin-list__ort { color: var(--muted); font-size: .9rem; width: 100%; }

/* Neueste Beiträge (Block) im Kartenstil */
.wp-block-latest-posts.wp-block-latest-posts__list { padding: 0 !important; }
.wp-block-latest-posts__list > li {
  margin: 0 0 14px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.wp-block-latest-posts__post-title { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.wp-block-latest-posts__post-date { color: var(--muted); font-size: .85rem; }
.wp-block-latest-posts__featured-image.alignright { margin: 0 0 8px 14px; }
.wp-block-latest-posts__featured-image img { border-radius: 4px; width: 150px; height: 110px; object-fit: cover; }
.wp-block-latest-posts__post-excerpt { margin: .4em 0 0; }

/* Aktuelles auf der Startseite (Shortcode ffab_aktuelles) */
.ffab-news, .entry-content ul.ffab-news { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 14px; }
.ffab-news__item {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px;
  padding: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.ffab-news__item.has-thumb { grid-template-columns: minmax(0, 1fr) 150px; }
.ffab-news__img { order: 2; }
.ffab-news__img img { display: block; width: 150px; height: 110px; object-fit: cover; border-radius: 4px; }
.ffab-news__meta { margin: 0 0 .35em; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-size: .85rem; }
.ffab-news__title { margin: 0; font-size: 1.05rem; }
.ffab-news__title a { text-decoration: none; }
.ffab-news__excerpt { margin: .4em 0 0; }
.ffab-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase; text-decoration: none; color: #fff; background: var(--red);
}
.ffab-badge:hover, .ffab-badge:focus-visible { color: #fff; filter: brightness(.88); }
/* je Kategorie ein eigener Rot-Ton */
.ffab-badge--aktuelles { background: var(--red); }
.ffab-badge--jugendfeuerwehr { background: var(--red-tint); color: var(--red-dark); box-shadow: inset 0 0 0 1px #f3b9b9; }
.ffab-badge--jugendfeuerwehr:hover, .ffab-badge--jugendfeuerwehr:focus-visible { color: var(--red-dark); }
.ffab-badge--wettkampfteam { background: #7a1414; }

/* Karten (Archive) */
.post-list { display: grid; gap: 18px; }
.card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card:not(.has-post-thumbnail) { grid-template-columns: minmax(0, 1fr); }
.card__image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__body { padding: 14px 18px; }
.card__title { margin: 0 0 .3em; font-size: 1.15rem; }
.card__title a { text-decoration: none; }
.card__excerpt p { margin: 0 0 .5em; }
.more-link { font-style: italic; }

.nav-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 24px; }
.nav-links .page-numbers { padding: 4px 11px; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; background: var(--paper); }
.nav-links .page-numbers.current { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------------------------------------------------------------- */
/* Einsätze                                                          */
/* ---------------------------------------------------------------- */

.einsatz-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0;
  margin: 0 0 1.5em;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  overflow: hidden;
}
.einsatz-details dt, .einsatz-details dd { margin: 0; padding: 7px 14px; border-bottom: 1px solid var(--line); }
.einsatz-details dt { color: var(--muted); font-weight: 600; }
.einsatz-details dt:nth-last-of-type(1), .einsatz-details dd:last-of-type { border-bottom: 0; }
.einsatz-bericht-title { margin-top: 0; }

.year-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.year-filter a {
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: .9rem; background: var(--paper);
}
.year-filter a[aria-current] { background: var(--red); border-color: var(--red); color: #fff; }

.einsatz-count { color: var(--muted); }
.einsatz-table thead th { background: var(--red); color: #fff; border: 0; }
.einsatz-table tbody tr:hover { background: var(--red-tint); }
.einsatz-table a { font-weight: 600; text-decoration: none; }
.einsatz-art { display: block; color: var(--muted); font-size: .82rem; }
.einsatz-time { color: var(--muted); }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: .72rem; border-radius: 3px; background: var(--red-tint); color: var(--red-dark); vertical-align: 1px; }

.post-nav { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 2.5em; padding-top: 1em; border-top: 1px solid var(--line); font-size: .92rem; }
.post-nav__all { font-weight: 700; }

/* ---------------------------------------------------------------- */
/* Footer                                                            */
/* ---------------------------------------------------------------- */

.site-footer { text-align: center; color: var(--red); font-size: .88rem; padding: 18px 20px 26px; border-top: 1px solid var(--line); }
.site-footer p { margin: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.footer-menu { list-style: none; margin: 0; padding: 0; display: inline-flex; gap: 14px; }
.footer-menu a { font-style: italic; text-decoration: none; }

/* ---------------------------------------------------------------- */
/* Responsiv                                                         */
/* ---------------------------------------------------------------- */

@media (max-width: 1080px) {
  .site-body { grid-template-columns: var(--nav-w) minmax(0, 1fr); }
  .site-sidebar { grid-column: 2; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-items: start; }
}

@media (max-width: 800px) {
  :root { --gap: 20px; }
  body { background-image: none; }
  .site { box-shadow: none; }
  .site-header { border-top: 0; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
  .site-header__photo { display: none; }
  .front-photo { display: block !important; margin: -18px -16px 18px; width: calc(100% + 32px); max-width: none; aspect-ratio: 999 / 374; object-fit: cover; }
  .site-header__bar { padding: 8px 14px; }
  .brand__logo { display: block; width: 52px; }
  .brand__text { flex-direction: column; }
  .brand__name { font-size: .82rem; font-style: normal; font-weight: 600; opacity: .9; }
  .brand__place { font-size: 1.05rem; }
  .nav-toggle { display: block; flex: none; }

  .site-body { grid-template-columns: minmax(0, 1fr); padding: 18px 16px; }
  .site-sidebar { grid-column: 1; }

  .site-nav {
    display: none;
    position: fixed;
    inset: 62px 0 0 0;
    z-index: 40;
    overflow-y: auto;
    background: var(--red);
    padding: 8px 0 30px;
  }
  .nav-open { overflow: hidden; }
  .nav-open .site-nav { display: block; }
  .site-nav > .menu, .site-nav > div > ul { box-shadow: none; border-radius: 0; padding: 0; }
  .site-nav .menu > li > a { padding: 12px 18px; font-size: 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .15); }
  .site-nav .sub-menu { margin: 0; border-radius: 0; background: #fff; }
  .site-nav .sub-menu .sub-menu { background: transparent; }
  .site-nav .sub-menu a { padding: 9px 30px; font-size: 1rem; }
  .member-box { margin: 20px 16px 0; background: #fff; color: var(--red); font-size: 1.3rem; padding: 14px; }
  .member-box:hover { background: #fff; color: var(--red-dark); }

  .card { grid-template-columns: minmax(0, 1fr); }
  .card__image img { aspect-ratio: 3 / 2; height: auto; }
  .hide-sm { display: none; }
  .einsatz-details { grid-template-columns: minmax(0, 1fr); }
  .einsatz-details dt { padding-bottom: 0; border-bottom: 0; font-size: .82rem; }
  .einsatz-details dd { padding-top: 0; }
  .wp-block-latest-posts__featured-image img { width: 110px; height: 80px; }
  .ffab-news__item.has-thumb { grid-template-columns: minmax(0, 1fr) 96px; gap: 10px; }
  .ffab-news__img img { width: 96px; height: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .member-box { transition: none; }
}

@media print {
  .site-nav, .site-sidebar, .site-header__bar, .nav-toggle { display: none !important; }
  .site-body { display: block; }
  body { background: #fff; }
}

/* Alte Tabellen aus dem Contao-Editor (border-Attribut, leere Spalten) */
.entry-content table[border] { border: 0; }
.entry-content table[border] td { border-width: 0 0 1px; border-style: solid; border-color: var(--line); }
.entry-content td:empty { padding: 0; width: 0; }

/* ---------- Lightbox mit Vor/Zurück ---------- */
.ffab-zoomable { cursor: zoom-in; }
.ffab-zoomable:focus-visible { outline: 3px solid var(--red, #d40000); outline-offset: 2px; }
html.lightbox-open { overflow: hidden; }
.ffab-lightbox {
  width: 100vw; height: 100vh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: rgba(0, 0, 0, .92); color: #fff;
}
.ffab-lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.ffab-lightbox__figure {
  margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 48px 64px; box-sizing: border-box;
}
.ffab-lightbox__figure img {
  max-width: 100%; max-height: calc(100% - 2em); object-fit: contain;
  box-shadow: 0 6px 30px rgba(0, 0, 0, .5); user-select: none;
}
.ffab-lightbox__figure figcaption { margin-top: .6em; text-align: center; font-size: .95rem; }
.ffab-lightbox__btn {
  position: absolute; border: 0; cursor: pointer; color: #fff; background: rgba(255, 255, 255, .12);
  width: 48px; height: 48px; border-radius: 50%; font-size: 2.2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0 0 4px;
}
.ffab-lightbox__btn:hover, .ffab-lightbox__btn:focus-visible { background: var(--red, #d40000); outline: none; }
.ffab-lightbox__btn[hidden] { display: none; }
.ffab-lightbox__prev { left: 10px; top: 50%; transform: translateY(-50%); }
.ffab-lightbox__next { right: 10px; top: 50%; transform: translateY(-50%); }
.ffab-lightbox__close { right: 10px; top: 10px; font-size: 1.9rem; }
.ffab-lightbox__count { position: absolute; left: 16px; top: 20px; font-size: .9rem; opacity: .8; }
@media (max-width: 600px) {
  .ffab-lightbox__figure { padding: 56px 8px 72px; }
  .ffab-lightbox__prev, .ffab-lightbox__next { top: auto; bottom: 12px; transform: none; }
  .ffab-lightbox__prev { left: calc(50% - 60px); }
  .ffab-lightbox__next { right: calc(50% - 60px); }
}
