/* ==========================================================================
   Téléphone dessiné (sans marque) et écrans de l'application, en HTML/CSS (D3).

   Composant, pour T4 à T7 :
     <div class="telephone" style="--tel-echelle:.8" role="img" aria-label="Ce que montre l'écran">
       <div class="telephone__ecran" aria-hidden="true">
         <div class="ecran" data-ecran="journee"> … écran dessiné à 390 × 844 px … </div>
         <div class="ecran" data-ecran="plan" hidden> … autre écran … </div>
       </div>
     </div>
   - Une seule variable de taille : --tel-echelle (0,8 → 332 × 695 px hors tout ; 0,72 → 299 × 626 px).
     Le cadre, ses arrondis et son bord suivent la même variable.
   - Chaque écran se dessine en pixels « téléphone » (390 × 844, comme la maquette), puis il est réduit.
     Les briques app-* ci-dessous (cartes, pastilles, anneau, barre d'onglets) reprennent l'espace enfant
     de la maquette (docs/design/maquette/source/EcranEnfant.dc.html) : réutilisez-les pour d'autres écrans.
   - Changer d'écran : MK.telephone.afficher(telephone, 'plan') (voir js/telephone.js), fondu d'entrée.
   - Boucle animée : attribut data-telephone-boucle sur .telephone. js/telephone.js pose la classe
     est-en-boucle quand le téléphone est à l'écran et que les animations tournent ; un seul téléphone boucle
     à la fois ; hors de l'écran, la boucle est suspendue (est-suspendu). Sans cette classe (JS coupé, pause,
     mouvement réduit), l'écran montre son état fixe, lisible : l'état « après » (mission cochée, 4/5).
   - Éléments animés de la boucle : classe .tj + une classe de rôle (tj-avant, tj-apres, tj-coche, tj-envol…).
     Toutes partagent la même durée (12 s) et le même décalage (--tel-boucle-decalage) : elles restent en phase.
   ========================================================================== */

.telephone {
  --tel-echelle: .8;
  --tel-bord: calc(12.5px * var(--tel-echelle));
  position: relative;
  flex: none;
  width: calc(390px * var(--tel-echelle) + 2 * var(--tel-bord));
  padding: var(--tel-bord);
  border-radius: calc(65px * var(--tel-echelle));
  background: var(--encre);
  box-shadow: var(--ombre-telephone);
}
.telephone__ecran {
  position: relative;
  width: calc(390px * var(--tel-echelle));
  height: calc(844px * var(--tel-echelle));
  border-radius: calc(52.5px * var(--tel-echelle));
  overflow: hidden;
  background: var(--vert-nuit);
  isolation: isolate;
}
.ecran {
  position: absolute; left: 0; top: 0;
  width: 390px; height: 844px;
  transform: scale(var(--tel-echelle)); transform-origin: 0 0;
  overflow: hidden;
  background: var(--vert-nuit); color: var(--creme);
  font: 400 15px/1.4 var(--police-texte);
  text-align: left;
}
.ecran[hidden] { display: none; }
.ecran.ecran--entre { animation: ecranEntre var(--duree-entree) var(--courbe-sortie) both; }
@keyframes ecranEntre { from { opacity: 0; } to { opacity: 1; } }
html.mouvement-reduit .ecran.ecran--entre { animation-duration: 1ms; }

.ecran .ic { display: block; width: 1em; height: 1em; flex: none; }
.ecran img { display: block; }

/* ---------- Briques de l'espace enfant (pixels « téléphone ») ---------- */

/* Fratrie et bouton Parents */
.app-fratrie { display: flex; align-items: center; gap: 8px; padding: 48px 16px 0 14px; }
.app-avatar { width: 56px; height: 56px; display: grid; place-items: center; flex: none; }
.app-avatar img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: 50% 22%; opacity: .55; }
.app-avatar--actif img { width: 48px; height: 48px; opacity: 1; outline: 4px solid var(--ambre); outline-offset: 2px; }
.app-fratrie__vide { flex: 1; }
.app-parents {
  display: flex; align-items: center; gap: 6px; height: 56px; padding: 0 18px 0 14px;
  border: 1.5px solid rgba(183, 201, 192, .4); border-radius: 999px;
  font: 600 16px/1 var(--police-titre);
}
.app-parents .ic { font-size: 20px; }

/* Identité : prénom, solde, anneau du jour */
.app-identite { position: relative; display: flex; align-items: center; gap: 12px; padding: 22px 20px 6px 24px; }
.app-identite__deco { position: absolute; display: block; }
.app-identite__deco--croissant { right: 124px; top: 14px; width: 30px; height: 30px; color: var(--ambre); }
.app-identite__deco--etoile-creme { right: 92px; top: 4px; width: 12px; height: 12px; color: var(--creme); }
.app-identite__deco--etoile-ambre { right: 136px; top: 112px; width: 9px; height: 9px; color: var(--ambre); }
.app-identite__nom { position: relative; flex: 1; min-width: 0; }
.app-prenom { font: 600 34px/1.1 var(--police-titre); }
.app-solde {
  display: inline-flex; align-items: center; gap: 3px; height: 36px; margin-top: 10px; padding: 0 14px 0 8px;
  border-radius: 999px; background: var(--ambre); color: var(--vert-nuit);
  font: 600 19px/1 var(--police-titre); font-variant-numeric: tabular-nums;
}
.app-solde .ic { font-size: 24px; }
.app-bascule { display: grid; }
.app-bascule > * { grid-area: 1 / 1; }
.app-solde .app-bascule { width: 22px; line-height: 24px; }
.app-jour { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.app-anneau { position: relative; width: 88px; height: 88px; }
.app-anneau svg { display: block; }
.app-anneau__piste { stroke: rgba(183, 201, 192, .22); stroke-width: 10; }
.app-anneau__plein { stroke: var(--vert-vif); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 238.76 238.76; stroke-dashoffset: 47.76; }
.app-anneau__texte { position: absolute; inset: 0; place-items: center; font: 600 24px/1 var(--police-titre); font-variant-numeric: tabular-nums; }
.app-jour__libelle { font: 600 13px/1.2 var(--police-texte); color: var(--gris-clair); }

/* Cartes (Coran, missions, niveau) */
.app-carte {
  display: flex; align-items: center; gap: 12px; margin: 12px 16px 0; padding: 12px;
  min-height: 88px; border-radius: 28px; background: var(--vert-profond);
}
.app-carte--coran { min-height: 80px; background: var(--vert-foret); }
.app-carte__texte { flex: 1; min-width: 0; }
.app-carte__titre { font: 600 19px/1.2 var(--police-titre); }
.app-carte__sous-titre { margin-top: 3px; font-size: 14px; color: var(--gris-clair); }
.app-picto { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; flex: none; color: var(--vert-nuit); font-size: 34px; }
.app-picto--56 { width: 56px; height: 56px; font-size: 30px; }
.app-picto--citron { background: var(--citron); }
.app-picto--ambre { background: var(--ambre); }
.app-rond-lecture { width: 56px; height: 56px; border-radius: 50%; background: var(--ambre); color: var(--vert-nuit); display: grid; place-items: center; flex: none; font-size: 34px; }
.app-mission__etoiles { display: flex; gap: 1px; margin-top: 4px; color: var(--ambre); font-size: 22px; }
.app-coche {
  position: relative; width: 60px; height: 60px; flex: none;
  border: 3px dashed var(--ambre); border-radius: 50%; color: var(--ambre);
  display: grid; place-items: center; font-size: 30px;
}
.app-coche__faite {
  position: absolute; inset: -3px; border-radius: 50%;
  background: var(--ambre); color: var(--vert-nuit);
  display: grid; place-items: center; font-size: 32px;
}
.app-envol {
  position: absolute; left: -1px; top: -1px; z-index: 90;
  width: 56px; height: 56px; color: var(--ambre); font-size: 56px;
  opacity: 0; pointer-events: none;
}

/* « Fait aujourd'hui » */
.app-fait {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; margin: 6px 16px 0; padding: 0 12px;
  color: var(--gris-clair); font: 600 16px/1.2 var(--police-titre);
}
.app-fait .ic { font-size: 24px; }

/* Arc des cinq prières */
.app-prieres { position: relative; display: flex; align-items: flex-start; gap: 2px; margin: 16px 16px 0; }
.app-prieres__arc { position: absolute; left: 12%; top: 4px; width: 60%; height: 44px; }
.app-prieres__arc path { stroke: var(--vert-foret); stroke-width: 2; stroke-dasharray: 1 7; stroke-linecap: round; }
.app-priere {
  position: relative; flex: 1; min-width: 0; margin-top: var(--arc, 0px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: 700 13px/1.2 var(--police-texte);
}
.app-priere__rond { width: 56px; height: 56px; border-radius: 50%; background: var(--vert-nuit); border: 2px dashed var(--gris-vert); display: grid; place-items: center; }
.app-priere__rond--faite { background: var(--vert-foret); border: 0; }
.app-priere__rond svg { width: 36px; height: 36px; }
.app-prieres__fleurs {
  flex: none; width: 76px; min-height: 56px; margin-top: 22px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--vert-vif); font: 700 12px/1.2 var(--police-texte); white-space: nowrap;
}
.app-prieres__fleurs .ic { font-size: 28px; }

/* Carte niveau */
.app-niveau { margin-top: 20px; padding: 16px; min-height: 0; }
.app-niveau__rond {
  width: 52px; height: 52px; flex: none; border-radius: 50%;
  background: var(--ambre); color: var(--vert-nuit); box-shadow: var(--halo-focus);
  display: grid; place-items: center; font-size: 26px;
}
.app-niveau__reste { font-size: 13px; color: var(--gris-clair); }

/* Barre d'onglets */
.app-onglets {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex;
  padding: 8px 8px 18px; border-radius: 24px 24px 0 0;
  background: var(--vert-profond); border-top: 1px solid rgba(183, 201, 192, .16);
}
.app-onglet {
  flex: 1; min-height: 60px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: 700 12px/1.2 var(--police-texte); color: var(--gris-clair);
}
.app-onglet__ico { width: 60px; height: 32px; border-radius: 16px; display: grid; place-items: center; font-size: 24px; }
.app-onglet--actif { color: var(--creme); }
.app-onglet--actif .app-onglet__ico { background: var(--ambre); color: var(--vert-nuit); }

/* ---------- Boucle « Ma journée » (12 s, d'après la planche B-Accueil) ----------
   55,0 % (6,6 s) : « Mettre la table » se coche (ressort doux), l'étoile surgit (×1,4, monte de 36 px) ;
   56,4 % → 60,1 % : elle vole vers la pastille du solde (450 ms, ease-out), 18 → 19 avec un rebond ;
   60,1 % → 63,9 % : l'anneau passe de 3/5 à 4/5 ; 95 → 99 % : fondu, puis la boucle reprend.
   Décalage de -3 s : la première coche arrive 3,6 s après le début de la boucle. */

/* État fixe (sans boucle) : l'état « après », lisible */
.tj-avant, .tj-avant-fait { opacity: 0; }
.tj-apres, .tj-apres-fait, .tj-coche { opacity: 1; }

.telephone.est-en-boucle .tj {
  animation-duration: var(--duree-sequence);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  animation-fill-mode: both;
  animation-delay: var(--tel-boucle-decalage, -3s);
}
.telephone.est-en-boucle .tj-avant { animation-name: tjAvant; }
.telephone.est-en-boucle .tj-apres { animation-name: tjApres; }
.telephone.est-en-boucle .tj-avant-fait { animation-name: tjAvantFait; }
.telephone.est-en-boucle .tj-apres-fait { animation-name: tjApresFait; }
.telephone.est-en-boucle .tj-coche { animation-name: tjCoche; }
.telephone.est-en-boucle .tj-envol { animation-name: tjEnvol; }
.telephone.est-en-boucle .tj-bump { animation-name: tjBump; }
.telephone.est-en-boucle .tj-anneau { animation-name: tjAnneau; }
/* Hors de l'écran : la boucle attend, à l'endroit où elle s'est arrêtée */
.telephone.est-suspendu .tj { animation-play-state: paused; }

@keyframes tjAvant { 0%, 60.1% { opacity: 1; } 60.5% { opacity: 0; } 96% { opacity: 0; } 99%, 100% { opacity: 1; } }
@keyframes tjApres { 0%, 60.1% { opacity: 0; } 60.5% { opacity: 1; } 96% { opacity: 1; } 99%, 100% { opacity: 0; } }
@keyframes tjAvantFait { 0%, 57% { opacity: 1; } 57.4% { opacity: 0; } 96% { opacity: 0; } 99%, 100% { opacity: 1; } }
@keyframes tjApresFait { 0%, 57% { opacity: 0; } 57.4% { opacity: 1; } 96% { opacity: 1; } 99%, 100% { opacity: 0; } }
@keyframes tjCoche {
  0%, 55% { transform: scale(.6); opacity: 0; animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  57.1% { transform: scale(1); opacity: 1; }
  95% { transform: scale(1); opacity: 1; }
  98%, 100% { transform: scale(1); opacity: 0; }
}
@keyframes tjEnvol {
  0%, 55% { transform: translate(0, 0) scale(.6); opacity: 0; }
  55.1% { transform: translate(0, 0) scale(.6); opacity: 1; animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  56.4% { transform: translate(0, -36px) scale(1.4); opacity: 1; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
  60.1% { transform: translate(var(--vol-x, -273px), var(--vol-y, -286px)) scale(.45); opacity: 1; }
  60.5%, 100% { transform: translate(var(--vol-x, -273px), var(--vol-y, -286px)) scale(.45); opacity: 0; }
}
@keyframes tjBump {
  0%, 60.1% { transform: scale(1); animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
  61.2% { transform: scale(1.25); animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
  62.3%, 100% { transform: scale(1); }
}
@keyframes tjAnneau {
  0%, 60.1% { stroke-dashoffset: 95.52; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
  63.9% { stroke-dashoffset: 47.76; }
  95% { stroke-dashoffset: 47.76; }
  99%, 100% { stroke-dashoffset: 95.52; }
}
