/* Barnevisning + innlogging. Skrevet for Safari 15 (iPad Air 2, iPadOS 15.8):
   grid, flex-gap og custom properties er trygt; CSS-nesting og container queries er ikke. */

:root {
  --bg: #fff8ec;
  --ink: #2b2b3a;
  --muted: #7a7a8c;
  --card: #ffffff;
  --accent: #4a90e2;
  --good: #2eb872;
  --wait: #f5a623;
  --radius: 28px;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---------- Velg barn ---------- */

.children-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  align-content: center;
}

.child-btn {
  min-height: 260px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff;
  font-size: 40px;
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}
.child-btn:active, .task-btn:active, .round-btn:active, .big-btn:active { transform: scale(0.96); }
.child-btn .icon { font-size: 110px; line-height: 1; text-shadow: none; }
.child-btn .balance {
  font-size: 26px;
  background: rgba(255, 255, 255, 0.25);
  padding: 6px 18px;
  border-radius: 999px;
}

/* ---------- Topplinje ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 34px; font-weight: 800; flex: 1; }
.topbar .who .icon { font-size: 56px; }
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 28px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
  padding: 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
}
.round-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  font-size: 40px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  flex: none;
}

/* ---------- Oppgaver ---------- */

.tasks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.task-btn {
  min-height: 220px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border: 6px solid transparent;
  transition: transform 0.1s;
}
.task-btn .icon { font-size: 96px; line-height: 1.1; }
.task-btn .name { font-size: 22px; font-weight: 700; text-align: center; }
.task-btn .value {
  font-size: 24px;
  font-weight: 800;
  color: #8a5a00;
  background: #ffe7a6;
  border-radius: 999px;
  padding: 4px 16px;
}
.task-btn.done-today { border-color: var(--good); }

.empty { text-align: center; font-size: 28px; color: var(--muted); padding: 40px; }

/* Denne ukas registreringer som små ikoner */
.week-strip {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 92px;
}
.week-strip .label { font-size: 22px; font-weight: 800; color: var(--muted); margin-right: 8px; }
.chip {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: #f1f1f6;
  font-size: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip .badge {
  position: absolute;
  right: -6px;
  bottom: -6px;
  font-size: 20px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---------- Historikk ---------- */

.big-balance {
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.big-balance .icon { font-size: 90px; line-height: 1; }
.big-balance .amount { font-size: 64px; font-weight: 900; }
.big-balance .pending { font-size: 26px; color: var(--wait); font-weight: 800; }

.list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list h2 { margin: 0; padding: 18px 22px 6px; font-size: 26px; }
.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-top: 1px solid #eee;
  font-size: 24px;
}
.row .grow { flex: 1; }
.row .amount { font-weight: 800; }
.row .pending { color: var(--wait); font-weight: 700; font-size: 20px; }

/* ---------- Overlays ---------- */

.overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(30, 30, 50, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 24px;
}
.dialog {
  background: var(--card);
  border-radius: 40px;
  padding: 36px;
  width: 100%;
  max-width: 560px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.dialog .icon { font-size: 150px; line-height: 1.1; }
.dialog .name { font-size: 36px; font-weight: 800; margin: 8px 0 28px; }
.dialog .actions { display: flex; gap: 20px; }

.big-btn {
  flex: 1;
  min-height: 110px;
  border-radius: 30px;
  font-size: 40px;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.1s;
}
.big-btn.yes { background: var(--good); flex: 2; }
.big-btn.no { background: #b9b9c8; }
.big-btn[disabled] { opacity: 0.6; }

/* Feiring */
.celebrate { background: rgba(255, 248, 236, 0.97); flex-direction: column; overflow: hidden; }
.celebrate .icon { font-size: 200px; line-height: 1; animation: pop 0.6s ease-out, wiggle 1s 0.6s ease-in-out infinite; }
.celebrate .text { font-size: 64px; font-weight: 900; color: var(--good); margin-top: 16px; }
.celebrate .plus { font-size: 44px; font-weight: 900; color: #8a5a00; margin-top: 8px; }
.celebrate .stars { font-size: 60px; margin-top: 12px; }

@keyframes pop {
  0% { transform: scale(0.2); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

.confetti {
  position: absolute;
  top: -30px;
  width: 16px;
  height: 26px;
  border-radius: 4px;
  animation-name: fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ---------- Innlogging ---------- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login form {
  background: var(--card);
  border-radius: 40px;
  box-shadow: var(--shadow);
  padding: 40px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.login .icon { font-size: 110px; line-height: 1; }
.login h1 { font-size: 34px; margin: 12px 0 24px; }
.login input {
  width: 100%;
  font-size: 36px;
  text-align: center;
  padding: 16px;
  border: 4px solid #e1e1ea;
  border-radius: 22px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login .big-btn { width: 100%; margin-top: 20px; background: var(--accent); }
.login .error { color: #d0021b; font-size: 22px; font-weight: 700; min-height: 30px; margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #d0021b;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  padding: 16px 28px;
  border-radius: 999px;
  z-index: 20;
}
