/* Compléments du design (chargé après theme.css) : rôles, chat, et toutes les animations du site.
   Les animations sont coupées si l'appareil demande moins de mouvement. */

/* ---------- Rôles, bannière sur toute la largeur, chat ---------- */
.bannieres { grid-template-columns: minmax(0, 1fr) !important; }
.rang.perso { color: var(--couleur-role); border-color: var(--couleur-role); background: color-mix(in srgb, var(--couleur-role) 12%, transparent); }
.rang-chat[style] { color: var(--couleur-role); background: color-mix(in srgb, var(--couleur-role) 16%, transparent); }
.grille-roles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); margin-bottom: 18px; }
.role-tete { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.liste-permissions { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
.liste-permissions li { margin: 3px 0; }
.permissions { border: 1px solid var(--bord); border-radius: 14px; padding: 12px 16px; display: grid; gap: 8px; min-width: 0; }
.permissions legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
/* Son propre nom au-dessus de ses messages, aligné à droite */
.mien .tete { margin: 0 12px 3px 0; flex-direction: row-reverse; }

/* ---------- Animations ---------- */
@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@media (prefers-reduced-motion: no-preference) {
  /* Fond : des halos de couleur qui dérivent lentement */
  body::before {
    content: ""; position: fixed; inset: -20%; z-index: -1; pointer-events: none;
    background:
      radial-gradient(38% 34% at 22% 28%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
      radial-gradient(34% 30% at 78% 72%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%),
      radial-gradient(26% 24% at 70% 18%, color-mix(in srgb, var(--violet) 12%, transparent), transparent 70%);
    animation: derive 26s ease-in-out infinite alternate;
  }
  @keyframes derive { from { transform: translate3d(-3%, -2%, 0) rotate(0deg) scale(1); } to { transform: translate3d(4%, 3%, 0) rotate(8deg) scale(1.08); } }

  /* Changement de page : l'ancienne recule, la nouvelle monte */
  ::view-transition-old(contenu) { animation: 110ms ease-in both page-sort; }
  ::view-transition-new(contenu) { animation: 300ms cubic-bezier(.16, 1, .3, 1) both page-entre; }
  @keyframes page-sort { to { opacity: 0; transform: scale(.985) translateY(-6px); } }
  @keyframes page-entre { from { opacity: 0; transform: translateY(26px) scale(.985); } }

  /* Les blocs d'une page arrivent l'un après l'autre */
  main > *, .grille > *, .grille-badges > *, .grille-cartes > *, .lignes-procs > li, .liste > li, .grille-encheres > *, .resume-badges > * {
    animation: apparait .42s cubic-bezier(.16, 1, .3, 1) both;
  }
  @keyframes apparait { from { opacity: 0; transform: translateY(18px) scale(.98); } }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(2) { animation-delay: 35ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(3) { animation-delay: 70ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(4) { animation-delay: 105ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(5) { animation-delay: 140ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(6) { animation-delay: 175ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(7) { animation-delay: 210ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(8) { animation-delay: 245ms; }
  :is(main, .grille, .grille-badges, .grille-cartes, .lignes-procs, .liste, .grille-encheres, .resume-badges) > :nth-child(n + 9) { animation-delay: 280ms; }
  /* Pas d'effet d'arrivée sur ce qui a déjà sa propre animation ou doit rester en place */
  main > .chat, .zone-booster > *, #tirage > *, .effets-collection { animation: none; }

  /* Menu : l'icône rebondit au survol, l'onglet actif s'allume, l'engrenage du logo tourne */
  .barre nav a .icone { transition: transform .35s cubic-bezier(.34, 1.56, .64, 1); }
  .barre nav a:hover .icone { transform: scale(1.22) rotate(-8deg); }
  .barre nav a.actif .icone { animation: rebond .6s cubic-bezier(.34, 1.56, .64, 1) both; }
  @keyframes rebond { from { transform: scale(.5); } }
  .barre nav a.actif::before { animation: barre-active .45s cubic-bezier(.16, 1, .3, 1) both; }
  @keyframes barre-active { from { transform: scaleY(0); } }
  .logo span { animation: engrenage 14s linear infinite; border-radius: 50%; } /* rond : seul l'engrenage semble tourner */
  .logo:hover span { animation-duration: 2.5s; }
  @keyframes engrenage { to { transform: rotate(360deg); } }
  .barre .badge { animation: pastille 2.4s ease-in-out infinite; }
  @keyframes pastille { 50% { transform: scale(1.18); } }

  /* Cartes : elles se soulèvent et s'éclairent */
  .carte.lien, .tuile, .carte.tech, .badge-carte, .carte-role { transition: transform .35s cubic-bezier(.16, 1, .3, 1), box-shadow .35s, border-color .25s; }
  .carte.lien:hover, .tuile:hover, .carte.tech:hover, .badge-carte.obtenu:hover, .carte-role:hover {
    transform: translateY(-6px) scale(1.012); border-color: color-mix(in srgb, var(--accent) 55%, var(--bord));
    box-shadow: 0 26px 50px -22px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  .tuile-icone { transition: transform .45s cubic-bezier(.34, 1.56, .64, 1); }
  .tuile:hover .tuile-icone { transform: scale(1.18) rotate(-10deg); }
  .ligne-proc { transition: transform .25s cubic-bezier(.16, 1, .3, 1), background .2s; }
  .ligne-proc:hover { transform: translateX(6px); }

  /* Boutons : un reflet les traverse au survol */
  .btn { position: relative; overflow: hidden; isolation: isolate; }
  .btn::after {
    content: ""; position: absolute; inset: 0; z-index: -1; transform: translateX(-120%) skewX(-20deg);
    background: linear-gradient(90deg, transparent, rgb(255 255 255 / .38), transparent);
  }
  .btn:hover:not(:disabled)::after { transform: translateX(120%) skewX(-20deg); transition: transform .7s ease; }
  .btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 28px -12px color-mix(in srgb, var(--accent) 85%, transparent); }
  .btn.secondaire:hover:not(:disabled) { box-shadow: 0 10px 22px -14px color-mix(in srgb, var(--accent) 70%, transparent); }

  /* Bannière : dégradé vivant et reflet qui flotte */
  .infos { background-size: 220% 220%; animation: degrade-vivant 14s ease-in-out infinite alternate; }
  @keyframes degrade-vivant { from { background-position: 0% 30%; } to { background-position: 100% 70%; } }
  .infos::after { animation: flotte 9s ease-in-out infinite alternate; }
  @keyframes flotte { to { transform: translate(-60px, 50px) scale(1.25); } }
  .techs li { animation: apparait .5s cubic-bezier(.34, 1.56, .64, 1) both; }

  /* Titres : un trait de couleur se dessine dessous */
  main h1 { position: relative; width: fit-content; max-width: 100%; }
  main h1::after {
    content: ""; position: absolute; left: 0; bottom: -6px; height: 4px; width: 56px; border-radius: 4px; background: var(--degrade);
    animation: trait .7s .15s cubic-bezier(.16, 1, .3, 1) both; transform-origin: left;
  }
  @keyframes trait { from { transform: scaleX(0); opacity: 0; } }
  .chat-tete h1::after, .centre h1::after { display: none; }

  /* Chat : les bulles surgissent, les alertes glissent depuis le bord */
  .ligne-msg.nouveau { animation: bulle .45s cubic-bezier(.34, 1.56, .64, 1) both; transform-origin: left bottom; }
  .ligne-msg.mien.nouveau { transform-origin: right bottom; }
  @keyframes bulle { from { opacity: 0; transform: scale(.6) translateY(14px); } }
  .toast-direct { animation: toast-glisse .55s cubic-bezier(.34, 1.56, .64, 1) both; }
  @keyframes toast-glisse { from { opacity: 0; transform: translateX(120%); } }
  .flash { animation: apparait .5s cubic-bezier(.34, 1.56, .64, 1) both; }
  .toast-badge { animation: apparait .6s cubic-bezier(.34, 1.56, .64, 1) both, lueur 2.2s ease-in-out 3; }
  @keyframes lueur { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent), 0 20px 40px -18px color-mix(in srgb, var(--accent) 70%, transparent); } }

  /* Chiffres clés : couleur d'accent (pas de dégradé sur le texte : il effacerait les emojis) */
  .stat .valeur { color: var(--accent); }

  /* Page de connexion : liseré lumineux qui tourne autour de la carte */
  .centre { position: relative; }
  .centre::before {
    content: ""; position: absolute; inset: -2px; z-index: -1; border-radius: 28px; padding: 2px;
    background: conic-gradient(from var(--angle), transparent 0 55%, var(--accent), var(--violet), var(--accent-2), transparent 95%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
    animation: tourne 6s linear infinite;
  }
  @keyframes tourne { to { --angle: 360deg; } }
}

/* ---------- Chat : liste des conversations (canaux et messages privés) ---------- */
.chat.avec-convs { flex-direction: row; }
.chat-principal { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; } /* min-height 0 : la zone des messages rétrécit, la saisie reste visible */
.chat-principal #messages { min-height: 0; }
.convs { flex: none; width: 236px; padding: 14px 10px; overflow-y: auto; border-right: 1px solid var(--bord); display: flex; flex-direction: column; gap: 3px;
         background: color-mix(in srgb, var(--fond) 55%, var(--surface)); }
.titre-convs { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.titre-convs:first-child { padding-top: 0; }
.ajout-conv { width: 24px; height: 24px; border-radius: 8px; border: 1px solid var(--bord); background: var(--surface); color: var(--accent); font-size: 16px; line-height: 1; cursor: pointer; }
.ajout-conv:hover { border-color: var(--accent); }
.conv { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 12px; background: none; color: var(--texte);
        font: inherit; font-weight: 500; text-align: left; cursor: pointer; transition: background .15s, transform .15s; }
.conv:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.conv.actif { background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); font-weight: 600; }
.conv .nom-conv { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .emoji-conv { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--surface); border: 1px solid var(--bord); font-size: 15px; }
.conv .avatar { width: 28px; height: 28px; font-size: 10px; position: relative; }
.conv .avatar.en-ligne::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; border: 2px solid var(--surface); }
.conv .cadenas { font-size: 11px; }
.conv .badge { margin: 0; }
.nouveau-prive { margin-top: 8px; padding: 8px 10px; font-size: 14px; }
#form-canal h2 { margin: 0; }
@media (max-width: 760px) {
  /* Téléphone : les conversations passent en bandeau horizontal au-dessus des messages */
  .chat.avec-convs { flex-direction: column; }
  .convs { width: auto; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--bord); padding: 8px 10px; scrollbar-width: none; }
  .convs::-webkit-scrollbar { display: none; }
  .titre-convs { padding: 0 4px; white-space: nowrap; gap: 6px; }
  .conv { width: auto; flex: none; padding: 6px 10px; }
  .conv .nom-conv { flex: none; }
  .nouveau-prive { margin: 0; width: auto; flex: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .conv:hover { transform: translateX(3px); }
  .conv .badge { animation: pastille 2.4s ease-in-out infinite; }
}

/* Téléphone, page Chat : la conversation occupe tout l’écran entre la barre du haut et les onglets du bas (champ de saisie toujours visible). */
@media (max-width: 899.98px) {
  body:has(main > .chat) .bloc-bannieres { display: none; }
  main:has(> .chat) { padding-top: 10px; }
  main > .chat { height: max(360px, calc(100dvh - 170px)); }
}

/* Liens en forme de bouton : en bloc, sinon le reflet et l’onde débordent du bouton (un lien « en ligne » ne les découpe pas). */
a.btn { display: inline-block; text-align: center; }
