/* ============================================
   On grimpe aujourd'hui ? — Styles
   Thème : topo papier épinglé devant une
   vraie paroi rocheuse (photo).
   ============================================ */

:root {
  --ink: #2b241c;
  --paper: #fbf3e3;
  --paper-edge: #e9dcc0;
  --rust: #c0562c;
  --rust-dark: #9c4020;
  --moss: #3f7a5c;
  --moss-dark: #285d42;
  --sun-glow: #ffb347;
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  color: var(--ink);
  position: relative;
  overflow-x: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: #1c1108;
}

h1, h2 { font-family: 'Baloo 2', cursive; }

/* ---------------- Décor : photo de falaise en fond ---------------- */
.bg-photo {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url('../images/bg-climber.jpg');
  background-size: cover;
  background-position: 82% 55%;
  transform: scale(1.02);
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(20,10,5,0.55) 0%, rgba(20,10,5,0.25) 35%, rgba(20,10,5,0.6) 100%),
    linear-gradient(90deg, rgba(15,8,4,0.55) 0%, rgba(15,8,4,0.15) 45%, rgba(15,8,4,0.1) 100%);
}

/* ---------------- Structure principale ---------------- */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.badge {
  background: var(--ink);
  color: #ffe9c7;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  padding: 8px 18px;
  border-radius: 999px;
  border: 2px dashed #ffe9c7;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}

.board {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.pin {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 35% 30%, #ff8a65, var(--rust-dark));
  border-radius: 50%;
  box-shadow: 0 4px 6px rgba(0,0,0,0.4);
  z-index: 5;
}

.pin::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 9px;
  width: 2px;
  height: 14px;
  background: #7a5230;
}

/* ---------------- La carte "topo" ---------------- */
/* NOTE : pas de transform ici (rotate, scale...) — un transform sur cet
   ancêtre transformerait le repère de positionnement des enfants en
   position:fixed (dont le bouton "Non" qui doit fuir à l'écran), ce qui
   le ferait disparaître hors champ dès le premier mouvement. */
.topo-card {
  position: relative;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(43,36,28,0.05) 27px 28px),
    var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 34px 26px 24px;
  width: 100%;
  text-align: center;
  box-shadow:
    0 2px 0 var(--paper-edge) inset,
    0 22px 50px rgba(0,0,0,0.55);
}

.topo-card::before {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, transparent 50%, var(--paper-edge) 50%);
  border-bottom-right-radius: var(--radius);
}

.grade-tag {
  display: inline-block;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--rust-dark);
  background: #fff;
  border: 2px solid var(--rust);
  border-radius: 8px;
  padding: 4px 12px;
  margin: 0 0 14px;
}

.topo-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.75rem, 6.2vw, 2.5rem);
  line-height: 1.15;
  color: var(--ink);
}

.subtitle {
  margin: 0 0 20px;
  font-size: 0.95rem;
  color: #6b5d47;
  font-weight: 600;
}

.note {
  min-height: 26px;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--rust-dark);
  margin-bottom: 14px;
  transition: transform 0.15s ease;
}

/* ---------------- Arène de boutons ---------------- */
.arena {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
  min-height: 190px;
  padding: 6px;
}

.btn {
  border: none;
  border-radius: 12px;
  font-family: 'Baloo 2', cursive;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s ease, font-size 0.25s ease, padding 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-oui {
  background: linear-gradient(135deg, var(--moss) 0%, var(--moss-dark) 100%);
  color: #fff8ec;
  font-size: 1.35rem;
  padding: 19px 44px;
  box-shadow: 0 8px 0 #1c4530, 0 16px 26px rgba(0,0,0,0.3);
  border: 2px solid #1c4530;
}

.btn-oui:hover { transform: translateY(-4px) scale(1.03); }
.btn-oui:active {
  transform: translateY(3px);
  box-shadow: 0 5px 0 #1c4530, 0 8px 14px rgba(0,0,0,0.25);
}

/* Le bouton OUI grandit par paliers à mesure que le Non est esquivé */
.btn-oui.grow-1 { font-size: 1.5rem; padding: 22px 50px; }
.btn-oui.grow-2 { font-size: 1.7rem; padding: 25px 56px; box-shadow: 0 10px 0 #1c4530, 0 18px 30px rgba(0,0,0,0.35); }
.btn-oui.grow-3 { font-size: 1.95rem; padding: 28px 62px; box-shadow: 0 12px 0 #1c4530, 0 20px 34px rgba(0,0,0,0.4); }
.btn-oui.grow-4 { font-size: 2.2rem; padding: 32px 70px; box-shadow: 0 14px 0 #1c4530, 0 22px 38px rgba(0,0,0,0.45); animation: pulse-glow 1.4s ease-in-out infinite; }

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 14px 0 #1c4530, 0 22px 38px rgba(0,0,0,0.45), 0 0 0 rgba(255,179,71,0); }
  50% { box-shadow: 0 14px 0 #1c4530, 0 22px 38px rgba(0,0,0,0.45), 0 0 34px rgba(255,179,71,0.55); }
}

.btn-non {
  position: relative;
  background: #f1e6cd;
  color: #a89778;
  font-size: 0.98rem;
  padding: 12px 22px;
  border: 2px dashed #c9b892;
  box-shadow: 0 3px 0 #d9c9a6;
  z-index: 5;
}

.btn-non:hover, .btn-non:focus {
  transform: scale(0.88) rotate(-5deg);
}

.hint {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: #8a7c63;
  font-style: italic;
}

/* Quand le bouton Non fuit, il est déplacé dans <body> par le JS (pas
   seulement en position:fixed) pour garantir qu'il se positionne bien
   par rapport à l'écran entier, même si un ancêtre a un transform. */
.btn-non.fleeing {
  position: fixed;
  transition: top 0.25s ease, left 0.25s ease, transform 0.25s ease;
}

/* ---------------- Piste de voie (jauge ludique) ---------------- */
.route-track {
  margin: 6px 0 4px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.route-track.visible {
  opacity: 1;
  max-height: 80px;
}

.track-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #a08a5f;
  margin-bottom: 6px;
  font-weight: 700;
}

.track-line {
  position: relative;
  height: 6px;
  background: #e3d5b3;
  border-radius: 999px;
  margin: 0 10px 22px;
}

.bolt {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  background: #b7a677;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.bolt[data-i="1"] { left: 15%; }
.bolt[data-i="2"] { left: 32%; }
.bolt[data-i="3"] { left: 50%; }
.bolt[data-i="4"] { left: 68%; }
.bolt[data-i="5"] { left: 85%; }

.bolt.clipped { background: var(--rust); box-shadow: 0 0 0 3px rgba(192,86,44,0.25); }

.anchor {
  position: absolute;
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
}

.climber {
  position: absolute;
  left: 0%;
  top: 50%;
  transform: translate(-50%, -60%);
  font-size: 1.4rem;
  transition: left 0.4s ease;
}

/* ---------------- Écran de célébration ---------------- */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: radial-gradient(circle at 50% 15%, var(--moss) 0%, #142a20 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: hidden;
}

.celebration.hidden { display: none; }

.celebration-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff8ec;
  max-width: 480px;
  animation: pop-in 0.4s ease;
}

@keyframes pop-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.stamp {
  display: inline-block;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--rust);
  border: 3px solid var(--rust);
  border-radius: 8px;
  padding: 6px 18px;
  transform: rotate(-6deg);
  margin-bottom: 14px;
  animation: stamp-in 0.5s ease 0.15s both;
}

@keyframes stamp-in {
  from { transform: rotate(-6deg) scale(2.2); opacity: 0; }
  to { transform: rotate(-6deg) scale(1); opacity: 1; }
}

.celebration-content h2 {
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  margin: 4px 0 12px;
}

.celebration-text {
  font-size: 1.08rem;
  margin-bottom: 26px;
  color: #d9ecdf;
}

.btn-replay {
  background: linear-gradient(135deg, var(--sun-glow), var(--rust));
  color: #2b1a0e;
  font-size: 1.08rem;
  padding: 14px 30px;
  box-shadow: 0 8px 0 #7a3315;
  border: 2px solid #7a3315;
}

.btn-replay:active {
  transform: translateY(2px);
  box-shadow: 0 5px 0 #7a3315;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.confetti-piece {
  position: absolute;
  top: -10%;
  width: 10px;
  height: 14px;
  opacity: 0.9;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-iteration-count: 1;
}

@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0.3; }
}

/* ---------------- Pied de page ---------------- */
.footer {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #ffe9c7;
  font-size: 0.8rem;
  max-width: 480px;
  line-height: 1.5;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  padding-bottom: 6px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 420px) {
  .topo-card { padding: 28px 18px 20px; }
  .btn-oui { padding: 17px 34px; font-size: 1.2rem; }
  .btn-oui.grow-1 { font-size: 1.35rem; padding: 19px 38px; }
  .btn-oui.grow-2 { font-size: 1.5rem; padding: 21px 42px; }
  .btn-oui.grow-3 { font-size: 1.65rem; padding: 23px 46px; }
  .btn-oui.grow-4 { font-size: 1.8rem; padding: 25px 50px; }
  .arena { min-height: 210px; }
}

@media (min-width: 700px) {
  .topo-card { padding: 46px 52px 34px; }
}
