/*
 * Helles und dunkles Erscheinungsbild sind gleichwertig gepflegt: Die
 * Farbwerte sind so gewählt, dass Fließtext in beiden Fällen deutlich
 * über dem WCAG-AA-Kontrast liegt und auch die gedämpften Hinweistexte
 * noch bequem lesbar bleiben.
 */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-sunken: #f0f2f5;
  --surface-hover: #e6e9ef;
  --fg: #14161a;
  --fg-muted: #565e6e;
  --border: #dde1e8;
  --border-strong: #c3cad6;
  --accent: #1f5fd0;
  --accent-hover: #1a4fb0;
  --accent-active: #163f8c;
  --accent-fg: #ffffff;
  --accent-subtle: #eef3fd;
  /* --danger trägt Text auf hellem Grund, --danger-solid füllt Flächen.
     Beides muss getrennt bleiben: Was als Schriftfarbe gut lesbar ist,
     taugt selten als Hintergrund und umgekehrt. */
  --danger: #b42318;
  --danger-solid: #d92d20;
  --danger-solid-hover: #a91d14;
  --danger-solid-active: #8a1610;
  --danger-solid-fg: #ffffff;
  --danger-subtle: #fdf0ef;
  --success: #10653f;
  --success-subtle: #eef8f2;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 4%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Drei Spaltenbreiten statt einer: Wie viel Raum eine Seite auf großen
     Bildschirmen bekommt, richtet sich danach, was auf ihr zu tun ist -
     nicht danach, wie viel Platz zufällig verfügbar ist. */
  --container-narrow: 34rem;
  --container-reading: 48rem;
  --container-wide: 76rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-sunken: #1e222a;
    --surface-hover: #2b323e;
    --fg: #e9ecf2;
    --fg-muted: #a4acbb;
    --border: #2a2f39;
    --border-strong: #3a4150;
    --accent: #6f9bff;
    --accent-hover: #93b6ff;
    --accent-active: #b3ccff;
    --accent-fg: #0f1115;
    --accent-subtle: #1a2334;
    /* Auf dunklem Grund werden gefüllte Flächen heller statt dunkler:
       Abdunkeln würde sie im Hintergrund verschwinden lassen, statt eine
       Rückmeldung zu geben. Die Schrift darauf ist entsprechend dunkel. */
    --danger: #ff9b93;
    --danger-solid: #ff8a80;
    --danger-solid-hover: #ffb3ac;
    --danger-solid-active: #ffd0cb;
    --danger-solid-fg: #2b0f0c;
    --danger-subtle: #2e1a18;
    --success: #7ce0a6;
    --success-subtle: #16271e;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 1px 3px rgb(0 0 0 / 30%);
  }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  flex: 1;
}

/* Modifikatoren: Jede Seite bekommt auf großen Bildschirmen die Breite, die
   zu ihrer Aufgabe passt - siehe Breakpoints weiter unten. Auf schmalen
   Bildschirmen bleiben alle drei identisch zu .page. */
.page-narrow,
.page-reading,
.page-wide {
  max-width: 44rem;
}

/* --- Kopfbereich --- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.brand svg {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--accent);
  flex: none;
}

.lang {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.lang button {
  border: none;
  background: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
}

.lang button:hover {
  color: var(--fg);
}

.lang button.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow);
}

/* --- Typografie --- */

h1 {
  /* Wächst zwischen Mobile- und Desktop-Breite mit, statt bei der
     Mobile-Größe zu verharren oder in einem Sprung an einem Breakpoint
     umzuschalten. */
  font-size: clamp(1.5rem, 1.25rem + 1.1vw, 2.25rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

h2 {
  font-size: clamp(1.05rem, 0.95rem + 0.45vw, 1.35rem);
  line-height: 1.35;
  margin: 0 0 0.75rem;
}

p {
  margin: 0 0 1rem;
}

p:last-child {
  margin-bottom: 0;
}

.tagline {
  color: var(--fg-muted);
  margin-bottom: 1.75rem;
}

.lead {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

/* --- Karten --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 1.25rem;
}

/* Das Ergebnis-Panel blendet sanft ein, statt abrupt zu erscheinen - der
   einzige bewegte Moment auf der Seite, ausgelöst durch eine echte
   Zustandsänderung (das Secret wurde erzeugt), nicht als Dekoration. */
@media (prefers-reduced-motion: no-preference) {
  #result:not([hidden]) {
    animation: reveal 0.35s ease-out;
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* --- Formularelemente --- */

.field + .field {
  margin-top: 1.25rem;
}

/* Honeypot-Feld: bewusst nicht display:none/visibility:hidden, das
   filtern manche automatisierten Formularausfüller gezielt heraus.
   Stattdessen liegt es außerhalb des sichtbaren Bereichs, bleibt aber
   im Layout vorhanden. */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.hint {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  resize: vertical;
  min-height: 9rem;
}

textarea::placeholder {
  color: var(--fg-muted);
  opacity: 0.85;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentcolor 50%),
    linear-gradient(135deg, currentcolor 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

:where(textarea, input, select, button, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  outline-offset: 1px;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.94rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.13s, border-color 0.13s, color 0.13s, transform 0.06s;
}

/* Beim Drücken sinkt die Fläche sichtbar ein - eine Rückmeldung, die
   unabhängig von der Farbwahrnehmung funktioniert. */
.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

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

.btn-primary:active:not(:disabled) {
  background: var(--accent-active);
}

.btn-secondary {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--border-strong);
}

/* Rahmen und Schrift wechseln mit: Eine reine Flächenänderung ist auf
   dunklem Grund kaum wahrnehmbar. */
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:active:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

/*
 * Zwischenzustand der Löschen-Schaltfläche: fragt nach, bevor sie handelt.
 * Die Schriftfarbe steht in jeder Zustandsregel erneut - träfen doch
 * einmal beide Varianten zusammen, würde sie sonst von der sekundären
 * Schaltfläche überschrieben und stünde blau auf rotem Grund.
 */
.btn-danger {
  background: var(--danger-solid);
  border-color: var(--danger-solid);
  color: var(--danger-solid-fg);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-solid-hover);
  border-color: var(--danger-solid-hover);
  color: var(--danger-solid-fg);
}

.btn-danger:active:not(:disabled) {
  background: var(--danger-solid-active);
  border-color: var(--danger-solid-active);
  color: var(--danger-solid-fg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn-icon {
  transition: background-color 0.13s, color 0.13s, transform 0.06s;
}

.btn-icon:active {
  transform: translateY(1px);
}

.btn-block {
  width: 100%;
  margin-top: 1.5rem;
}

.btn-icon {
  border: none;
  background: none;
  color: var(--fg-muted);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-subtle);
}

/* --- Dateiauswahl --- */

.dropzone {
  display: block;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--fg-muted);
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent);
}

.dropzone.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.dropzone.disabled:hover {
  border-color: var(--border-strong);
  background: var(--surface-sunken);
  color: var(--fg-muted);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.4rem;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.5rem 0.55rem 0.8rem;
  font-size: 0.9rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-size {
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --- Ergebnis: Links zum Kopieren --- */

/* Die Aktionen sitzen als kleine Symbole rechts im Feld selbst. Das Feld
   hält rechts genug Innenabstand frei, damit der Link nicht unter den
   Symbolen verschwindet - er bleibt seitlich scrollbar. */
.copy-row {
  position: relative;
}

.copy-row input {
  min-width: 0;
  padding-right: 4.75rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface-sunken);
}

.copy-row input:disabled {
  color: var(--fg-muted);
  text-decoration: line-through;
}

.copy-actions {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateY(-50%);
  display: flex;
  gap: 0.15rem;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--fg-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.13s, color 0.13s, transform 0.06s;
}

.action-icon svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-icon:hover:not(:disabled) {
  color: var(--accent);
  background: var(--surface-hover);
}

.action-icon:active:not(:disabled) {
  transform: translateY(1px);
}

.action-icon:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Nach dem Kopieren steht kurz ein Häkchen statt des Kopiersymbols. */
.action-icon .icon-done,
.action-icon.done .icon-idle {
  display: none;
}

.action-icon.done .icon-done {
  display: block;
}

/* Die Maus steht beim Kopieren noch auf dem Symbol - ohne die
   Hover-Variante bliebe das Häkchen in der Hover-Farbe statt grün. */
.action-icon.done,
.action-icon.done:hover:not(:disabled) {
  color: var(--success);
}

/* --- Rückmeldungen --- */

.status {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}

progress {
  width: 100%;
  height: 6px;
  margin-top: 0.75rem;
  accent-color: var(--accent);
}

.notice,
.error,
.success {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid;
}

.notice {
  color: var(--fg-muted);
  background: var(--surface-sunken);
  border-color: var(--border);
}

/* Ein Hinweis, der eine Handlung verlangt, soll sich vom bloßen
   Erklärtext abheben - ohne gleich nach Fehler auszusehen. */
.notice-accent {
  color: var(--fg);
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.error {
  color: var(--danger);
  background: var(--danger-subtle);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  margin-bottom: 1.25rem;
}

/* Gelungene Aktionen bekommen einen eigenen Farbton. Rot bleibt
   Problemen vorbehalten - sonst wäre am Farbton nicht mehr abzulesen,
   ob etwas schiefging. */
.success {
  color: var(--success);
  background: var(--success-subtle);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

/*
 * Rot und Grün liegen in ihrer Helligkeit fast gleichauf. Bei einer
 * Rot-Grün-Sehschwäche - der häufigsten Form - wären beide Meldungen
 * allein am Farbton kaum auseinanderzuhalten. Das vorangestellte Zeichen
 * trägt die Unterscheidung unabhängig von der Farbwahrnehmung.
 */
.error::before,
.success::before {
  font-weight: 700;
  margin-right: 0.45rem;
}

.error::before {
  content: "✕";
}

.success::before {
  content: "✓";
}

.notice-spaced {
  margin-top: 1.25rem;
}

/* --- Angezeigte Nachricht --- */

.message-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0 0 1rem;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* Kopier-Symbol oben rechts im Textfeld, wie bei Codeblöcken üblich.
   Der Text hält rechts Abstand, damit die erste Zeile nicht unter dem
   Symbol verschwindet; die eigene Fläche deckt längere Zeilen ab. */
.output-wrap {
  position: relative;
}

.output-wrap .message-output {
  padding-right: 3rem;
}

.output-copy {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  background: var(--surface-sunken);
}

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

footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem;
}

footer nav {
  max-width: 44rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.85rem;
}

/* Die Fußzeile ist serverseitig auf jeder Seite identisch und kennt ihre
   Container-Breite deshalb nicht von sich aus - sie übernimmt sie von der
   .page-Variante, die weiter oben im Dokument steht, damit ihr linker und
   rechter Rand mit dem Seiteninhalt darüber fluchtet. */
@media (min-width: 64rem) {
  body:has(.page-reading) footer nav {
    max-width: var(--container-reading);
  }

  body:has(.page-narrow) footer nav {
    max-width: var(--container-narrow);
  }

  body:has(.page-wide) footer nav {
    max-width: var(--container-wide);
  }
}

@media (min-width: 90rem) {
  body:has(.page-wide) footer nav {
    max-width: calc(var(--container-wide) + 4rem);
  }
}

footer a {
  color: var(--fg-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* --- Infoseite --- */

.prose h2 {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.prose section:first-of-type h2 {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.prose h3 {
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 1.25rem 0 0.5rem;
}

.prose ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.05rem 0.3rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* Quellenliste des technischen Abschnitts: Die Nummern entsprechen den
   Verweisen in eckigen Klammern im Text. */
.prose ol.references {
  margin: 0 0 1rem;
  padding-left: 1.75rem;
  font-size: 0.9rem;
}

.prose ol.references li::marker {
  content: "[" counter(list-item) "] ";
  color: var(--fg-muted);
}

.prose ol.references a {
  overflow-wrap: anywhere;
}

.prose strong {
  font-weight: 650;
}

/* Hebt einzelne, für Betroffene besonders wichtige Absätze hervor - zur
   Zeit nur das Widerrufsrecht in der Datenschutzerklärung. */
.prose .callout {
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-sm);
}

.prose .callout p:last-child {
  margin-bottom: 0;
}

[data-lang-block] {
  display: none;
}

[data-lang-block].active {
  display: block;
}

/* --- Compose: Ablauf-Panel --- */

/* Auf schmalen Bildschirmen ein normaler Block unterhalb des Formulars;
   das eigentliche Zweispalten-Layout entsteht erst im Desktop-Breakpoint
   unten. compose.js kennt nur #compose und #result und bleibt von diesem
   Wrapper unberührt. */
.compose-layout {
  display: block;
}

.compose-story {
  margin-top: 1.75rem;
}

.compose-story h2 {
  font-size: 1.05rem;
}

.compose-story ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.compose-story li {
  position: relative;
  padding-left: 2.5rem;
  color: var(--fg-muted);
}

/* Durchnummeriert, weil es hier tatsächlich eine Abfolge ist: genau so
   durchläuft ein Secret seinen Lebenszyklus, in exakt dieser Reihenfolge. */
.compose-story li::before {
  counter-increment: story-step;
  content: counter(story-step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: 50%;
}

.compose-story ol {
  counter-reset: story-step;
}

.compose-story strong {
  display: block;
  color: var(--fg);
  font-weight: 650;
  margin-bottom: 0.15rem;
}

/* --- Breakpoints: Desktop --- */

@media (min-width: 40rem) {
  .page,
  .page-narrow,
  .page-reading,
  .page-wide {
    padding: 2.5rem 2rem;
  }
}

@media (min-width: 64rem) {
  .page-reading {
    max-width: var(--container-reading);
  }

  .page-narrow {
    max-width: var(--container-narrow);
  }

  .page-wide {
    max-width: var(--container-wide);
  }

  /* Formular links in Lesebreite, Ablauf-Panel rechts im verbleibenden
     Raum - der zusätzliche Platz auf großen Bildschirmen bekommt dadurch
     eine Aufgabe, statt als Leerraum um eine zentrierte Spalte zu bleiben. */
  .compose-layout {
    display: grid;
    grid-template-columns: minmax(0, var(--container-reading)) 1fr;
    gap: 3rem;
    align-items: start;
  }

  .compose-story {
    margin-top: 0;
    position: sticky;
    top: 2.5rem;
  }
}

@media (min-width: 90rem) {
  .page-wide {
    max-width: calc(var(--container-wide) + 4rem);
  }
}

@media (max-width: 32rem) {
  .page {
    padding: 1.5rem 1rem;
  }

  .card {
    padding: 1.15rem;
  }
}
