/* ================================
    Naturschutz Artikel Template
    - Agenda rechts sticky (vertikal)
    - Header/Banner/Footer bleiben extern
    ================================ */

.na-page {
  --max: 1100px; /* etwas breiter wegen rechter Spalte */
  --contentMax: 78ch; /* Textbreite */

  --text: #111;
  --muted: #5b5b5b;

  --surface: #ffffff;
  --surface2: #f6f6f7;

  --border: rgba(0, 0, 0, 0.1);
  --border2: rgba(0, 0, 0, 0.16);

  --shadow-sm: 0 8px 20px rgba(0, 0, 0, 0.07);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.09);

  /* Grün */
  --accent: #1f5e3b;
  --accentLine: var(--accent);

  --focusRing: 0 0 0 4px rgba(31, 94, 59, 0.22);

  /* Sticky-Offset für rechten TOC (falls Header fixed) */
  --stickyTop: 110px;

  max-width: var(--max);
  margin: 0 auto;
  padding: 22px 16px 64px;

  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Arial,
    sans-serif;
}

/* Top-Link */
.na-topnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 6px 0 18px;
  font-size: 14px;
  color: var(--muted);
}

.na-topnav a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
}

.na-topnav a:hover {
  border-bottom-color: rgba(0, 0, 0, 0.55);
}

/* Titel */
.na-title {
  margin: 0 0 12px;
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.05;
  text-decoration: underline;
  text-underline-offset: 7px;
  text-decoration-thickness: 2px;
}

/* Autor/Datum */
.na-byline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 14px;

  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #444;
}

.na-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #eee;
  border: 1px solid #ddd;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.na-byline a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
}

.na-byline a:hover {
  border-bottom-color: rgba(0, 0, 0, 0.55);
}

/* Linie */
.na-rule {
  height: 4px;
  background: var(--accentLine);
  border: 0;
  margin: 14px 0 18px;
}

/* ================================
    Layout: Content links, Agenda rechts
    ================================ */
.na-layout {
  display: grid;
  grid-template-columns: 1fr 320px; /* rechte Spalte */
  gap: 28px;
  align-items: start;
}

/*
  RESPONSIVE-FIX (wichtig für Mobile):
  Grid-/Flex-Items haben standardmäßig min-width:auto.
  Sobald im Content ein „breites“ Element steckt (z.B. Tabellen mit min-width,
  lange URLs, Codeblöcke), kann der ganze Artikel horizontal überlaufen.
  -> min-width:0 erlaubt dem Content zu schrumpfen und überlässt das Scrollen
     dem jeweiligen Container (z.B. Tabellen-Wrapper).
*/
.na-layout > * {
  min-width: 0;
}

@media (max-width: 980px) {
  .na-layout {
    grid-template-columns: 1fr;
  }
}

/* Content */
.na-content {
  max-width: var(--contentMax);
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Medien/Embeds nie breiter als der Content */
.na-content img,
.na-content video,
.na-content iframe {
  max-width: 100%;
  height: auto;
}

/* Code/Pre darf nicht die Seite sprengen */
.na-content pre {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Optionaler Tabellen-Wrapper (falls du Tabellen sauber ohne Inline-Styles willst) */
.na-tablewrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.na-tablewrap table {
  width: 100%;
  border-collapse: collapse;
}

/* wichtig für Anchor-Sprünge wegen sticky header */
.na-content h2,
.na-content h3 {
  scroll-margin-top: calc(var(--stickyTop) + 20px);
}

.na-content h2 {
  margin: 26px 0 12px;
  font-size: 26px;
  line-height: 1.2;
}

.na-content h3 {
  margin: 20px 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

.na-content p,
.na-content li {
  font-size: 18px;
  line-height: 1.9;
  color: #1f1f1f;
}

.na-content ul,
.na-content ol {
  padding-left: 22px;
}

.na-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ================================
    Agenda rechts (vertikal sticky)
    ================================ */
.na-toc {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  box-shadow: var(--shadow-sm);

  position: sticky;
  top: var(--stickyTop);
  align-self: start;
}

.na-toc__title {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #333;
  font-weight: 850;
}

#toc {
  display: grid;
  gap: 8px;
}

#toc a {
  display: block;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;

  border-left: 3px solid transparent;
  padding: 9px 10px;
  border-radius: 12px;

  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);

  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

#toc a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

#toc a.is-active {
  border-color: rgba(31, 94, 59, 0.45);
  background: rgba(31, 94, 59, 0.1);
  border-left-color: var(--accent);
}

#toc a.toc__sub {
  padding-left: 18px;
  font-size: 14px;
  color: #333;
}

/* Auf Mobile: TOC als normale Box über/unter Content */
@media (max-width: 980px) {
  .na-toc {
    position: static;
  }
}

/* Zitat */
.na-quote {
  margin: 20px 0;
  padding: 16px 18px;
  border-left: 4px solid var(--accent);
  background: rgba(0, 0, 0, 0.03);
  border-radius: 12px;
}

.na-quote cite {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-style: normal;
  font-size: 16px;
}

/* Bilder */
.na-figure {
  margin: 22px 0;
  cursor: zoom-in;
}

/* Optional: schmaleres Bild (z.B. Portrait-Fotos nicht übergroß anzeigen) */
.na-figure--narrow {
  max-width: min(100%, 560px);
  margin-left: auto;
  margin-right: auto;
}

/* Galerie: kompakte Thumbnails (klickbar -> Lightbox) */
.na-gallery {
  margin: 22px 0;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.na-figure--thumb {
  margin: 0;
  cursor: zoom-in;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.na-figure--thumb:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.na-figure--thumb img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  /* Einheitliche Höhe... */
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.na-figure--thumb.is-landscape img {
  aspect-ratio: 4 / 3;
}

.na-figure--thumb figcaption {
  margin-top: 0;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.02);
}

.na-figure img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.na-figure figcaption {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.na-credit {
  color: #777;
  font-size: 13px;
}

/* Footer (Tags + Link kopieren) */
.na-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.na-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.na-tag {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 14px;
  color: #333;
  background: #fff;
}

.na-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border2);
  padding: 11px 15px;
  font-weight: 750;
  background: var(--surface);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}

.na-btn:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.na-btn:focus-visible {
  outline: none;
  border-color: rgba(31, 94, 59, 0.45);
  box-shadow: var(--focusRing), var(--shadow-sm);
}

.na-copymsg {
  margin-left: 8px;
  color: #666;
  font-size: 14px;
}

/* Lesebalken */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(0, 0, 0, 0.08);
  z-index: 50;
}

.reading-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accentLine);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 80;
}

.lightbox.is-open {
  display: block;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.lightbox__dialog {
  position: relative;
  width: min(980px, calc(100% - 2rem));
  margin: 6vh auto 0;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 10px;
}

.lightbox__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  cursor: pointer;
}

.lightbox__img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  background: #f2f2f2;
}

.lightbox__caption {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ================================
    FIX: Lesefortschritt + Agenda (Mobile/Tablet)
    ================================ */

/* Lesefortschritt-Leiste muss über dem Header liegen */
.reading-progress {
  z-index: 10001;
  pointer-events: none;
}

/* Grid-Reihenfolge auf Mobile: Agenda vor Content
    (funktioniert für beide Layouts: .na-content UND .na-articlewrap / .na-tocdesktop) */
.na-layout {
  grid-template-areas: "content toc";
}

.na-content,
.na-articlewrap {
  grid-area: content;
}

.na-toc,
.na-tocdesktop {
  grid-area: toc;
}

@media (max-width: 980px) {
  .na-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toc"
      "content";
  }
}

/* Seiten mit Mobile-Agenda per <details> (z.B. #na-toc-mobile) */
.na-tocmobile {
  display: none;
}

@media (max-width: 980px) {
  .na-tocdesktop {
    display: none;
  }
  .na-tocmobile {
    display: block;
    margin: 12px 0 0;
  }
}

/* Desktop-Agenda Styling auch für .na-tocdesktop */
.na-tocdesktop {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  box-shadow: var(--shadow-sm);

  position: sticky;
  top: var(--stickyTop);
  align-self: start;
}

/* TOC-Listen (für #na-toc und #na-toc-mobile) */
.na-toclist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.na-toclist a {
  display: block;
  font-size: 15px;
  text-decoration: none;
  color: #222;
  padding: 10px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);

  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.na-toclist a:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.na-toclist a.is-active {
  border-color: rgba(31, 94, 59, 0.45);
  background: rgba(31, 94, 59, 0.1);
  border-left-color: var(--accent);
}

/* Unterpunkte wie bei #toc */
.na-toclist a.toc__sub {
  padding-left: 18px;
  font-size: 14px;
  color: #333;
}

/* ================================
    Variante ohne Agenda (für Seiten mit .na-page--no-toc)
    ================================ */

/* Ohne Agenda: Content zentrieren und nicht "endlos" breit werden lassen */
.na-page--no-toc {
  --contentMax: min(100%, 86ch);
}

.na-page--no-toc .na-layout {
  grid-template-columns: 1fr;
  grid-template-areas: "content";
}

.na-page--no-toc .na-content {
  max-width: var(--contentMax);
  margin-left: auto;
  margin-right: auto;
}

/* Agenda komplett ausblenden (falls sie auf anderen Seiten per Template drin bleibt) */
.na-page--no-toc .na-toc,
.na-page--no-toc .na-tocdesktop,
.na-page--no-toc .na-tocmobile {
  display: none !important;
}
