/* ==========================================================================
   Dementophobia – Theme „Das grüne Grauen“
   Dunkel: Sumpfnacht mit fahlgrünem Schimmer. Hell: vergilbtes Pergament, grüne Tinte.
   Nur Systemschriften, keine externen Dateien.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg: #0a0e0b;              /* Grund: fast schwarzes Sumpfgrün */
  --bg-glow: #14281a;         /* Schimmer von oben */
  --bg-soft: #111a14;         /* Kästen, Seitenleiste */
  --bg-raised: #16211a;
  --text: #c3cdb9;            /* fahles Grüngrau */
  --text-bone: #ddd6ba;       /* Knochenfarbe für Überschriften */
  --muted: #7d8a76;
  --line: #243329;
  --line-strong: #35503c;
  --accent: #8fd672;          /* giftiges Grün */
  --accent-deep: #4f9a45;
  --glow: rgba(143, 214, 114, 0.45);
  --accent-soft: rgba(143, 214, 114, 0.10);
  --link-missing: #8a7d5a;
  --mark: rgba(143, 214, 114, 0.22);
  --code-bg: #0e1511;
  --selection: rgba(143, 214, 114, 0.30);
  --noise-opacity: 0.07;
  --shade: rgba(0, 0, 0, 0.35);        /* Vignette und Schatten an Kopf und Fuß */

  --serif: "Palatino Linotype", "Book Antiqua", Palatino, "URW Palladio L", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --c-note: #6fa7c9; --c-abstract: #5fb8a8; --c-info: #6fa7c9; --c-todo: #6fa7c9;
  --c-tip: #5fc9a0; --c-success: #8fd672; --c-question: #c9b35f; --c-warning: #d69a4a;
  --c-failure: #c95f5f; --c-danger: #d24a4a; --c-bug: #c95f5f; --c-example: #a58ad6;
  --c-quote: #8a9482;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #ece4cc;            /* vergilbtes Pergament */
    --bg-glow: #f5efdc;
    --bg-soft: #e3d9bc;
    --bg-raised: #ddd2b2;
    --text: #2a2b1f;
    --text-bone: #1f3322;
    --muted: #6b6a55;
    --line: #cfc3a0;
    --line-strong: #a9a07c;
    --accent: #2e6b33;        /* dunkelgrüne Tinte */
    --accent-deep: #1f4d24;
    --glow: rgba(46, 107, 51, 0.25);
    --accent-soft: rgba(46, 107, 51, 0.10);
    --link-missing: #8a6a3a;
    --mark: rgba(120, 170, 80, 0.30);
    --code-bg: #e2d8ba;
    --selection: rgba(46, 107, 51, 0.22);
    --noise-opacity: 0.10;
    --shade: rgba(110, 85, 40, 0.14);  /* nachgedunkelte Pergamentränder */
  }
}

/* --------------------------------------------------------------- Grundlagen */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1.5rem; }
::selection { background: var(--selection); }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  background:
    radial-gradient(ellipse 120% 60% at 50% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(ellipse 80% 50% at 50% 110%, var(--shade), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* Filmkorn über allem – verstärkt die Atmosphäre, klickt nicht mit */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.6 0 0 0 0 0.5 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --------------------------------------------------------------- Kopf */

.kopf-rahmen { max-width: 76rem; margin: 0 auto; padding: 0 1.5rem; }

.seitenkopf {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, var(--shade), transparent);
  font-family: var(--sans);
  font-size: 0.92rem;
}
.seitenkopf .kopf-rahmen {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.5rem 1.5rem; padding-top: 1rem; padding-bottom: 1rem;
}

.marke {
  display: inline-flex; align-items: center; gap: 0.6rem;
  color: var(--text-bone); text-decoration: none;
  font-family: var(--serif); font-variant: small-caps; letter-spacing: 0.12em;
  font-size: 1.35rem; font-weight: 600;
}
.marke:hover { color: var(--text-bone); text-shadow: 0 0 14px var(--glow); }
.auge { width: 2rem; height: 2rem; color: var(--accent); filter: drop-shadow(0 0 6px var(--glow)); flex: none; }
.auge .pupille { fill: var(--bg); }
.marke:hover .auge { animation: blinzeln 0.35s ease-in-out; }
@keyframes blinzeln { 50% { transform: scaleY(0.1); } }

.hauptnavigation { display: flex; gap: 1.4rem; }
.hauptnavigation a {
  color: var(--muted); text-decoration: none;
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem;
}
.hauptnavigation a:hover, .hauptnavigation a[aria-current] { color: var(--accent); text-shadow: 0 0 10px var(--glow); }

.menue-knopf { display: none; }

/* --------------------------------------------------------------- Seitenaufbau */

.seite {
  flex: 1;
  width: 100%;
  max-width: 76rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
}
.inhaltsspalte { max-width: 44rem; min-width: 0; }

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

.seitenleiste {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.45;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.seitenleiste h2 {
  font-family: var(--serif); font-variant: small-caps; letter-spacing: 0.14em;
  font-size: 0.95rem; font-weight: 600; color: var(--muted);
  margin: 0 0 0.6rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
  background: none;
  text-shadow: none;
}
.seitenleiste nav + nav { margin-top: 2rem; }
.seitenleiste ul { list-style: none; margin: 0; padding: 0; }
.seitenleiste li + li { margin-top: 0; }
.seitenleiste a {
  display: block; padding: 0.2rem 0.5rem; border-radius: 3px;
  color: var(--text); text-decoration: none; opacity: 0.85;
  border-left: 2px solid transparent;
}
.seitenleiste a:hover { opacity: 1; color: var(--accent); background: var(--accent-soft); }
.seitenleiste a[aria-current] {
  opacity: 1; color: var(--accent); background: var(--accent-soft);
  border-left-color: var(--accent); text-shadow: 0 0 8px var(--glow);
}

.inhaltsverzeichnis .ebene-2 a { padding-left: 1.2rem; font-size: 0.95em; }
.inhaltsverzeichnis .ebene-3 a { padding-left: 2rem; font-size: 0.9em; }

.baum ul ul { margin-left: 0.55rem; padding-left: 0.4rem; border-left: 1px dotted var(--line-strong); }
.baum summary {
  cursor: pointer; list-style: none; padding: 0.2rem 0.5rem;
  color: var(--text-bone); font-weight: 600; letter-spacing: 0.02em;
}
.baum summary::-webkit-details-marker { display: none; }
.baum summary::before {
  content: "▸"; display: inline-block; width: 1em; color: var(--accent-deep);
  transition: transform 0.15s;
}
.baum details[open] > summary::before { transform: rotate(90deg); }
.baum summary:hover { color: var(--accent); }

/* --------------------------------------------------------------- Text */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-bone);
  margin: 2.4rem 0 0.8rem;
}
h1 {
  font-size: 2.4rem; margin-top: 0;
  font-variant: small-caps; letter-spacing: 0.06em;
  text-shadow: 0 0 22px var(--glow);
}
h2 {
  font-size: 1.55rem; font-variant: small-caps; letter-spacing: 0.05em;
  padding-bottom: 0.35rem;
  background: linear-gradient(to right, var(--line-strong), transparent) bottom / 100% 1px no-repeat;
}
h3 { font-size: 1.25rem; font-style: italic; }
h4, h5, h6 { font-size: 1.05rem; letter-spacing: 0.04em; text-transform: uppercase; font-family: var(--sans); font-size: 0.9rem; }

p, ul, ol, blockquote, pre, .tabelle, .callout { margin: 0 0 1.15rem; }
ul, ol { padding-left: 1.5rem; }
li::marker { color: var(--accent-deep); }
li > ul, li > ol { margin: 0.25rem 0; }
li + li { margin-top: 0.2rem; }

/* Erster Buchstabe einer Notiz: normale Größe, nur grün mit leichtem Glühen */
.notiz .inhalt > p:first-child::first-letter {
  color: var(--accent);
  text-shadow: 0 0 10px var(--glow);
}

hr {
  border: 0; height: 2rem; margin: 2.2rem 0; overflow: visible;
  text-align: center; color: var(--accent-deep);
  background: linear-gradient(to right, transparent, var(--line-strong) 30%, transparent 45%, transparent 55%, var(--line-strong) 70%, transparent) center / 100% 1px no-repeat;
}
hr::after { content: "✥"; font-size: 1.3rem; line-height: 2rem; text-shadow: 0 0 10px var(--glow); }

img, video { max-width: 100%; height: auto; border-radius: 3px; border: 1px solid var(--line); }
audio { width: 100%; }
mark { background: var(--mark); color: inherit; padding: 0 0.2em; border-radius: 2px; box-shadow: 0 0 8px var(--mark); }
del { color: var(--muted); }
strong { color: var(--text-bone); }

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; transition: text-shadow 0.2s, color 0.2s; }
a:hover { text-shadow: 0 0 10px var(--glow); text-decoration-color: currentColor; }
a.extern::after { content: "↗"; font-size: 0.7em; margin-left: 0.15em; vertical-align: super; line-height: 0; opacity: 0.7; }
.link-fehlt {
  color: var(--link-missing); font-style: italic; cursor: help;
  border-bottom: 1px dashed currentColor; opacity: 0.85;
}

code, pre { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--code-bg); border: 1px solid var(--line); padding: 0.05em 0.35em; border-radius: 3px; color: var(--text-bone); }
pre {
  background: var(--code-bg); border: 1px solid var(--line); border-left: 3px solid var(--accent-deep);
  padding: 0.9rem 1.1rem; border-radius: 3px; overflow-x: auto; line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; color: var(--text); }

blockquote {
  position: relative;
  margin-left: 0; padding: 0.3rem 0 0.3rem 1.4rem;
  border-left: 2px solid var(--accent-deep);
  color: var(--muted); font-style: italic;
}
blockquote::before {
  content: "❝"; position: absolute; left: -0.1rem; top: -0.9rem;
  font-size: 2.4rem; color: var(--accent-deep); opacity: 0.35; font-style: normal;
}
blockquote > :last-child { margin-bottom: 0; }

.formel { font-family: var(--mono); text-align: center; margin: 0 0 1.15rem; white-space: pre-wrap; }

/* --------------------------------------------------------------- Tabellen */

.tabelle { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95em; }
th, td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.7rem; text-align: left; vertical-align: top; }
th {
  font-family: var(--serif); font-variant: small-caps; letter-spacing: 0.08em;
  color: var(--text-bone); border-bottom: 1px solid var(--line-strong);
}
tbody tr:hover { background: var(--accent-soft); }

/* --------------------------------------------------------------- Aufgaben */

li.aufgabe { list-style: none; margin-left: -1.4rem; }
li.aufgabe input { margin: 0 0.45rem 0 0; vertical-align: middle; accent-color: var(--accent-deep); }
li.erledigt { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }

/* --------------------------------------------------------------- Callouts */

.callout {
  --c: var(--c-note);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 7%, transparent);
  border-radius: 3px; padding: 0.75rem 1.1rem;
  box-shadow: inset 0 0 24px color-mix(in srgb, var(--c) 6%, transparent);
}
.callout-title { font-family: var(--serif); font-variant: small-caps; letter-spacing: 0.06em; font-weight: 600; color: var(--c); }
.callout-icon { display: inline-block; width: 1.2em; text-align: center; }
details.callout > summary { cursor: pointer; list-style: none; }
details.callout > summary::-webkit-details-marker { display: none; }
details.callout > summary::after { content: "›"; display: inline-block; margin-left: 0.4rem; transition: transform 0.15s; }
details.callout[open] > summary::after { transform: rotate(90deg); }
.callout-body { margin-top: 0.5rem; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-abstract { --c: var(--c-abstract); } .callout-info { --c: var(--c-info); } .callout-todo { --c: var(--c-todo); }
.callout-tip { --c: var(--c-tip); } .callout-success { --c: var(--c-success); } .callout-question { --c: var(--c-question); }
.callout-warning { --c: var(--c-warning); } .callout-failure { --c: var(--c-failure); } .callout-danger { --c: var(--c-danger); }
.callout-bug { --c: var(--c-bug); } .callout-example { --c: var(--c-example); } .callout-quote { --c: var(--c-quote); }

/* --------------------------------------------------------------- Einbettungen */

.einbettung {
  border: 1px solid var(--line); border-left: 3px double var(--line-strong);
  border-radius: 3px; padding: 0.9rem 1.1rem; margin: 0 0 1.15rem;
  background: var(--bg-soft);
}
.einbettung-titel {
  font-family: var(--sans); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}
.einbettung > :last-child { margin-bottom: 0; }
.einbettung h1 { font-size: 1.4rem; }

/* --------------------------------------------------------------- Notizkopf */

.notiz-kopf { margin-bottom: 2rem; }
.notiz-kopf h1 { margin-bottom: 0.5rem; }
.meta { font-family: var(--sans); font-size: 0.84rem; color: var(--muted); margin: 0 0 0.7rem; }
.trenner { margin: 0 0.3rem; color: var(--line-strong); }
/* Reifegrad: Spore → Wucherung → Uralt – die Symbole sind SVGs in der Textfarbe */
.reife { white-space: nowrap; }
.reife svg { width: 1.1em; height: 1.1em; vertical-align: -0.18em; fill: currentColor; }
.reife svg .pupille { fill: var(--bg); }
.reife-spore { color: var(--muted); }
.reife-wucherung { color: var(--accent-deep); }
.reife-uralt { color: var(--accent); filter: drop-shadow(0 0 3px var(--glow)); }
.meta .reife {
  border: 1px solid var(--line-strong); color: var(--text-bone);
  padding: 0.1rem 0.6rem; border-radius: 999px; background: var(--accent-soft);
}
.meta .reife svg { margin-right: 0.15em; }
.meta .reife-spore svg { color: var(--muted); }
.meta .reife-wucherung svg { color: var(--accent-deep); }
.meta .reife-uralt svg { color: var(--accent); }

.tags, .tagwolke { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags li + li, .tagwolke li + li { margin-top: 0; }
a.tag {
  font-family: var(--sans); font-size: 0.78em; text-decoration: none; letter-spacing: 0.03em;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft); color: var(--accent);
  padding: 0.05rem 0.55rem; border-radius: 999px;
}
a.tag:hover { box-shadow: 0 0 10px var(--glow); }
.tagwolke { gap: 0.7rem 1rem; }
.tagwolke a.tag { font-size: 0.95rem; }
.anzahl { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); }
.tag-zeichen { color: var(--accent-deep); font-weight: 400; }

/* --------------------------------------------------------------- Fußnoten */

sup.fn { line-height: 0; }
sup.fn a { text-decoration: none; padding: 0 0.1em; }
.fussnoten { border-top: 1px solid var(--line); margin-top: 2.5rem; padding-top: 1rem; font-size: 0.9rem; color: var(--muted); }
.fn-zurueck { text-decoration: none; }

/* --------------------------------------------------------------- Notizlisten */

.notizliste { list-style: none; padding: 0; }
.notizliste li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.15rem 0; border-bottom: 1px dotted var(--line); }
.notizliste li + li { margin-top: 0; }
.notizliste time { margin-left: auto; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); white-space: nowrap; padding-left: 1rem; }
.notizliste .reife { width: 1.4em; flex: none; }

.verweise {
  margin-top: 3.5rem; padding: 1.1rem 1.3rem 0.4rem;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 3px;
}
.verweise h2 {
  font-size: 0.8rem; margin: 0 0 0.6rem; color: var(--muted); background: none; padding: 0;
  font-family: var(--sans); font-variant: normal; text-transform: uppercase; letter-spacing: 0.14em;
}
.verweise .notizliste li:last-child { border-bottom: 0; }

.zuletzt { margin-top: 3.5rem; }
.mehr { font-family: var(--sans); font-size: 0.88rem; margin-top: 1rem; }

.legende { font-family: var(--sans); font-size: 0.84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; }
.alphabet { font-family: var(--serif); font-variant: small-caps; font-size: 1.15rem; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; margin-bottom: 1rem; }
.alphabet a { text-decoration: none; }

/* --------------------------------------------------------------- Fuß */

.seitenfuss {
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.9rem; font-style: italic;
  background: linear-gradient(to top, var(--shade), transparent);
}
.seitenfuss .kopf-rahmen { padding-top: 1.5rem; padding-bottom: 2rem; text-align: center; }
.seitenfuss p { margin: 0 0 0.3rem; }

.fusszitat { max-width: 38rem; margin: 0 auto 1.4rem; cursor: default; }
.fusszitat .zitat-text {
  font-family: var(--serif); font-size: 1.05rem; line-height: 1.55; color: var(--text);
  margin: 0 0 0.4rem;
}
.fusszitat .zitat-quelle {
  font-family: var(--sans); font-style: normal; font-size: 0.75rem;
  letter-spacing: 0.08em; color: var(--accent-deep);
}

.reife-legende {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0.3rem 1.2rem;
  font-family: var(--sans); font-style: normal; font-size: 0.78rem; letter-spacing: 0.05em; opacity: 0.85;
}

/* --------------------------------------------------------------- Schmale Bildschirme */

@media (max-width: 60rem) {
  .seite { display: block; padding-top: 1.5rem; }
  .inhaltsspalte { margin: 0 auto; }

  .menue-knopf {
    display: inline-block; cursor: pointer; user-select: none;
    color: var(--accent); border: 1px solid var(--line-strong); border-radius: 3px;
    padding: 0.2rem 0.7rem; font-size: 0.85rem; letter-spacing: 0.05em;
  }
  .seitenleiste {
    display: none; position: static; max-height: none; overflow: visible;
    margin: 0 auto 2rem; max-width: 44rem; padding: 1rem 1.1rem;
    background: var(--bg-soft); border: 1px solid var(--line); border-radius: 3px;
  }
  .menue-schalter:checked ~ .seite .seitenleiste { display: block; }
  .menue-schalter:checked ~ .seitenkopf .menue-knopf { background: var(--accent-soft); }
}

@media (max-width: 30rem) {
  body { font-size: 1.05rem; }
  h1 { font-size: 1.8rem; }
  .hauptnavigation { gap: 1rem; }
  .notizliste li { flex-wrap: wrap; }
  .notizliste time { margin-left: 2em; padding-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  body { background: #fff; color: #000; }
  body::after, .seitenleiste, .hauptnavigation, .menue-knopf, .seitenfuss { display: none; }
  .seite { display: block; }
  a.extern::after { content: " (" attr(href) ")"; font-size: 0.8em; vertical-align: baseline; }
}
