/*
 * PIA – Oberfläche
 *
 * Gestaltungsidee: Antworten lesen sich wie ein Auszug aus einer Prozessbeschreibung
 * (Randlinie links, ruhiger Satz). Prozesskennungen wie „B-49-01-S“ werden als kleine
 * Marken hervorgehoben. Alles andere bleibt zurückhaltend.
 *
 * Schriften: bewusst nur Systemschriften. Webfonts von Drittanbietern würden die IP-Adressen
 * der Besucher weitergeben und müssten in der Content-Security-Policy freigegeben werden.
 */

:root {
  --papier: #f6f7f5;
  --flaeche: #ffffff;
  --tinte: #1b2230;
  --schiefer: #586273;
  --linie: #d8dde2;
  --petrol: #0e5c66;
  --petrol-dunkel: #0a464e;
  --petrol-hell: #e4eeef;
  --fehler: #8e2a2a;
  --fehler-hell: #f8eceb;
  --hinweis: #6b4e00;
  --hinweis-hell: #fbf3dc;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --spalte: 44rem;
  --radius-klein: 4px;
  --radius: 8px;

  color-scheme: light;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--papier);
  color: var(--tinte);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--petrol);
  outline-offset: 2px;
}

/* ---------- Grundgerüst ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Kopfzeile ---------- */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem clamp(1rem, 4vw, 2rem);
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-width: 0;
}

.brand__mark {
  flex: none;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--petrol);
  padding-right: 0.875rem;
  border-right: 1px solid var(--linie);
}

.brand__text {
  min-width: 0;
}

.brand__name {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.brand__org {
  margin: 0.125rem 0 0;
  font-size: 0.8125rem;
  color: var(--schiefer);
}

/* ---------- Schaltflächen ---------- */

.btn {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius);
  padding: 0.625rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn--primary {
  background: var(--petrol);
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: var(--petrol-dunkel);
}

.btn--primary:disabled {
  background: #9fb4b7;
}

.btn--quiet {
  flex: none;
  background: transparent;
  color: var(--petrol);
  border-color: var(--linie);
  font-weight: 500;
}

.btn--quiet:hover:not(:disabled) {
  border-color: var(--petrol);
}

/* ---------- Hinweisleiste ---------- */

.banner {
  margin: 0;
  padding: 0.625rem clamp(1rem, 4vw, 2rem);
  background: var(--hinweis-hell);
  color: var(--hinweis);
  border-bottom: 1px solid #ecdcae;
  font-size: 0.9375rem;
}

/* ---------- Verlauf ---------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-padding-bottom: 1.5rem;
}

.messages:focus {
  outline: none;
}

.messages > * {
  width: 100%;
  max-width: var(--spalte);
  margin-inline: auto;
}

/* Begrüßung */

.welcome__title {
  margin: 0 0 0.5rem;
  font-family: var(--serif);
  font-size: clamp(1.375rem, 3.2vw, 1.75rem);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

.welcome__text {
  margin: 0 0 1.5rem;
  color: var(--schiefer);
  max-width: 60ch;
}

.welcome__label {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  color: var(--schiefer);
}

.examples {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.example {
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--tinte);
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-left: 3px solid var(--petrol);
  border-radius: var(--radius-klein);
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.example:hover {
  background: var(--petrol-hell);
  border-color: var(--petrol);
}

/* Eine Frage mit ihrer Antwort bzw. Fehlermeldung */

.turn {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Frage: rechts innerhalb der Spalte */

.message--user {
  align-self: flex-end;
  max-width: min(36rem, 85%);
  background: var(--petrol-hell);
  color: var(--tinte);
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius) var(--radius) var(--radius-klein) var(--radius);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Antwort – wie ein Auszug aus einer Prozessbeschreibung */

.message--assistant {
  border-left: 3px solid var(--petrol);
  padding: 0.125rem 0 0.125rem 1rem;
}

.message__label {
  margin: 0 0 0.25rem;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--petrol);
}

.message__body {
  overflow-wrap: break-word;
  hyphens: auto;
}

.message__body > :first-child {
  margin-top: 0;
}

.message__body > :last-child {
  margin-bottom: 0;
}

.message__body p,
.message__body ul,
.message__body ol {
  margin: 0 0 0.75rem;
  max-width: 68ch;
}

.message__body ul,
.message__body ol {
  padding-left: 1.25rem;
}

.message__body li + li {
  margin-top: 0.25rem;
}

.message__body h1,
.message__body h2,
.message__body h3,
.message__body h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.25;
  margin: 1.25rem 0 0.5rem;
}

.message__body h1 { font-size: 1.25rem; }
.message__body h2 { font-size: 1.125rem; }
.message__body h3,
.message__body h4 { font-size: 1rem; }

.message__body strong {
  font-weight: 650;
}

.message__body a[href] {
  color: var(--petrol);
  text-underline-offset: 2px;
}

.message__body code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: #eef0f1;
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.message__body pre {
  overflow-x: auto;
  background: #eef0f1;
  padding: 0.75rem;
  border-radius: var(--radius-klein);
}

.message__body pre code {
  background: none;
  padding: 0;
}

.message__body blockquote {
  margin: 0 0 0.75rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--linie);
  color: var(--schiefer);
}

.message__body table {
  border-collapse: collapse;
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}

.message__body th,
.message__body td {
  border: 1px solid var(--linie);
  padding: 0.375rem 0.625rem;
  text-align: left;
  vertical-align: top;
}

.message__body th {
  background: #eef2f2;
  font-weight: 600;
}

.message__body hr {
  border: 0;
  border-top: 1px solid var(--linie);
  margin: 1rem 0;
}

/* Prozesskennung, z.B. B-49-01-S */
.kennung {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.8125em;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--petrol-dunkel);
  background: var(--petrol-hell);
  border: 1px solid #c3d9db;
  border-radius: 3px;
  padding: 0 0.3em;
  white-space: nowrap;
}

/* Lade-Anzeige */

.typing {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--schiefer);
  font-size: 0.9375rem;
}

.typing__dots {
  display: inline-flex;
  gap: 4px;
}

.typing__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--petrol);
  opacity: 0.3;
  animation: puls 1.2s infinite ease-in-out;
}

.typing__dots span:nth-child(2) { animation-delay: 0.15s; }
.typing__dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes puls {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* Fehler- und Systemmeldungen */

.message--error {
  background: var(--fehler-hell);
  color: var(--fehler);
  border-left: 3px solid var(--fehler);
  padding: 0.625rem 0.875rem;
  border-radius: 0 var(--radius-klein) var(--radius-klein) 0;
  overflow-wrap: anywhere;
}

/* ---------- Eingabe ---------- */

.composer {
  padding: 0.75rem clamp(1rem, 4vw, 2rem) 1rem;
  background: var(--flaeche);
  border-top: 1px solid var(--linie);
}

.composer__box {
  max-width: var(--spalte);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--flaeche);
  border: 1px solid #b9c1c9;
  border-radius: var(--radius);
  padding: 0.375rem 0.375rem 0.375rem 0.875rem;
  transition: border-color 0.15s ease;
}

.composer__box:focus-within {
  border-color: var(--petrol);
  box-shadow: 0 0 0 3px rgba(14, 92, 102, 0.15);
}

.composer__input {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  font: inherit;
  color: var(--tinte);
  background: transparent;
  line-height: 1.5;
  padding: 0.375rem 0;
  max-height: 10rem;
  min-height: 2.25rem;
}

.composer__input::placeholder {
  color: #7d8696;
}

.composer__send {
  flex: none;
  min-width: 5.5rem;
}

.composer__hint {
  max-width: var(--spalte);
  margin: 0.5rem auto 0;
  font-size: 0.8125rem;
  color: var(--schiefer);
}

/* ---------- Bestätigungsdialog ---------- */

.consent {
  width: min(34rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  border: 0;
  border-top: 4px solid var(--petrol);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--tinte);
  box-shadow: 0 24px 48px rgba(27, 34, 48, 0.22);
}

.consent::backdrop {
  background: rgba(27, 34, 48, 0.55);
}

.consent__form {
  padding: clamp(1.25rem, 4vw, 2rem);
}

.consent__mark {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--petrol);
}

.consent__title {
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.consent__text p {
  margin: 0 0 0.75rem;
  color: #343d4c;
}

.consent__check {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 1.25rem 0 1.5rem;
  padding: 0.875rem;
  background: var(--petrol-hell);
  border-radius: var(--radius-klein);
  font-weight: 600;
  cursor: pointer;
}

.consent__check input {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  margin: 0.125rem 0 0;
  accent-color: var(--petrol);
  cursor: pointer;
}

.consent__btn {
  width: 100%;
  padding: 0.75rem 1rem;
}

/* ---------- Schmale Fenster (auch im eingebetteten iframe) ---------- */

@media (max-width: 560px) {
  .brand__mark {
    font-size: 1.625rem;
    padding-right: 0.625rem;
  }

  .brand__name {
    font-size: 0.9375rem;
  }

  .brand__org {
    display: none;
  }

  .btn--quiet {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .message--user {
    max-width: 92%;
  }

  .composer__hint {
    font-size: 0.75rem;
  }
}

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

  .typing__dots span {
    opacity: 0.6;
  }
}
