/* =====================================================================
   COSI - gemeinsame Grundgestaltung
   Zwei Oberflaechen bauen darauf auf:
     public/kind/kind.css     riesig, bunt, fingerfreundlich
     public/eltern/eltern.css ruhig, dicht, arbeitstauglich
   ===================================================================== */

:root {
  --paper:      #f4f7fb;
  --card:       #ffffff;
  --ink:        #1d2733;
  --ink-soft:   #5a6b7d;
  --line:       #dde5ee;

  --brand:      #3fa9f5;
  --brand-dark: #1f7fc4;
  --accent:     #ffd23f;
  --good:       #43aa8b;
  --warn:       #f4a300;
  --bad:        #e63946;
  --gold:       #f2b705;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 26px;
  --r-xl: 34px;

  --shadow:    0 2px 8px rgba(29, 39, 51, .08);
  --shadow-lg: 0 10px 30px rgba(29, 39, 51, .16);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  /* Kein versehentliches Verschieben beim Malen auf dem Tablet */
  overscroll-behavior: none;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
p { margin: 0 0 1em; line-height: 1.55; }
a { color: var(--brand-dark); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

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

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------ Bausteine */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: .65em 1.1em;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:hover:not(:disabled) { filter: brightness(1.06); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--soft  { background: #eef4fb; color: var(--brand-dark); }
.btn--good  { background: var(--good); }
.btn--warn  { background: var(--warn); }
.btn--bad   { background: var(--bad); }
.btn--big   { padding: .9em 1.6em; font-size: 1.1rem; border-radius: var(--r); }

.field { display: block; margin-bottom: 1rem; }
.field > span {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: .35em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: .7em .85em;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(63, 169, 245, .18);
}
.field small { display: block; margin-top: .35em; color: var(--ink-soft); font-size: .8rem; }

.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > * { flex: 1 1 12rem; min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .2em .7em; border-radius: 999px;
  font-size: .78rem; font-weight: 700;
  background: #eef4fb; color: var(--brand-dark);
}
.pill--good { background: #e6f6f0; color: #26735c; }
.pill--warn { background: #fff2dc; color: #9a6600; }
.pill--bad  { background: #fde8ea; color: #a51e29; }

.note {
  padding: .8em 1em;
  border-radius: var(--r-sm);
  background: #eef4fb;
  color: var(--brand-dark);
  font-size: .9rem;
}
.note--warn { background: #fff6e6; color: #8a5b00; }
.note--bad  { background: #fdeaec; color: #96202b; }

/* ------------------------------------------------------ Meldungen */
#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 900;
  pointer-events: none;
  width: min(92vw, 28rem);
}
.toast {
  padding: .8em 1.1em;
  border-radius: var(--r);
  background: #1d2733;
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  animation: toast-in .18s ease-out;
}
.toast--good { background: #2f8b70; }
.toast--bad  { background: #b3303b; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------ Dialoge */
dialog {
  border: none;
  border-radius: var(--r-lg);
  padding: 0;
  max-width: min(94vw, 34rem);
  width: 100%;
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  background: var(--card);
}
dialog::backdrop { background: rgba(19, 28, 38, .55); }
.dialog__head { padding: 1.2rem 1.4rem .4rem; }
.dialog__body { padding: 0 1.4rem 1rem; }
.dialog__foot {
  display: flex; justify-content: flex-end; gap: .6rem;
  padding: 1rem 1.4rem 1.3rem;
}

/* ------------------------------------------------------ Ladezustand */
.loading {
  display: grid;
  place-items: center;
  min-height: 60vh;
  color: var(--ink-soft);
  font-weight: 600;
}
.spinner {
  width: 2.4rem; height: 2.4rem;
  border: 4px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: .8rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
