/* ============================================================
   Variables — valeurs par défaut, synchronisées avec js/config.js
   (app.js réécrit ces variables au chargement pour rester la
   source unique de vérité : change les couleurs dans config.js)
   ============================================================ */
:root {
  --rose: #ff6b9d;
  --rose-clair: #ffc2d9;
  --rose-tres-clair: #fff0f5;
  --accent: #ff3d71;
  --fond: #fff5f8;
  --texte: #4a2c3a;
  --blanc: #ffffff;

  --rayon: 24px;
  --ombre: 0 8px 24px rgba(255, 61, 113, 0.18);

  /* 100dvh corrige le bug de hauteur de Safari iOS (barre d'adresse qui
     apparaît/disparaît). On garde un fallback pour les navigateurs
     qui ne connaissent pas dvh. */
  --hauteur-app: 100vh;
}
@supports (height: 100dvh) {
  :root {
    --hauteur-app: 100dvh;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none; /* empêche le rebond de scroll iOS */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(160deg, var(--rose-tres-clair), var(--rose-clair));
  color: var(--texte);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--hauteur-app);
}

/* ============================================================
   Cadre "téléphone" — sur mobile il occupe tout l'écran ;
   sur grand écran il reste centré et proportionné.
   ============================================================ */
#phone-frame {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: var(--hauteur-app);
  max-height: 900px;
  background: var(--fond);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: pan-y;
}

@media (min-width: 560px) {
  #phone-frame {
    height: min(var(--hauteur-app), 900px);
    border-radius: 40px;
    box-shadow: 0 30px 80px rgba(74, 44, 58, 0.25);
    border: 10px solid var(--blanc);
  }
}

/* ============================================================
   Barre de progression
   ============================================================ */
#progress-bar {
  height: 6px;
  background: rgba(255, 107, 157, 0.15);
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--rose);
  border-radius: 0 4px 4px 0;
  transition: width 0.35s ease;
}

/* ============================================================
   Container des écrans + transitions slide
   ============================================================ */
#screen-container {
  position: relative;
  flex: 1;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 32px 24px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  will-change: transform, opacity;
}

.screen.slide-in-right {
  animation: slideInRight 0.35s ease forwards;
}
.screen.slide-in-left {
  animation: slideInLeft 0.35s ease forwards;
}

@keyframes slideInRight {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes slideInLeft {
  from {
    transform: translateX(-40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============================================================
   Éléments communs
   ============================================================ */
.screen__header {
  display: flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 16px;
}

.btn-retour {
  background: none;
  border: none;
  color: var(--rose);
  font-size: 16px;
  font-weight: 600;
  padding: 8px;
  margin-left: -8px;
  cursor: pointer;
}
.btn-retour:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.screen__titre {
  font-size: 28px;
  font-weight: 800;
  margin: 8px 0 4px;
  text-align: center;
}
.screen__sous-titre {
  font-size: 16px;
  opacity: 0.75;
  text-align: center;
  margin: 0 0 24px;
}

.screen__corps {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ============================================================
   Accueil
   ============================================================ */
.accueil-emoji {
  font-size: 64px;
  text-align: center;
  margin-bottom: 16px;
}

/* ============================================================
   Grille de cartes
   ============================================================ */
.grille-cartes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.carte {
  background: var(--blanc);
  border: 2px solid transparent;
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--texte);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  touch-action: manipulation;
}

.carte:active {
  transform: scale(0.95);
}

.carte.selectionnee {
  border-color: var(--rose);
  background: var(--rose-tres-clair);
  transform: scale(1.03);
}

.carte__emoji {
  font-size: 32px;
}

.carte:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Boutons principaux
   ============================================================ */
.btn-principal {
  appearance: none;
  border: none;
  border-radius: 999px;
  background: var(--rose);
  color: var(--blanc);
  font-size: 17px;
  font-weight: 700;
  padding: 16px 24px;
  box-shadow: var(--ombre);
  cursor: pointer;
  margin-top: 24px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn-principal:active {
  transform: scale(0.97);
}
.btn-principal:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-principal:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
   Écran date / heure
   ============================================================ */
.champ-groupe {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.champ-groupe label {
  font-weight: 600;
  font-size: 14px;
}
.champ-groupe input {
  border: 2px solid var(--rose-clair);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 16px; /* >=16px : évite le zoom auto de Safari iOS au focus */
  background: var(--blanc);
  color: var(--texte);
}
.champ-groupe input:focus-visible {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   Confirmation
   ============================================================ */
.recap {
  background: var(--blanc);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
  margin-bottom: 24px;
}
.recap p {
  margin: 6px 0;
}

.zone-boutons-confirmation {
  position: relative;
  flex: 1;
  min-height: 220px;
}

.btn-oui,
.btn-non {
  position: absolute;
  border: none;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--ombre);
}

.btn-oui {
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--rose);
  color: var(--blanc);
  font-size: 18px;
  padding: 16px 32px;
  transition: transform 0.2s ease, font-size 0.2s ease;
  z-index: 2;
}

.btn-non {
  top: 20px;
  left: 50%;
  transform: translate(-50%, 0);
  background: var(--rose-clair);
  color: var(--texte);
  font-size: 15px;
  padding: 12px 22px;
  z-index: 3;
  touch-action: none; /* on gère nous-mêmes le tactile, pas de scroll/zoom parasite */
  transition: transform 0.25s ease-out; /* esquive fluide, pas de téléportation */
}

/* ============================================================
   Succès + confettis coeurs
   ============================================================ */
.succes-contenu {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
}
.succes-emoji {
  font-size: 72px;
}

.confettis {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.coeur-confetti {
  position: absolute;
  top: -10%;
  font-size: 22px;
  animation-name: tomber;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
  will-change: transform, opacity;
}

@keyframes tomber {
  from {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: translateY(115vh) rotate(360deg);
    opacity: 0.9;
  }
}

.message-erreur {
  background: var(--rose-tres-clair);
  border: 1px solid var(--rose-clair);
  border-radius: 16px;
  padding: 14px;
  font-size: 14px;
  margin-top: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .coeur-confetti,
  .carte,
  .btn-principal {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
