/* La page d'aide des gestes (js/ui/aide-gestes.js) : un voile par-dessus
   le menu, une boite avec quatre onglets dont le corps defile (jamais la
   page), des cartes par coup. Le doigt parcourt sa trace, la balle vole et
   rebondit ; la grille des zones se touche. Faite pour le telephone et la
   tablette en paysage : peu de hauteur, on economise chaque pixel. */

.aide-gestes {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 10, 30, 0.82);
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
           max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  font-family: 'Lilita One', system-ui, sans-serif;
  color: #fff;
}
.aide-gestes.ouverte { display: flex; }

.aide-boite {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1040px, 100%);
  max-height: 100%;
  min-height: 0;
  background: linear-gradient(180deg, #14205a 0%, #0b1440 100%);
  border: 2px solid #ffd23f;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* --- L'entete : titre, croix, onglets --- */
.aide-entete {
  flex: 0 0 auto;
  padding: 10px 60px 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.aide-boite h2 {
  margin: 0 0 6px;
  font-size: clamp(20px, 3.4vw, 30px);
  letter-spacing: 0.02em;
  color: #ffd23f;
  line-height: 1.1;
}
.aide-fermer {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #ffd23f;
  color: #14205a;
  font: inherit;
  font-size: 30px;
  line-height: 44px;
  cursor: pointer;
}
.aide-fermer:focus-visible { outline: 3px solid #fff; }

.aide-onglets {
  display: flex;
  gap: 6px;
  margin: 0 -60px 0 0;
  padding: 0 0 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.aide-onglets::-webkit-scrollbar { display: none; }
.aide-onglet {
  flex: 0 0 auto;
  border: 0;
  border-radius: 10px 10px 0 0;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: clamp(14px, 2.2vw, 18px);
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
}
.aide-onglet.actif { background: #ffd23f; color: #14205a; }
.aide-onglet:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

/* --- Le corps : la seule chose qui defile --- */
.aide-corps {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 16px 16px;
}
.aide-section[hidden] { display: none; }

.aide-sous-titre {
  margin: 0 0 8px;
  font-family: system-ui, sans-serif;
  font-size: clamp(13px, 2vw, 16px);
  line-height: 1.35;
  opacity: 0.9;
}
.aide-regles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  font-family: system-ui, sans-serif;
  font-size: clamp(12px, 1.9vw, 15px);
}
.aide-regles strong { color: #ffd23f; font-family: 'Lilita One', system-ui, sans-serif; }
.aide-groupe {
  margin: 12px 0 6px;
  font-size: clamp(15px, 2.4vw, 20px);
  color: #ffd23f;
  letter-spacing: 0.02em;
}
.aide-groupe:first-child { margin-top: 0; }

/* --- Les cartes --- */
.aide-grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}
.aide-carte {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 8px 8px 10px;
}
.aide-carte h3 {
  margin: 4px 0 2px;
  font-size: 18px;
  color: #ffd23f;
}
.aide-carte p {
  margin: 4px 0 0;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  opacity: 0.92;
}
.aide-essayer {
  align-self: flex-start;
  margin-top: 8px;
  border: 1px solid #ffd23f;
  border-radius: 999px;
  padding: 5px 14px;
  background: transparent;
  color: #ffd23f;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.aide-essayer:hover, .aide-essayer:focus-visible { background: #ffd23f; color: #14205a; outline: 0; }
.aide-photo { margin: 6px 0 0; }
.aide-photo[hidden] { display: none; }
.aide-photo img { display: block; width: 100%; border-radius: 8px; }
.aide-photo figcaption { font-family: system-ui, sans-serif; font-size: 11px; opacity: 0.7; }
.aide-astuce {
  margin: 12px 0 0;
  padding: 8px 12px;
  border-left: 4px solid #ffd23f;
  background: rgba(255, 210, 63, 0.1);
  font-family: system-ui, sans-serif;
  font-size: 13px;
  border-radius: 6px;
}

/* --- Le petit ecran de telephone, la trace et le doigt --- */
.aide-ecran { width: 100%; height: auto; display: block; }
.aide-telephone { fill: #06102e; stroke: #8fa0ff; stroke-width: 2; }
.aide-table-mini { fill: #1f5fd0; opacity: 0.8; }
.aide-filet-mini { stroke: #fff; stroke-width: 1; opacity: 0.8; }
.doigt-trace {
  fill: none;
  stroke: #ffd23f;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 220;
  stroke-dashoffset: 220;
  animation: aide-dessine 1.6s ease-out infinite;
}
.doigt-trace.vif { animation-duration: 0.9s; }
.doigt-fleche { fill: none; stroke: none; }
marker path { fill: #ffd23f; }
.doigt-point {
  fill: #ffd23f;
  animation: aide-pulse 1.4s ease-in-out infinite;
}
/* Le doigt vu de dessus : un bout de doigt clair, le corps qui le suit. */
.aide-doigt-corps { fill: #f3c9a6; stroke: #b98a63; stroke-width: 1; opacity: 0.7; }
.aide-doigt-bout { fill: #ffe0c4; stroke: #b98a63; stroke-width: 1; opacity: 0.9; }
.aide-doigt.immobile .aide-doigt-bout { animation: aide-pulse-bout 1.4s ease-in-out infinite; }
@keyframes aide-dessine {
  0% { stroke-dashoffset: 220; opacity: 1; }
  80% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes aide-pulse {
  0%, 100% { r: 6; opacity: 0.7; }
  50% { r: 9; opacity: 1; }
}
@keyframes aide-pulse-bout {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* --- La table vue de cote et le vol de la balle --- */
.aide-vol { width: 100%; height: auto; display: block; margin-top: 2px; }
.aide-table { stroke: #4f86ff; stroke-width: 3; stroke-linecap: round; }
.aide-pied { stroke: #4f86ff; stroke-width: 2; opacity: 0.7; }
.aide-filet { stroke: #fff; stroke-width: 2; }
.aide-balle-vol { fill: none; stroke: #ffd23f; stroke-width: 1.2; stroke-dasharray: 3 3; opacity: 0.55; }
.aide-balle { fill: #ff8c1a; }
.aide-raquette { fill: #e63946; }

/* --- Le lancer au service --- */
.aide-lancer { width: 100%; height: auto; display: block; }
.aide-appui-fond { fill: rgba(255, 255, 255, 0.15); }
.aide-appui { fill: #ffd23f; }
.aide-legende { fill: #fff; font-family: system-ui, sans-serif; font-size: 9px; opacity: 0.85; }
.aide-legende.forte { fill: #ffd23f; font-family: 'Lilita One', system-ui, sans-serif; font-size: 11px; opacity: 1; }
.aide-legende.petite { font-size: 6px; }

/* --- Les neuf zones --- */
.aide-zones {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(200px, 1fr);
  gap: 14px;
  align-items: start;
}
.aide-grille-zones { width: 100%; height: auto; display: block; }
.aide-zone rect { fill: rgba(255, 255, 255, 0.08); stroke: #fff; stroke-width: 0.8; cursor: pointer; transition: fill 0.15s; }
.aide-zone:hover rect, .aide-zone:focus rect { fill: rgba(255, 210, 63, 0.35); }
.aide-zone:focus { outline: 0; }
.aide-zone.active rect { fill: #ffd23f; stroke: #fff; }
.aide-zone-ecran { max-width: 320px; }
.aide-zone-phrase {
  margin: 6px 0 0;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.35;
}

/* --- Les fautes --- */
.aide-tableau { overflow-x: auto; }
.aide-tableau table {
  width: 100%;
  border-collapse: collapse;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.3;
}
.aide-tableau th, .aide-tableau td { padding: 6px 8px; text-align: left; vertical-align: top; border-bottom: 1px solid rgba(255, 255, 255, 0.14); }
.aide-tableau thead th { font-family: 'Lilita One', system-ui, sans-serif; color: #ffd23f; font-weight: normal; font-size: 15px; }
.aide-tableau tbody th { font-family: 'Lilita One', system-ui, sans-serif; font-weight: normal; white-space: nowrap; }
.aide-tableau .rentre { color: #9ef0a0; }
.aide-tableau .sort { color: #ffb3a7; }

/* --- Telephone en paysage : deux cartes par ligne, tout plus serre --- */
@media (max-height: 460px) {
  .aide-gestes { padding: 4px max(6px, env(safe-area-inset-right)) 4px max(6px, env(safe-area-inset-left)); }
  .aide-boite { border-radius: 12px; }
  .aide-entete { padding: 6px 52px 0 12px; }
  .aide-boite h2 { font-size: 18px; margin-bottom: 4px; }
  .aide-fermer { width: 36px; height: 36px; line-height: 36px; font-size: 24px; top: 5px; right: 8px; }
  .aide-onglet { padding: 6px 10px; font-size: 14px; }
  .aide-corps { padding: 8px 12px 12px; }
  .aide-grille { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
  .aide-carte h3 { font-size: 16px; }
  .aide-carte p { font-size: 12px; }
  .aide-zones { gap: 10px; }
}
@media (max-width: 600px) {
  .aide-grille { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .aide-zones { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .doigt-trace, .doigt-point, .aide-doigt-bout { animation: none; stroke-dashoffset: 0; }
}
