/* ==========================================================================
   Note dal vivo: «Scrivi insieme» (js/live.js, js/nb/editor.js)
   Barra della nota (chi c'è, stato), blocchi dove scrive un altro, segno sulle schede.
   ========================================================================== */

/* --- barra della nota: avatar e stato --- */
.lv-slot { display: inline-flex; align-items: center; min-width: 0; flex: 0 1 auto; }
.lv-bar { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.lv-avs { display: inline-flex; align-items: center; flex: none; }
.lv-av {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--lv, #8e8e93); color: #fff;
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em; line-height: 1;
  box-shadow: 0 0 0 2px var(--sheet, #fff);
  user-select: none;
}
.lv-av + .lv-av { margin-left: -7px; }
.lv-av.me { opacity: .55; }
.lv-av.more { background: var(--fill-2); color: var(--ink-2); }
.lv-chip {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 30px; padding: 0 11px;
  border: 0; border-radius: 999px; background: var(--fill-2); color: var(--ink-2);
  font: inherit; font-size: 13px; white-space: nowrap; cursor: pointer;
}
.lv-chip i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); }
.lv-chip .lv-more { overflow: hidden; text-overflow: ellipsis; color: var(--ink-3); }
.lv-chip .lv-more:empty { display: none; }
.lv-chip[data-st="live"] { background: rgba(48, 209, 88, 0.14); color: #1f8a3c; }
.lv-chip[data-st="live"] i { background: #30d158; box-shadow: 0 0 0 3px rgba(48, 209, 88, 0.25); animation: lv-pulse 2.4s ease-in-out infinite; }
.lv-chip[data-st="connecting"] i { background: #ffd60a; animation: lv-pulse 1s ease-in-out infinite; }
.lv-chip[data-st="offline"] { background: rgba(255, 159, 10, 0.16); color: #b26a00; }
.lv-chip[data-st="offline"] i { background: #ff9f0a; }
:root[data-theme="dark"] .lv-chip[data-st="live"] { color: #4fe07a; }
:root[data-theme="dark"] .lv-chip[data-st="offline"] { color: #ffb340; }
@keyframes lv-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .lv-chip i { animation: none !important; } }
@media (max-width: 1100px) { .lv-chip .lv-more { display: none; } }
/* telefono: solo il pallino dello stato e al massimo tre persone */
@media (max-width: 600px) {
  .lv-bar { gap: 5px; }
  .lv-av { width: 24px; height: 24px; font-size: 10px; }
  .lv-avs .lv-av:nth-child(n+4):not(.more) { display: none; }
  .lv-chip { padding: 0 9px; height: 28px; }
  .lv-chip .lv-st { display: none; }
}

/* --- blocchi: dove scrive un altro (bloccato, con il suo colore e il suo nome) --- */
.nb-doc > [data-lk] {
  outline: 2px solid var(--lk, #ff9f0a); outline-offset: 4px; border-radius: 4px;
  background: color-mix(in srgb, var(--lk, #ff9f0a) 7%, transparent);
  cursor: not-allowed; caret-color: transparent;
  transition: outline-color .2s, background-color .2s;
}
.lv-tags { position: absolute; inset: 0 auto auto 0; width: 100%; height: 0; pointer-events: none; z-index: 3; }
.lv-tag {
  position: absolute; transform: translate(-100%, calc(-100% - 6px));
  max-width: 180px; padding: 2px 8px; border-radius: 7px 7px 2px 7px;
  background: var(--lk, #ff9f0a); color: #fff;
  font-size: 11.5px; font-weight: 600; line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16);
}
/* iniziali e nomi leggibili anche sui colori chiari (arancione, verde, azzurro, giallo): testo scuro
   quando la luminosità OKLCH del colore supera 0,72, bianco sotto. Senza il supporto resta bianco.
   La stessa regola è in css/live-ink.css e css/condivisi.css */
@supports (color: oklch(from red l c h)) {
  .lv-av { color: oklch(from var(--lv, #8e8e93) clamp(0.2, (0.72 - l) * 1000, 1) 0 0); }
  .lv-tag { color: oklch(from var(--lk, #ff9f0a) clamp(0.2, (0.72 - l) * 1000, 1) 0 0); }
}
/* in attesa dei pezzi dal server (prima apertura) */
.nb-ed-shell.lv-wait .nb-doc { opacity: .5; }
.nb-ed-shell.lv-wait::after {
  content: attr(data-wait); position: absolute; top: 6px; left: 0; /* il testo lo mette js/nb/editor.js, tradotto */
  color: var(--ink-3); font-size: 14px;
}
.nb-ed-shell.lv-wait.is-empty .nb-doc::before { content: none; }

/* --- schede delle note: «dal vivo» con chi ci scrive --- */
.lv-badge {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  margin-top: 4px; padding: 2px 4px 2px 9px; border-radius: 999px;
  background: rgba(48, 209, 88, 0.13); color: #1f8a3c;
  font-size: 12px; font-weight: 600; line-height: 22px;
}
:root[data-theme="dark"] .lv-badge { color: #4fe07a; }
.lv-badge > i { width: 7px; height: 7px; border-radius: 50%; background: #30d158; }
.lv-badge:not(:has(.lv-avs)) { padding-right: 9px; }
.lv-badge .lv-av { width: 20px; height: 20px; font-size: 9px; box-shadow: 0 0 0 1.5px var(--card, var(--sheet, #fff)); }
.lv-badge .lv-av + .lv-av { margin-left: -5px; }
