/*
 * Stylesheet des MiddleManTrust-Portals im Stil von havenlock.de: heller Grund, dunkelgruener Kopf mit Goldkante, weisse
 * Karten mit dem Streifen Gruen-Gold-Stahl, gruene Knoepfe, goldener Hauptknopf, dunkelgruener Fuss mit goldenen Links.
 * Keine Schriften, Bilder oder Importe von aussen (CSP: style-src 'self'). Alle Farben stehen als Variablen oben; ein Test
 * (PortalCssTest) rechnet die Kontraste der Farbpaare nach. Stufen-Marken: .stufe-0 ... .stufe-7 nach der Position der Stufe in
 * der Konfiguration (Palettengroesse in texte.yml), nie nach Namen.
 */
:root {
  color-scheme: light;

  /* Havenlock-Grundfarben (wie deploy/website/site/assets/style.css) */
  --brand: #1b6a41;
  --brand-2: #0f3d30;
  --brand-3: #0f4b38;
  --gold: #d8b15a;
  --steel: #516a73;

  /* Flaechen */
  --bg: #f4f6f0;
  --bg-raised: #ffffff;
  --bg-inset: #edf1ed;
  --bg-own: #e3f1e7;
  --border: #d7ded8;

  /* Schrift */
  --text: #17211b;
  --text-muted: #56665b;
  --link: #17603a;

  /* Knoepfe: gruen (Formulare), gold (Hauptlink), rot (Gefahr) */
  --accent: #1b6a41;
  --on-accent: #ffffff;
  --gold-hell: #f2d183;
  --gold-dunkel: #bf8d2a;
  --on-gold: #16251d;
  --danger: #9d2637;
  --on-danger: #ffffff;

  /* Zustaende und Hinweise */
  --ok: #17603a;
  --warn: #8a5000;
  --bad: #9d2637;
  --bg-banner: #fff0f2;
  --bg-note: #fff6e7;

  /* Fokus: dunkel auf hellem Grund, gold im dunklen Kopf und Fuss */
  --focus: #0f3d30;
  --focus-dunkel: #f5d889;

  /* Kopf und Fuss (der Kopf ist halbdurchsichtig; ueber Weiss gemischt bleibt er dunkler als #243c32) */
  --kopf: #112b20;
  --kopf-text: #edf7ef;
  --kopf-leise: #c3d6c9;
  --kopf-aktiv: #f8dfa0;
  --fuss: #10241c;
  --fuss-text: #cddbd1;
  --fuss-link: #f5d889;

  --stufe-0-bg: #e9eee9; --stufe-0-fg: #2d3b33;
  --stufe-1-bg: #e1ecfa; --stufe-1-fg: #1c4378;
  --stufe-2-bg: #dcf2e2; --stufe-2-fg: #135a2f;
  --stufe-3-bg: #faefcf; --stufe-3-fg: #634400;
  --stufe-4-bg: #efe3f8; --stufe-4-fg: #56287a;
  --stufe-5-bg: #fbe3ea; --stufe-5-fg: #852042;
  --stufe-6-bg: #d8eff1; --stufe-6-fg: #11535a;
  --stufe-7-bg: #fbe6d4; --stufe-7-fg: #773b0b;
  --stufe-neutral-bg: #f4f6f0; --stufe-neutral-fg: #56665b;

  --schatten: 0 12px 34px rgba(27, 48, 34, 0.07);
  --streifen: linear-gradient(90deg, var(--brand), var(--gold), var(--steel));
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

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

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

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
}
body::selection { background: var(--gold); color: var(--on-gold); }

/* ---- Fokus: auf jedem bedienbaren Element sichtbar ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
header a:focus-visible, header button:focus-visible, footer a:focus-visible { outline-color: var(--focus-dunkel); }

a { color: var(--link); text-decoration: underline; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

.sprung { position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem; background: var(--bg-raised); color: var(--link); font-weight: 800; border-radius: 6px; z-index: 30; }
.sprung:focus { left: 0.5rem; top: 0.5rem; }

/* ---- Seitenkopf: dunkelgruen, klebt oben, Goldkante ---- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--kopf);
  color: var(--kopf-text);
  border-bottom: 1px solid rgba(216, 177, 90, 0.45);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  header { background: rgba(17, 43, 32, 0.92); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
}
.kopf {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 18px;
  padding: 10px 0;
}
.marke {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--kopf-text);
  text-decoration: none;
  white-space: nowrap;
}
.marke:hover { color: var(--kopf-aktiv); text-decoration: none; }
.marke-zeichen {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
  font-weight: 900;
  color: var(--kopf-aktiv);
  border: 1px solid rgba(216, 177, 90, 0.8);
  border-radius: 6px;
  background: linear-gradient(145deg, var(--brand), #10261f);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}
header nav ul { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; }
header nav a {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--kopf-text);
  font-weight: 800;
  text-decoration: none;
}
header nav a:hover { background: rgba(255, 255, 255, 0.14); }
header nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: var(--kopf-aktiv); box-shadow: inset 0 -3px 0 var(--gold); }
header .konto { color: var(--kopf-leise); margin-left: 6px; overflow-wrap: anywhere; }
header .konto a { color: var(--kopf-text); }
header form { display: inline; margin: 0; }
header button {
  background: transparent;
  color: var(--kopf-text);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: none;
  min-height: 2.25rem;
  padding: 0.25rem 0.8rem;
}
header button:hover { background: rgba(255, 255, 255, 0.14); box-shadow: none; }

/* ---- Inhalt ---- */
main {
  flex: 1 0 auto;
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 52px;
}
h1 { font-size: clamp(1.75rem, 4.5vw, 2.75rem); line-height: 1.08; font-weight: 900; margin: 0 0 18px; overflow-wrap: anywhere; color: var(--text); }
main > h1 + p { color: var(--text-muted); font-size: 1.125rem; }
h2 { font-size: 1.35rem; line-height: 1.2; margin: 28px 0 12px; }
h3 { font-size: 1.1rem; margin: 18px 0 8px; }
p, li, dd { max-width: 75ch; overflow-wrap: anywhere; }
section { margin: 18px 0; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--bg-inset); padding: 2px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.zeit { border-bottom: 1px dotted var(--text-muted); cursor: help; }

/* Abschnitte als Karten (wie .panel/.feature auf havenlock.de), mit dem Streifen oben */
main > section {
  position: relative;
  overflow: hidden;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--schatten);
}
main > section::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--streifen); }
main > section > h2:first-child, main > section > h3:first-child { margin-top: 0; }
main > section > :last-child { margin-bottom: 0; }
main > section section { margin: 18px 0 0; }

/* ---- Meldungen und Hinweise (wie .notice auf havenlock.de) ---- */
.banner {
  padding: 13px 15px;
  background: var(--bg-banner);
  border-left: 5px solid var(--bad);
  border-radius: 6px;
  margin: 0 0 18px;
  max-width: 75ch;
}
.hinweis {
  padding: 13px 15px;
  background: var(--bg-note);
  border-left: 5px solid var(--warn);
  border-radius: 6px;
  max-width: 75ch;
}
/* "Kommt mit ..." im Wiki steht als Marke in Zeilen und Zellen, nicht als Kasten */
span.hinweis { display: inline; padding: 0; background: none; border: 0; border-radius: 0; color: var(--warn); font-weight: 700; }

/* ---- Tabellen: weisse Karte, scrollen im eigenen Rahmen, nie die Seite ---- */
.tabelle {
  overflow-x: auto;
  max-width: 100%;
  margin: 12px 0 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-raised);
  box-shadow: var(--schatten);
}
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--bg-inset); font-weight: 800; color: var(--text); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tr.eigene-stufe td { background: var(--bg-own); }
tr.eigene-stufe td:first-child { box-shadow: inset 5px 0 0 var(--brand); }
/* Freitext (Grund, Ergebnis, Beschreibung, Einzelheiten): bricht an Wortgrenzen, nur ein ueberlanges Wort bricht im Wort. Alles andere in Tabellen bleibt einzeilig. */
td.frei, th.frei { white-space: normal; overflow-wrap: anywhere; min-width: 16ch; max-width: 32rem; }
td code { overflow-wrap: normal; white-space: nowrap; }
td.frei code { white-space: normal; overflow-wrap: anywhere; }

/* ---- Formulare ---- */
form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 12px 0; }
label { font-weight: 800; }
input[type="text"], input[type="search"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--text-muted);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  min-height: 2.75rem;
  max-width: 100%;
}
input[type="text"]:hover, input[type="search"]:hover, select:hover, textarea:hover { border-color: var(--brand); }
select { padding-right: 2rem; cursor: pointer; }
button, .button {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 800;
  color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent), var(--brand-3));
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  min-height: 2.75rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(27, 106, 65, 0.22);
}
button:hover { box-shadow: 0 16px 34px rgba(27, 106, 65, 0.3); }
/* Links als Knopf sind die Hauptwege (Anmelden, Zur Uebersicht): gold wie "Zum Portal" auf havenlock.de */
a.button {
  color: var(--on-gold);
  background: linear-gradient(135deg, var(--gold-hell), var(--gold-dunkel));
  box-shadow: 0 16px 38px rgba(216, 177, 90, 0.34);
}
a.button:hover { text-decoration: none; box-shadow: 0 18px 40px rgba(191, 141, 42, 0.4); }
/* Ueberschriften, Absaetze und Tabellen in einem Formular nehmen eine eigene Zeile in voller Breite (nicht neben dem Knopf). */
form > h2, form > h3, form > p, form > .tabelle { flex-basis: 100%; width: 100%; }
td form { margin: 6px 0 0; }
/* Formulare mit weitreichender Wirkung: ein normales Formular, nur der Knopf ist rot */
form.gefahr button { background: var(--danger); color: var(--on-danger); box-shadow: 0 12px 28px rgba(157, 38, 55, 0.2); }

/* ---- Zustaende (immer mit Wort, die Farbe unterstuetzt nur) ---- */
.zaehlt, .status-done { color: var(--ok); font-weight: 700; }
.zaehlt-nicht, .verfallen, .status-pending, .status-expired { color: var(--warn); font-weight: 700; }
.gesperrt, .status-denied, .status-failed { color: var(--bad); font-weight: 700; }
.zyklus { color: var(--text-muted); font-style: italic; }
.aktiv { font-weight: 800; }
.status { display: inline-block; padding: 1px 9px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.85em; font-weight: 800; background: var(--bg-raised); }
dd[data-zustand="ja"] { color: var(--ok); font-weight: 700; }
dd[data-zustand="nein"] { color: var(--bad); font-weight: 700; }
dd[data-zustand="unbekannt"] { color: var(--warn); font-weight: 700; }

#anfrage {
  padding: 14px 16px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: 8px;
  max-width: 75ch;
  box-shadow: var(--schatten);
}
#anfrage p { margin: 0; }
#anfrage[data-status="done"] { border-left-color: var(--ok); }
#anfrage[data-status="denied"], #anfrage[data-status="failed"] { border-left-color: var(--bad); }
#anfrage[data-status="pending"], #anfrage[data-status="expired"] { border-left-color: var(--warn); }

/* ---- Stufen-Marken: helle Pillen, Farbe nach Position, der Name steht immer dabei ---- */
.stufe { display: inline-block; max-width: 100%; vertical-align: bottom; white-space: nowrap; padding: 0 0.6rem; border-radius: 999px; border: 1px solid currentColor; font-weight: 800; font-size: 0.9em; }
/* Ausserhalb von Tabellen darf ein langer Stufenname umbrechen (nie abgeschnitten); in Zellen bleibt die Marke einzeilig. */
p .stufe, li .stufe, dd .stufe { white-space: normal; overflow-wrap: anywhere; }
.stufe-0 { background: var(--stufe-0-bg); color: var(--stufe-0-fg); }
.stufe-1 { background: var(--stufe-1-bg); color: var(--stufe-1-fg); }
.stufe-2 { background: var(--stufe-2-bg); color: var(--stufe-2-fg); }
.stufe-3 { background: var(--stufe-3-bg); color: var(--stufe-3-fg); }
.stufe-4 { background: var(--stufe-4-bg); color: var(--stufe-4-fg); }
.stufe-5 { background: var(--stufe-5-bg); color: var(--stufe-5-fg); }
.stufe-6 { background: var(--stufe-6-bg); color: var(--stufe-6-fg); }
.stufe-7 { background: var(--stufe-7-bg); color: var(--stufe-7-fg); }
.stufe-neutral { background: var(--stufe-neutral-bg); color: var(--stufe-neutral-fg); border-style: dashed; }

/* ---- Listen, Baum, Detailangaben ---- */
ul.baum { list-style: none; padding-left: 1.2rem; border-left: 2px solid var(--border); }
main > ul.baum { padding-left: 0; border-left: 0; }
details > summary { cursor: pointer; padding: 2px 0; }
dl { display: grid; grid-template-columns: minmax(10rem, max-content) 1fr; gap: 6px 20px; margin: 12px 0; padding: 16px 18px; background: var(--bg-raised); border: 1px solid var(--border); border-radius: 8px; }
dt { font-weight: 800; }
dd { margin: 0; }

/* ---- Unternavigation: helle Pillen, die aktuelle dunkelgruen mit Gold ---- */
nav.unternav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0 0 20px 0; }
nav.unternav a {
  display: inline-block;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--link);
  font-weight: 800;
  text-decoration: none;
}
nav.unternav a:hover { border-color: var(--brand); }
nav.unternav a[aria-current="page"] { background: var(--brand-2); border-color: var(--brand-2); color: var(--kopf-aktiv); }
main nav[aria-label] { margin: 8px 0; }

/* ---- Wiki-Uebersicht: die Unterseiten als Karten ---- */
ul#wiki-seiten { list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; padding: 0; margin: 18px 0; }
ul#wiki-seiten li {
  position: relative;
  overflow: hidden;
  max-width: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px 20px 18px;
  box-shadow: var(--schatten);
}
ul#wiki-seiten li::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--streifen); }
ul#wiki-seiten a { display: block; font-size: 1.15rem; font-weight: 900; margin-bottom: 4px; }

/* ---- Seitenfuss wie auf havenlock.de ---- */
footer {
  flex-shrink: 0;
  color: var(--fuss-text);
  background: var(--fuss);
  border-top: 1px solid rgba(216, 177, 90, 0.28);
  padding: 34px 0 40px;
}
.fuss {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
  align-items: start;
}
.fuss p { margin: 0 0 6px; }
.fuss strong { color: var(--kopf-text); }
footer a { color: var(--fuss-link); font-weight: 800; text-decoration: none; }
footer a:hover { text-decoration: underline; }
.fuss-links ul { list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 14px; margin: 0; padding: 0; }

/* ---- Bewegung nur, wenn erwuenscht (wie "rise" auf havenlock.de) ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  a, button, .button, nav.unternav a { transition: background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease; }
  button:hover, .button:hover { transform: translateY(-2px); }
  header nav a:hover, header nav a[aria-current="page"] { transform: translateY(-1px); }
  main > section, ul#wiki-seiten li { animation: rise 0.5s ease both; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Sprungziele nicht unter dem klebenden Kopf verstecken */
@media (min-width: 701px) {
  main, main [id] { scroll-margin-top: 140px; }
}

/* ---- Mittlere Breite: Kopf und Fuss untereinander ---- */
@media (max-width: 800px) {
  .kopf { flex-direction: column; align-items: flex-start; padding: 14px 0; }
  .fuss { grid-template-columns: 1fr; }
  .fuss-links ul { justify-content: flex-start; }
}

/* ---- Schmale Bildschirme: eine Spalte ---- */
@media (max-width: 700px) {
  /* Der Kopf mit allen Eintraegen ist hier hoch: er scrollt mit, statt den Bildschirm zu verdecken. */
  header { position: static; }
  main { width: calc(100% - 24px); padding: 20px 0 40px; }
  .kopf { width: calc(100% - 24px); }
  .fuss { width: calc(100% - 24px); }
  main > section { padding: 16px; }
  dl { grid-template-columns: 1fr; gap: 2px 0; padding: 12px 14px; }
  dd { margin-bottom: 8px; }
  main form { flex-direction: column; align-items: stretch; }
  main input[type="text"], main input[type="search"], main select, main textarea { width: 100%; }
  main button { width: 100%; }
  header nav ul { gap: 4px; }
  header nav a { padding: 6px 9px; }
  header .konto { margin-left: 0; }
}
