/* =====================================================
   QUIZZIFY — Design System
   Style : "Quizzy UI Kit" décliné en BLEU CIEL dominant
   Coins très arrondis · ombres douces · friendly · mobile-first
   ===================================================== */

:root {
    /* ---------- Couleur dominante : bleu ciel ---------- */
    --sky-50:  #f0f9ff;
    --sky-100: #e0f2fe;
    --sky-200: #bae6fd;
    --sky-300: #7dd3fc;
    --sky-400: #38bdf8;
    --sky-500: #0ea5e9;   /* couleur principale */
    --sky-600: #0284c7;
    --sky-700: #0369a1;
    --sky-800: #075985;
    --sky-900: #0c4a6e;

    /* ---------- Rôles ---------- */
    --primary:        var(--sky-500);
    --primary-hover:  var(--sky-600);
    --primary-soft:   var(--sky-100);
    --primary-ink:    var(--sky-700);

    /* Dégradé d'ambiance (fonds, projection, héros) */
    --gradient-primary: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 45%, #0284c7 100%);
    --gradient-soft:    linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);

    /* ---------- Couleurs des réponses QCM (style Kahoot) ---------- */
    --rep-1: #ef4444;   /* rouge   */
    --rep-2: #3b82f6;   /* bleu    */
    --rep-3: #f59e0b;   /* jaune/orange */
    --rep-4: #22c55e;   /* vert    */
    --rep-5: #a855f7;   /* violet  */
    --rep-6: #ec4899;   /* rose    */

    /* ---------- Sémantique ---------- */
    --success: #22c55e;
    --danger:  #ef4444;
    --warning: #f59e0b;
    --info:    var(--sky-500);

    /* ---------- Neutres ---------- */
    --ink:          #0f172a;   /* texte principal */
    --ink-soft:     #475569;   /* texte secondaire */
    --muted:        #64748b;   /* texte discret (contraste AA) */
    --line:         #e2e8f0;   /* bordures */
    --surface:      #ffffff;   /* cartes */
    --surface-alt:  #f8fafc;   /* fond de page */

    /* ---------- Rayons (coins très arrondis) ---------- */
    --r-sm:  10px;
    --r-md:  16px;
    --r-lg:  24px;
    --r-xl:  32px;
    --r-full: 9999px;

    /* ---------- Ombres douces ---------- */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-md: 0 6px 18px rgba(15, 23, 42, .08);
    --shadow-lg: 0 16px 40px rgba(14, 165, 233, .18);
    --shadow-primary: 0 10px 24px rgba(14, 165, 233, .35);

    /* ---------- Typographie ---------- */
    --font: 'Poppins', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;

    /* ---------- Transitions ---------- */
    --t-fast: .15s ease;
    --t:      .25s ease;
}

/* =====================================================
   Base
   ===================================================== */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--surface-alt);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; margin: 0 0 .5em; }
a { color: var(--primary-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =====================================================
   Boutons
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .8rem 1.4rem;
    font: inherit;
    font-weight: 600;
    border: none;
    border-radius: var(--r-full);
    cursor: pointer;
    transition: transform var(--t-fast), box-shadow var(--t), background var(--t);
    text-decoration: none;
}
.btn:active { transform: translateY(1px) scale(.99); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }

.btn-ghost {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--surface-alt); text-decoration: none; }

.btn-lg  { padding: 1rem 1.8rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* =====================================================
   Cartes
   ===================================================== */
.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
}
.card-pad-lg { padding: 2rem; }

/* =====================================================
   Tuiles de réponse (style Kahoot) — joueur / animation / projection
   Toute la mise en forme est ICI (classe) pour ne JAMAIS être écrasée
   par un :style dynamique d'Alpine (qui ne gère que la couleur de fond).
   ===================================================== */
.qtile {
    position: relative;
    overflow: hidden;
    border: none;
    border-radius: var(--r-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .3em;
    text-align: center;
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow-md);
    transition: opacity .3s, transform .15s;
}
.qtile, .qtile * { color: #fff; }

/* Emojis uniformisés (Twemoji) : dimensionnés comme du texte, alignés sur la ligne */
img.qz-emoji, img.emoji { height: 1em; width: 1em; margin: 0 .05em; vertical-align: -0.125em; display: inline-block; }
/* min-height:0 → les tuiles se laissent compresser pour tenir dans la hauteur dispo.
   font-size en clamp() = base réactive ; l'auto-ajustement JS (fit.js) la réduit si besoin. */
.qtile-player { min-height: 0; padding: clamp(.45rem, 2.5vw, 1.25rem); font-size: clamp(.8rem, 4.5vw, 1.5rem); cursor: pointer; }
.qtile-player:active { transform: scale(.98); }
.qtile-proj   { min-height: 72px; padding: clamp(.6rem, 1.6vw, 2rem); font-size: clamp(1.05rem, 2.6vw, 3.2rem); }
/* Mauvaise réponse en correction : fortement grisée. On utilise filter (et non opacity)
   car l'animation pop-in se termine à opacity:1 et écraserait une simple opacity. */
.qtile-dim    { filter: grayscale(0.92) opacity(0.4); }
.qtile-img    { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.qtile-shape  { font-size: 1.5em; opacity: .95; position: relative; z-index: 1; line-height: 1; }
.qtile-txt    { position: relative; z-index: 1; max-width: 100%; overflow-wrap: anywhere; line-height: 1.15; }
.qtile-txt-img { background: rgba(0,0,0,.5); padding: .35rem 1rem; border-radius: 14px; }
.qtile-check  { font-size: clamp(2.8rem, 7vh, 5.5rem); line-height: 1; position: relative; z-index: 1; text-shadow: 0 2px 6px rgba(0,0,0,.25); }
.qtile-votes  { position: absolute; bottom: 12px; right: 14px; background: rgba(255,255,255,.3); border-radius: 999px; padding: .25rem 1rem; font-size: 1.2rem; z-index: 1; }
.qtile-bar    { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: rgba(0,0,0,.18); z-index: 1; }
.qtile-bar > i { display: block; height: 100%; background: rgba(255,255,255,.85); }

/* =====================================================
   Podium (formateur / projection)
   ===================================================== */
.podium-wrap  { display: flex; align-items: flex-end; justify-content: center; gap: clamp(1rem, 3vw, 3rem); flex-wrap: wrap; }
.podium-col   { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: clamp(150px, 16vw, 250px); }
.podium-col-1 { order: 2; } .podium-col-2 { order: 1; } .podium-col-3 { order: 3; }
.podium-medal { font-size: 3.4rem; line-height: 1; }
.podium-ava   { font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1; }
.podium-name  { font-weight: 800; font-size: 1.1rem; margin: .25rem 0 0; }
.podium-score { color: var(--primary); font-weight: 700; margin-bottom: .4rem; }
.podium-bar   { width: 100%; border-radius: 16px 16px 0 0; background: var(--gradient-primary); color: #fff; font-weight: 800; font-size: 1.8rem; display: flex; align-items: flex-start; justify-content: center; padding-top: .6rem; }
.podium-bar-1 { height: 150px; } .podium-bar-2 { height: 105px; } .podium-bar-3 { height: 72px; }

/* Podium "bloc" (projection : avatar + infos EN HAUT du bloc, hauteurs très étagées
   → le gagnant est nettement plus haut que le 2e, lui-même plus haut que le 3e) */
.podium-block { background:#fff; color:var(--ink); border-radius:var(--r-lg) var(--r-lg) 0 0; padding:1.5rem 1rem 1rem; text-align:center; display:flex; flex-direction:column; justify-content:flex-start; align-items:center; gap:.4rem; width:clamp(150px,16vw,250px); box-shadow:var(--shadow-lg); }
.podium-block-1 { min-height:clamp(300px,46vh,520px); }
.podium-block-2 { min-height:clamp(220px,34vh,380px); }
.podium-block-3 { min-height:clamp(165px,25vh,290px); }
.podium-block .pb-medal { font-size:clamp(2.8rem,5.5vh,4.6rem); line-height:1; }
.podium-block .pb-ava   { font-size:clamp(2.8rem,6vh,5rem); line-height:1; }
.podium-block .pb-name  { font-weight:800; font-size:clamp(1.2rem,2.6vh,2rem); }
.podium-block .pb-score { color:var(--primary); font-weight:800; font-size:clamp(1rem,2.2vh,1.6rem); }
.podium-myst { background:rgba(255,255,255,.2); border-radius:var(--r-lg) var(--r-lg) 0 0; display:flex; align-items:flex-start; justify-content:center; padding-top:1.5rem; width:clamp(150px,16vw,250px); font-size:clamp(2.4rem,5vh,4rem); }
.podium-myst-1 { min-height:clamp(300px,46vh,520px); }
.podium-myst-2 { min-height:clamp(220px,34vh,380px); }
.podium-myst-3 { min-height:clamp(165px,25vh,290px); }

/* =====================================================
   Champs de formulaire
   ===================================================== */
.field { margin-bottom: 1.1rem; }
.label {
    display: block;
    font-size: .9rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: .4rem;
}
.input, .textarea, .select {
    width: 100%;
    padding: .85rem 1rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: var(--r-md);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--sky-400);
    box-shadow: 0 0 0 4px var(--sky-100);
}
.textarea { min-height: 110px; resize: vertical; }

/* =====================================================
   Alertes / flash
   ===================================================== */
.alert {
    padding: .9rem 1.1rem;
    border-radius: var(--r-md);
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-info    { background: var(--sky-100); color: var(--sky-800); }

/* =====================================================
   Badges / pastilles
   ===================================================== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .75rem;
    border-radius: var(--r-full);
    font-size: .8rem;
    font-weight: 600;
    background: var(--primary-soft);
    color: var(--primary-ink);
}

/* =====================================================
   Utilitaires
   ===================================================== */
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 460px; }
.text-center { text-align: center; }
.gradient-bg { background: var(--gradient-primary); }
.soft-bg { background: var(--gradient-soft); }

/* =====================================================
   Animations communes
   ===================================================== */
@keyframes pop-in {
    0%   { transform: scale(.92); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
}
.pop-in { animation: pop-in .3s ease both; }

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.float { animation: float 3s ease-in-out infinite; }

@keyframes bounce-in {
    0%   { transform: scale(.5); opacity: 0; }
    50%  { transform: scale(1.25); }
    70%  { transform: scale(.92); }
    100% { transform: scale(1); opacity: 1; }
}
.bounce { animation: bounce-in .6s ease both; }

/* --- Animations de jeu (feedback, suspense, podium) --- */

/* Mauvaise réponse : secousse */
@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); }
    40%, 60% { transform: translateX(6px); }
}
.shake { animation: shake .55s ease both; }

/* Bonne réponse : halo vert + rebond */
@keyframes glow-correct {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); transform: scale(1); }
    35%  { transform: scale(1.09); }
    /* État final PERSISTANT (animation-fill-mode both) : la bonne réponse reste
       agrandie avec un halo vert épais → elle ressort nettement des autres (grisées). */
    100% { box-shadow: 0 0 0 .55rem rgba(34, 197, 94, .95), var(--shadow-lg); transform: scale(1.05); }
}
.glow-correct { animation: glow-correct .9s ease both; position: relative; z-index: 2; }

/* Points qui s'envolent */
@keyframes fly-up {
    0%   { opacity: 0; transform: translate(-50%, 10px) scale(.7); }
    15%  { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}
.fly-points {
    position: absolute; left: 50%; top: -6px;
    font-weight: 800; font-size: 1.4rem; color: var(--success);
    animation: fly-up 1.4s ease-out both;
    pointer-events: none; z-index: 50; white-space: nowrap;
    text-shadow: 0 1px 4px rgba(255,255,255,.8);
}

/* Apparition en glissant du bas (cascade de réponses, classement) */
@keyframes slide-up-in {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: none; }
}
.slide-up { animation: slide-up-in .45s cubic-bezier(.2, .8, .3, 1.15) both; }

/* Montée théâtrale (podium) */
@keyframes rise-in {
    0%   { opacity: 0; transform: translateY(90px) scale(.8); }
    60%  { opacity: 1; transform: translateY(-8px) scale(1.03); }
    100% { opacity: 1; transform: none; }
}
.rise-in { animation: rise-in .7s cubic-bezier(.2, .8, .3, 1.1) both; }

/* Barre qui pousse (résultats) : anime depuis 0 vers la largeur inline */
@keyframes grow-x { from { width: 0; } }
.grow-x { animation: grow-x 1s cubic-bezier(.2, .8, .3, 1) both; }

/* Écran qui "chauffe" pendant un streak */
@keyframes heat-pulse {
    0%, 100% { box-shadow: inset 0 0 0 3px rgba(245, 158, 11, .45); }
    50%      { box-shadow: inset 0 0 0 6px rgba(239, 68, 68, .35); }
}
.heat { animation: heat-pulse 1.6s ease-in-out infinite; }

/* Clignotement doux (urgence, suspense) */
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.pulse-soft { animation: pulse-soft .85s ease-in-out infinite; }

/* Vague d'avatars (salle d'attente) */
@keyframes wave-y { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.wave-y { animation: wave-y 1.7s ease-in-out infinite; display: inline-flex; }

/* Toasts de notification */
@keyframes toast-in {
    from { opacity: 0; transform: translateX(60px); }
    to   { opacity: 1; transform: none; }
}
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }
.toast-anim { animation: toast-in .4s cubic-bezier(.2, .8, .3, 1.15) both; }
.toast-anim.toast-exit { animation: toast-out .35s ease both; }

/* Surlignage temporaire (élément qui vient d'être ajouté) */
@keyframes flash-highlight {
    0%   { box-shadow: 0 0 0 4px rgba(14, 165, 233, .55); background: var(--primary-soft); }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); }
}
:target.q-card-anchor, .flash-new { animation: flash-highlight 1.8s ease both; }

/* Bouton icône-seule : le libellé apparaît au survol */
.btn-ih { overflow: hidden; }
.btn-ih .lbl {
    display: inline-block; max-width: 0; opacity: 0; overflow: hidden;
    white-space: nowrap; vertical-align: middle;
    transition: max-width .25s ease, opacity .2s ease, margin-left .2s ease;
}
.btn-ih:hover .lbl, .btn-ih:focus-visible .lbl { max-width: 160px; opacity: 1; margin-left: .35rem; }

/* =====================================================
   Accessibilité (WCAG AA)
   ===================================================== */
:focus-visible {
    outline: 3px solid var(--sky-500);
    outline-offset: 2px;
    border-radius: 4px;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -999px; top: 0; z-index: 200;
    background: var(--primary); color: #fff; padding: .6rem 1rem;
    border-radius: 0 0 var(--r-md) 0; font-weight: 600;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
