/* =====================================================================
   BAMANE-Vorlage für öffentliche Seiten — pub-*
   ---------------------------------------------------------------------
   Für alle Seiten ohne Login, die Studierende oder Externe öffnen
   (Terminbuchung, Anfrage, Abgabe, Umfrage …). Gleicher Look wie das
   Intranet: Silbergrau als Fläche, weiße Karte, Petrol als Akzent,
   Manrope für Text, DM Mono für Daten und Kicker. Hell und dunkel.

   Einbinden (Reihenfolge wichtig):
     <link rel="stylesheet" href="/css/fonts.css">
     <link rel="stylesheet" href="/css/oeffentlich.css">
     <script src="/js/theme-init.js"></script>
   Gerüst und alle Bausteine: docs/vorlagen/oeffentliche-seite.html
   Regeln: DESIGNSYSTEM.md, Abschnitt „Öffentliche Seiten — pub-*“.

   style.css wird hier bewusst nicht geladen (400 KB, App-Gerüst mit
   Sidebar). Die Tokens unten spiegeln deren Werte 1:1 und tragen
   dieselben Namen — wer dort Farben ändert, zieht sie hier nach.

   Tool-Akzent: Eine Seite darf --accent/--accent-dim/--accent-hover
   auf ihrem <html> oder <body> überschreiben (z. B. Pinny-Pink). Alles
   andere — Flächen, Text, Linien, Abstände, Schrift — bleibt gleich.
   ===================================================================== */

:root, [data-theme="light"] {
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Consolas', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.18s ease;

  --fs-2xs: 9px;  --fs-xs: 11px; --fs-sm: 13px; --fs-base: 16px;
  --fs-md: 22px;  --fs-lg: 28px; --fs-xl: 36px;
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;

  --bg: #F5F5F3; --bg-card: #FFFFFF; --bg-elevated: #FAFAF9; --bg-hover: #F0F0EE;
  --border: #E4E4E2; --border-light: #ECECEA;
  --text: #1C1A16; --text-secondary: #4E5560; --text-muted: #676C7B;
  --accent: #005176; --accent-dim: rgba(0,81,118,0.09); --accent-hover: #003E59;
  --action-bg: #003E59; --action-hover: #005176; --action-text: #FFFFFF;
  --green: #16A34A; --green-dim: rgba(22,163,74,0.08);
  --red: #DC2626; --red-dim: rgba(220,38,38,0.06); --red-hover: #B91C1C;
  --orange: #D97706; --orange-dim: rgba(217,119,6,0.08);
  --shadow-sm: 0 1px 2px rgba(20,28,48,0.06);
  --shadow: 0 4px 14px rgba(20,28,48,0.08);
}
[data-theme="dark"] {
  --bg: #111111; --bg-card: #1A1A1A; --bg-elevated: #161616; --bg-hover: #222;
  --border: #2A2A2A; --border-light: #202020;
  --text: #F2EFE7; --text-secondary: #A6ACB4; --text-muted: #8E939D;
  --accent: #6FB4D4; --accent-dim: rgba(111,180,212,0.12); --accent-hover: #8DC9E3;
  --action-bg: #6FB4D4; --action-hover: #8DC9E3; --action-text: #092D3E;
  --green: #34D399; --green-dim: rgba(52,211,153,0.1);
  --red: #F87171; --red-dim: rgba(248,113,113,0.08); --red-hover: #EF4444;
  --orange: #FBBF24; --orange-dim: rgba(251,191,36,0.1);
  --shadow-sm: 0 1px 2px rgba(8,4,0,0.35);
  --shadow: 0 6px 20px rgba(8,4,0,0.45);
}

/* ----- Grundlage ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh; min-height: 100dvh;
}
body { display: flex; flex-direction: column; }
::selection { background: var(--accent); color: var(--action-text); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ----- Kopfleiste: Wortmarke links, Hell/Dunkel rechts ----- */
.pub-leiste { background: var(--bg-card); border-bottom: 1px solid var(--border); }
.pub-leiste-innen {
  max-width: 680px; margin: 0 auto; padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
}
.pub-marke { font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text); text-decoration: none; }
.pub-theme {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}
.pub-theme:hover { color: var(--accent); border-color: var(--accent); }

/* ----- Inhalt: eine Spalte, eine weiße Karte ----- */
.pub-main { flex: 1; width: 100%; max-width: 680px; margin: var(--space-6) auto 0; padding: 0 var(--space-4); }
.pub-main-breit { max-width: 960px; }
.pub-blatt {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: var(--space-6);
}
.pub-blatt + .pub-blatt { margin-top: var(--space-4); }

/* ----- Kopf der Karte ----- */
.pub-kicker {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 400;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.pub-titel {
  font-weight: 800; font-size: clamp(24px, 5.5vw, var(--fs-lg));
  letter-spacing: -0.02em; line-height: 1.15; color: var(--text); overflow-wrap: anywhere;
}
.pub-meta { margin-top: var(--space-1); font-size: 14px; color: var(--text-muted); overflow-wrap: anywhere; }
.pub-text { margin-top: var(--space-3); font-size: 15px; line-height: 1.55; color: var(--text-secondary); overflow-wrap: anywhere; }
.pub-text-umbruch { white-space: pre-line; }

/* ----- Abschnitt mit Hairline und Zähler rechts (z. B. ein Tag) ----- */
.pub-abschnitt { margin-top: var(--space-5); }
.pub-abschnitt-kopf {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
  padding-bottom: var(--space-2); margin-bottom: var(--space-3); border-bottom: 1px solid var(--border-light);
  font-size: 14px; font-weight: 700; color: var(--text);
}
.pub-zahl { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 400; color: var(--text-muted); white-space: nowrap; }

/* ----- Auswahl-Kacheln (Zeiten, Optionen) ----- */
.pub-auswahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--space-2); }
.pub-wahl {
  min-height: 44px; padding: var(--space-2) var(--space-1);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 14px; color: var(--text-secondary); cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.pub-wahl:hover, .pub-wahl:focus-visible { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); outline: none; }
.pub-wahl[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--action-text); }

/* ----- Akzentfläche: hervorgehobene Info (gewählter Termin, Zusammenfassung) ----- */
.pub-akzent { margin-top: var(--space-5); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--accent-dim); }
.pub-akzent .pub-kicker { margin-bottom: var(--space-1); }
.pub-akzent-titel { font-weight: 700; font-size: var(--fs-base); color: var(--text); }
.pub-akzent-sub { margin-top: 2px; font-family: var(--font-mono); font-size: 14px; color: var(--text-secondary); }

/* ----- Formular (Optik von ed-field / ed-label im Intranet) ----- */
.pub-feld { display: flex; flex-direction: column; margin-top: var(--space-4); }
.pub-label {
  display: block; margin-bottom: var(--space-2);
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted);
}
.pub-optional { margin-left: var(--space-1); font-weight: 400; letter-spacing: 0.02em; text-transform: none; }
.pub-input {
  width: 100%; font: inherit; font-size: var(--fs-base); line-height: 1.4; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3);
  transition: border-color var(--transition);
}
.pub-input:focus { outline: none; border-color: var(--accent); }
.pub-input::placeholder { color: var(--text-muted); }
.pub-input[aria-invalid="true"] { border-color: var(--red); }
textarea.pub-input { min-height: 96px; resize: vertical; line-height: 1.55; }
select.pub-input { cursor: pointer; }
.pub-feld-hinweis { margin-top: var(--space-1); font-size: var(--fs-sm); color: var(--text-muted); }
.pub-haken {
  display: flex; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-4);
  font-size: var(--fs-sm); line-height: 1.5; color: var(--text-secondary); cursor: pointer;
}
.pub-haken input { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; accent-color: var(--accent); }

/* ----- Knöpfe (Optik von ed-btn) — ein Primärknopf pro Ansicht ----- */
.pub-aktionen { display: flex; gap: var(--space-2); margin-top: var(--space-5); flex-wrap: wrap; }
.pub-knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-3) var(--space-5); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600; letter-spacing: 0.005em; line-height: 1;
  border: 1px solid var(--action-bg); background: var(--action-bg); color: var(--action-text);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform 100ms ease-out;
}
.pub-knopf:hover { background: var(--action-hover); border-color: var(--action-hover); color: var(--action-text); }
.pub-knopf:active { transform: translateY(1px); }
.pub-knopf-leise { background: transparent; color: var(--text); border-color: var(--border); }
.pub-knopf-leise:hover { background: transparent; color: var(--accent); border-color: var(--accent); }
.pub-knopf-gefahr { background: var(--red); border-color: var(--red); color: #fff; }
.pub-knopf-gefahr:hover { background: var(--red-hover); border-color: var(--red-hover); color: #fff; }
.pub-knopf:disabled { cursor: progress; opacity: 0.78; pointer-events: none; }
/* Während eines Requests: Klasse setzen + disabled — Spinner links vom Text */
.pub-knopf-laeuft::before {
  content: ''; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; animation: pub-drehen 0.7s linear infinite;
}
@keyframes pub-drehen { to { transform: rotate(360deg); } }

/* ----- Hinweise (Optik von ed-notice) ----- */
.pub-hinweis {
  margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: 8px;
  background: linear-gradient(to right, var(--red-dim) 0%, var(--bg-card) 30%);
  font-size: 14px; line-height: 1.55; color: var(--text);
}
.pub-hinweis-gut { border-left-color: var(--green); background: linear-gradient(to right, var(--green-dim) 0%, var(--bg-card) 30%); }
.pub-hinweis-warn { border-left-color: var(--orange); background: linear-gradient(to right, var(--orange-dim) 0%, var(--bg-card) 30%); }
.pub-hinweis-info { border-left-color: var(--accent); background: linear-gradient(to right, var(--accent-dim) 0%, var(--bg-card) 30%); }

/* ----- Leerer Zustand: immer mit Handlungshinweis ----- */
.pub-leer {
  margin-top: var(--space-5); padding: var(--space-4);
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-secondary);
}

/* ----- Zustandsseite (gesendet, gebucht, Fehler, lädt) ----- */
.pub-status { text-align: center; padding: var(--space-5) 0 var(--space-2); }
.pub-zeichen {
  width: 52px; height: 52px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 22px; font-weight: 500;
  color: var(--accent); background: var(--accent-dim); border: 1px solid var(--accent);
}
.pub-status-gut .pub-zeichen { color: var(--green); background: var(--green-dim); border-color: var(--green); }
.pub-status-warn .pub-zeichen { color: var(--orange); background: var(--orange-dim); border-color: var(--orange); }
.pub-status-titel { margin: var(--space-4) 0 var(--space-2); font-weight: 800; font-size: var(--fs-md); letter-spacing: -0.02em; line-height: 1.2; }
.pub-status-text { max-width: 440px; margin: 0 auto; font-size: 15px; color: var(--text-secondary); }
.pub-status .pub-knopf { margin-top: var(--space-5); }
.pub-laedt .pub-zeichen { animation: pub-puls 1.4s ease-in-out infinite; }
@keyframes pub-puls { 50% { opacity: 0.45; } }

/* ----- Zeile mit Text links und Wahl rechts (Umfrage: ein Vorschlag) ----- */
.pub-zeile {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--space-2) var(--space-4);
  padding: var(--space-3) 0; border-bottom: 1px solid var(--border-light);
}
.pub-zeile:last-child { border-bottom: 0; }
.pub-zeile-text { font-family: var(--font-mono); font-size: 15px; color: var(--text); overflow-wrap: anywhere; }
.pub-zeile-sub { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); }
.pub-zeile-fest { margin: 0 calc(-1 * var(--space-3)); padding-left: var(--space-3); padding-right: var(--space-3); border-radius: var(--radius-sm); background: var(--accent-dim); }

/* ----- Dreifach-Wahl Ja / Wenn nötig / Nein (Radios, segmentiert) ----- */
.pub-dreiwahl { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-card); }
.pub-dreiwahl label { position: relative; cursor: pointer; }
.pub-dreiwahl input { position: absolute; opacity: 0; width: 0; height: 0; }
.pub-dreiwahl span {
  display: block; min-width: 60px; min-height: 40px; padding: 11px var(--space-3);
  border-left: 1px solid var(--border); font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; text-align: center;
  color: var(--text-secondary); transition: background var(--transition), color var(--transition);
}
.pub-dreiwahl label:first-child span { border-left: 0; }
.pub-dreiwahl label:hover span { color: var(--accent); }
.pub-dreiwahl input:checked + .pub-ja { background: var(--accent); color: var(--action-text); }
.pub-dreiwahl input:checked + .pub-vielleicht { background: var(--accent-dim); color: var(--accent); }
.pub-dreiwahl input:checked + .pub-nein { background: var(--bg-hover); color: var(--text); }
.pub-dreiwahl input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ----- Eintrag zum Ankreuzen (Abfrage, Mitbringliste) ----- */
.pub-eintrag {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light); cursor: pointer;
}
.pub-eintrag:last-child { border-bottom: 0; }
.pub-eintrag input { flex: none; width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
.pub-eintrag-mitte { flex: 1; min-width: 0; }
.pub-eintrag-text { display: block; font-size: var(--fs-base); color: var(--text); overflow-wrap: anywhere; }
.pub-eintrag-sub { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.pub-eintrag-voll { cursor: default; }
.pub-eintrag-voll .pub-eintrag-text { color: var(--text-muted); }

/* ----- Balken: Anteil oder belegte Plätze ----- */
.pub-balken { display: flex; height: 6px; margin-top: var(--space-2); overflow: hidden; background: var(--border-light); border-radius: 999px; }
.pub-balken > span { display: block; height: 100%; background: var(--accent); }
.pub-balken > .pub-balken-hell { opacity: 0.35; }
.pub-balken-voll > span { background: var(--green); }

/* ----- Ergebnistabelle: erste Spalte bleibt beim Wischen stehen ----- */
.pub-tabelle-rahmen { position: relative; margin: 0 calc(-1 * var(--space-6)); padding: 0 var(--space-6); overflow-x: auto; }
.pub-tabelle { min-width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.pub-tabelle th, .pub-tabelle td { padding: var(--space-2); text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border-light); }
.pub-tabelle thead th { vertical-align: bottom; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.pub-tabelle thead .pub-tabelle-mono { font-family: var(--font-mono); font-weight: 400; color: var(--text); }
.pub-tabelle th[scope="row"] { position: sticky; left: 0; min-width: 130px; max-width: 220px; text-align: left; white-space: normal; font-weight: 600; color: var(--text); background: var(--bg-card); }
.pub-tabelle-notiz { display: block; margin-top: 2px; font-size: var(--fs-xs); font-weight: 400; font-style: italic; color: var(--text-muted); }
.pub-tabelle .pub-z-ja { font-weight: 700; color: var(--accent); }
.pub-tabelle .pub-z-vielleicht { color: var(--accent); opacity: 0.75; }
.pub-tabelle .pub-z-nein { color: var(--text-muted); }
.pub-tabelle tfoot th, .pub-tabelle tfoot td { font-weight: 700; color: var(--text); border-bottom: 0; }

/* ----- Link zum Kopieren ----- */
.pub-link-zeile { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.pub-link-zeile .pub-input { flex: 1 1 220px; min-width: 0; padding: var(--space-2) var(--space-3); font-family: var(--font-mono); font-size: var(--fs-sm); }
.pub-link-zeile .pub-knopf { min-height: 40px; padding: var(--space-2) var(--space-4); }

/* ----- Nur für Screenreader ----- */
.pub-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ----- Honeypot für Formulare ----- */
.pub-hp { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ----- Fußzeile ----- */
.pub-fuss {
  width: 100%; max-width: 680px; margin: 0 auto;
  padding: var(--space-5) var(--space-4) max(var(--space-6), env(safe-area-inset-bottom));
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-2);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); text-align: center;
}
.pub-fuss-sep { color: var(--text-muted); opacity: 0.5; }
.pub-fuss a { color: inherit; text-decoration: none; white-space: nowrap; }
.pub-fuss a:hover { color: var(--accent); }

/* ----- Mobil ----- */
@media (max-width: 520px) {
  .pub-main { margin-top: var(--space-4); padding: 0 var(--space-3); }
  .pub-blatt { padding: var(--space-5) var(--space-4); }
  .pub-aktionen .pub-knopf { flex: 1 1 auto; }
  .pub-zeile { grid-template-columns: minmax(0, 1fr); }
  .pub-dreiwahl { display: flex; }
  .pub-dreiwahl label { flex: 1; }
  .pub-dreiwahl span { min-width: 0; }
  .pub-tabelle-rahmen { margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
