/* Discussion à trois canaux (25/11/2026, demande de Kiko) : Tout le monde (bleu), Ami (rose), Guilde (jaune).
   Fermée : les 8 dernières lignes passent puis s'effacent, comme avant. Ouverte : un panneau avec tout l'historique qu'on
   fait défiler (molette, doigt, stick droit), les onglets des canaux et la saisie de la couleur du canal. */
#chat { --c-tous: #6fb4ff; --c-ami: #ff86c8; --c-guilde: #ffd34d; --c: var(--c-tous); }
#chat.canal-ami { --c: var(--c-ami); }
#chat.canal-guilde { --c: var(--c-guilde); }
#chat.recu { display: flex; }

/* ---- Historique ---- */
#chat .chat-log { max-height: none; overflow: hidden; scrollbar-width: thin; scrollbar-color: var(--c) transparent; overscroll-behavior: contain; }
#chat:not(.ecrit) .chat-log .chat-ligne.old { display: none; }
#chat.ecrit .chat-log {
  pointer-events: auto; overflow-y: auto; max-height: min(42vh, 380px); padding: 6px 6px 6px 4px;
  background: linear-gradient(180deg, rgba(8, 15, 40, .35), rgba(8, 15, 40, .72));
  border: 1px solid rgba(127, 166, 239, .28); border-radius: 4px; touch-action: pan-y;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22px); mask-image: linear-gradient(180deg, transparent 0, #000 22px);
}
#chat.ecrit .chat-log .chat-ligne.old { opacity: .92; }
#chat .chat-log .chat-ligne { position: relative; border-left: 3px solid var(--cl, var(--c-tous)); padding-left: 8px; }
#chat .chat-log .chat-ligne.c-tous { --cl: var(--c-tous); }
#chat .chat-log .chat-ligne.c-ami { --cl: var(--c-ami); background: rgba(60, 10, 40, .5); }
#chat .chat-log .chat-ligne.c-guilde { --cl: var(--c-guilde); background: rgba(50, 38, 4, .52); }
#chat .chat-log .chat-ligne b { color: color-mix(in srgb, var(--cl) 70%, #fff); }
#chat .chat-log .chat-ligne.c-ami .chat-txt { color: #ffe1f1; }
#chat .chat-log .chat-ligne.c-guilde .chat-txt { color: #fff1c2; }
#chat .chat-log .chat-ligne.moi { border-left-style: double; }
#chat .chat-log .chat-ligne.sys { color: #ffb4a8; font-size: .8em; border-left-color: #ff8a78; background: rgba(40, 8, 8, .6); }
#chat .chat-tag { display: inline-flex; align-items: center; margin-right: 6px; vertical-align: -2px; filter: drop-shadow(0 1px 0 #000); }
#chat .chat-tag .pxi { --k: 1.5px; }
#chat .chat-dp { margin: 0 6px 0 2px; opacity: .8; }
#chat .chat-fl { margin: 0 5px; color: var(--c-ami); }
#chat .chat-sig {
  display: none; margin-left: 8px; padding: 0 7px; border-radius: 3px; font-size: .75em; cursor: pointer;
  color: #ffb4a8; border: 1px solid rgba(255, 138, 120, .5); background: rgba(40, 8, 8, .6); vertical-align: 1px;
}
#chat.ecrit .chat-ligne:hover .chat-sig, body.is-touch #chat.ecrit .chat-sig, #chat .chat-sig.arme, #chat .chat-sig.fait { display: inline-block; }
#chat .chat-sig.arme { color: #fff; background: #b8312a; border-color: #ff8a78; }
#chat .chat-sig.fait { color: #9dffb0; border-color: #4fd36a; background: rgba(8, 40, 14, .6); cursor: default; }

/* ---- Saisie (onglets, ami choisi, aide) : seulement quand on écrit ---- */
#chat .chat-saisie { display: none; flex-direction: column; gap: 5px; pointer-events: auto; }
#chat.ecrit .chat-saisie { display: flex; animation: chat-ouvre .18s ease-out; }
@keyframes chat-ouvre { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#chat .chat-onglets { display: flex; gap: 4px; align-items: stretch; }
#chat .chat-onglet {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 9px; font: inherit; font-size: 18px; cursor: pointer;
  color: rgba(232, 240, 255, .7); background: rgba(8, 15, 40, .82); border: 2px solid rgba(127, 166, 239, .3); border-bottom-width: 3px; border-radius: 4px 4px 2px 2px;
  transition: color .12s, border-color .12s, background .12s, transform .12s;
}
#chat .chat-onglet[data-canal="tous"] { --co: var(--c-tous); }
#chat .chat-onglet[data-canal="ami"] { --co: var(--c-ami); }
#chat .chat-onglet[data-canal="guilde"] { --co: var(--c-guilde); }
#chat .chat-onglet:hover { color: #fff; border-color: color-mix(in srgb, var(--co) 60%, transparent); }
#chat .chat-onglet.on { color: #0a1233; background: var(--co); border-color: color-mix(in srgb, var(--co) 55%, #000); text-shadow: none; transform: translateY(-2px); box-shadow: 0 0 12px color-mix(in srgb, var(--co) 45%, transparent); }
#chat .chat-onglet.vide:not(.on) { opacity: .45; }
#chat .chat-onglet.pop { animation: chat-pop .22s ease-out; }
@keyframes chat-pop { 0% { transform: translateY(-2px) scale(1); } 45% { transform: translateY(-3px) scale(1.08); } 100% { transform: translateY(-2px) scale(1); } }
#chat .chat-lr { display: none; margin-left: auto; align-items: center; gap: 3px; }
#chat .chat-lr kbd { font: inherit; font-size: 13px; padding: 1px 5px; border: 1px solid rgba(232, 240, 255, .4); border-radius: 3px; color: #e8f0ff; background: rgba(8, 15, 40, .8); }
#chat.pad .chat-lr { display: inline-flex; }
#chat .chat-row { align-items: stretch; }
#chat .chat-in { border-color: var(--c) !important; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5), 0 0 14px color-mix(in srgb, var(--c) 30%, transparent); transition: border-color .15s, box-shadow .15s; }
#chat .chat-send { border-color: var(--c) !important; color: var(--c) !important; }
#chat .chat-dest {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; font-size: 20px; cursor: pointer; white-space: nowrap;
  color: #4a0b2c; background: var(--c-ami); border: 2px solid #c93d86; border-radius: 3px;
}
#chat .chat-dest.hidden { display: none; }
#chat .chat-dest b { font-weight: normal; }
#chat .chat-dest i { font-style: normal; opacity: .6; font-size: .8em; }
#chat .chat-dest.pop { animation: chat-pop .22s ease-out; }
#chat .chat-amis { display: flex; flex-direction: column; gap: 2px; max-width: 340px; padding: 4px; background: rgba(8, 15, 40, .92); border: 2px solid var(--c-ami); border-radius: 4px; animation: chat-ouvre .14s ease-out; }
#chat .chat-amis.hidden { display: none; }
#chat .chat-ami { display: flex; align-items: center; gap: 8px; padding: 3px 10px; font: inherit; font-size: 19px; text-align: left; color: #ffe1f1; background: transparent; border: 1px solid transparent; border-radius: 3px; cursor: pointer; }
#chat .chat-ami b { font-weight: normal; }
#chat .chat-ami:hover, #chat .chat-ami.sel { background: rgba(255, 134, 200, .2); border-color: var(--c-ami); color: #fff; }
#chat .chat-pt { width: 8px; height: 8px; border-radius: 50%; background: #6b7390; box-shadow: 0 0 0 1px #000; }
#chat .chat-pt.on { background: #4fe36a; box-shadow: 0 0 6px #4fe36a; }
#chat .chat-ami-vide { padding: 4px 8px; font-size: 16px; color: rgba(255, 225, 241, .75); }
#chat .chat-aide { font-size: 14px; color: rgba(232, 240, 255, .6); text-shadow: 0 1px 0 #000; min-height: 0; }
#chat .chat-aide:empty { display: none; }
body.grand-texte #chat .chat-onglet { font-size: 22px; }

/* ---- (26/11) Taille choisie : poignée en haut à droite (souris), LT + stick gauche (manette) ---- */
#chat.taille { width: var(--chat-l); }
#chat.taille.ecrit .chat-log { height: var(--chat-h); max-height: none; }
#chat .chat-poignee {
  display: none; position: absolute; top: -9px; right: -9px; width: 22px; height: 22px; cursor: nesw-resize; pointer-events: auto; z-index: 2;
  background: rgba(8, 15, 40, .9); border: 2px solid color-mix(in srgb, var(--c) 70%, #000); border-radius: 4px; box-shadow: 0 0 0 1px #000;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
#chat .chat-poignee i, #chat .chat-poignee::before, #chat .chat-poignee::after { content: ''; position: absolute; height: 2px; background: var(--c); right: 3px; transform-origin: right center; transform: rotate(-45deg); }
#chat .chat-poignee i { top: 4px; width: 12px; }
#chat .chat-poignee::before { top: 8px; width: 7px; }
#chat .chat-poignee::after { top: 12px; width: 3px; }
#chat.ecrit .chat-poignee { display: block; animation: chat-ouvre .18s ease-out; }
#chat .chat-poignee:hover, #chat.etire .chat-poignee { transform: scale(1.15); border-color: var(--c); box-shadow: 0 0 10px color-mix(in srgb, var(--c) 55%, transparent); }
#chat.etire .chat-log { outline: 2px dashed color-mix(in srgb, var(--c) 60%, transparent); outline-offset: 2px; }
#chat .chat-lr-t { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; font-size: 13px; color: rgba(232, 240, 255, .7); }
body.is-touch #chat .chat-poignee { display: none !important; }

/* Téléphone : onglets plus gros au doigt, historique moins haut (le clavier prend la place). */
body.is-touch #chat.ecrit .chat-log { max-height: 30vh; }
body.is-touch #chat .chat-saisie { width: 100%; }
body.is-touch #chat .chat-onglets { justify-content: center; }
body.is-touch #chat .chat-onglet { font-size: 16px; padding: 6px 12px; min-height: 36px; }
body.is-touch #chat .chat-amis { align-self: center; width: min(320px, 100%); }
body.is-touch #chat .chat-aide { display: none; }
@media (prefers-reduced-motion: reduce) { #chat .chat-saisie, #chat .chat-onglet.pop, #chat .chat-dest.pop, #chat .chat-amis { animation: none !important; } }
