/* Spectateurs des jeux. Bornes d'arcade (public/js/arcade-live.js) : la petite fenêtre de qui
   regarde, en bas à droite au-dessus du zoom, et la carte « Vous regarde » dans la borne du joueur.
   Tables de jeu (public/js/spectators.js) : la pastille « Farid regarde ». Mêmes jetons que app.css
   et jeux.css. */

/* --- Fenêtre de qui regarde ------------------------------------------------------------------ */

.watch {
  position: absolute;
  right: calc(var(--edge) + var(--panel-space));
  bottom: calc(var(--edge) + 72px + var(--gap));
  z-index: 6;
  /* L'écran (192 × 160) à une fois et demie : trois pixels Retina par pixel de jeu, net. Les
     32 px de plus : les marges de la fenêtre et du cadre de l'écran. */
  width: calc(288px + 32px);
  padding: 10px;
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition:
    right var(--slide),
    bottom var(--slide);
  animation: watch-in var(--dur-slow) var(--ease-spring) both;
}
.watch.leaving {
  animation: watch-out var(--dur-base) var(--ease-in) both;
}
@keyframes watch-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.94);
  }
}
@keyframes watch-out {
  to {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
}
/* Grand écran : deux fois ; petit écran : une fois. */
@media (min-width: 1680px) {
  .watch {
    width: calc(384px + 32px);
  }
}
@media (max-width: 760px) {
  .watch {
    width: calc(192px + 32px);
  }
}
/* Écran étroit : le zoom monte au-dessus du dock et de la carte, la fenêtre aussi. */
.app.card-up .watch {
  bottom: calc(var(--edge) + 2 * (var(--dock-h) + var(--gap)) + 72px + var(--gap));
}
/* Le bouton « Recentrer » lui laisse la place : à gauche du zoom. */
.app.watching:not(.card-up) .recenter {
  right: calc(var(--edge) + 40px + var(--gap) + var(--panel-space));
  bottom: var(--edge);
}

.watch-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}
.watch-face {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--fill);
  overflow: hidden;
  flex: none;
}
.watch-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.watch-title b {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sub);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.watch-title > span {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-footnote);
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.watch-muted {
  display: inline-flex;
  color: var(--red);
}
.watch-muted .ic {
  width: 13px;
  height: 13px;
}
/* En direct : un point rouge qui respire, doucement. */
.watch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  flex: none;
  animation: watch-breathe 2.4s var(--ease-out) infinite;
}
@keyframes watch-breathe {
  50% {
    opacity: 0.45;
  }
}

/* L'écran : celui de la borne, en petit. */
.watch-screen {
  padding: 6px;
  border-radius: 14px;
  background: #0b0816;
  box-shadow:
    inset 0 0 0 2px #3b3566,
    inset 0 0 24px rgba(0, 0, 0, 0.85);
}
.watch-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 192 / 160;
  border-radius: 6px;
  image-rendering: pixelated;
}

.watch-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 2px;
}
.watch-mic {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--fill);
  color: var(--text);
  font: 600 var(--fs-footnote) / 1 var(--font);
  cursor: pointer;
  transition:
    background var(--dur-fast) var(--ease-out),
    transform var(--dur-slow) var(--ease-spring);
}
.watch-mic:hover {
  background: var(--fill-2);
}
.watch-mic:active {
  transform: scale(0.95);
  transition-duration: var(--dur-press);
}
.watch-mic .ic {
  width: 14px;
  height: 14px;
  color: var(--red);
}
.watch-mic.on .ic {
  color: var(--green-text);
}
.watch-mic kbd {
  margin: 0;
}
.watch-peers {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-left: auto;
  font-size: var(--fs-footnote);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.watch-peers .ic {
  width: 13px;
  height: 13px;
}

/* --- Chez le joueur : qui le regarde ------------------------------------------------------- */

/* Repliée tant que personne ne regarde ; elle se déplie en douceur, sans pousser l'écran de jeu
   (elle est dans la colonne des records). La marge négative rend l'écart de la colonne. */
.arcade-card.watchers {
  display: grid;
  grid-template-rows: 0fr;
  padding-block: 0;
  margin-bottom: -10px;
  opacity: 0;
  background: color-mix(in srgb, var(--accent) 13%, var(--fill));
  transition:
    grid-template-rows var(--dur-sheet) var(--ease-sheet),
    padding var(--dur-sheet) var(--ease-sheet),
    margin var(--dur-sheet) var(--ease-sheet),
    opacity var(--dur-base) var(--ease-out);
}
.arcade-card.watchers.on {
  grid-template-rows: 1fr;
  padding-block: 10px;
  margin-bottom: 0;
  opacity: 1;
}
.watchers-in {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.arcade-card.watchers small .ic {
  color: var(--accent);
}
.watchers-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.watcher {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 2px 8px 2px 2px;
  border-radius: var(--r-pill);
  background: var(--fill);
  font-size: var(--fs-sub);
}
.watcher canvas,
.watcher .ic {
  border-radius: 50%;
  flex: none;
}
.watcher b {
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.watcher.more {
  padding: 2px 8px;
  color: var(--text-2);
}
.watchers-talk {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 0;
  font-size: var(--fs-footnote);
  font-weight: 600;
  color: var(--text-2);
}
.watchers-talk .ic {
  width: 14px;
  height: 14px;
  color: var(--red);
}
.watchers-talk.on .ic {
  color: var(--green-text);
}
.watchers-keys {
  margin: 0;
  font-size: var(--fs-footnote);
  color: var(--text-3);
}

/* --- Tables de jeu : qui regarde ------------------------------------------------------------- */

/* Dans la barre du titre, repliée tant que personne ne regarde ; elle apparaît en douceur. */
.watch-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 0;
  height: 30px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent) 13%, var(--fill));
  font-size: var(--fs-footnote);
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  opacity: 0;
  transition:
    max-width var(--dur-sheet) var(--ease-sheet),
    padding var(--dur-sheet) var(--ease-sheet),
    opacity var(--dur-base) var(--ease-out);
}
.watch-pill.on {
  max-width: 340px;
  padding: 0 12px 0 10px;
  opacity: 1;
}
.watch-pill > .ic {
  width: 14px;
  height: 14px;
  color: var(--accent);
}
.watch-pill > span:not(.watch-pill-key) {
  overflow: hidden;
  text-overflow: ellipsis;
}
.watch-pill-key {
  flex: none;
  color: var(--text-3);
  font-weight: 500;
}
.watch-pill-key::before {
  content: "· ";
}

@media (prefers-reduced-motion: reduce) {
  .watch,
  .watch.leaving,
  .watch-dot {
    animation: none;
  }
}
