/* Dasar tata letak, tipografi, dan komponen umum. Semua warna dari tokens.css. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.4;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  transition: background-color 0.3s;
}

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

img,
svg {
  display: block;
}

[hidden] {
  display: none !important;
}

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

#app {
  min-height: 100dvh;
}

/* ---------- Layar ---------- */

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 720px;
  margin: 0 auto;
  animation: masuk 0.35s ease-out;
}

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

/* Latar langit + bukit + jalan setapak (ui/latar.js) */
.latar {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--c-langit-bawah);
}
.latar__alam {
  width: 100%;
  height: 100%;
}
.latar__hiasan {
  position: absolute;
  left: 0;
  animation: melayang linear infinite;
  will-change: transform;
}
.latar__hiasan img {
  width: 100%;
  height: auto;
  opacity: 0.9;
}
@keyframes melayang {
  from {
    transform: translateX(-140px);
  }
  to {
    transform: translateX(calc(100vw + 20px));
  }
}

/* Top bar: pill putih dengan bayangan bawah tipis */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: calc(var(--tap) + 8px);
  padding: 4px;
  border-radius: 999px;
  background: var(--c-surface);
  box-shadow: 0 3px 0 var(--c-line);
}
.topbar .btn {
  box-shadow: none;
  background: transparent;
}
.topbar .btn:active {
  transform: scale(0.94);
}
.topbar__title {
  flex: 1;
  margin: 0;
  font-size: 1.4rem;
  text-align: center;
}

@keyframes masuk {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* ---------- Teks ---------- */

.title {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
}
.lead {
  margin: 0;
  font-size: 1.25rem;
  color: var(--c-ink-soft);
}
.small {
  font-size: 0.95rem;
  color: var(--c-ink-soft);
}
.error-text {
  min-height: 1.4em;
  margin: 0;
  color: var(--c-danger);
  font-weight: 700;
}

/* ---------- Ikon ---------- */

.ikon {
  width: 1.4em;
  height: 1.4em;
  flex: none;
}

/* ---------- Tombol: tebal, membulat, "bisa ditekan" ---------- */

.btn {
  --btn-bg: var(--c-surface);
  --btn-ink: var(--c-ink);
  --btn-edge: var(--c-line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 24px;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--btn-bg);
  color: var(--btn-ink);
  box-shadow: var(--shadow-drop) var(--btn-edge);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active {
  transform: translateY(var(--tekan));
  box-shadow: 0 2px 0 var(--btn-edge);
}
.btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.btn--primary {
  --btn-bg: var(--c-primary);
  --btn-ink: var(--c-primary-ink);
  --btn-edge: var(--c-primary-dark);
}
.btn--accent {
  --btn-bg: var(--c-accent);
  --btn-ink: var(--c-accent-ink);
  --btn-edge: var(--c-accent-dark);
}
.btn--block {
  width: 100%;
}
.btn--big {
  min-height: 96px;
  font-size: 1.5rem;
  border-radius: var(--radius-l);
}
.btn--icon {
  width: var(--tap);
  padding: 0;
  border-radius: 50%;
}
.btn--text {
  min-height: 48px;
  background: none;
  box-shadow: none;
  color: var(--c-ink-soft);
  text-decoration: underline;
  font-weight: 400;
  font-size: 1rem;
}
.btn--text:active {
  transform: none;
  box-shadow: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 420px;
}

/* ---------- Form (untuk orang tua) ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.field input {
  min-height: 56px;
  padding: 10px 16px;
  border: 3px solid var(--c-line);
  border-radius: var(--radius-s);
  background: var(--c-surface);
  font-size: 1.1rem;
}
.field input:focus {
  border-color: var(--c-primary);
  outline: none;
}

/* ---------- Kartu ---------- */

.card {
  padding: 20px;
  border-radius: var(--radius-l);
  background: var(--c-surface);
  box-shadow: var(--shadow-drop) var(--c-line);
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
}

/* ---------- Karakter ---------- */

.karakter {
  width: 140px;
  height: 140px;
}
.karakter--kecil {
  width: 72px;
  height: 72px;
}
.karakter--gerak {
  animation: lompat 0.9s var(--ease-bounce);
}
@keyframes lompat {
  30% {
    transform: translateY(-18px) rotate(-4deg);
  }
  60% {
    transform: translateY(0) rotate(3deg);
  }
}

/* ---------- Profil anak ---------- */

.profil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  width: 100%;
}
.profil-btn {
  flex-direction: column;
  min-height: 150px;
  padding: 16px 8px;
  border-radius: var(--radius-l);
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}
.profil-btn .karakter--kecil {
  pointer-events: none;
}
.profil-btn--baru {
  --btn-bg: transparent;
  --btn-edge: transparent;
  border: 3px dashed var(--c-line);
  color: var(--c-ink-soft);
}

/* ---------- Pilih tema ---------- */

.tema-list {
  display: grid;
  gap: 16px;
  width: 100%;
}
@media (min-width: 640px) {
  .tema-list {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tema-btn {
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: var(--radius-l);
  border: 4px solid transparent;
  /* tombol membawa data-theme sendiri, jadi token di bawah memakai warna tema itu */
  --btn-bg: var(--c-bg-deep);
  --btn-ink: var(--c-ink);
  --btn-edge: var(--c-primary-dark);
}
.tema-btn[data-theme='laut'],
.tema-btn[data-theme='balon'] {
  --btn-bg: var(--c-langit-atas);
}
.tema-btn[aria-pressed='true'] {
  border-color: var(--c-ink);
}
.tema-btn img {
  width: 110px;
  height: 110px;
}
.tema-pilih .btn[aria-pressed='true'] {
  --btn-bg: var(--c-primary);
  --btn-ink: var(--c-primary-ink);
  --btn-edge: var(--c-primary-dark);
}

/* ---------- Home ---------- */

.home-mode {
  display: grid;
  gap: 18px;
  width: 100%;
}
@media (min-width: 640px) {
  .home-mode {
    grid-template-columns: 1fr 1fr;
  }
}
.home-mode .btn {
  flex-direction: column;
  min-height: 160px;
}
.home-mode .ikon {
  width: 48px;
  height: 48px;
}

/* ---------- Gerbang orang tua (dialog) ---------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.45);
  animation: fade 0.2s;
}
.dialog__box {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.dialog__box .stack {
  max-width: none;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- Menu orang tua ---------- */

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.menu-list .btn {
  justify-content: flex-start;
}
.tema-pilih {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tema-pilih .btn {
  flex: 1;
  min-width: 100px;
}

.progres-anak {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.progres-anak li {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.progres-anak__label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.ikon-bintang {
  width: 28px;
  height: 28px;
}
.bar {
  height: 14px;
  border-radius: 7px;
  background: var(--c-bg-deep);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--c-primary);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
