/* ============================================================
   Wochenplan-Kind – app.css
   Fröhlich, weich gerundet, kindgerecht.
   Palette: Sonnengelb #fbbf24 + Himmelblau #60a5fa
   ============================================================ */

:root {
  --sun: #fbbf24;
  --sun-deep: #f59e0b;
  --sky: #60a5fa;
  --sky-deep: #3b82f6;
  --green: #22c55e;
  --green-deep: #16a34a;
  --pink: #f472b6;

  --bg: #fef9ec;
  --bg-soft: #fff6dd;
  --surface: #ffffff;
  --surface-alt: #f3f8ff;
  --text: #2b2a22;
  --text-soft: #6b6857;
  --line: #f0e3bd;
  --shadow: 0 10px 26px rgba(245, 158, 11, 0.18);
  --shadow-soft: 0 4px 14px rgba(96, 165, 250, 0.14);
  --radius: 26px;
  --radius-sm: 16px;
  --focus: #1d4ed8;

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

  --fs-base: clamp(16px, 4.2vw, 19px);
}

[data-theme="dark"] {
  --bg: #1d2230;
  --bg-soft: #232a3b;
  --surface: #2a3142;
  --surface-alt: #323a4e;
  --text: #f4f1e6;
  --text-soft: #b8bdcb;
  --line: #3a4357;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.35);
  --focus: #93c5fd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: "Comic Sans MS", "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 110% -10%, rgba(96, 165, 250, 0.20), transparent 60%),
    radial-gradient(900px 460px at -10% 0%, rgba(251, 191, 36, 0.28), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(120px + var(--safe-bottom));
  -webkit-text-size-adjust: 100%;
}

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--sky-deep);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 14px 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

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

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: linear-gradient(135deg, var(--sun) 0%, #fcd34d 55%, var(--sky) 160%);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}
[data-theme="dark"] .app-header {
  background: linear-gradient(135deg, #b9831c 0%, #8a6515 55%, #2d5fa6 160%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-icon { font-size: 1.7rem; }
.brand-title {
  margin: 0;
  font-size: clamp(1.3rem, 6vw, 1.7rem);
  color: #3a2c05;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.4);
}
[data-theme="dark"] .brand-title { color: #fff4d6; text-shadow: none; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.star-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.78);
  color: #7a5a07;
  font-weight: 800;
  padding: 8px 13px;
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  font-size: 1.05rem;
}
[data-theme="dark"] .star-badge { background: rgba(0, 0, 0, 0.3); color: #ffe6a3; }

.icon-btn {
  border: none;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.8);
  width: 46px;
  height: 46px;
  border-radius: 16px;
  font-size: 1.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, background 0.2s ease;
}
[data-theme="dark"] .icon-btn { background: rgba(0, 0, 0, 0.3); color: var(--text); }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Day Tabs ---------- */
.day-tabs {
  display: flex;
  gap: 9px;
  padding: 16px 14px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.day-tabs::-webkit-scrollbar { display: none; }

.day-tab {
  flex: 0 0 auto;
  border: 3px solid transparent;
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 18px;
  padding: 9px 4px 8px;
  min-width: 60px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
  font-family: inherit;
}
.day-tab .tab-day { font-weight: 800; font-size: 1rem; color: var(--text); }
.day-tab .tab-mini { font-size: 0.72rem; }
.day-tab:hover { transform: translateY(-2px); }
.day-tab[aria-selected="true"] {
  border-color: var(--sky);
  background: linear-gradient(180deg, var(--surface), var(--surface-alt));
}
.day-tab.is-today {
  position: relative;
}
.day-tab.is-today::after {
  content: "Heute";
  position: absolute;
  top: -9px;
  background: var(--sun);
  color: #3a2c05;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.day-tab .tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-top: 1px;
}
.day-tab .tab-dot.is-hidden { background: transparent; }

/* ---------- Content ---------- */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 0;
}

.day-headline { margin: 10px 2px 14px; }
.day-title {
  margin: 0;
  font-size: clamp(1.5rem, 7vw, 2rem);
  color: var(--sky-deep);
}
[data-theme="dark"] .day-title { color: var(--sky); }
.day-subtitle {
  margin: 2px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
}

/* ---------- Progress ---------- */
.progress-wrap { margin: 0 2px 18px; }
.progress-track {
  height: 16px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #4ade80);
  transition: width 0.4s ease;
}
.progress-text {
  margin: 6px 2px 0;
  font-size: 0.9rem;
  color: var(--text-soft);
  font-weight: 700;
}

/* ---------- Task list ---------- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.task-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  border: 3px solid transparent;
  position: relative;
  transition: transform 0.12s ease, border-color 0.2s ease;
}
.task-card.is-done {
  border-color: var(--green);
  background: linear-gradient(180deg, var(--surface), rgba(34, 197, 94, 0.1));
}

.task-check {
  flex: 0 0 auto;
  width: 78px;
  height: 78px;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  font-size: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s ease, background 0.2s ease;
  position: relative;
  line-height: 1;
}
.task-check:hover { transform: translateY(-2px); }
.task-check:active { transform: scale(0.92); }
.task-card.is-done .task-check {
  background: linear-gradient(180deg, #dcfce7, #bbf7d0);
}
.task-check .check-overlay {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--green-deep);
  color: #fff;
  font-size: 1.05rem;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.task-card.is-done .task-check .check-overlay { display: flex; }

.task-info {
  flex: 1 1 auto;
  min-width: 0;
}
.task-word {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text);
  overflow-wrap: break-word;
  word-break: break-word;
}
.task-card.is-done .task-word {
  text-decoration: line-through;
  text-decoration-color: var(--green);
  color: var(--text-soft);
}
.task-state {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.task-tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tool-btn {
  border: none;
  cursor: pointer;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-alt);
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: transform 0.12s ease, background 0.2s ease;
}
.tool-btn:hover { transform: translateY(-1px); }
.tool-btn:active { transform: scale(0.92); }
.tool-btn.delete:hover { background: #fde2e2; color: #b91c1c; }
[data-theme="dark"] .tool-btn.delete:hover { background: #4a2222; color: #fca5a5; }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 3px dashed var(--line);
}
.empty-emoji { font-size: 4rem; }
.empty-text {
  color: var(--text-soft);
  margin: 8px 0 18px;
  font-size: 1.05rem;
}

/* ---------- Buttons ---------- */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  padding: 13px 22px;
  border-radius: 16px;
  transition: transform 0.12s ease, filter 0.2s ease, background 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--sky), var(--sky-deep));
  color: #fff;
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.35);
}
.btn-ghost {
  background: var(--surface-alt);
  color: var(--text);
}
.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.3);
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(20px + var(--safe-bottom));
  width: 66px;
  height: 66px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sun), var(--sun-deep));
  color: #3a2c05;
  font-size: 2.4rem;
  line-height: 1;
  box-shadow: var(--shadow);
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s ease;
}
.fab:hover { transform: translateY(-2px) rotate(8deg); }
.fab:active { transform: scale(0.92); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(30, 25, 5, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.2s ease;
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; padding: 20px; }
}

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  animation: slideUp 0.26s ease;
}
@media (min-width: 560px) {
  .modal { border-radius: 28px; animation: popIn 0.22s ease; }
}
.modal-small { max-width: 380px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal-title {
  margin: 0;
  font-size: 1.3rem;
  color: var(--sky-deep);
}
[data-theme="dark"] .modal-title { color: var(--sky); }
.modal-close { width: 40px; height: 40px; font-size: 1.1rem; }

.modal-body { padding: 4px 20px 22px; }

.preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: linear-gradient(180deg, var(--surface-alt), var(--surface));
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 18px;
  border: 3px solid var(--line);
}
.preview-emoji { font-size: 3.4rem; line-height: 1; }
.preview-word { font-size: 1.4rem; font-weight: 800; }

.field-label {
  display: block;
  font-weight: 800;
  margin: 12px 0 7px;
  color: var(--text);
}
.text-input {
  width: 100%;
  font-family: inherit;
  font-size: 1.1rem;
  padding: 13px 15px;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: var(--surface-alt);
  color: var(--text);
}
.text-input:focus {
  border-color: var(--sky);
  outline: none;
}
.field-error {
  margin: 6px 2px 0;
  color: #dc2626;
  font-size: 0.85rem;
  font-weight: 700;
}
[data-theme="dark"] .field-error { color: #fca5a5; }

/* Emoji grid */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}
.emoji-cell {
  border: 3px solid transparent;
  background: var(--surface-alt);
  border-radius: 16px;
  font-size: 1.8rem;
  padding: 8px 0;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.2s ease;
  line-height: 1;
}
.emoji-cell:hover { transform: translateY(-2px); }
.emoji-cell[aria-checked="true"] {
  border-color: var(--sun-deep);
  background: var(--bg-soft);
}

/* Day picker */
.day-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.day-chip {
  border: 3px solid transparent;
  background: var(--surface-alt);
  border-radius: 14px;
  padding: 9px 14px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.1s ease, border-color 0.2s ease, background 0.2s ease;
}
.day-chip:hover { transform: translateY(-1px); }
.day-chip[aria-checked="true"] {
  border-color: var(--sky);
  background: var(--surface-alt);
  color: var(--sky-deep);
}
[data-theme="dark"] .day-chip[aria-checked="true"] { color: var(--sky); }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 22px;
}
.modal-actions .btn { flex: 1 1 auto; }
@media (min-width: 420px) {
  .modal-actions .btn { flex: 0 0 auto; }
}

.confirm-text { margin: 0 0 4px; color: var(--text-soft); }

/* ---------- Celebrate ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.celebrate-star {
  font-size: 8rem;
  animation: pop 0.9s ease forwards;
  filter: drop-shadow(0 8px 16px rgba(245, 158, 11, 0.5));
}
.confetti {
  position: fixed;
  top: -20px;
  font-size: 1.6rem;
  z-index: 199;
  pointer-events: none;
  animation: fall linear forwards;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 13px 20px;
  border-radius: 16px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 150;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pop {
  0% { transform: scale(0.2) rotate(-12deg); opacity: 0; }
  45% { transform: scale(1.25) rotate(6deg); opacity: 1; }
  70% { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(1.1) rotate(0); opacity: 0; }
}
@keyframes fall {
  to { transform: translateY(108vh) rotate(540deg); opacity: 0.2; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
.wiggle { animation: wiggle 0.4s ease; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .celebrate-star { animation: none; opacity: 1; }
  .confetti { display: none; }
}
