/* === Grundlayout === */
body {
  margin: 0;
  font-family: 'Cinzel', serif;
  background-color: #1e1b2c;
  color: #f5f5dc;
}

/* === Header === */
.site-header {
  background-color: #1c1a2e;
  color: #ffd700;
  text-align: center;
  padding: 30px 40px;
  border-bottom: 2px solid #ffd700;
}

.site-header h1 {
  margin: 0;
  font-size: 2.5em;
}

/* === Hauptinhalt === */
.news-detail {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.news-article h2 {
  font-size: 2em;
  color: #ffd700;
  margin-bottom: 10px;
}

.news-date {
  font-size: 0.9em;
  color: #c0b283;
  margin-bottom: 20px;
}

.news-image img {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 20px;
  border: 2px solid #ffd700;
}

.news-summary {
  font-size: 1.1em;
  font-style: italic;
  margin-bottom: 30px;
  color: #f5f5dc;
}

.news-content {
  font-size: 1em;
  line-height: 1.6;
  color: #f5f5dc;
}

.news-content h3,
.news-content h4 {
  color: #ffd700;
  margin-top: 30px;
}

.news-content p {
  margin-bottom: 20px;
}

.news-content ul,
.news-content ol {
  margin: 20px 0 20px 40px;
}

.news-content li {
  margin-bottom: 10px;
}

.news-content a {
  color: #ffd700;
  text-decoration: underline;
}

.news-content strong {
  color: #fff;
}

.news-content em {
  font-style: italic;
  color: #f5f5dc;
}

/* === Zurück-Link === */
.back-link {
  margin-top: 40px;
  text-align: left;
}

.back-link a {
  color: #ffd700;
  text-decoration: none;
  font-weight: bold;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}

.back-link a:hover {
  border-color: #ffd700;
}

/* === Footer === */
.site-footer {
  text-align: center;
  padding: 20px;
  font-size: 0.9em;
  color: #999;
  border-top: 1px solid #444;
  margin-top: 60px;
}

/* === Responsive === */
@media (max-width: 600px) {
  .news-detail {
    padding: 0 10px;
  }

  .site-header h1 {
    font-size: 2em;
  }

  .news-article h2 {
    font-size: 1.6em;
  }

  .image-row {
    flex-direction: column;
    gap: 10px;
  }

  .news-content table {
    font-size: 0.9em;
  }
}

/* === Header === */
header {
  background-color: #2c2540;
  padding: 20px;
  text-align: center;
}

.site-header h1 {
  margin: 0;
  font-size: 2.5em;
}

.site-subline {
  margin-top: 10px;
  font-size: 1.1em;
  color: #f5f5dc;
}

.logo img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
}

nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 30px;
}

nav a {
  color: #ffd700;
  text-decoration: none;
  font-weight: bold;
}

/* === Navigation === */
.site-nav {
  background-color: #2e2a3f;
  padding: 20px 40px;
  border-bottom: 1px solid #444;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}

.site-nav li {
  display: inline-block;
}

.site-nav a {
  color: #ffd700;
  text-decoration: none;
  font-weight: bold;
  padding: 10px 20px;
  border: 2px solid transparent;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.site-nav a:hover {
  background-color: #ffd700;
  color: #1c1a2e;
  border-color: #ffd700;
}

/* === Artikelbox === */
.news-article {
  background-color: #2e2a3f;
  border: 2px solid #ffd700;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.news-article:hover {
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
  transition: box-shadow 0.3s ease;
}

/* === Tabellen === */
.news-content table {
  width: 100%;
  margin: 30px 0;
  border-collapse: collapse;
  background-color: #2c2540;
  color: #f5f5dc;
}

.news-content th,
.news-content td {
  border: 1px solid #ffd700;
  padding: 12px 16px;
  text-align: left;
}

.news-content th {
  background-color: #1c1a2e;
  color: #ffd700;
  font-weight: bold;
}

/* === Image Grid: make images share available width equally === */
/* Primary: use .image-grid when server-side wrapping exists */
.image-grid {
  display: grid;
  gap: 12px;
  margin: 12px 0;
  align-items: stretch;
  justify-items: stretch;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  grid-auto-rows: auto;
}

/* ensure figures inserted into .image-grid fill their grid cell and do NOT add extra margin */
.image-grid > .image,
.image-grid > figure {
  margin: 0;
  padding: 0;
  display: block;
  width: 100%;
  height: auto;
  box-sizing: border-box;
}

/* images fill the grid cell; use cover for equal visual tiles, but keep natural height when not cropped */
.image-grid img,
.image-grid figure > img,
.news-content .image-grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

/* If you prefer no cropping for grid images, change object-fit to contain and grid-auto-rows to auto:
   .image-grid { grid-auto-rows: auto; }
   .image-grid img { object-fit: contain; height: auto; }
*/

/* Fallback: when no .image-grid exists, make consecutive figure.image elements behave like a grid */
/* This supports older content where wrapper was removed by sanitizer. */
.news-content .figure-inline-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.news-content figure.image {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Responsive adjustments: smaller min width on narrow screens */
@media (max-width: 900px) {
  .image-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
  .news-content .figure-inline-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (max-width: 480px) {
  .image-grid {
    grid-template-columns: 1fr;
  }
  .news-content .figure-inline-grid {
    grid-template-columns: 1fr;
  }
}

/* === Einzelne Bilder zentriert (legacy) === */
/* Keep a sensible rule for images not part of a grid; reduce default margins so they don't double up */
.news-content img {
  display: block;
  margin: 8px auto;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

/* If you need a stricter cap for single images, add a class .single and limit it:
.news-content img.single { max-width: 600px; }
*/

/* === Bildreihen (legacy fallback using flex if JS groups into .image-row) === */
.image-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 20px 0;
}

/* make images in image-row expand evenly */
.image-row img {
  display: inline-block;
  margin: 0;
  flex: 1 1 220px;
  max-width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #ffd700;
}

/* small screens adjustments */
@media (max-width: 600px) {
  .news-article {
    padding: 20px;
  }
  .image-row img {
    flex-basis: 100%;
    max-width: 100%;
  }
}

/* Einzelne Stilhilfen */
.image-row img {
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

/* Debug / Fix: ensure grid images use full column width and natural height when necessary */
.news-content .image-grid,
.news-content .image-grid * {
  box-sizing: border-box;
}

/* Ensure grid establishes rows by content (no tiny clipped rows) */
.news-content .image-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
  grid-auto-rows: auto !important;
  gap: 12px !important;
}

/* Figures inside grid should fill their cell and not shrink */
.news-content .image-grid > figure,
.news-content .image-grid > .image {
  width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  display: block !important;
}

/* Make images fill available width; height follows aspect ratio for single images but grids stay tiled */
.news-content .image-grid img,
.news-content figure.image img {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  object-fit: cover !important;
  border-radius: 6px;
  border: 2px solid #ffd700;
  box-shadow: 0 0 10px rgba(255,215,0,0.15);
}

/* Reduce legacy margin override to avoid large vertical gaps */
.news-content img {
  max-width: none !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* === Lightbox / Modal für größere Bilddarstellung === */
.lb-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 24px;
}

.lb-backdrop.open {
  display: flex;
}

.lb-content {
  max-width: 96%;
  max-height: 96%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.lb-image {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  border: 4px solid rgba(255,215,0,0.06);
  background: #111;
}

.lb-caption {
  color: #f5f5dc;
  font-size: 0.95rem;
  text-align: center;
  max-width: 90%;
  word-break: break-word;
}

/* Controls */
.lb-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.06);
  color: #ffd700;
  padding: 8px 10px;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  z-index: 10000;
}
.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  color: #ffd700;
  border: none;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.lb-prev { left: 18px; }
.lb-next { right: 18px; }

/* small screens: reduce button size and spacing */
@media (max-width: 600px) {
  .lb-close { top: 12px; right: 12px; padding: 6px 8px; }
  .lb-prev, .lb-next { padding: 8px 10px; left: 8px; right: 8px; }
  .lb-image { max-height: 70vh; }
}

/* === Responsive YouTube embeds (from news-detail.php removed inline CSS) ===
   This controls embedded video sizing. Default max-width is 960px (centered).
   Use .media-wrapper.media-small / .media-medium / .media-large to override per-embed. */
.media-wrapper {
  width: 100%;
  max-width: 960px;
  margin: 18px auto;
  aspect-ratio: 16 / 9;
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid #ffd700;
  background: #000;
}
.media-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* presets */
.media-wrapper.media-small  { max-width: 480px; }
.media-wrapper.media-medium { max-width: 720px; }
.media-wrapper.media-large  { max-width: 1200px; }

/* fallback for very narrow containers */
.media-wrapper { min-height: 180px; }

@media (max-width: 600px) {
  .media-wrapper { max-width: 100%; aspect-ratio: 16 / 9; min-height: 160px; }
}
