/* ═══════════════════════════════════════════
   BarberClub — La transition accueil ↔ page salon (30/10/2026)

   Au toucher d'une carte, sa photo s'ouvre en plein écran et devient le fond
   de la page du salon : la fenêtre de la carte s'agrandit jusqu'aux bords
   pendant que la photo se recadre et prend le ton de la page. Le nom de la
   ville file de la carte au grand titre, le bouton de l'appli devient le
   bouton retour, le logo de l'accueil devient celui de l'en-tête, les deux
   autres cartes reculent dans le noir, la barre basse monte. Au retour, tout
   revient se ranger dans la carte.

   C'est l'API View Transitions entre deux pages (« @view-transition », déjà
   active dans page-transitions.css). La photo qui s'ouvre est un vrai
   élément de la page d'arrivée (le « relais », posé par
   assets/js/transition-salons.js) : elle reste nette du début à la fin.
   Navigateur qui ne connaît pas l'API (Firefox) : la page change simplement.

   À charger EN DERNIER dans le <head> de l'accueil et des trois pages salon,
   avec assets/js/transition-salons.js. Les classes vt-arrivee / vt-retour
   et les variables --vt-* sont posées par ce script.
   ═══════════════════════════════════════════ */

:root {
    --vt-duree: 820ms;                              /* la photo s'ouvre (ou se range) */
    --vt-courbe: cubic-bezier(0.5, 0, 0.1, 1);      /* départ franc, longue arrivée */
    --vt-glisse: cubic-bezier(0.65, 0, 0.25, 1);    /* les grands déplacements de la DA */
    --vt-sortie: cubic-bezier(0.16, 1, 0.3, 1);     /* la courbe d'arrivée de la DA */
}


/* ═══ LE RELAIS : la photo de la carte, posée sur la page le temps de la transition ═══
   Sa fenêtre (clip-path) va du rectangle de la carte au plein écran ; l'image,
   posée à sa place finale, part du cadrage de la carte (transform). */
.relais {
    position: fixed;
    inset: 0;
    z-index: 3;                         /* page salon : sous le titre, l'en-tête et la barre */
    pointer-events: none;
    clip-path: inset(0 round 0px);
}
.accueil > .relais { z-index: 1; }      /* accueil : sous les cartes (la carte d'arrivée a sa photo masquée) */
.relais img {
    position: absolute;
    left: var(--vt-p1x);
    top: var(--vt-p1y);
    width: var(--vt-p1w);
    height: var(--vt-p1h);
    max-width: none;
    max-height: none;
    transform-origin: 0 0;
    filter: var(--vt-filtre);
}
.relais .relais-fond {                  /* le fond de la page salon, quand ce n'est pas la photo de la carte (Grenoble) */
    position: absolute;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0;
}
.relais::after {                        /* le voile du fond de la page salon */
    content: '';
    position: absolute;
    inset: 0;
    background: var(--vt-voile, none);
}
.relais.fondu {
    opacity: 0;
    transition: opacity var(--vt-fondu, 0.5s) cubic-bezier(0.4, 0, 0.2, 1);
}

/* accueil → salon : la fenêtre s'ouvre, la photo se recadre et prend le ton de la page */
html.vt-arrivee .relais { animation: vt-fenetre-ouvre var(--vt-duree) var(--vt-courbe) both; }
html.vt-arrivee .relais img {
    animation: vt-photo-ouvre var(--vt-duree) var(--vt-courbe) both,
               vt-ton-ouvre var(--vt-duree) cubic-bezier(0.35, 0, 0.45, 1) both;
}
html.vt-arrivee .relais::after { animation: vt-voile-ouvre var(--vt-duree) cubic-bezier(0.35, 0, 0.45, 1) both; }
html.vt-arrivee .relais .relais-fond { animation: vt-fond-arrive var(--vt-duree) linear both; }

/* salon → accueil : l'inverse, la photo se range dans sa carte */
html.vt-retour .relais { animation: vt-fenetre-ferme var(--vt-duree) var(--vt-courbe) both; }
html.vt-retour .relais img {
    animation: vt-photo-ferme var(--vt-duree) var(--vt-courbe) both,
               vt-ton-ferme var(--vt-duree) cubic-bezier(0.4, 0, 0.5, 1) both;
}
html.vt-retour .relais::after { animation: vt-voile-ferme var(--vt-duree) cubic-bezier(0.4, 0, 0.5, 1) both; }
html.vt-retour .relais .relais-fond { animation: vt-fond-repart var(--vt-duree) linear both; }
/* la carte d'arrivée garde sa place, sa photo est tenue par le relais */
html.vt-retour .carte.vt-cible picture { visibility: hidden; }

@keyframes vt-fenetre-ouvre {
    from { clip-path: inset(var(--vt-ct) var(--vt-cr) var(--vt-cb) var(--vt-cl) round var(--vt-r)); }
    to   { clip-path: inset(0px 0px 0px 0px round 0px); }
}
@keyframes vt-fenetre-ferme {
    from { clip-path: inset(0px 0px 0px 0px round 0px); }
    to   { clip-path: inset(var(--vt-ct) var(--vt-cr) var(--vt-cb) var(--vt-cl) round var(--vt-r)); }
}
@keyframes vt-photo-ouvre { from { transform: translate(var(--vt-dx), var(--vt-dy)) scale(var(--vt-k)); } to { transform: translate(0px, 0px) scale(1); } }
@keyframes vt-photo-ferme { from { transform: translate(0px, 0px) scale(1); } to { transform: translate(var(--vt-dx), var(--vt-dy)) scale(var(--vt-k)); } }
@keyframes vt-ton-ouvre { from { filter: var(--vt-filtre-carte); } to { filter: var(--vt-filtre); } }
@keyframes vt-ton-ferme { from { filter: var(--vt-filtre); } to { filter: var(--vt-filtre-carte); } }
@keyframes vt-voile-ouvre { from { opacity: 0; } to { opacity: 1; } }
@keyframes vt-voile-ferme { from { opacity: 1; } to { opacity: 0; } }
/* le fond de la page se lève dans la photo pendant qu'elle finit de s'ouvrir (et s'efface au retour) */
@keyframes vt-fond-arrive {
    0%, 35% { opacity: 0; animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
    100% { opacity: 1; }
}
@keyframes vt-fond-repart {
    0% { opacity: 1; animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
    55%, 100% { opacity: 0; }
}


/* ═══ CE QUE LA PAGE FAISAIT SEULE À SON ARRIVÉE ═══
   C'est la transition qui amène le titre, les boutons et le logo : pas de
   seconde apparition par-dessus. (Les classes restent sur la page : les
   retirer relancerait ces animations.) */
html.vt-arrivee .hero-title .letter {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
}
html.vt-arrivee .back-btn,
html.vt-arrivee .account-btn,
html.vt-arrivee .header-logo { animation: none; opacity: 1; }
html.vt-arrivee .bottom-nav { transition-delay: 0.3s; }        /* la barre monte quand la photo a pris l'écran */
/* au retour, les cartes et les boutons de l'accueil sont déjà en place */
html.vt-retour .accueil.avant .carte,
html.vt-retour .accueil.avant .bouton-app,
html.vt-retour .accueil.avant .bouton-compte { opacity: 1; }
html.vt-retour .accueil .carte,
html.vt-retour .accueil .bouton-app,
html.vt-retour .accueil .bouton-compte { animation: none !important; }


/* ═══ LES PLANS ═══ (du plus bas au plus haut) */
::view-transition-group(bc-avant-1), ::view-transition-group(bc-avant-2),
::view-transition-group(bc-apres-1), ::view-transition-group(bc-apres-2) { z-index: 1; }
::view-transition-group(bc-relais) { z-index: 2; }
::view-transition-group(bc-carte) { z-index: 3; }
::view-transition-group(bc-hero),
::view-transition-group(bc-entete),
::view-transition-group(bc-dock) { z-index: 4; }
::view-transition-group(bc-nom) { z-index: 5; }
::view-transition-group(bc-gauche),
::view-transition-group(bc-compte) { z-index: 6; }


/* ═══ LA PHOTO ═══
   Le groupe ne bouge pas : c'est le relais (vivant) qui s'anime. Côté départ,
   la photo de la carte reste posée à sa place, sous le relais : elle ne se
   voit que si l'image du relais n'est pas encore prête. */
html.vt-arrivee::view-transition-group(bc-relais),
html.vt-retour::view-transition-group(bc-relais) { animation: none; }
html.vt-arrivee::view-transition-image-pair(bc-relais) { isolation: auto; }
html.vt-arrivee::view-transition-old(bc-relais),
html.vt-arrivee::view-transition-new(bc-relais) { animation: none; mix-blend-mode: normal; }
html.vt-arrivee::view-transition-old(bc-relais) {
    left: var(--vt-w0x);
    top: var(--vt-w0y);
    width: var(--vt-w0w);
    height: var(--vt-w0h);
    clip-path: inset(0 round var(--vt-r));
}
html.vt-retour::view-transition-new(bc-relais) { animation: vt-apparait 240ms ease-out both; }


/* ═══ LA CARTE TOUCHÉE (son voile, l'adresse, l'horaire, la flèche) ═══ */
html.vt-arrivee::view-transition-old(bc-carte) { animation: vt-efface 240ms ease-out both; }
html.vt-retour::view-transition-new(bc-carte) { animation: vt-apparait 300ms ease-out 520ms both; }


/* ═══ LES DEUX AUTRES CARTES : elles reculent dans le noir (et reviennent) ═══
   --vt-ax / --vt-ay : l'axe de la liste (colonne sur téléphone, ligne sur ordinateur). */
html.vt-arrivee::view-transition-old(bc-avant-1),
html.vt-arrivee::view-transition-old(bc-avant-2) { animation: vt-recule-avant 520ms cubic-bezier(0.4, 0, 0.7, 1) both; }
html.vt-arrivee::view-transition-old(bc-apres-1),
html.vt-arrivee::view-transition-old(bc-apres-2) { animation: vt-recule-apres 520ms cubic-bezier(0.4, 0, 0.7, 1) both; }
html.vt-arrivee::view-transition-old(bc-avant-2),
html.vt-arrivee::view-transition-old(bc-apres-2) { animation-delay: 50ms; }
html.vt-retour::view-transition-new(bc-avant-1),
html.vt-retour::view-transition-new(bc-avant-2) { animation: vt-revient-avant 620ms var(--vt-sortie) 300ms both; }
html.vt-retour::view-transition-new(bc-apres-1),
html.vt-retour::view-transition-new(bc-apres-2) { animation: vt-revient-apres 620ms var(--vt-sortie) 300ms both; }
html.vt-retour::view-transition-new(bc-avant-2),
html.vt-retour::view-transition-new(bc-apres-2) { animation-delay: 360ms; }

@keyframes vt-recule-avant {
    to { transform: translate(calc(var(--vt-ax) * -44px), calc(var(--vt-ay) * -44px)) scale(0.9); opacity: 0; filter: blur(6px); }
}
@keyframes vt-recule-apres {
    to { transform: translate(calc(var(--vt-ax) * 44px), calc(var(--vt-ay) * 44px)) scale(0.9); opacity: 0; filter: blur(6px); }
}
@keyframes vt-revient-avant {
    from { transform: translate(calc(var(--vt-ax) * -44px), calc(var(--vt-ay) * -44px)) scale(0.9); opacity: 0; filter: blur(6px); }
}
@keyframes vt-revient-apres {
    from { transform: translate(calc(var(--vt-ax) * 44px), calc(var(--vt-ay) * 44px)) scale(0.9); opacity: 0; filter: blur(6px); }
}


/* ═══ LE NOM DE LA VILLE : de la carte au grand titre ═══
   Les deux écritures (le chrome de la carte, le titre de la page) se
   relaient en un éclair, au plus vite du mouvement ; une ombre douce les
   garde lisibles sur la photo claire pendant le vol. */
::view-transition-group(bc-nom) { animation-duration: var(--vt-duree); animation-timing-function: var(--vt-glisse); }
::view-transition-old(bc-nom),
::view-transition-new(bc-nom) { height: 100%; object-fit: fill; }
::view-transition-old(bc-nom) { animation: vt-efface 160ms linear 300ms both, vt-nom-ombre var(--vt-duree) linear both; }
::view-transition-new(bc-nom) { animation: vt-apparait 160ms linear 300ms both, vt-nom-ombre var(--vt-duree) linear both; }
@keyframes vt-nom-ombre {
    0%, 100% { filter: drop-shadow(0 2px 16px rgba(0, 0, 0, 0)); }
    25%, 70% { filter: drop-shadow(0 2px 16px rgba(0, 0, 0, 0.6)); }
}


/* ═══ LES BOUTONS DE L'EN-TÊTE : l'appli devient le retour (et l'inverse) ═══ */
::view-transition-group(bc-gauche),
::view-transition-group(bc-compte) { animation-duration: 640ms; animation-timing-function: var(--vt-glisse); }


/* ═══ LE LOGO : celui du fond de l'accueil devient celui de l'en-tête ═══
   --vt-logo-o : le centre du logo de l'en-tête ; --vt-logo-t, --vt-logo-k :
   le déplacement et l'échelle qui le posent sur celui de l'accueil. */
html.vt-arrivee::view-transition-new(bc-entete) {
    transform-origin: var(--vt-logo-o, 50% 50%);
    animation: vt-logo-arrive 560ms var(--vt-sortie) 60ms both;
}
html.vt-retour::view-transition-old(bc-entete) {
    transform-origin: var(--vt-logo-o, 50% 50%);
    animation: vt-logo-repart 420ms var(--vt-glisse) both;
}
@keyframes vt-logo-arrive {
    from { opacity: 0; transform: translate(var(--vt-logo-t, 0px, 0px)) scale(var(--vt-logo-k, 1)); }
}
@keyframes vt-logo-repart {
    to { opacity: 0; transform: translate(var(--vt-logo-t, 0px, 0px)) scale(var(--vt-logo-k, 1)); }
}


/* ═══ LE TEXTE DE LA PAGE SALON (le kicker, la ligne de lumière) ET LA BARRE ═══
   À l'arrivée, le kicker et la ligne apparaissent quand le titre se pose ;
   la barre est vivante : elle monte d'elle-même (bottom-nav.css), un peu
   plus tard que d'habitude. */
html.vt-arrivee::view-transition-new(bc-hero) { animation: vt-apparait 480ms ease-out 420ms both; }
html.vt-arrivee::view-transition-new(bc-dock) { animation: none; }
html.vt-retour::view-transition-old(bc-hero) { animation: vt-efface 220ms ease-out both; }
html.vt-retour::view-transition-old(bc-dock) { animation: vt-dock-descend 420ms cubic-bezier(0.5, 0, 0.75, 0) both; }
@keyframes vt-dock-descend { to { transform: translateY(140%); opacity: 0; } }


/* ═══ LE RESTE DE LA PAGE (les fonds) ═══ */
html.vt-arrivee::view-transition-old(root) { animation: vt-efface 420ms ease-out both; }
html.vt-arrivee::view-transition-new(root) { animation: vt-apparait 420ms ease-in-out 140ms both; }
html.vt-retour::view-transition-old(root) { animation: vt-efface 380ms ease-out both; }
html.vt-retour::view-transition-new(root) { animation: vt-apparait 440ms ease-in-out 120ms both; }

@keyframes vt-efface { to { opacity: 0; } }
@keyframes vt-apparait { from { opacity: 0; } }


/* Moins d'animations : le script ne pose rien, la page bascule simplement. */
@media (prefers-reduced-motion: reduce) {
    .relais { display: none; }
}
