/* ux.css — améliorations d'ergonomie partagées par tous les jeux (chargé via includes/game_header.php) */

/* Parcours en 3 étapes */
.ux-steps {
    margin: 12px 16px 4px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.10);
    position: relative;
}
.ux-steps-list {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.ux-steps-list li {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    text-align: center; font-size: .72rem; font-weight: 700; line-height: 1.25;
    color: var(--muted, #94a3b8);
}
.ux-steps-list .ux-n {
    width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: .8rem;
    background: var(--theme, #1db87a); color: #111;
}
.ux-steps-tv {
    margin-top: 10px; padding: 6px 10px; border-radius: 10px;
    font-size: .72rem; font-weight: 800; text-align: center;
    background: rgba(249,115,22,.14); color: #f97316; border: 1px solid rgba(249,115,22,.35);
}
.ux-steps-close {
    position: absolute; top: 2px; right: 4px; min-width: 32px; min-height: 32px;
    background: none; border: 0; color: var(--muted, #94a3b8); font-size: 1.1rem; cursor: pointer;
}

/* Toast (Copié !, etc.) */
.ux-toast {
    position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
    font-weight: 800; font-size: .85rem; z-index: 100000;
    border: 1px solid rgba(255,255,255,.15); box-shadow: 0 8px 24px rgba(0,0,0,.4);
    transition: opacity .2s ease, transform .2s ease;
}
.ux-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Bouton occupé : feedback immédiat + anti double-clic */
.ux-busy { position: relative; pointer-events: none; opacity: .75; }
.ux-busy::after {
    content: ''; display: inline-block; width: 14px; height: 14px; margin-left: 10px;
    border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
    vertical-align: -2px; animation: ux-spin .7s linear infinite;
}
@keyframes ux-spin { to { transform: rotate(360deg); } }

/* Zones tactiles confortables (≥ 44 px) */
.btn-cta, .tab-btn, .bottom-nav button, .bottom-nav a { min-height: 44px; }
button, [role="button"], a.btn-cta { touch-action: manipulation; }

/* Le bouton flottant Stev'Bot ne masque plus le bas du contenu */
.page-content { padding-bottom: max(var(--ux-bottom-gap, 0px), 0px); }
body.ux-has-bot .page-content { padding-bottom: 110px; }

/* Accessibilité : focus visible au clavier */
:focus-visible { outline: 3px solid var(--theme, #1db87a); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Options avancées repliables */
details.ux-adv { margin: 4px 0 16px; border: 1px solid var(--border, rgba(255,255,255,.12)); border-radius: 14px; padding: 4px 14px 10px; background: rgba(255,255,255,.03); }
details.ux-adv > summary { cursor: pointer; font-weight: 800; font-size: .85rem; padding: 12px 0; min-height: 44px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.ux-adv > summary::-webkit-details-marker { display: none; }
details.ux-adv > summary::after { content: '▾'; margin-left: auto; transition: transform .2s; }
details.ux-adv[open] > summary::after { transform: rotate(180deg); }
details.ux-adv > summary small { font-weight: 600; color: var(--muted, #94a3b8); }

/* ═══════════════════════════════════════════════════════════════
   MODE LUDIQUE — couche de fun partagée (rebonds, confettis, ripples…)
   Tout est désactivé automatiquement si prefers-reduced-motion.
   ═══════════════════════════════════════════════════════════════ */
:root {
    --fun-spring: cubic-bezier(.34, 1.56, .64, 1);
    --fun-pink: #ff5ea8; --fun-yellow: #ffd23f; --fun-cyan: #3ee6ff; --fun-violet: #a06bff;
}

/* Emojis flottants en arrière-plan */
.fun-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.fun-bg span {
    position: absolute; bottom: -60px; font-size: var(--s, 28px); opacity: 0;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,.35));
    animation: fun-float var(--d, 16s) linear var(--delay, 0s) infinite;
}
@keyframes fun-float {
    0%   { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 0; }
    10%  { opacity: .13; }
    90%  { opacity: .13; }
    100% { transform: translate3d(var(--x, 30px), -110vh, 0) rotate(var(--r, 360deg)); opacity: 0; }
}

/* Titre : dégradé animé + petit balancement */
.hero h1 {
    background-size: 220% 100% !important;
    animation: fun-shimmer 5s ease-in-out infinite;
}
@keyframes fun-shimmer { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
.hero { animation: fun-pop-in .6s var(--fun-spring) both; }
.hero .fun-wiggle, .hero-emoji { display: inline-block; animation: fun-wiggle 2.8s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes fun-wiggle { 0%,100% { transform: rotate(0); } 10% { transform: rotate(-12deg); } 20% { transform: rotate(10deg); } 30% { transform: rotate(-6deg); } 40% { transform: rotate(0); } }
@keyframes fun-pop-in { from { opacity: 0; transform: scale(.8) translateY(14px); } to { opacity: 1; transform: none; } }

/* Entrée en cascade des cartes */
.fun-stagger { animation: fun-pop-in .5s var(--fun-spring) both; animation-delay: calc(var(--i, 0) * 70ms); }

/* Boutons : rebond tactile + brillance */
.btn-cta, .studio-btn, .help-opt, .mode-card, .studio-card, .profile-link { transition-timing-function: var(--fun-spring); }
.btn-cta:hover { transform: translateY(-3px) scale(1.03); }
.btn-cta:active { transform: scale(.92) !important; }
.btn-cta-primary {
    position: relative; overflow: hidden;
    background-image: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.45) 50%, transparent 70%);
    background-size: 250% 100%; background-position: 200% 0; background-repeat: no-repeat;
    animation: fun-shine 3.6s ease-in-out infinite;
}
@keyframes fun-shine { 0%, 55% { background-position: 200% 0; } 100% { background-position: -100% 0; } }
.mode-card:hover, .studio-card:hover { transform: translateY(-3px) rotate(-.4deg); }
.mode-card.selected, .mode-card.active, .help-opt.selected { animation: fun-jelly .5s var(--fun-spring); }
@keyframes fun-jelly {
    0% { transform: scale(1); } 30% { transform: scale(1.07, .93); } 50% { transform: scale(.95, 1.05); }
    70% { transform: scale(1.03, .98); } 100% { transform: scale(1); }
}
.mode-icon, .studio-icon { transition: transform .4s var(--fun-spring); }
.mode-card:hover .mode-icon, .studio-card:hover .studio-icon { transform: scale(1.25) rotate(-10deg); }

/* Ripple */
.fun-ripple { position: absolute; border-radius: 50%; pointer-events: none; background: rgba(255,255,255,.55); transform: scale(0); animation: fun-ripple .6s ease-out forwards; }
@keyframes fun-ripple { to { transform: scale(1); opacity: 0; } }
.mode-card, .studio-btn, .nav-item, .help-opt { position: relative; overflow: hidden; }

/* Champ code : pop à chaque lettre + halo */
.code-input.fun-typed, #codeInput.fun-typed, #game-code.fun-typed, #join-code.fun-typed, #join-code-input.fun-typed { animation: fun-key .18s var(--fun-spring); }
@keyframes fun-key { 0% { transform: scale(1); } 50% { transform: scale(1.04); } 100% { transform: scale(1); } }
.code-input:focus, #codeInput:focus, #game-code:focus, #join-code:focus, #join-code-input:focus {
    box-shadow: 0 0 0 4px rgba(var(--neon-rgb, 29,184,122), .25), 0 0 24px rgba(var(--neon-rgb, 29,184,122), .35) !important;
}

/* Barre du bas : nav qui rebondit, FAB qui pulse */
.nav-item.active { animation: fun-jelly .5s var(--fun-spring); }
.fab-join { position: relative; }
.fab-join::before {
    content: ''; position: absolute; inset: -6px; border-radius: 50%;
    border: 2px solid rgba(29,184,122,.7); animation: fun-ring 2.2s ease-out infinite; pointer-events: none;
}
@keyframes fun-ring { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }

/* Crédits : pièce qui brille + pop quand la valeur change */
.credits-badge::before { content: '🪙'; font-size: .95rem; display: inline-block; animation: fun-coin 3.5s ease-in-out infinite; }
@keyframes fun-coin { 0%,70%,100% { transform: rotateY(0); } 85% { transform: rotateY(360deg) scale(1.2); } }
.credits-badge.fun-bump { animation: fun-jelly .6s var(--fun-spring); }

/* Étapes : numéros qui rebondissent à tour de rôle */
.ux-steps-list .ux-n { animation: fun-bounce 2.4s ease-in-out infinite; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.ux-steps-list li:nth-child(2) .ux-n { animation-delay: .25s; }
.ux-steps-list li:nth-child(3) .ux-n { animation-delay: .5s; }
@keyframes fun-bounce { 0%,60%,100% { transform: translateY(0); } 30% { transform: translateY(-8px); } 45% { transform: translateY(0); } 52% { transform: translateY(-3px); } }

/* Toast ludique */
.ux-toast { transition-timing-function: var(--fun-spring); background: linear-gradient(135deg, #1f2937, #111827); }
.ux-toast.show { transform: translate(-50%, 0) scale(1.04); }

/* SweetAlert : entrée « pop » */
.swal2-popup.swal2-show { animation: fun-pop-in .45s var(--fun-spring) !important; }

/* Confettis (canvas) */
.fun-confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100001; }

/* Mascotte flottante cliquable (easter egg) */
.fun-hint { position: fixed; left: 12px; bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); z-index: 90; font-size: 1.6rem; cursor: pointer; background: none; border: 0; animation: fun-bounce 3s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
    .fun-bg, .fab-join::before, .fun-confetti { display: none !important; }
}

/* ── Lisibilité : champ « CODE » (placeholder et bordure plus contrastés) ── */
.code-input::placeholder, #codeInput::placeholder, #game-code::placeholder, #join-code::placeholder, #join-code-input::placeholder {
    color: rgba(255,255,255,.55) !important; opacity: 1 !important; letter-spacing: 4px;
}
.code-input, #codeInput, #game-code, #join-code, #join-code-input {
    border-color: rgba(255,255,255,.28) !important; font-size: max(16px, 2rem) !important; /* ≥16px : pas de zoom auto sur iPhone */
}
/* iOS : aucun champ ne doit déclencher le zoom automatique */
input, select, textarea { font-size: max(16px, 1em); }
/* Petits écrans : bulle d'aide du bot discrète, jamais par-dessus un champ */
@media (max-width: 420px) { #stev-bot-bubble, .stev-bot-bubble { display: none !important; } }
/* Pas de débordement horizontal sur mobile */
html, body { max-width: 100%; overflow-x: hidden; }
img, video, canvas { max-width: 100%; }
