/* app.css — basisstijl volgens CONTRACTS.md sectie 7.
   Mobiel-first, vrolijk, dikke knoppen, safe-area voor iPhone-notch. */

:root {
  --kleur-primair: #58CC02;   /* groen */
  --kleur-accent: #1CB0F6;    /* blauw */
  --kleur-fout: #FF4B4B;      /* rood */
  --kleur-goud: #FFC800;      /* geel */
  --kleur-achtergrond: #FFF9F0; /* licht crème */
  --kleur-kaart: #FFFFFF;
  --kleur-tekst: #3C3C3C;
  --kleur-grijs: #E5E0D8;
  --kleur-grijs-donker: #AFA79B;
  --radius: 16px;
  --schaduw-hoogte: 4px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--kleur-tekst);
  background: var(--kleur-achtergrond);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0.4em 0;
}
h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 0.6em 0 0.3em;
}
p {
  margin: 0.4em 0;
}

/* ---------- Stats-bar ---------- */
#stats-bar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: var(--kleur-kaart);
  border-bottom: 2px solid var(--kleur-grijs);
  position: sticky;
  top: 0;
  z-index: 10;
}
#stats-bar.hidden {
  display: none;
}
.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.05rem;
}
.stat-icon {
  font-size: 1.2rem;
}

/* ---------- Scherm-container ---------- */
#screen {
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- Knoppen (dik, drukbaar) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 12px 22px;
  margin: 8px 0;
  width: 100%;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: var(--kleur-primair);
  box-shadow: 0 var(--schaduw-hoogte) 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active {
  transform: translateY(var(--schaduw-hoogte));
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.18);
}
.btn-primary {
  background: var(--kleur-primair);
}
.btn-secondary {
  background: var(--kleur-accent);
}
.btn-danger {
  background: var(--kleur-fout);
}

/* ---------- Melding / notice ---------- */
.notice {
  text-align: center;
  padding: 40px 20px;
}
.notice-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

/* ---------- Kaart-scherm (placeholder) ---------- */
.map-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.world-card {
  --wereld-kleur: var(--kleur-goud);
  background: var(--kleur-kaart);
  border: 3px solid var(--wereld-kleur);
  border-radius: var(--radius);
  padding: 14px;
}
.world-card.locked {
  opacity: 0.55;
  border-color: var(--kleur-grijs);
}
.world-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.world-emoji {
  font-size: 2rem;
}
.world-titles {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.world-title {
  font-weight: 800;
  font-size: 1.15rem;
}
.world-subtitle {
  font-size: 0.9rem;
  color: var(--kleur-grijs-donker);
}
.world-lock {
  font-size: 1.3rem;
}
.level-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.level-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--kleur-achtergrond);
  color: var(--kleur-tekst);
  text-decoration: none;
  font-weight: 700;
}
.level-item.done {
  background: #E7F7D8;
}
.level-item.disabled {
  color: var(--kleur-grijs-donker);
}
.settings-link {
  margin-top: 8px;
}

/* ---------- Les-scherm (placeholder) ---------- */
.lesson-screen {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
}
.lesson-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) 4px 8px;
}
.lesson-close {
  font-size: 1.4rem;
  text-decoration: none;
  color: var(--kleur-grijs-donker);
  line-height: 1;
}
.lesson-label {
  font-weight: 800;
}
.lesson-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.lesson-emoji {
  font-size: 3rem;
}
.lesson-body .btn {
  max-width: 340px;
}
.result-stars {
  font-size: 2.4rem;
  color: var(--kleur-goud);
  letter-spacing: 4px;
}
.result-line {
  font-weight: 800;
  font-size: 1.1rem;
}
.result-bonus {
  font-weight: 800;
  color: var(--kleur-accent);
}

/* ---------- Instellingen-scherm ---------- */
.settings-screen {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-back {
  text-decoration: none;
  color: var(--kleur-accent);
  font-weight: 800;
  padding: 6px 0;
}
.settings-block {
  background: var(--kleur-kaart);
  border: 2px solid var(--kleur-grijs);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 4px;
}
.settings-block.danger {
  border-color: var(--kleur-fout);
}
.settings-label {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
}
.settings-input,
.settings-textarea {
  width: 100%;
  padding: 12px;
  font-family: inherit;
  font-size: 1rem;
  border: 2px solid var(--kleur-grijs);
  border-radius: 12px;
  background: var(--kleur-achtergrond);
  color: var(--kleur-tekst);
}
.settings-textarea {
  min-height: 100px;
  resize: vertical;
  margin-top: 8px;
}
.settings-msg {
  min-height: 1.2em;
  font-weight: 700;
  color: var(--kleur-primair);
}

/* ---------- Toast-meldingen ---------- */
#toast-container {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 100;
  width: calc(100% - 32px);
  max-width: 420px;
  pointer-events: none; /* tikken gaat door de toasts heen */
}
.toast {
  background: var(--kleur-tekst);
  color: #fff;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  text-align: center;
  max-width: 100%;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.toast-in {
  opacity: 1;
  transform: translateY(0);
}
.toast.toast-out {
  opacity: 0;
  transform: translateY(12px);
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
    transform: none;
  }
  .toast.toast-in,
  .toast.toast-out {
    transform: none;
  }
}

/* ---------- Stats-bar: gedoofd vlammetje + freeze-voortgang ---------- */
.stat-icon.flame-cold {
  filter: grayscale(1);
  opacity: 0.45;
}
.stat-freeze {
  gap: 8px;
}
.freeze-progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.freeze-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--kleur-grijs);
  display: inline-block;
}
.freeze-dot.filled {
  background: var(--kleur-accent);
}
.freeze-count {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--kleur-grijs-donker);
}
.freeze-full {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--kleur-accent);
  background: #E3F4FD;
  border-radius: 8px;
  padding: 2px 7px;
}

/* ---------- Dev-sectie "Voor papa" ---------- */
.dev-section {
  background: var(--kleur-kaart);
  border: 2px dashed var(--kleur-grijs-donker);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 4px;
}
.dev-section > summary {
  cursor: pointer;
  font-weight: 800;
  padding: 14px;
  min-height: 44px;
  display: flex;
  align-items: center;
  -webkit-user-select: none;
  user-select: none;
}
.dev-body {
  padding: 0 14px 14px;
}
.dev-disclaimer {
  background: #FFF3D6;
  border: 2px solid var(--kleur-goud);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
}
.dev-json {
  background: var(--kleur-achtergrond);
  border: 2px solid var(--kleur-grijs);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  overflow-x: auto;
  margin: 0.4em 0;
}
.dev-note {
  font-size: 0.85rem;
  color: var(--kleur-grijs-donker);
}
.btn-dev {
  background: var(--kleur-grijs-donker);
  font-size: 0.95rem;
}

/* ---------- Emoji-plaatjes (OpenMoji, met tekst-fallback) ---------- */
/* De <img> erft de font-size van zijn wrapper (.mc-emoji/.tt-emoji/.banner-emoji),
   dus 1em = de bedoelde emoji-grootte. Valt de SVG weg, dan komt er via onerror
   een tekst-emoji terug die dezelfde font-size erft. */
.emoji-img {
  display: inline-block;
  width: 1em;
  height: 1em;
  object-fit: contain;
  vertical-align: middle;
}

/* ---------- Bronvermelding in instellingen ---------- */
.settings-credit {
  font-size: 0.8rem;
  color: var(--kleur-grijs-donker);
  text-align: center;
  margin: 1.2em 0 0.4em;
}

/* ---------- iOS-installatiehint (dismissbaar balkje) ---------- */
/* Alleen zichtbaar op de kaart (install-hint.js zet `hidden` op andere
   schermen). Rechts ruimte vrijhouden voor de zwevende ⚙️-knop (.map-gear:
   right ~14px + 54px breed) zodat die klikbaar blijft. */
.install-hint {
  position: fixed;
  left: 8px;
  right: calc(78px + env(safe-area-inset-right, 0px));
  max-width: 480px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--kleur-kaart);
  border: 2px solid var(--kleur-primair);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  font-size: 0.92rem;
  line-height: 1.3;
}
/* `display: flex` zou het `hidden`-attribuut overrulen — expliciet uitzetten,
   zodat een verborgen hint écht geen hit-area heeft. */
.install-hint[hidden] {
  display: none;
}
.install-hint-text {
  flex: 1;
}
.install-hint-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--kleur-grijs-donker);
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: 12px;
}
