/* ===========================================================
   Crêpe Tracker — palette brun / beige, vibe joyeuse & mignonne
   =========================================================== */
:root {
  --bg: #fdf3e3;
  --bg-2: #f7e4c8;
  --cream: #fffaf0;
  --brown-900: #3c2614;
  --brown-700: #5b3a20;
  --brown-600: #6f4a2a;
  --brown-500: #9c6b3f;
  --caramel: #d49a5a;
  --golden: #ecb56a;
  --golden-light: #f4c886;
  --butter: #ffd97a;
  --pink: #f4a0b5;
  --shadow: rgba(110, 70, 35, 0.18);
  --radius-lg: 28px;
  --font: "Baloo 2", ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--brown-900);
  background:
    radial-gradient(1200px 600px at 80% -10%, #ffe9c4 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #f9dcc0 0%, transparent 55%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ---------- doodles flottants en fond ---------- */
.bg-doodles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.doodle {
  position: absolute;
  font-size: 28px;
  opacity: 0.16;
  filter: saturate(0.85);
  animation: doodle-float var(--dur, 14s) ease-in-out infinite alternate;
  animation-delay: var(--delay, 0s);
}
@keyframes doodle-float {
  from { transform: translate(0, 0) rotate(-12deg) scale(1); }
  50%  { transform: translate(14px, -26px) rotate(8deg) scale(1.08); }
  to   { transform: translate(-10px, 12px) rotate(-6deg) scale(0.96); }
}

/* ---------- header ---------- */
.topbar {
  position: relative;
  z-index: 2;
  width: min(680px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 4px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-pan {
  width: 44px;
  height: 44px;
  flex: none;
  transform-origin: 70% 80%;
  animation: pan-rock 3.4s ease-in-out infinite;
}
@keyframes pan-rock {
  0%, 100% { transform: rotate(-4deg); }
  50%      { transform: rotate(5deg) translateY(-2px); }
}
.title {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.2px;
  color: var(--brown-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title .ch {
  display: inline-block;
  animation: ch-bounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i) * 40ms);
}
@keyframes ch-bounce {
  from { transform: translateY(14px) scale(0.6); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* ---------- toggle de langue ---------- */
.lang-toggle {
  position: relative;
  flex: none;
  display: flex;
  background: var(--cream);
  border: 2px solid #ecd9bd;
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 3px 10px var(--shadow);
}
.lang-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  color: var(--brown-500);
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s;
}
.lang-btn.active { color: #fff; }
.lang-pill {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  left: 3px;
  background: linear-gradient(145deg, var(--caramel), var(--brown-500));
  border-radius: 999px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lang-toggle.en .lang-pill { transform: translateX(100%); }

/* ---------- contenu ---------- */
.app {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 24px;
  flex: 1;
}
.tagline {
  margin: 2px 0 8px;
  font-weight: 700;
  color: var(--brown-500);
  font-size: 16px;
}

/* ---------- pile de crêpes ---------- */
.stack-zone {
  position: relative;
  width: min(340px, 86vw);
  margin-top: 4px;
}
.stack-svg-wrap svg { width: 100%; height: auto; display: block; }

.crepe-layer { transform-box: fill-box; transform-origin: center; }
.crepe-layer.drop {
  animation: crepe-drop 0.65s cubic-bezier(0.22, 1.4, 0.4, 1) both;
}
@keyframes crepe-drop {
  0%   { transform: translateY(-150px) rotate(-9deg) scale(1.05, 0.9); opacity: 0; }
  55%  { transform: translateY(6px) rotate(2deg) scale(0.96, 1.12); opacity: 1; }
  75%  { transform: translateY(-4px) scale(1.04, 0.92); }
  100% { transform: translateY(0) rotate(0) scale(1); }
}
.butter-pat {
  transform-box: fill-box;
  transform-origin: center;
  animation: butter-wobble 2.6s ease-in-out infinite;
}
@keyframes butter-wobble {
  0%, 100% { transform: rotate(-3deg) scale(1); }
  50%      { transform: rotate(4deg) scale(1.06, 0.95); }
}

.steam {
  position: absolute;
  top: -6%;
  width: 10px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.85));
  filter: blur(2px);
  opacity: 0;
  animation: steam-rise 2.8s ease-in-out infinite;
}
.steam-1 { left: 38%; animation-delay: 0s; }
.steam-2 { left: 50%; animation-delay: 0.9s; height: 42px; }
.steam-3 { left: 62%; animation-delay: 1.7s; }
@keyframes steam-rise {
  0%   { transform: translateY(16px) scaleY(0.6) rotate(-4deg); opacity: 0; }
  35%  { opacity: 0.8; }
  100% { transform: translateY(-30px) scaleY(1.25) rotate(5deg); opacity: 0; }
}
.stack-zone.cold .steam { display: none; }

.overflow-badge {
  position: absolute;
  top: 2%;
  right: -2%;
  background: linear-gradient(145deg, var(--pink), #e8849d);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  padding: 6px 14px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(220, 120, 145, 0.45);
  transform: rotate(8deg);
  animation: badge-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes badge-pop {
  from { transform: rotate(8deg) scale(0); }
  to   { transform: rotate(8deg) scale(1); }
}

/* ---------- compteur ---------- */
.counter { text-align: center; margin-top: -6px; }
.count-num {
  font-size: clamp(56px, 16vw, 84px);
  font-weight: 800;
  line-height: 1;
  color: var(--brown-700);
  text-shadow: 0 4px 0 #e8cfa9;
}
.count-num.pop { animation: count-pop 0.5s cubic-bezier(0.34, 1.8, 0.64, 1); }
@keyframes count-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35) rotate(-4deg); color: var(--caramel); }
  100% { transform: scale(1); }
}
.count-word {
  font-weight: 700;
  color: var(--brown-500);
  font-size: 18px;
  margin-top: 2px;
}
.empty-hint {
  margin: 10px 0 0;
  font-size: 14.5px;
  font-weight: 600;
  color: #b08a5e;
  animation: hint-sway 3s ease-in-out infinite;
}
@keyframes hint-sway {
  0%, 100% { transform: rotate(-1.2deg); }
  50%      { transform: rotate(1.2deg) translateY(-2px); }
}

/* ---------- gros bouton ---------- */
.big-btn {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  font: inherit;
  font-size: clamp(18px, 4.6vw, 23px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(160deg, #e2a763 0%, #c98a47 55%, #b27538 100%);
  border: 0;
  border-radius: 999px;
  padding: 16px 30px 16px 20px;
  cursor: pointer;
  box-shadow:
    0 7px 0 #8a5a36,
    0 16px 28px var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s;
  animation: btn-breathe 3.2s ease-in-out infinite;
}
@keyframes btn-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.025); }
}
.big-btn:hover { filter: brightness(1.06); }
.big-btn:active,
.big-btn.pressed {
  transform: translateY(5px) scale(0.97);
  box-shadow: 0 2px 0 #8a5a36, 0 6px 12px var(--shadow);
  animation: none;
}
.btn-pan { width: 58px; height: 41px; flex: none; }
.btn-pan-g { transform-origin: 40% 70%; }
.big-btn.cooking .btn-pan-g { animation: pan-shake 0.5s ease-in-out; }
@keyframes pan-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-9deg) translateY(2px); }
  60% { transform: rotate(6deg) translateY(-2px); }
}
.btn-crepe { transform-box: fill-box; transform-origin: center; }
.big-btn.cooking .btn-crepe { animation: crepe-flip 0.5s ease-in-out; }
@keyframes crepe-flip {
  0%   { transform: translateY(0) rotateX(0); }
  50%  { transform: translateY(-26px) rotateX(180deg); }
  100% { transform: translateY(0) rotateX(360deg); }
}
.btn-label { text-shadow: 0 2px 0 rgba(90, 55, 25, 0.35); }

/* ---------- bouton annuler ---------- */
.undo-btn {
  margin-top: 14px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--brown-500);
  background: rgba(255, 250, 240, 0.7);
  border: 2px dashed #d9bd97;
  border-radius: 999px;
  padding: 6px 16px;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.undo-btn:hover { transform: scale(1.05) rotate(-1deg); background: var(--cream); }

/* ---------- stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 460px;
  margin-top: 30px;
}
.stat-card {
  background: var(--cream);
  border: 2px solid #f0dec0;
  border-radius: var(--radius-lg);
  padding: 14px 8px 12px;
  text-align: center;
  box-shadow: 0 6px 16px var(--shadow);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-5px) rotate(-1deg); box-shadow: 0 12px 22px var(--shadow); }
.stat-emoji { font-size: 24px; }
.stat-num {
  font-size: 28px;
  font-weight: 800;
  color: var(--brown-700);
  line-height: 1.1;
}
.stat-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brown-500);
}

/* ---------- footer ---------- */
.footer {
  position: relative;
  z-index: 1;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  font-size: 13px;
  font-weight: 600;
  color: #bb9468;
}

/* ---------- toast jalon ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, calc(100% + 60px));
  opacity: 0;
  background: linear-gradient(150deg, var(--brown-600), var(--brown-900));
  color: #ffe9c4;
  font-weight: 800;
  font-size: 16px;
  padding: 14px 24px;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(60, 38, 20, 0.4);
  z-index: 50;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
.toast.show { transform: translate(-50%, 0) rotate(-1deg); opacity: 1; }

/* ---------- particules & éléments volants (créés en JS) ---------- */
.confetti {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  font-size: 20px;
  will-change: transform, opacity;
}
.confetti-dot { width: 10px; height: 10px; border-radius: 50%; }
.fly-crepe {
  position: fixed;
  z-index: 41;
  width: 64px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 38%, #f4c886 0%, #ecb56a 55%, #c8863f 100%);
  box-shadow: 0 3px 6px rgba(90, 55, 25, 0.3);
  pointer-events: none;
  will-change: transform;
}
.float-word {
  position: fixed;
  z-index: 42;
  font-weight: 800;
  font-size: 20px;
  color: var(--caramel);
  text-shadow: 0 1px 0 #fff;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- accessibilité : réduire les animations ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 420px) {
  .stats { gap: 8px; }
  .stat-card { border-radius: 20px; }
}
