/* ============================================================
   TRI SWIPE — direction visuelle
   Fond nuit (collecte des sacs en soirée à Bruxelles) sur lequel
   les 4 couleurs de sacs officielles ressortent comme la seule
   vraie palette du site. Les cartes reprennent le détail du sac
   noué (pastille/oeillet en haut), et le verdict s'affiche comme
   un tampon de centre de tri.
   ============================================================ */

:root {
  --bg: #14161b;
  --bg-elevated: #1c1f26;
  --paper: #f5f3ee;
  --ink: #14161b;
  --muted: #9ca0aa;
  --line: #2a2e37;

  --blanc: #f5f3ee;
  --blanc-ink: #14161b;
  --bleu: #2f6fed;
  --jaune: #ffc93c;
  --orange: #ff7a29;

  --good: #35c98f;
  --bad: #ff5e5e;

  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(circle at 20% 0%, rgba(47, 111, 237, 0.10), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(255, 122, 41, 0.10), transparent 40%);
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 32px;
  min-height: 100dvh;
}

.screen { display: none; flex: 1; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Header / branding ---------- */
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}
.brand-mark span { color: var(--orange); }
.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 24px 0 6px;
}

h1.title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  line-height: 1.15;
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

p.lede {
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
  margin: 0 0 20px;
}

/* ---------- Bag picker ---------- */
.bag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.bag-card {
  position: relative;
  border: none;
  border-radius: 18px;
  padding: 22px 16px 18px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 30px;
  font-family: var(--font-body);
  transition: transform 0.15s ease;
}
.bag-card:active { transform: scale(0.97); }

.bag-card .knot {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
}

.bag-card .bag-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}
.bag-card .bag-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bag-card[data-bag="blanc"] { background: var(--blanc); color: var(--blanc-ink); }
.bag-card[data-bag="bleu"] { background: var(--bleu); color: white; }
.bag-card[data-bag="jaune"] { background: var(--jaune); color: var(--blanc-ink); }
.bag-card[data-bag="orange"] { background: var(--orange); color: white; }

/* ---------- Game screen ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.hud-bag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.hud-bag .dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.hud-score {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--paper);
}

.progress-track {
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 24px;
}
.progress-fill {
  height: 100%;
  background: var(--good);
  width: 0%;
  transition: width 0.3s ease;
}

.card-stack {
  position: relative;
  flex: 1;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waste-card {
  position: absolute;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 3 / 4;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 28px;
  user-select: none;
  touch-action: pan-y;
  will-change: transform;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
}

.waste-card .tie {
  position: absolute;
  top: -8px;
  width: 34px;
  height: 16px;
  border-radius: 10px;
  background: var(--line);
}

.waste-card .emoji {
  font-size: 4.2rem;
  line-height: 1;
}

.waste-card .label {
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.25;
}

.waste-card .question {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}

.stamp {
  position: absolute;
  top: 30px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.05em;
  padding: 6px 16px;
  border: 4px solid currentColor;
  border-radius: 8px;
  transform: rotate(-12deg);
  opacity: 0;
  text-transform: uppercase;
}
.stamp.yes { right: 20px; color: var(--good); }
.stamp.no { left: 20px; color: var(--bad); }

.score-popup {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 4.5rem;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 999;
  animation: scorePopupAnim 1.5s ease forwards;
}
.score-popup.plus { color: var(--good); }
.score-popup.minus { color: var(--bad); }

@keyframes scorePopupAnim {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  15% { opacity: 1; transform: translate(-50%, -52%) scale(1.15); }
  25% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -65%) scale(1); }
}

.swipe-actions {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-top: 22px;
}
.swipe-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  color: var(--paper);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.swipe-btn.no { color: var(--bad); }
.swipe-btn.yes { color: var(--good); }
.swipe-btn:active { transform: scale(0.92); }

.swipe-legend {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 10px;
  max-width: 340px;
  margin-inline: auto;
  width: 100%;
}

/* ---------- Result screen ---------- */
.result-score {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 800;
  margin: 6px 0 2px;
}
.result-score span { color: var(--muted); font-size: 1.6rem; font-weight: 500; }

.result-msg { color: var(--muted); margin-bottom: 24px; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-field label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.form-field input {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 0.98rem;
}
.form-field input:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--orange); color: white; }
.btn-secondary {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  margin-top: 10px;
}

.form-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.4;
}

.form-error {
  color: var(--bad);
  font-size: 0.8rem;
  min-height: 1em;
  margin-top: -6px;
  margin-bottom: 8px;
}

/* ---------- Leaderboard ---------- */
.leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.leaderboard-item.me { border-color: var(--orange); }
.rank {
  font-family: var(--font-mono);
  font-weight: 700;
  width: 26px;
  text-align: center;
  color: var(--muted);
}
.leaderboard-item:nth-child(1) .rank { color: var(--jaune); }
.leaderboard-item:nth-child(2) .rank { color: #d7d7d7; }
.leaderboard-item:nth-child(3) .rank { color: #cd8a53; }

.lb-info { flex: 1; }
.lb-name { font-weight: 600; font-size: 0.92rem; }
.lb-bag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
}
.lb-score {
  font-family: var(--font-mono);
  font-weight: 700;
}

.demo-banner {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--jaune);
  border: 1px dashed var(--jaune);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 16px;
  line-height: 1.4;
}

.spinner-row {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
