/* ==========================================================================
   Gerüst, Kopf, Fuß, Knöpfe, Formulare
   ========================================================================== */

/* --------------------------------------------------------------- Bühne ----
   Fläche im Seitenverhältnis der Referenz (1911 × 1076), die immer
   vollständig ins Fenster passt. --u ist ein Design-Pixel: Kinder werden mit
   calc(<Zahl aus der Referenz> * var(--u)) positioniert und sitzen dadurch
   bei jeder Fenstergröße exakt wie in der Vorlage.
   -------------------------------------------------------------------------- */

.buehne {
  --u: min(100vw / var(--design-w), 100dvh / var(--design-h));
  position: relative;
  width: calc(var(--design-w) * var(--u));
  height: calc(var(--design-h) * var(--u));
  margin: auto;
  /* Bewusst nicht hidden: was ein paar Pixel übersteht, soll in den Rand
     ragen statt still zu verschwinden. Gescrollt wird ohnehin nicht – der
     body ist overflow: hidden. */
  overflow: visible;
}

body.buehnen-seite {
  display: flex;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Ein Element der Bühne: x, y, w, h in Design-Pixeln. */
.pos {
  position: absolute;
  left: calc(var(--x, 0) * var(--u));
  top: calc(var(--y, 0) * var(--u));
  width: calc(var(--w, 0) * var(--u));
}

.pos--h { height: calc(var(--h, 0) * var(--u)); }

/* --------------------------------------------------------- App-Gerüst ----
   Für Übersicht, Board und Admin: fix im Fenster, kein Seiten-Scroll.
   -------------------------------------------------------------------------- */

body.app {
  display: grid;
  /* minmax(0, 1fr) statt der automatischen Spalte: sonst darf jedes Kind,
     das breiter ist als das Fenster (eine Fußzeile, die nicht umbricht),
     die ganze Seite mit aufdehnen – am Handy liefen dann die Kacheln aus
     dem Bild. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--h-kopf) minmax(0, 1fr) var(--h-fuss);
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

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

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pad-x);
  padding: 0 var(--pad-right) 0 var(--pad-x);
  min-width: 0;
}

.kopf__logo {
  display: block;
  flex: 0 0 auto;
  color: var(--lila);
  text-decoration: none;
}

.kopf__logo svg {
  width: clamp(120px, 11.7vw, 223px);   /* 223 px in der Impressum-Referenz */
  height: auto;
  fill: currentColor;
}

.kopf__logo:hover { color: var(--rot); }

.kopf__nav {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.7vw, 32px);
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.fuss {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(14px, 4.3vw, 83px);
  padding: 0 clamp(16px, 6.4vw, 122px) 0 var(--pad-x);
  font-family: var(--font-ui);
  font-size: clamp(13px, 1.5vw, 29px);
  line-height: var(--zh-ui);
}

.fuss__link {
  text-decoration: none;
  white-space: nowrap;
}

.fuss__link:hover,
.fuss__link:focus-visible { text-decoration: underline; }

.fuss__link--gruen { color: var(--gruen); }
.fuss__link--rot   { color: var(--rot); }
.fuss__link--lila  { color: var(--lila); }

/* Auf der Bühne sitzt der Fuß absolut an der Stelle aus der Referenz.
   Neun Design-Pixel höher als dort: Kiris Unterlänge (das g in
   „kleeneausstellung") reicht 0,52 em unter die Grundlinie und wäre sonst
   am unteren Bühnenrand abgeschnitten. */
.buehne .fuss {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(1030 * var(--u));
  height: calc(30 * var(--u));
  padding-right: calc(122 * var(--u));
  gap: calc(83 * var(--u));
  font-size: calc(29 * var(--u));
}

/* ---------------------------------------------------------- Aussehen -----
   Knopf in der Fußzeile und das Auswahlfeld dazu (aussehen.js).
   -------------------------------------------------------------------------- */

.fuss__aussehen {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tinte);
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}

.fuss__aussehen[hidden] { display: none !important; }

/* Drei versetzte Quadrate in den Akzentfarben – das Logo-Prinzip im Kleinen.
   Färbt sich mit dem Theme, zeigt also immer, was gerade gilt. */
.fuss__muster {
  position: relative;
  display: inline-block;
  width: 0.62em;
  height: 0.62em;
  margin-right: 0.18em;
  background: var(--lila);
  box-shadow: 0.14em 0.14em 0 var(--gruen), 0.28em 0.28em 0 var(--rot);
}

.aussehen {
  /* Die Popover-API bringt eigene Vorgaben mit (mittig, Rahmen, Canvas-Farben) –
     alle überschrieben. Die Lage setzt aussehen.js neben den Knopf. */
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(36rem, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: auto;
  padding: 14px 16px 16px;
  border: 3px solid var(--lila);
  background: var(--papier);
  color: var(--tinte);
  box-shadow: 8px 8px 0 var(--gruen), 16px 16px 0 var(--rot);
  font-family: var(--font-ui);
  line-height: var(--zh-ui);
}

.aussehen__titel {
  margin: 0 0 10px;
  color: var(--lila);
  font-size: 1.35em;
  /* Erste Zeile im Kasten mit overflow: auto – Oberlängen brauchen Luft. */
  padding-top: var(--ragt-ui);
}

.aussehen__gruppe {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.aussehen__gruppe + .aussehen__gruppe { margin-top: 14px; }

.aussehen__legende {
  padding: 0;
  margin-bottom: 6px;
  color: var(--rot);
  font-size: 0.95em;
}

.aussehen__liste {
  display: grid;
  /* Fünf Spalten auch bei den drei Schriften – so sind alle Muster gleich
     groß und stehen bündig untereinander. */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.aussehen__wahl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 0.8em;
  text-align: center;
}

/* Lieber an der Silbe trennen als mitten im Wort („nachtschic|ht") – wo
   der Browser kein deutsches Trennwörterbuch hat, bricht er notfalls
   trotzdem, statt in den Nachbarn zu laufen. */
.aussehen__name {
  max-width: 100%;
  hyphens: auto;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

/* Farbmuster: Papier des Themes, darauf versetzt die drei Akzente,
   davor „Aa" in seiner Tinte. Alles aus den Variablen des Musters selbst. */
.aussehen__muster {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: var(--papier);
  color: var(--tinte);
  border: 2px solid var(--grau);
  overflow: hidden;
}

.aussehen__muster i {
  position: absolute;
  width: 42%;
  height: 46%;
}

.aussehen__muster i:nth-child(1) { left: 14%; top: 16%; background: var(--rot); }
.aussehen__muster i:nth-child(2) { left: 10%; top: 12%; background: var(--gruen); }
.aussehen__muster i:nth-child(3) { left: 6%;  top: 8%;  background: var(--lila); }

.aussehen__muster b {
  position: absolute;
  right: 10%;
  bottom: 6%;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 1.5em;
  line-height: 1;
}

/* Schriftprobe: „Aa" in der jeweiligen Schrift. */
.aussehen__probe {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 2px solid var(--grau);
  background: var(--hellgrau);
  color: var(--tinte);
  font-family: var(--font-ui);
  font-size: 1.9em;
  line-height: 1;
}

/* Gewählt: harter Rahmen in der ersten Akzentfarbe plus versetzter Schatten. */
.aussehen__wahl:has(input:checked) .aussehen__muster,
.aussehen__wahl:has(input:checked) .aussehen__probe {
  border-color: var(--lila);
  border-width: 3px;
  box-shadow: 4px 4px 0 var(--rot);
}

.aussehen__wahl:has(input:checked) .aussehen__name { color: var(--lila); }

.aussehen__wahl:hover .aussehen__muster,
.aussehen__wahl:hover .aussehen__probe { border-color: var(--rot); }

/* Die Auswahlknöpfe sind unsichtbar (nur-sr), der Fokus muss also am Muster
   zu sehen sein. */
.aussehen__wahl:has(input:focus-visible) .aussehen__muster,
.aussehen__wahl:has(input:focus-visible) .aussehen__probe {
  outline: 3px solid var(--tinte);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  /* Schmal nur das Farbsymbol – vier beschriftete Einträge passen nicht in
     die Fußzeile. Der Name bleibt für Screenreader stehen. */
  .fuss__aussehen-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .fuss__aussehen { padding: 6px; margin: -6px; }   /* Tippfläche */
  .fuss__muster { width: 0.9em; height: 0.9em; margin-right: 0.28em; }
}

@media (max-width: 600px) {
  /* Auf dem Handy als Blatt am unteren Rand. */
  .aussehen {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    width: auto;
    box-shadow: 6px 6px 0 var(--gruen);
  }

  /* Drei breite statt fünf schmale Muster – sonst passt kein Name. */
  .aussehen__liste { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Tuschezeichnungen: die Striche ohne eigene Farbe sind Tinte – im dunklen
   Theme werden sie damit hell statt unsichtbar. */
.landing__tusche svg,
.impressum__tusche svg,
.fehler__tusche svg,
.kontakt__tusche svg { fill: var(--tinte); }

/* --------------------------------------------------------------- Knöpfe --- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(10px, 1.4vw, 26px);
  min-width: clamp(92px, 8.7vw, 166px);   /* 166 px in hauptseite ref_1 */
  height: clamp(30px, 2.6vw, 50px);       /* 49–50 px */
  border: 3px solid currentColor;
  border-radius: 0;
  background: transparent;
  font-family: var(--font-ui);
  font-size: clamp(13px, 1.45vw, 28px);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--zeit), color var(--zeit);
}

.knopf--lila { color: var(--lila); }
.knopf--rot  { color: var(--rot);  min-width: clamp(110px, 11vw, 210px); }
.knopf--gruen{ color: var(--gruen); }

.knopf:hover:not(:disabled),
.knopf:focus-visible:not(:disabled) {
  color: var(--auf-farbe);
  background: var(--knopf-farbe);
  border-color: var(--knopf-farbe);
}

.knopf--lila  { --knopf-farbe: var(--lila); }
.knopf--rot   { --knopf-farbe: var(--rot); }
.knopf--gruen { --knopf-farbe: var(--gruen); }
.knopf--gruen:hover:not(:disabled),
.knopf--gruen:focus-visible:not(:disabled) { color: var(--auf-gruen); }

/* Handschrift in umrandeten Knöpfen: Kiris Oberlängen sind so hoch (1,45 em),
   dass sie bei der Knopfhöhe an den Rahmen stießen – „abmelden" berührte
   oben die Linie, das p in „sperren" unten. font-size-adjust setzt nur Kiri
   kleiner (x-Höhe 0,665 → 0,53, also 80 %), ohne jede einzelne Schriftgröße
   anzufassen; der kleine Schub nach unten gleicht aus, dass Kiri über der
   Mitte sitzt. Grotesk und Schreibmaschine sind davon nicht betroffen. In
   der Vorlage sind die Knöpfe unbeschriftet – das ist also keine
   Abweichung von ihr. Gemessen an allen 59 Knöpfen der Verwaltung. */
:root:not([data-schrift]) :is(.knopf, .mini, .stufe, .leiste__knopf),
[data-schrift="hand"] :is(.knopf, .mini, .stufe, .leiste__knopf) {
  font-size-adjust: ex-height 0.53;
}

:root:not([data-schrift]) .knopf,
[data-schrift="hand"] .knopf { padding-top: 0.12em; }

.knopf:disabled {.knopf:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Vollflächiger Balken-Knopf, wie der E-Mail-Balken im Impressum. */
.balken {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0;
  background: var(--rot);
  color: var(--auf-farbe);
  font-family: var(--font-ui);
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--zeit);
}

.balken:hover:not(:disabled),
.balken:focus-visible:not(:disabled) { background: var(--lila); }

.balken:disabled { opacity: 0.5; cursor: progress; }

/* ----------------------------------------------------------- Formulare ----
   Nach der Login-Vorlage: weißes Feld in einem grauen Rahmen, keine Rundung.
   -------------------------------------------------------------------------- */

.feld {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: var(--papier);
  padding: 0 0.5em;
  font-family: var(--font-text);
}

.feld-rahmen {
  background: var(--grau);
  padding: 4px 7px;
}

.feld:focus { outline: none; }

.feld-rahmen:focus-within {
  background: var(--lila);
}

.etikett {
  font-family: var(--font-ui);
  line-height: 1;
}

/* --------------------------------------------------------------- Meldung -- */

.meldung {
  font-family: var(--font-ui);
  padding: 0.4em 0.7em;
  background: var(--rot);
  color: var(--auf-farbe);
}

.meldung--still {
  background: var(--hellgrau);
  color: var(--tinte);
}

.meldung[hidden] { display: none !important; }

/* --------------------------------------------------------------- Laden ---- */

.laden {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 3px solid currentColor;
  border-right-color: transparent;
  animation: dreh 700ms linear infinite;
}

@keyframes dreh { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- Mobil ----
   Auf schmalen Schirmen müssen Logo und Knöpfe in eine Zeile passen,
   sonst wächst die Kopfzeile ins Board hinein.
   -------------------------------------------------------------------------- */

@media (max-width: 760px) {
  /* Die Fußzeile darf umbrechen und wird dafür so hoch wie nötig – in der
     Handschrift ist „kleeneausstellung.de" allein schon halb so breit wie
     ein Handy. */
  body.app { grid-template-rows: var(--h-kopf) minmax(0, 1fr) auto; }

  .app .fuss {
    min-height: var(--h-fuss);
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 14px;
    padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  }

  .kopf {
    gap: 8px;
    padding: 0 8px;
  }

  .kopf__logo svg { width: 88px; }

  .kopf__nav { gap: 6px; flex-wrap: nowrap; }

  .knopf,
  .knopf--rot {
    min-width: 0;
    height: 34px;
    padding: 0 10px;
    border-width: 2px;
    font-size: 14px;
  }

  /* Touch-Ziele bleiben trotzdem groß genug: der Knopf bekommt außen Luft. */
  .kopf__nav .knopf { position: relative; }
  .kopf__nav .knopf::before {
    content: "";
    position: absolute;
    inset: -7px -4px;
  }
}
