/* ==========================================================================
   WEB APP INSTALLABLE (lot 3) — webapp.js, MdWebApp.php
   Invitation à installer, rubrique « Application mobile » de l'espace client,
   barre de navigation et écran de chargement de l'application installée.
   ========================================================================== */

/* ------------------------------------------------ invitation (une fois) */
.invitation-app { width: min(92vw, 440px); padding: var(--e-6); border: 0; border-top: 4px solid var(--marque); border-radius: var(--rayon-2); background: var(--md-papier); box-shadow: var(--ombre-2); color: var(--md-encre); }
.invitation-app::backdrop { background: rgba(14, 23, 38, .6); }
.invitation-app__tete { display: flex; align-items: center; gap: var(--e-4); margin-bottom: var(--e-4); }
.invitation-app__icone { flex: none; width: 56px; height: 56px; border-radius: 12px; box-shadow: 0 0 0 1px var(--md-trait); }
.invitation-app__titre { margin: 0; font-size: var(--t-3); font-weight: 800; line-height: 1.2; }
.invitation-app__texte { margin: 0 0 var(--e-5); font-size: var(--t-1); line-height: 1.5; color: var(--md-encre-2); }
.invitation-app__etapes { margin: 0 0 var(--e-5); font-size: var(--t-1); line-height: 1.5; }
.invitation-app__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--e-3); }
.invitation-app__actions .bouton { flex: 1 1 auto; }
.invitation-app__note { margin: var(--e-4) 0 0; font-size: var(--t-0); color: var(--md-encre-3); }
.invitation-app__etapes small { display: block; color: var(--md-encre-3); font-size: var(--t-0); }
/* Flèche animée vers les boutons de Safari (⋯ / Partager), en bas sur iPhone, en haut sur iPad. */
.invitation-app__fleche { display: flex; justify-content: flex-end; padding-right: var(--e-2); color: #007AFF; }
.invitation-app__fleche svg { width: 40px; height: 40px; animation: webapp-fleche 1s ease-in-out infinite alternate; }
.invitation-app__fleche--haut svg { transform: rotate(180deg); animation-name: webapp-fleche-haut; }
@keyframes webapp-fleche { from { transform: translateY(-4px); } to { transform: translateY(8px); } }
@keyframes webapp-fleche-haut { from { transform: rotate(180deg) translateY(-4px); } to { transform: rotate(180deg) translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .invitation-app__fleche svg { animation: none; } }
.invitation-app__note a { color: inherit; text-decoration: underline; }

/* --------------------------------------- rubrique de l'espace client */
.webapp { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--e-5); }
.webapp__presentation { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: var(--e-5); }
.webapp__icone { width: 96px; height: 96px; border-radius: 20px; box-shadow: 0 0 0 1px var(--md-trait); }
@media (max-width: 520px) {
  .webapp__presentation { grid-template-columns: minmax(0, 1fr); }
  .webapp__icone { width: 72px; height: 72px; border-radius: 16px; }
}
.webapp .bloc__titre { margin-bottom: var(--e-3); }
.webapp__texte { margin: 0; color: var(--md-encre-2); font-size: var(--t-1); line-height: 1.55; }
.webapp__action { margin: var(--e-4) 0 0; }
.webapp__modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--e-5); }
@media (max-width: 760px) { .webapp__modes { grid-template-columns: minmax(0, 1fr); } }
/* L'appareil du client passe en premier et ressort. */
.webapp__mode--actif { order: -1; border-color: var(--marque); box-shadow: inset 0 4px 0 var(--marque); }
.webapp__etapes, .webapp__liste { margin: 0; padding-left: 1.3em; font-size: var(--t-1); line-height: 1.55; color: var(--md-encre-2); }
.webapp__etapes li + li, .webapp__liste li + li { margin-top: var(--e-2); }
.webapp__etapes strong { color: var(--md-encre); }
.webapp__picto { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; color: #007AFF; }

/* ------------------------------------- application installée (plein écran) */

.webapp-barre { display: none; }
@media (max-width: 760px) {
  .webapp-autonome body { padding-bottom: calc(60px + var(--webapp-bande, env(safe-area-inset-bottom, 0px))); }
  .webapp-barre {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 955;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-bottom: var(--webapp-bande, env(safe-area-inset-bottom, 0px));
    background: var(--md-papier); border-top: 1px solid var(--md-trait); box-shadow: 0 -2px 12px rgba(14, 23, 38, .06);
  }
  .webapp-barre__lien { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; color: var(--md-encre-3); font-size: 11px; font-weight: 600; text-decoration: none; }
  .webapp-barre__lien svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .webapp-barre__lien--actif { color: var(--accent-texte); }
  [data-marque="sidat"] .webapp-barre__lien--actif { box-shadow: inset 0 3px 0 var(--jaune); }
}
/* iPhone à bords arrondis (webapp.js : webapp-ios-arrondi) : bande aux couleurs de la marque
   sous les icônes (bleu Meat, jaune Sidat), pour que la courbe de l'écran ne rogne pas la barre.
   Retour de Jean du 24/11/2026. */
html.webapp-ios-arrondi { --webapp-bande: max(env(safe-area-inset-bottom, 0px), 26px); }
html.webapp-ios-arrondi .webapp-barre {
  background: linear-gradient(to top, var(--annonce-fond) var(--webapp-bande), var(--md-papier) var(--webapp-bande));
}
@media print { .webapp-barre { display: none !important; } }

/* ------------------------- écran de chargement (application installée seulement)
   Au lancement ET à chaque page : fond blanc et logo gris pâle qui « respire »,
   SOUS le bandeau, l'en-tête et la barre du bas, qui restent à l'écran.
   Affiché par le CSS dès le premier rendu (display-mode), retiré par webapp.js
   (classe webapp-pret) ; de retour au départ vers une autre page (webapp-depart).
   Sécurité : sans JS, il disparaît seul au bout de 4 s. Retour de Jean du 24/11. */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html::before, html::after { content: ""; position: fixed; pointer-events: none; transition: opacity .25s ease, visibility 0s linear .25s; }
  html::before { inset: 0; z-index: 940; background: var(--md-papier, #FFFFFF); animation: webapp-secours 0s linear 4s forwards; }
  html::after {
    left: 50%; top: 50%; z-index: 941; width: 168px; height: 111px; margin: -56px 0 0 -84px;
    background: url("/design/app/meatdoria-logo-gris.png") center / contain no-repeat; opacity: .55;
    animation: webapp-souffle 1.1s ease-in-out infinite alternate, webapp-secours 0s linear 4s forwards;
  }
  html[data-marque="sidat"]::after { width: 232px; height: 62px; margin: -31px 0 0 -116px; background-image: url("/design/app/sidat-logo-gris.png"); }
  html.webapp-pret::before, html.webapp-pret::after { opacity: 0; visibility: hidden; animation: none; }
  /* Départ vers une autre page : l'écran revient, après 150 ms pour ne pas clignoter sur une page rapide. */
  html.webapp-pret.webapp-depart::before, html.webapp-pret.webapp-depart::after { visibility: visible; transition: opacity .2s ease .15s, visibility 0s linear .15s; }
  html.webapp-pret.webapp-depart::before { opacity: 1; }
  html.webapp-pret.webapp-depart::after { opacity: .55; animation: webapp-souffle 1.1s ease-in-out infinite alternate; }
}
@keyframes webapp-souffle { from { transform: scale(.9); } to { transform: scale(1.06); } }
/* Neige de Noël (session habillage, noel.css) : masquée tant que l'écran de chargement est affiché,
   visible une fois la page chargée (retour de Jean du 25/11/2026). */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html:not(.webapp-pret) .neige-noel, html.webapp-depart .neige-noel { visibility: hidden; }
}
@keyframes webapp-secours { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { html::after { animation: webapp-secours 0s linear 4s forwards !important; } }

/* ---------------- bandeau, en-tête et recherche dans l'application installée
   Bandeau « … distribuée par M&D France » et en-tête collants, au-dessus de
   l'écran de chargement ; sur téléphone la recherche est masquée et la loupe
   de la barre du bas l'ouvre dans l'en-tête, champ prêt à saisir ; elle se
   referme quand on fait défiler la page (webapp.js, --h-annonce).
   Retours de Jean du 24/11/2026. */
@media (display-mode: standalone), (display-mode: fullscreen) {
  html .annonce { position: sticky; top: 0; z-index: 960; }
  html .entete { position: sticky; top: var(--h-annonce, 0px); z-index: 950; }
}
html.webapp-autonome .annonce { position: sticky; top: 0; z-index: 960; }
html.webapp-autonome .entete { position: sticky; top: var(--h-annonce, 0px); z-index: 950; }
@media (max-width: 720px) and (display-mode: standalone), (max-width: 720px) and (display-mode: fullscreen) {
  html .entete .recherche { display: none; }
  html.webapp-recherche-ouverte .entete .recherche { display: flex; }
}
@media (max-width: 720px) {
  html.webapp-autonome .entete .recherche { display: none; }
  html.webapp-autonome.webapp-recherche-ouverte .entete .recherche { display: flex; }
  .webapp-recherche-ouverte .webapp-barre__lien[data-webapp-recherche] { color: var(--accent-texte); }
}
