/*
  Ausmalbild – Corporate Design der Katholischen KiTa gGmbH Saarland
  (wie gruppe7.ministo.de / kita-picturemod): Blau #003885, Dunkelblau
  #00265C, Gelb #FFD302, Schrift Carlito (metrisch gleich zu Calibri).
  Bedienung nach den Apple Human Interface Guidelines: Tippflächen ≥ 44 pt,
  sichere Bereiche, Bewegung reduzieren, Zustände sichtbar.
*/

@font-face {
  font-family: "Carlito";
  src: url("/fonts/carlito-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Carlito";
  src: url("/fonts/carlito-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --blue: #003885;
  --blue-dark: #00265c;
  --blue-link: #3d6fb4;
  --yellow: #ffd302;
  --tint-blue: #eaf0fa;
  --bg-grey: #f5f7fa;
  --ink: #2a2a2a;
  --ink-soft: #5c6672;
  --line: #d7deea;
  --white: #ffffff;
  --red: #c4291c;
  --radius: 0.75rem;
  --tap: 2.75rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

/*
  Skalierung: Alle Maße sind in rem und hängen an der Grundschriftgröße.
  Sie wächst mit dem Bildschirm (iPad ≈ 16 px, großes Display mehr) und
  wird mit --zoom multipliziert: automatisch größer auf großen
  Touch-Bildschirmen (Whiteboard), sonst über „Darstellung“ wählbar
  (html[data-groesse], gespeichert im Gerät, auch per ?groesse=… setzbar).
*/
html {
  --zoom: 1;
  font-size: calc(clamp(16px, 0.6vmin + 11px, 22px) * var(--zoom));
  -webkit-text-size-adjust: 100%;
}
@media (pointer: coarse) and (min-width: 1600px) {
  html { --zoom: 1.5; } /* Whiteboard / großes Touch-Display */
}
html[data-groesse="normal"] { --zoom: 1; }
html[data-groesse="gross"] { --zoom: 1.35; }
html[data-groesse="sehr-gross"] { --zoom: 1.75; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-grey);
  color: var(--ink);
  font-family: "Carlito", "Calibri", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--blue-link); }
img { display: block; }
[hidden] { display: none !important; }

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

.brandbar {
  background: var(--blue);
  color: var(--white);
  padding: calc(0.625rem + var(--safe-top)) calc(1.25rem + var(--safe-right)) 0.625rem calc(1.25rem + var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.brandbar .org { display: flex; align-items: center; gap: 0.625rem; color: inherit; text-decoration: none; min-height: var(--tap); }
.brandbar .mark {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--yellow); color: var(--blue);
  font-weight: 700; font-size: 0.8125rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brandbar .marks { display: flex; }
@media (max-width: 30rem) { .brandbar .group-tag { display: none; } }
.brandbar .marks .mark + .mark { margin-left: -0.25rem; box-shadow: 0 0 0 2px var(--blue); }
.brandbar .org-name { font-size: 0.8125rem; line-height: 1.3; }
.brandbar .org-name strong { display: block; font-size: 0.875rem; }
.brand-right { display: flex; align-items: center; gap: 0.375rem; }
.brandbar .group-tag {
  background: var(--yellow); color: var(--blue-dark);
  font-weight: 700; font-size: 0.75rem; padding: 5px 0.75rem; border-radius: 1.25rem; white-space: nowrap;
}
.icon-btn {
  -webkit-appearance: none; appearance: none; border: none; background: none; cursor: pointer; padding: 0;
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: var(--white);
}
.icon-btn svg { width: 1.375rem; height: 1.375rem; fill: currentColor; opacity: .85; }
.icon-btn:active { background: rgba(255,255,255,.15); }

.brandfooter {
  background: var(--blue);
  color: var(--white);
  border-top: 4px solid var(--yellow);
  padding: 1.25rem calc(1.25rem + var(--safe-right)) calc(1.25rem + var(--safe-bottom)) calc(1.25rem + var(--safe-left));
  font-size: 0.8125rem;
  line-height: 1.6;
}
.brandfooter .inner { max-width: 68.75rem; margin: 0 auto; }
.brandfooter .tagline { font-style: italic; opacity: .85; }
.brandfooter .tool-note { margin-top: 0.625rem; font-size: 0.75rem; opacity: .75; }

.offline-banner {
  background: var(--yellow);
  color: var(--blue-dark);
  font-weight: 700;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* ---------- Seite ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 68.75rem;
  margin: 0 auto;
  padding: 1.75rem calc(1.25rem + var(--safe-right)) 3rem calc(1.25rem + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.loading, .empty-note { color: var(--ink-soft); text-align: center; padding: 1.5rem 0; }
.hero { display: flex; flex-direction: column; gap: 0.375rem; }
.hero-row { display: flex; flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.eyebrow {
  font-size: 0.8125rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--blue-link);
}
h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 2.3rem); color: var(--blue); line-height: 1.15; text-wrap: balance; }
h2 { margin: 0 0 0.75rem; font-size: 1.25rem; color: var(--blue); }
.lede { margin: 0; color: var(--ink-soft); max-width: 60ch; }
.hint { color: var(--ink-soft); font-size: .9rem; margin: 0.375rem 0 0; }
.hint.error, .error-text { color: var(--red); }
.back {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: var(--tap);
  font-weight: 700; text-decoration: none; color: var(--blue-link);
}
.back::before { content: "‹"; font-size: 1.6em; line-height: 1; margin-top: -2px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ---------- Schaltflächen (HIG: ≥ 44 pt, sichtbarer Druckzustand) ---------- */

.btn {
  -webkit-appearance: none; appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.625rem;
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform .08s ease, opacity .15s;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.secondary { background: var(--tint-blue); color: var(--blue); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid currentColor; }
.btn.small { min-height: 2.25rem; padding: 0.375rem 0.875rem; font-size: .95rem; }
.btn.yellow { background: var(--yellow); color: var(--blue-dark); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.625rem; align-items: center; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* ---------- Formulare ---------- */

.field { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }
.field label { font-weight: 700; color: var(--blue-dark); font-size: .95rem; }
input[type=text], input[type=search], input[type=password], textarea {
  font: inherit;
  font-size: 1.0625rem; /* ≥ 16 px: iOS zoomt sonst beim Fokussieren */
  min-height: var(--tap);
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.625rem;
  background: var(--white);
  color: var(--ink);
  width: 100%;
}
textarea { min-height: 5rem; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--blue-link); box-shadow: 0 0 0 3px var(--tint-blue); }
.search { max-width: 22.5rem; }

/* ---------- Darstellung (Größe) ---------- */

.segmente { display: flex; flex-direction: column; gap: 0.5rem; }
.segmente label {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--tap); padding: 0.5rem 0.875rem;
  border: 1px solid var(--line); border-radius: 0.625rem; cursor: pointer;
}
.segmente input { width: 1.25rem; height: 1.25rem; accent-color: var(--blue); }
.segmente label:has(input:checked) { border-color: var(--blue); background: var(--tint-blue); font-weight: 700; }

/* ---------- Dialoge (Anmeldung, Neu, QR) ---------- */

dialog {
  border: none;
  border-radius: 1rem;
  padding: 0;
  width: min(26.25rem, calc(100vw - 2rem));
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  color: var(--ink);
}
dialog::backdrop { background: rgba(0, 38, 92, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dlg-head { padding: 1.25rem 1.375rem 4px; font-size: 1.25rem; font-weight: 700; color: var(--blue); }
.dlg-body { padding: 0.75rem 1.375rem; }
.dlg-foot { padding: 0.5rem 1.375rem 1.25rem; display: flex; gap: 0.625rem; justify-content: flex-end; flex-wrap: wrap; }
.pin-input { text-align: center; font-size: 1.6rem !important; letter-spacing: .25em; }
.qr { display: flex; justify-content: center; padding: 0.5rem; background: #fff; }
.qr svg { width: 100%; max-width: 17.5rem; height: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.5rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--blue-dark);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  font-weight: 700;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.error { background: var(--red); }

.spinner {
  width: 1.125rem; height: 1.125rem; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: drehen .8s linear infinite;
}
@keyframes drehen { to { transform: rotate(360deg); } }

/* HIG: „Bewegung reduzieren“ respektieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
  .brandbar, .brandfooter, .btn, .back { display: none !important; }
}

/* ---------- Ausmalbild ---------- */

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (max-width: 52rem) { .layout { grid-template-columns: 1fr; } }
.select {
  font: inherit; min-height: var(--tap); padding: 0.5rem 0.75rem; width: 100%;
  border: 1px solid var(--line); border-radius: 0.625rem; background: var(--white); color: var(--ink);
}
.wahl { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.wahl label {
  flex: 1 1 8rem; display: flex; flex-direction: column; gap: 0.125rem; cursor: pointer;
  min-height: var(--tap); padding: 0.625rem 0.75rem; border: 1px solid var(--line); border-radius: 0.625rem; background: var(--white);
}
.wahl input { position: absolute; opacity: 0; pointer-events: none; }
.wahl label:has(input:checked) { border-color: var(--blue); background: var(--tint-blue); box-shadow: inset 0 0 0 1px var(--blue); }
.wahl label:has(input:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 2px; }
.wahl strong { color: var(--blue); }
.wahl span { font-size: 0.85rem; color: var(--ink-soft); }
.check { display: flex; align-items: center; gap: 0.625rem; min-height: var(--tap); cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--blue); }

.blatt {
  background: var(--white); border: 1px solid var(--line); border-radius: 0.375rem;
  box-shadow: 0 0.375rem 1.5rem rgba(0, 38, 92, .12);
  aspect-ratio: 210 / 297; display: flex; flex-direction: column; padding: 6%;
  position: relative; overflow: hidden;
}
.blatt.quer { aspect-ratio: 297 / 210; }
.blatt .ueberschrift { font-size: clamp(1rem, 3.2vw, 1.6rem); font-weight: 700; text-align: center; margin: 0 0 3%; color: #000; min-height: 1em; }
.blatt .motiv { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.blatt .motiv img, .blatt .motiv canvas { max-width: 100%; max-height: 100%; object-fit: contain; }
.blatt .namenszeile { margin-top: 3%; font-size: clamp(0.75rem, 2vw, 1rem); color: #000; }
.blatt .leer { color: var(--ink-soft); text-align: center; padding: 1rem; }
.blatt .malt { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 0.75rem; align-items: center; justify-content: center; background: rgba(255,255,255,.85); color: var(--blue); font-weight: 700; text-align: center; padding: 1rem; }

.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr)); gap: 0.875rem; }
.galerie button.eintrag {
  -webkit-appearance: none; appearance: none; font: inherit; text-align: left; cursor: pointer;
  background: var(--white); border: 1px solid var(--line); border-radius: 0.625rem; overflow: hidden; padding: 0;
  display: flex; flex-direction: column;
}
.galerie button.eintrag:active { transform: scale(.97); }
.galerie img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #fff; border-bottom: 1px solid var(--line); }
.galerie span { padding: 0.375rem 0.5rem 0.5rem; font-size: 0.85rem; color: var(--ink); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ergebnis { margin-top: 0.75rem; }
.field .label { font-weight: 700; color: var(--blue-dark); font-size: 0.95rem; }
.link-btn {
  -webkit-appearance: none; appearance: none; border: none; background: none; padding: 0.25rem 0;
  font: inherit; color: var(--blue-link); text-decoration: underline; cursor: pointer;
}

/* Auswahlschalter Hoch/Quer (Segmented Control nach Apple HIG) */
.segment {
  display: flex; padding: 0.1875rem; margin-bottom: 0.875rem;
  background: var(--tint-blue); border-radius: 0.75rem; gap: 0.1875rem;
}
.segment label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--tap); padding: 0.375rem 0.75rem; border-radius: 0.5625rem; cursor: pointer;
  font-weight: 700; color: var(--blue); transition: background .15s, box-shadow .15s;
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment svg { width: 1.375rem; height: 1.375rem; fill: none; stroke: currentColor; stroke-width: 2; }
.segment label:has(input:checked) { background: var(--white); box-shadow: 0 1px 4px rgba(0, 38, 92, .18); }
.segment label:has(input:focus-visible) { outline: 3px solid var(--yellow); outline-offset: 1px; }

.hinweis-format {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem;
  margin: 0 0 0.875rem; padding: 0.625rem 0.875rem; border-radius: 0.625rem;
  background: #fff8d6; border: 1px solid var(--yellow); color: var(--blue-dark); font-size: 0.95rem;
}
