/* ==========================================================================
   ESPACE DE DISCUSSION — salon d'auditeurs
   --------------------------------------------------------------------------
   Deux colonnes : le salon à gauche, le contexte d'antenne à droite.
   Sous 1080 px, la colonne latérale passe sous le salon.
   ========================================================================== */

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: var(--sp-4);
  align-items: start;
}

/* --------------------------------------------------------------- Le salon */
.chat-panel {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Message épinglé de la station ------------------------------------------ */
.chat-pinned {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(105deg, var(--ink-900), var(--royal-500));
  color: var(--text-on-night);
  border-bottom: 3px solid var(--gold-400);
}
.chat-pinned__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(248, 148, 66, 0.18);
  color: var(--gold-300);
}
.chat-pinned p { margin: 0; font-size: var(--fs-sm); line-height: 1.55; }
.chat-pinned strong { color: var(--gold-300); }

/* Barre d'état : combien de personnes écoutent -------------------------- */
.chat-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem var(--sp-3);
  padding: 0.9rem var(--sp-4);
  background: var(--cream-200);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.chat-online {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  color: var(--slate-700);
}
.chat-online strong { color: var(--clay-700); font-variant-numeric: tabular-nums; }
.chat-status__note { color: var(--text-soft); }

/* Fil de messages -------------------------------------------------------- */
.chat-messages {
  padding: var(--sp-4);
  max-height: 62vh;
  min-height: 420px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--cream-300) transparent;
  background:
    radial-gradient(circle at 12% 0%, rgba(248, 148, 66, 0.07), transparent 55%),
    radial-gradient(circle at 88% 100%, rgba(0, 66, 140, 0.06), transparent 55%);
}
.chat-messages:focus-visible { outline: 3px solid var(--gold-500); outline-offset: -3px; }
.chat-messages::-webkit-scrollbar { width: 10px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--cream-300); border-radius: 999px; }

.chat-msg {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 0.9rem;
  margin-bottom: var(--sp-3);
}
.chat-msg:last-child { margin-bottom: 0; }

.msg-avatar {
  flex: none;
  width: 46px; height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
}
.msg-avatar.is-tone-a { background: var(--gold-200); color: #6d3300; }
.msg-avatar.is-tone-b { background: var(--cream-200); color: var(--royal-500); }
.msg-avatar.is-tone-c { background: var(--clay-100); color: var(--clay-700); }
.msg-avatar.is-host-avatar {
  background: linear-gradient(145deg, var(--royal-500), var(--ink-800));
  color: var(--gold-300);
  border-color: var(--gold-300);
}

.msg-body { min-width: 0; }
.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.6rem;
  margin: 0 0 0.35rem;
  font-size: var(--fs-sm);
  line-height: 1.3;
}
.msg-name { font-weight: 700; color: var(--slate-700); }
.msg-place { color: var(--text-soft); }
.msg-place::before { content: "· "; }
.msg-time { color: var(--slate-500); font-variant-numeric: tabular-nums; }
.msg-host-badge {
  padding: 0.1rem 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--gold-500);
  color: var(--ink-900);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.msg-bubble {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px var(--radius) var(--radius) var(--radius);
  padding: 0.85rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.msg-bubble p { margin: 0; font-size: var(--fs-sm); line-height: 1.62; }

.chat-msg.is-host .msg-bubble {
  background: linear-gradient(160deg, var(--ink-900), var(--ink-700));
  border-color: var(--royal-400);
  color: var(--text-on-night);
}
.chat-msg.is-host .msg-name { color: var(--slate-700); }

.chat-msg.is-mine .msg-bubble { background: var(--gold-100); border-color: var(--gold-300); }
.chat-msg.is-mine .msg-avatar { background: var(--ink-700); color: var(--gold-300); }

.msg-report {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin-top: 0.15rem;
  padding: 0.2rem 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--slate-500);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s var(--ease), color 0.18s var(--ease);
}
.chat-msg:hover .msg-report,
.msg-report:focus-visible { opacity: 1; }
.msg-report:hover { color: var(--clay-700); text-decoration: underline; }
.msg-report[disabled] { opacity: 1; color: var(--leaf-700); cursor: default; text-decoration: none; }

/* Zone de saisie --------------------------------------------------------- */
.chat-compose {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--cream-100);
}
.chat-compose__row { display: flex; gap: 0.6rem; align-items: stretch; }
.chat-compose__row input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: var(--touch);
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--white);
  border: 2px solid var(--cream-300);
  border-radius: var(--radius-pill);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.chat-compose__row input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(244, 133, 36, 0.16);
}
.chat-tool {
  flex: none;
  width: var(--touch); height: var(--touch);
  display: grid; place-items: center;
  border: 2px solid var(--cream-300);
  border-radius: 50%;
  background: var(--white);
  color: var(--slate-500);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), color 0.18s var(--ease), background-color 0.18s var(--ease);
}
.chat-tool:hover,
.chat-tool[aria-expanded="true"] { border-color: var(--gold-500); color: var(--gold-700); background: var(--gold-100); }
.chat-send { flex: none; min-height: var(--touch); padding-inline: 1.6rem; }

.chat-emoji {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.chat-emoji[hidden] { display: none; }
.chat-emoji__btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-size: 1.35rem;
  line-height: 1;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  transition: background-color 0.16s var(--ease), transform 0.16s var(--ease);
}
.chat-emoji__btn:hover { background: var(--gold-100); transform: scale(1.12); }

.chat-compose__hint {
  margin: 0.75rem 0 0;
  font-size: var(--fs-sm);
  color: var(--text-soft);
}
.chat-compose__hint span { font-variant-numeric: tabular-nums; font-weight: 600; }
.chat-compose__hint.is-low span { color: var(--clay-700); }

/* Retours au participant : confirmation, avertissement, refus. */
.chat-note {
  margin-top: 0.85rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  background: var(--leaf-100);
  border: 1px solid rgba(10, 74, 122, 0.28);
  color: var(--leaf-700);
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.chat-note.is-warn {
  background: var(--gold-100);
  border-color: var(--gold-300);
  color: var(--gold-700);
}
.chat-note.is-error {
  background: var(--clay-100);
  border-color: rgba(124, 45, 18, 0.3);
  color: var(--clay-700);
}
.chat-note[hidden] { display: none; }

/* ------------------------------------------------- Inscription au salon */
.chat-join {
  padding: var(--sp-4);
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 100% 0%, rgba(0, 66, 140, 0.07), transparent 60%),
    var(--cream-100);
}
.chat-join[hidden] { display: none; }
.chat-join__head h3 {
  margin: 0 0 0.35rem;
  font-size: 1.4rem;
}
.chat-join__head p {
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-soft);
  max-width: 62ch;
}

.chat-join__row { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--sp-3); }
.chat-join__fields { display: grid; gap: var(--sp-3); min-width: 0; }

/* Photo, facultative — un monogramme doré tant qu'il n'y en a pas. */
.chat-join__photo {
  position: relative;
  display: grid; justify-items: center; align-content: start;
  gap: 0.5rem;
}
.chat-join__avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  display: grid; place-items: center;
  overflow: hidden;
  background: linear-gradient(150deg, var(--ink-700), var(--royal-500));
  color: var(--gold-300);
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 600;
  box-shadow: 0 0 0 3px var(--cream-50), 0 0 0 5px var(--gold-300), var(--shadow-sm);
}
.chat-join__avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-join__photobtn {
  display: inline-flex; flex: none;
  min-width: 108px; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 1rem;
  border-radius: var(--radius-pill);
  border: 2px solid var(--gold-400);
  background: var(--white);
  color: var(--gold-700);
  font-size: var(--fs-sm); font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background-color 0.16s var(--ease);
}
.chat-join__photobtn:hover { background: var(--gold-100); }
.chat-join__photo input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.chat-join__photo input[type="file"]:focus-visible + .chat-join__photobtn,
.chat-join__photobtn:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.chat-join__photohint {
  font-size: var(--fs-sm);
  color: var(--slate-500);
}
.chat-join__photoclear {
  border: 0; background: none; cursor: pointer;
  font: inherit; font-size: var(--fs-sm);
  color: var(--slate-500);
  min-height: 34px;
  text-decoration: underline;
}
.chat-join__photoclear:hover { color: var(--clay-700); }

.chat-join__label,
.chat-join .field > label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--slate-700);
}
.chat-join .field input[type="text"],
.chat-join .field input[type="email"],
.chat-join .field input[type="tel"] {
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 1rem;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--white);
  border: 2px solid var(--cream-300);
  border-radius: var(--radius);
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.chat-join .field input:focus {
  outline: none;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(244, 133, 36, 0.16);
}
.chat-join .hint {
  display: block;
  margin-top: 0.35rem;
  font-size: var(--fs-sm);
  color: var(--slate-500);
  line-height: 1.5;
}
.chat-join .req { color: var(--clay-700); }

/* Courriel ou téléphone : un seul champ, deux modes. */
.chat-join__seg {
  display: inline-flex;
  padding: 4px;
  margin-bottom: 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--cream-200);
  border: 1px solid var(--cream-300);
}
.chat-join__segbtn {
  min-height: 38px; padding: 0 1.1rem;
  border: 0; border-radius: var(--radius-pill);
  background: none; cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  color: var(--slate-500);
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}
.chat-join__segbtn[aria-pressed="true"] {
  background: var(--ink-800);
  color: var(--white);
  box-shadow: var(--shadow-sm);
}

/* Plus spécifique que « .chat-join .field > label », sinon la case à cocher
   hérite du display:block des étiquettes et le texte ne s'aligne plus. */
.chat-join .field--check > label.check {
  display: flex; align-items: flex-start; gap: 0.7rem;
  margin-bottom: 0;
  font-weight: 400;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--text);
  cursor: pointer;
}
.chat-join .check input {
  flex: none;
  width: 22px; height: 22px;
  margin-top: 2px;
  accent-color: var(--gold-500);
}

.chat-join__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.chat-join__legal {
  margin: 0;
  flex: 1 1 18rem;
  font-size: var(--fs-sm);
  color: var(--slate-500);
  line-height: 1.5;
}

/* ------------------------------------------------- Bandeau « c'est vous » */
.chat-me {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.chat-me__avatar {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  overflow: hidden;
  background: linear-gradient(150deg, var(--ink-700), var(--royal-500));
  color: var(--gold-300);
  font-family: var(--font-display);
  font-size: 1rem; font-weight: 600;
  box-shadow: 0 0 0 2px var(--cream-50), 0 0 0 3px var(--gold-300);
}
.chat-me__avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-me__text { display: grid; min-width: 0; }
.chat-me__text small {
  font-size: var(--fs-sm);
  color: var(--slate-500);
  line-height: 1.3;
}
.chat-me__text strong {
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
  color: var(--slate-700);
}
.chat-me__leave {
  margin-left: auto;
  min-height: 40px; padding: 0 1rem;
  border: 2px solid var(--cream-300);
  border-radius: var(--radius-pill);
  background: var(--white);
  cursor: pointer;
  font: inherit; font-size: var(--fs-sm); font-weight: 600;
  color: var(--slate-500);
  transition: border-color 0.16s var(--ease), color 0.16s var(--ease);
}
.chat-me__leave:hover { border-color: var(--gold-400); color: var(--gold-700); }

/* Photo de profil dans le fil, quand l'auditeur en a mis une. */
.msg-avatar.has-photo { overflow: hidden; padding: 0; }
.msg-avatar.has-photo img { width: 100%; height: 100%; object-fit: cover; }

.msg-you {
  padding: 0.1rem 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--ink-800);
  color: var(--gold-300);
  font-size: 0.9375rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}

/* Bouclier du bandeau d'état : le filtre est visible, pas seulement promis. */
.chat-status__note { display: inline-flex; align-items: center; gap: 0.45em; }
.chat-status__shield { display: inline-flex; color: var(--leaf-700); }

/* ------------------------------------------------------ Colonne latérale */
.chat-side { display: grid; gap: var(--sp-3); }

.side-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--sp-3) var(--sp-3) var(--sp-4);
}
.side-card h2 {
  font-size: 1.2rem;
  margin: 0.65rem 0 0.5rem;
}
.side-card__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: var(--lh-snug);
  margin: 0.7rem 0 0.25rem;
  color: var(--slate-700);
}
.side-card__sub { margin: 0; font-size: var(--fs-sm); color: var(--text-soft); }
.side-card__next {
  margin: 0.85rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  color: var(--text-soft);
}
.side-card__next strong { color: var(--slate-700); font-variant-numeric: tabular-nums; }

.badge-live,
.badge-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius-pill);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.badge-live { background: var(--clay-100); color: var(--clay-700); }
.badge-gold { background: var(--gold-100); color: var(--gold-700); }

/* Titre en cours, en miniature ------------------------------------------ */
.side-np__row { display: flex; align-items: center; gap: 0.9rem; margin-top: 0.85rem; }
.side-np__media {
  position: relative;
  flex: none;
  width: 72px; height: 72px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink-800);
}
.side-np__media .np-card__art {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.side-np__text { display: grid; gap: 0.15rem; min-width: 0; }
.side-np__text strong {
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.25;
  color: var(--slate-700);
}
.side-np__text span { font-size: var(--fs-sm); color: var(--text-soft); }

/* Règles du salon -------------------------------------------------------- */
.rules-list {
  margin: 0 0 0.9rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.7rem;
}
.rules-list li {
  position: relative;
  padding-left: 1.7rem;
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.rules-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--gold-500);
}

.side-cta {
  background: linear-gradient(150deg, var(--ink-900), var(--royal-500));
  border-color: var(--royal-400);
  color: var(--text-on-night);
}
.side-cta h2 { color: var(--white); margin-top: 0; }
.side-cta p { font-size: var(--fs-sm); color: var(--text-on-night-soft); }

/* ------------------------------------------------------------ Adaptatif */
@media (max-width: 1080px) {
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .side-rules { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .chat-side { grid-template-columns: minmax(0, 1fr); }
  .chat-join { padding: var(--sp-3); }
  .chat-join__row { grid-template-columns: minmax(0, 1fr); }
  .chat-join__photo { justify-items: start; }
  .chat-me__leave { margin-left: 0; width: 100%; }
  .chat-me { flex-wrap: wrap; }
  .chat-messages { padding: var(--sp-3); max-height: none; min-height: 340px; }
  .chat-pinned, .chat-status, .chat-compose { padding-inline: var(--sp-3); }
  .chat-msg { grid-template-columns: 38px minmax(0, 1fr); gap: 0.65rem; }
  .msg-avatar { width: 38px; height: 38px; font-size: 0.95rem; }
  .chat-send { padding-inline: 1.1rem; }
  .msg-report { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-emoji__btn:hover { transform: none; }
}
