/* Lumière et mouvement, partagés par toutes les pages. Chaque page définit --halo (sa couleur de lumière).
   Seuls transform et opacity sont animés : fluide même sur un vieux téléphone. Tout s'arrête si l'appareil demande moins d'animations. */
@property --tour { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
:root { --cta: #2fd671; --surcta: #04170b; --halo: #ff6b2c; --ressort: cubic-bezier(.34, 1.4, .64, 1); }

/* Bouton principal : lueur qui respire, reflet qui suit le doigt, trait de lumière qui fait le tour */
.principal { position: relative; isolation: isolate; border-radius: 20px; transition: transform .35s var(--ressort), background .3s, filter .2s; }
.principal:not(:disabled) { color: var(--surcta); background: radial-gradient(150px circle at var(--mx, 50%) var(--my, -30%), rgba(255,255,255,.22), transparent 70%), linear-gradient(180deg, var(--cta), color-mix(in srgb, var(--cta) 80%, #000)); box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 10px 30px -8px color-mix(in srgb, var(--cta) 55%, transparent); }
.principal:not(:disabled)::after { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; box-shadow: 0 0 22px 1px color-mix(in srgb, var(--cta) 60%, transparent), 0 14px 54px color-mix(in srgb, var(--cta) 50%, transparent); animation: respire 2.8s ease-in-out infinite; }
.principal:not(:disabled)::before { content: ''; position: absolute; inset: -1.5px; z-index: 1; padding: 1.5px; border-radius: 21.5px; pointer-events: none; background: conic-gradient(from var(--tour), transparent 0 58%, color-mix(in srgb, var(--cta) 80%, transparent) 72%, #fff 80%, color-mix(in srgb, var(--cta) 80%, transparent) 88%, transparent 100%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); animation: tourne 4.5s linear infinite; }
.principal:active:not(:disabled) { transform: scale(.965); transition-duration: .1s; }
@media (hover: hover) { .principal:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); } }
@keyframes respire { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes tourne { to { --tour: 360deg; } }

/* Aurore : deux nappes de lumière qui dérivent lentement derrière le contenu */
.aurore { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.aurore::before, .aurore::after { content: ''; position: absolute; width: 90vmax; height: 90vmax; max-width: 900px; max-height: 900px; border-radius: 50%; will-change: transform; background: radial-gradient(circle, color-mix(in srgb, var(--halo) 42%, transparent), transparent 62%); }
.aurore::before { left: -28%; top: -55%; animation: derive 16s ease-in-out infinite alternate; }
.aurore::after { right: -38%; bottom: -70%; opacity: .6; animation: derive 21s ease-in-out infinite alternate-reverse; }
@keyframes derive { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(14%, 12%, 0) scale(1.18); } }

/* Cartes : une lumière suit le doigt ou la souris */
.lumiere { position: relative; }
.lumiere::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s; background: radial-gradient(220px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--halo) 26%, transparent), transparent 70%); }
@media (hover: hover) { .lumiere:hover::after { opacity: 1; } }
.lumiere:active::after { opacity: 1; transition-duration: .05s; }

/* Apparition au défilement */
.avant { opacity: 0; transform: translateY(26px) scale(.97); }
.apparait { transition: opacity .7s cubic-bezier(.2, .7, .2, 1) var(--retard, 0ms), transform .8s cubic-bezier(.2, .7, .2, 1) var(--retard, 0ms); }
.saute { animation: saute .5s var(--ressort); }
@keyframes saute { 40% { transform: scale(1.35); } }
::view-transition-group(piece) { animation-duration: .42s; animation-timing-function: cubic-bezier(.32, .72, 0, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; }

@media (prefers-reduced-motion: reduce) {
  .principal::before, .principal::after, .aurore::before, .aurore::after, .saute { animation: none !important; }
  .avant { opacity: 1; transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- Ergonomie mobile commune ---------- */
/* Plusieurs appuis rapides sur un bouton ne font plus zoomer la page (le pincement pour zoomer reste possible) */
button, a, label, summary, input, select, textarea, .etape, .piece { touch-action: manipulation; }
button, summary, .principal, .second { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* La page derrière une feuille ouverte ne défile pas */
html:has(dialog[open]) { overflow: hidden; }
/* Le clavier ne cache plus le bouton : la feuille se cale au-dessus de lui */
dialog { max-height: min(94dvh, calc(var(--vue, 100dvh) - 14px)) !important; margin-bottom: var(--clavier, 0px) !important; transition: margin-bottom .2s; }
@media (min-width: 720px) { dialog { margin-bottom: auto !important; } }
/* Poignée : on peut tirer la feuille vers le bas pour la fermer */
dialog .tete { position: relative; touch-action: none; padding-top: 20px !important; }
dialog .tete::before { content: ''; position: absolute; left: 50%; top: 8px; width: 38px; height: 5px; border-radius: 9px; translate: -50% 0; background: currentColor; opacity: .2; }
.lien { min-height: 44px !important; min-width: 44px; display: inline-flex !important; align-items: center; }
