/* ============================================================
   Bacoco Mlimizi — le jardin d'épices
   Feuille de style unique (tokens + composants). Aucun build.
   « épices saturées, heure dorée », cadre kanga/saluva mahorais.
   ============================================================ */

:root {
  /* feuillage profond */
  --bg-1: #1f4a2e;
  --bg-2: #143020;

  /* terre */
  --soil: #5a3a24;
  --soil-2: #4a2f1c;
  --soil-rim: #3a2516;

  /* feuilles */
  --leaf: #56a85f;
  --leaf-d: #2f6b3d;

  /* accents épices */
  --turmeric: #f4b53c; /* curcuma — accent principal / pièces */
  --piment: #e2533a; /* piment rouge */
  --vanilla: #f5ead0; /* crème — texte */
  --cardamom: #9ad17f;

  /* surfaces */
  --card: #20402b;
  --card-2: #18331f;
  --ink: #122318;

  /* dérivés */
  --text: var(--vanilla);
  --text-dim: #cdbf9e;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-s: 0 4px 12px rgba(0, 0, 0, 0.3);

  /* typographie (Baloo 2 / Nunito si dispo, sinon système) */
  --font-title: "Baloo 2", system-ui, "Segoe UI", sans-serif;
  --font-body: "Nunito", system-ui, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(120% 90% at 50% -10%, #2a6b3f 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

h1,
h2,
h3 {
  font-family: var(--font-title);
  font-weight: 700;
  margin: 0;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  color: var(--ink);
}

/* ---------- Layout ---------- */
#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 12px 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100dvh;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.hud__title {
  font-size: 1.25rem;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud__title small {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
/* sur écran étroit, on retire le sous-titre pour laisser la place au bouton retour */
@media (max-width: 400px) {
  .hud__title small {
    display: none;
  }
}

.back-link {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(244, 181, 60, 0.35);
  color: var(--turmeric);
  text-decoration: none;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  padding-bottom: 3px;
  transition: transform 0.08s ease;
}
.back-link:active {
  transform: translateY(1px);
}
.back-link:focus-visible {
  outline: 3px solid var(--turmeric);
  outline-offset: 2px;
}

.hud__right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(244, 181, 60, 0.35);
  color: var(--turmeric);
  flex: 0 0 auto;
}
.mute svg {
  width: 20px;
  height: 20px;
  display: block;
}
.mute .ico-off {
  display: none;
}
body.muted .mute {
  color: var(--text-dim);
}
body.muted .mute .ico-on {
  display: none;
}
body.muted .mute .ico-off {
  display: block;
}
.mute:focus-visible {
  outline: 3px solid var(--turmeric);
  outline-offset: 2px;
}

.coins {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(244, 181, 60, 0.35);
  color: var(--turmeric);
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}
.coins .day {
  white-space: nowrap;
}
.coins svg {
  width: 18px;
  height: 18px;
  display: block;
}
.coins .day {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.8rem;
}

/* ---------- Dialogue Bacoco ---------- */
.dialogue {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-s);
  min-height: 86px;
}
.dialogue__portrait {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--ink);
  overflow: hidden;
  border: 2px solid rgba(244, 181, 60, 0.4);
}
.dialogue__portrait svg {
  width: 100%;
  height: 100%;
  display: block;
}
.dialogue__bubble {
  flex: 1;
  align-self: center;
}
.dialogue__name {
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--turmeric);
  font-size: 0.95rem;
  line-height: 1.1;
}
.dialogue__text {
  margin-top: 2px;
  font-size: 0.98rem;
  line-height: 1.32;
  color: var(--text);
}
.dialogue__text b {
  color: var(--turmeric);
}

/* ---------- Cadre + bordure kanga ---------- */
.field-frame {
  position: relative;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: var(--shadow);
}
/* bandes kanga (triangles turmeric/piment/crème) */
.kanga {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 7px;
  background:
    repeating-linear-gradient(
        45deg,
        var(--turmeric) 0 10px,
        var(--piment) 10px 20px,
        var(--vanilla) 20px 30px
      )
      border-box;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ---------- Jardin (grille) ---------- */
.field {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-s);
  background:
    repeating-linear-gradient(
      90deg,
      var(--soil) 0 calc(100% / 18),
      var(--soil-2) calc(100% / 18) calc(100% / 9)
    );
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
}
.cell {
  position: relative;
  padding: 0;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}
.cell:focus-visible {
  outline: 3px solid var(--turmeric);
  outline-offset: -3px;
  z-index: 3;
}
/* plant container in a planted cell */
.cell__plant {
  position: absolute;
  inset: 6%;
  display: none;
}
.cell.is-planted .cell__plant {
  display: block;
}
.cell__plant svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* pousse → mûr */
.cell.is-young .cell__plant {
  transform: scale(0.55);
  transform-origin: bottom center;
  opacity: 0.85;
  transition:
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.7s ease;
}
.cell.is-ripe .cell__plant {
  transform: scale(1);
  opacity: 1;
}
.cell.is-ripe::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 181, 60, 0.35), transparent 70%);
  animation: halo 2.4s ease-in-out infinite;
  pointer-events: none;
}
.cell.is-faded .cell__plant {
  opacity: 0.4;
  filter: saturate(0.6);
}
/* surbrillance « compter ensemble » */
.cell.is-counting::before {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 8px;
  background: rgba(244, 181, 60, 0.55);
  box-shadow: 0 0 14px 3px rgba(244, 181, 60, 0.6);
  animation: pop 0.3s ease;
  z-index: 2;
}

/* rectangle de tracé live */
.tracer {
  position: absolute;
  border: 2.5px dashed var(--turmeric);
  background: rgba(244, 181, 60, 0.14);
  border-radius: 6px;
  pointer-events: none;
  display: none;
  z-index: 4;
}
.tracer.is-bad {
  border-color: var(--piment);
  background: rgba(226, 83, 58, 0.18);
}
.tracer__count {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(1.2rem, 7vw, 2.2rem);
  color: var(--vanilla);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
.tracer.is-bad .tracer__count {
  color: #ffd9cf;
}

/* maki qui traverse */
.visitor {
  position: absolute;
  bottom: 4%;
  left: -20%;
  width: 16%;
  z-index: 5;
  pointer-events: none;
}
.visitor svg {
  width: 100%;
  height: auto;
  display: block;
}
.visitor.is-walking {
  animation: walk 4s linear forwards;
}

/* ---------- Hint / commande ---------- */
.order-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  color: var(--text-dim);
  font-size: 0.92rem;
}
.order-hint .dims {
  color: var(--turmeric);
  font-size: 1.1rem;
  font-family: var(--font-title);
}
.order-hint .species-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* Repère visuel de transition : nouvelle commande / nouvelle question */
.dialogue.cue-new,
.order-hint.cue-new,
.btn--harvest.cue-new {
  animation: cueNew 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cueNew {
  0% {
    transform: scale(0.96);
    box-shadow: 0 0 0 0 rgba(244, 181, 60, 0);
  }
  45% {
    transform: scale(1.025);
    box-shadow: 0 0 0 3px rgba(244, 181, 60, 0.6);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(244, 181, 60, 0);
  }
}

/* fallback clavier */
.kbd-fallback {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.kbd-fallback input {
  width: 48px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--ink);
  color: var(--vanilla);
}
.kbd-fallback button {
  background: var(--leaf-d);
  color: var(--vanilla);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 800;
}

/* ---------- Boutons généraux ---------- */
.btn {
  background: var(--turmeric);
  color: var(--ink);
  font-weight: 800;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1rem;
  box-shadow: var(--shadow-s);
  transition: transform 0.12s ease;
}
.btn:active {
  transform: translateY(2px);
}
.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn--harvest {
  background: var(--piment);
  color: var(--vanilla);
  width: 100%;
}

/* ---------- Modal récolte ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 18, 12, 0.72);
  backdrop-filter: blur(2px);
  z-index: 50;
}
.modal.is-open {
  display: flex;
}
.modal__card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(244, 181, 60, 0.25);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: rise 0.25s ease;
}
.modal__card.is-shaking {
  animation: shake 0.4s ease;
}
.modal__q {
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.3;
}
.modal__q b {
  color: var(--turmeric);
}

/* grille de pieds mûrs visible (échafaudage) */
.harvest-grid {
  display: grid;
  gap: 3px;
  justify-content: center;
  padding: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  max-height: 38vh;
}
.harvest-grid .pip {
  width: clamp(14px, 4.6vw, 26px);
  aspect-ratio: 1;
}
.harvest-grid .pip svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.harvest-grid .pip.is-counting {
  filter: drop-shadow(0 0 6px var(--turmeric));
  transform: scale(1.18);
  transition: transform 0.12s ease;
}

/* affichage de la saisie */
.answer {
  text-align: center;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: 4px;
  min-height: 2.4rem;
  color: var(--vanilla);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 6px;
}
.answer:empty::before {
  content: "—";
  color: var(--text-dim);
}

/* pavé numérique */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.numpad button {
  background: var(--leaf-d);
  color: var(--vanilla);
  font-weight: 800;
  font-size: 1.3rem;
  padding: 14px 0;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}
.numpad button:active {
  transform: translateY(2px);
}
.numpad .key--ok {
  background: var(--turmeric);
  color: var(--ink);
}
.numpad .key--del {
  background: var(--soil);
}

.modal__help {
  background: transparent;
  color: var(--cardamom);
  border: 1px solid rgba(154, 209, 127, 0.4);
  font-weight: 800;
  padding: 10px;
  border-radius: 12px;
  font-size: 0.92rem;
}

/* ---------- avatar enfant ---------- */
.avatar {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 56px;
  height: 56px;
  z-index: 20;
  pointer-events: none;
}
.avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}
.avatar.react-plant {
  animation: avatarHop 0.5s ease;
}
.avatar.react-harvest {
  animation: avatarJoy 0.6s ease;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  width: max-content;
  max-width: 90vw;
}
.toast {
  background: var(--ink);
  border: 1px solid rgba(244, 181, 60, 0.4);
  color: var(--vanilla);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow);
  animation:
    rise 0.25s ease,
    fade 0.4s ease 2.6s forwards;
  text-align: center;
}

/* ---------- Écran d'accueil ---------- */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(120% 90% at 50% -10%, #2a6b3f 0%, var(--bg-1) 45%, var(--bg-2) 100%);
}
.welcome.is-hidden {
  display: none;
}
.welcome__logo {
  width: 120px;
  height: 120px;
}
.welcome h1 {
  font-size: 2.1rem;
  line-height: 1.1;
  color: var(--turmeric);
}
.welcome__tag {
  margin: -10px 0 0 !important;
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--cardamom);
  font-size: 1.05rem;
}
.welcome p {
  max-width: 320px;
  color: var(--text);
  line-height: 1.4;
}

/* permettre le défilement si le contenu (tutoriel) dépasse l'écran */
.welcome {
  overflow-y: auto;
}
.welcome--onboard {
  justify-content: flex-start;
  gap: 14px;
  padding-top: 32px;
}

/* champ prénom (création de compte) */
.name-input {
  width: min(280px, 80vw);
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid rgba(244, 181, 60, 0.5);
  background: var(--ink);
  color: var(--vanilla);
}
.name-input::placeholder {
  color: var(--text-dim);
  font-weight: 600;
}
.name-input:focus {
  outline: none;
  border-color: var(--turmeric);
}
.name-input.shake {
  animation: shake 0.4s ease;
}

/* choix du jardinier (multi-profils) */
.profile-list {
  list-style: none;
  margin: 4px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 90vw);
}
.profile-card {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.profile-pick {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 14px;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.profile-pick:hover,
.profile-pick:focus-visible {
  border-color: var(--turmeric);
  transform: translateY(-1px);
  outline: none;
}
.profile-ava {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink);
  display: grid;
  place-items: center;
}
.profile-ava svg {
  width: 100%;
  height: 100%;
  display: block;
}
.profile-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--vanilla);
}
.profile-del {
  flex: 0 0 auto;
  width: 44px;
  border-radius: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  display: grid;
  place-items: center;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.profile-del:hover,
.profile-del:focus-visible {
  color: #e7796b;
  border-color: #e7796b;
  outline: none;
}
.profile-del svg {
  width: 20px;
  height: 20px;
}

/* étapes du tutoriel */
.steps {
  list-style: none;
  margin: 4px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, 90vw);
  text-align: left;
}
.steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.3;
  font-size: 0.96rem;
}
.steps b {
  color: var(--turmeric);
}
.step-ico {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink);
  display: grid;
  place-items: center;
}
.step-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}
.onboard-note {
  max-width: 360px;
  color: var(--cardamom);
  font-weight: 700;
  font-size: 0.92rem;
}

/* bilan de fin de journée */
.bilan-stats {
  list-style: none;
  margin: 4px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, 90vw);
}
.bilan-stats li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.98rem;
  text-align: left;
}
.bilan-stats b {
  color: var(--turmeric);
  font-size: 1.15rem;
}
.bilan-ico {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
}
.bilan-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Animations ---------- */
@keyframes halo {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}
@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
@keyframes fade {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-9px);
  }
  40% {
    transform: translateX(8px);
  }
  60% {
    transform: translateX(-6px);
  }
  80% {
    transform: translateX(4px);
  }
}
@keyframes walk {
  to {
    left: 110%;
  }
}
@keyframes avatarHop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-12px) rotate(-4deg);
  }
}
@keyframes avatarJoy {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.15) rotate(6deg);
  }
  70% {
    transform: scale(1.05) rotate(-4deg);
  }
  100% {
    transform: scale(1);
  }
}

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

/* ---------- Responsive ---------- */
@media (min-width: 480px) {
  .hud__title {
    font-size: 1.45rem;
  }
}
