/* ==================================================================
   base.css — Design-Tokens, Grundelemente, Overlays
   Wird von der Kinder-App und vom Elternbereich geteilt.
   ================================================================== */

:root {
  /* Farben */
  --c-orange: #ff8a3d;
  --c-blue: #4dc9f6;
  --c-green: #7ed957;
  --c-purple: #c77dff;
  --c-yellow: #ffd23f;
  --c-pink: #ff6392;
  --c-teal: #00b8a9;

  --c-ink: #23314a;
  --c-ink-soft: #5c6b85;
  --c-line: #e3e9f2;
  --c-bg: #f4f8ff;
  --c-surface: #ffffff;

  --c-ok: #2fa84f;
  --c-warn: #e8a33d;
  --c-error: #e4574f;

  /* Abstände */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Radien */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-pill: 999px;

  /* Schatten */
  --shadow-sm: 0 2px 6px rgba(35, 49, 74, .08);
  --shadow-md: 0 6px 18px rgba(35, 49, 74, .12);
  --shadow-lg: 0 16px 40px rgba(35, 49, 74, .18);

  /* Typografie */
  --font: 'Nunito', 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.has-panel { overflow: hidden; }

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }

button { font-family: inherit; }

/* ------------------------------------------------------------------
   Screens
   ------------------------------------------------------------------ */

.screen {
  min-height: 100dvh;
  padding: var(--sp-5) var(--sp-4) var(--sp-7);
  max-width: 1100px;
  margin: 0 auto;
}

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

.screen--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------------
   Buttons
   ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  border: none;
  border-radius: var(--r-pill);
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  text-decoration: none;
}

.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn--primary {
  background: linear-gradient(180deg, var(--c-blue), #2fb6e8);
  color: #fff;
  box-shadow: 0 5px 0 #1f9ac9, var(--shadow-sm);
}
.btn--primary:active { box-shadow: 0 2px 0 #1f9ac9; }

.btn--success {
  background: linear-gradient(180deg, var(--c-green), #5fc63f);
  color: #14421a;
  box-shadow: 0 5px 0 #4fae33, var(--shadow-sm);
}

.btn--danger {
  background: linear-gradient(180deg, #ff8078, var(--c-error));
  color: #fff;
  box-shadow: 0 5px 0 #c9433c, var(--shadow-sm);
}

.btn--ghost {
  background: var(--c-surface);
  color: var(--c-ink);
  border: 2px solid var(--c-line);
}

.btn--big { padding: 16px 30px; font-size: 1.15rem; }
.btn--block { width: 100%; }

.link-btn {
  background: none;
  border: none;
  color: var(--c-blue);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  padding: var(--sp-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn--muted { color: var(--c-ink-soft); }

/* ------------------------------------------------------------------
   Karten & Formulare
   ------------------------------------------------------------------ */

.card {
  background: var(--c-surface);
  border-radius: var(--r-xl);
  padding: var(--sp-6) var(--sp-5);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.card__emoji { font-size: 3.5rem; line-height: 1; }
.card__title { font-size: 1.8rem; margin-top: var(--sp-2); }
.card__subtitle { color: var(--c-ink-soft); margin-top: var(--sp-1); }
.card__links { margin-top: var(--sp-4); display: grid; gap: var(--sp-1); }
.card__actions { display: grid; gap: var(--sp-3); margin-top: var(--sp-5); }

.form { margin-top: var(--sp-5); display: grid; gap: var(--sp-4); text-align: left; }

.field { display: grid; gap: var(--sp-1); }
.field__label { font-weight: 800; font-size: .9rem; color: var(--c-ink-soft); }

.field__input,
.field__select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--c-line);
  border-radius: var(--r-md);
  font-size: 1.05rem;
  font-family: inherit;
  background: #fbfcff;
  color: var(--c-ink);
}

.field__input:focus,
.field__select:focus {
  outline: none;
  border-color: var(--c-blue);
  background: #fff;
}

.form__error {
  background: #fdecea;
  color: #a3312a;
  border-radius: var(--r-sm);
  padding: var(--sp-3);
  font-weight: 700;
  font-size: .95rem;
}

/* ------------------------------------------------------------------
   Fortschrittsbalken
   ------------------------------------------------------------------ */

.progress {
  height: 12px;
  background: var(--c-line);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.progress--big { height: 20px; }

.progress__fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--c-green), var(--c-teal));
  border-radius: var(--r-pill);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

/* ------------------------------------------------------------------
   Slide-in-Panel (statt Modal)
   ------------------------------------------------------------------ */

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 49, 74, 0);
  display: flex;
  justify-content: flex-end;
  z-index: 100;
  transition: background .26s ease;
}

.panel-backdrop.is-open { background: rgba(35, 49, 74, .45); }

.panel {
  width: min(460px, 100%);
  height: 100%;
  background: var(--c-surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
}

.panel-backdrop.is-open .panel { transform: translateX(0); }

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 2px solid var(--c-line);
}

.panel__title { font-size: 1.25rem; }

.panel__close {
  border: none;
  background: var(--c-bg);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--c-ink-soft);
}

.panel__body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.panel__footer { padding: var(--sp-4) var(--sp-5); border-top: 2px solid var(--c-line); }

@media (max-width: 560px) {
  .panel-backdrop { justify-content: stretch; align-items: flex-end; }
  .panel {
    width: 100%;
    height: min(92dvh, 100%);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .panel-backdrop.is-open .panel { transform: translateY(0); }
}

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

.pin-body { text-align: center; }
.pin-emoji { font-size: 3rem; }
.pin-title { font-weight: 800; font-size: 1.15rem; margin-top: var(--sp-3); }
.pin-hint { color: var(--c-ink-soft); font-size: .92rem; min-height: 1.4em; margin-top: var(--sp-2); }
.pin-hint--error { color: var(--c-error); font-weight: 700; }

.pin-dots {
  display: flex;
  justify-content: center;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--c-line);
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.pin-dot.is-filled {
  background: var(--c-blue);
  border-color: var(--c-blue);
  transform: scale(1.15);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.keypad__key {
  border: 2px solid var(--c-line);
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 18px 0;
  font-size: 1.5rem;
  font-weight: 800;
  cursor: pointer;
  color: var(--c-ink);
}

.keypad__key:active { background: var(--c-bg); transform: translateY(2px); }
.keypad__key--del { color: var(--c-ink-soft); }
.keypad__spacer { visibility: hidden; }

/* ------------------------------------------------------------------
   Toasts & Konfetti
   ------------------------------------------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--c-ink);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--r-pill);
  font-weight: 700;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 200;
  max-width: min(560px, 90vw);
  text-align: center;
}

.toast.is-in { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: var(--c-error); }
.toast--success { background: var(--c-ok); }

.big-toast {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  background: rgba(255, 255, 255, .92);
  z-index: 210;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}

.big-toast.is-in { opacity: 1; }
.big-toast__emoji { font-size: 6rem; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.big-toast__text { font-size: 1.6rem; font-weight: 900; color: var(--c-ink); text-align: center; padding: 0 var(--sp-5); }

@keyframes pop {
  0% { transform: scale(0) rotate(-20deg); }
  70% { transform: scale(1.25) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 220;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .2; }
}

/* ------------------------------------------------------------------
   Ladeanzeige
   ------------------------------------------------------------------ */

.loader { text-align: center; }
.loader__emoji { font-size: 4rem; animation: bob 1.4s ease-in-out infinite; }
.loader__text { margin-top: var(--sp-3); color: var(--c-ink-soft); font-weight: 700; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.empty-note {
  text-align: center;
  color: var(--c-ink-soft);
  padding: var(--sp-6) var(--sp-4);
  font-weight: 600;
}

/* ------------------------------------------------------------------
   Barrierefreiheit
   ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

:focus-visible {
  outline: 3px solid var(--c-blue);
  outline-offset: 3px;
}
