/* ————————————————————————————————————————————————
   Ayo — danse avec ta main
   Le fond de page est EXACTEMENT la couleur du fond de la sprite (#d6d4d2) :
   c'est ce qui rend invisible le bord de l'image quand Ayo se déplace.
   ———————————————————————————————————————————————— */

:root {
  --bg: #d6d4d2;
  --ink: #23211f;
  --ink-soft: #6a6660;
  /* contraste vérifié : 4,9:1 avec du texte blanc dessus (AA) */
  --gold: #8a6d1f;
  --gold-dark: #6f5818;
  --red: #d6332b;
  --yellow: #edb92e;
  --card: rgba(255, 255, 255, .82);
  --line: rgba(0, 0, 0, .12);
}

* { box-sizing: border-box; }

/* doit primer sur les règles display: des composants ci-dessous */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ————— Scène ————— */

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: end center;
  touch-action: none;
  cursor: crosshair;
}

/* Ayo est fixe : seule l'image affichée change */
.puppet {
  position: relative;
  /* on laisse la place à la barre de position et aux boutons en bas */
  margin-bottom: clamp(104px, 14vh, 140px);
}

.ayo {
  height: min(62vh, 62svh, 560px);
  aspect-ratio: 369 / 720;
  /* l'image est choisie par app.js (grande ou allégée) : une seule source
     de vérité, pour ne pas télécharger les deux */
  background-repeat: no-repeat;
  /* 8 colonnes × 4 lignes */
  background-size: 800% 400%;
  background-position: 0% 0%;
}

/* ombre de contact : en multiply, elle assombrit le gris identique du fond
   et de la sprite, donc le raccord reste invisible */
.shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 78%;
  height: 26px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,.34) 0%, rgba(0,0,0,.14) 45%, rgba(0,0,0,0) 72%);
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* ————— Arc de position + texte ————— */

.bottom {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

/* court volontairement : un petit geste de la main suffit à parcourir
   toute l'animation.
   Le rapport doit rester celui du viewBox (220×56) : sinon l'arc est
   centré dans une boîte plus haute et le repère flotte au-dessus. */
.track {
  position: relative;
  width: 150px;
  aspect-ratio: 220 / 56;
}

.arc {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.track-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.status {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
}
.status.ok   { color: var(--gold); }
.status.warn { color: var(--red); }

/* ————— Contrôles, en haut à droite ————— */

.controls {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  display: flex;
  gap: 8px;
  align-items: center;
}

.ico {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* caméra active : le bouton passe au doré */
.btn.is-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.btn.is-on:hover { background: var(--gold-dark); }

/* ————— Boutons ————— */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 15px;
  border-radius: 99px;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.btn:hover { background: #fff; }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* taille fixe et contenu centré : le bouton ne peut pas se déformer,
   quoi qu'on mette dedans */
.btn-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 0;
}

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
  font-weight: 600;
  padding: 12px 22px;
  font-size: 15px;
}
.btn-primary:hover { background: var(--gold-dark); }

/* ————— Aperçu caméra ————— */

.cam {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  width: clamp(240px, 30vw, 440px);
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .16);
}

.cam-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* miroir : plus intuitif */
  display: block;
}

.hand-dot {
  position: absolute;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid var(--yellow);
  border-radius: 50%;
  background: rgba(237, 185, 46, .22);
  pointer-events: none;
}

/* ————— Panneaux plein écran ————— */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(214, 212, 210, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
}

.sheet-inner {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: clamp(22px, 5vw, 32px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .14);
}

.title {
  margin: 0 0 10px;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.15;
  letter-spacing: -.02em;
}
.title .hl { color: var(--gold); }

.title-sm {
  margin: 0 0 14px;
  font-size: clamp(19px, 4.5vw, 22px);
  letter-spacing: -.01em;
}

.lede {
  margin: 0 0 18px;
  color: var(--ink-soft);
}

.privacy {
  margin: 0 0 20px;
  padding: 13px 15px;
  border-radius: 12px;
  background: #f4f2ef;
  border: 1px solid var(--line);
  font-size: 13.5px;
  line-height: 1.6;
  color: #4a463f;
}
.privacy strong { color: var(--ink); }

.list {
  margin: 0 0 18px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #4a463f;
}
.list li { margin-bottom: 9px; }
.list strong { color: var(--ink); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.fineprint {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: #8a857d;
}

/* ————— Chargement ————— */

.loader {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 30;
  transform: translate(-50%, -50%);
  width: min(300px, 82vw);
  padding: 18px 20px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .16);
  text-align: center;
}

.loader-text {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
}

.loader-track {
  height: 5px;
  border-radius: 99px;
  background: #eceae7;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: var(--gold);
  transition: width .2s;
}

/* ————— Petits écrans ————— */

@media (max-width: 560px) {
  .ayo { height: min(46vh, 46svh, 420px); }
  .puppet { margin-bottom: clamp(104px, 17vh, 140px); }
  .track { width: 126px; }
  .controls { gap: 6px; }
  /* à droite aussi sur mobile, mais glissé sous les boutons : en bas il
     entrerait dans l'arc, trop large pour la largeur d'un téléphone */
  .cam {
    top: calc(max(14px, env(safe-area-inset-top)) + 48px);
    bottom: auto;
    width: clamp(150px, 44vw, 210px);
  }
}

/* écrans courts en paysage (téléphone couché) */
@media (max-height: 460px) {
  .ayo { height: min(64vh, 64svh, 300px); }
  .puppet { margin-bottom: 48px; }
  .track { width: min(340px, 56vw); }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
