/* Real-time "living document" affordances: the change flash, viewer presence,
   per-cell editing rings, and the AI-is-filling banner. Colors come from the
   shared design tokens so this reads as part of the same surface. */

/* ---- Change flash -------------------------------------------------------- */
/* Added by realtime_controller.js to any element whose value just changed via a
   broadcast (a teammate's edit, the AI filling a cell, a re-rag). The element
   blooms in the accent tint and settles. Honors reduced-motion. */
/* The bloom is an opacity-crossfaded overlay (compositor, S-tier) rather than an
   animated background-color/box-shadow (paint, C-tier). realtime_controller
   injects a `.rt-flash-layer` child into the changed element and removes it on
   animationend — a single mechanism that works for every flash target, including
   td.cell whose ::before (RAG stripe) and ::after (peer-edit label) are both taken. */
@keyframes rt-flash-kf {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.rt-flash-layer {
  position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent-edge);
  pointer-events: none;
  animation: rt-flash-kf 1.15s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* The flash hosts must establish a positioning context for the absolute layer.
   Most already do; feed-item and ad-hoc [data-rt-flash] targets need it added. */
.feed-item, [data-rt-flash] { position: relative; }
@media (prefers-reduced-motion: reduce) {
  .rt-flash-layer { animation-duration: 0.01ms; }
}

/* ---- Viewer presence (who's looking at this scorecard) ------------------- */
.rt-presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.rt-presence-avatars {
  display: inline-flex;
  flex-direction: row-reverse; /* later avatars tuck behind earlier ones */
}
.rt-presence-av {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  margin-left: -7px;
  display: inline-grid;
  place-items: center;
  font: 500 10px/1 var(--sans);
  color: #fff;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-1, 0 1px 2px rgba(20, 18, 12, 0.08));
  background: var(--accent);
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}
.rt-presence-av.rt-enter { transform: scale(0.4); opacity: 0; }
.rt-presence-av.rt-more {
  background: var(--surface-2);
  color: var(--ink-3);
}
.rt-presence-count {
  font: 450 11.5px/1 var(--sans);
  color: var(--ink-4);
  white-space: nowrap;
}

/* ---- Per-cell editing ring (someone else is editing this cell) ----------- */
td.cell.rt-editing {
  box-shadow: inset 0 0 0 2px var(--rt-peer-color, var(--accent));
  position: relative;
  z-index: 1;
}
td.cell.rt-editing::after {
  content: attr(data-rt-editor);
  position: absolute;
  top: -9px;
  right: -4px;
  z-index: 3;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--rt-peer-color, var(--accent));
  color: #fff;
  font: 500 9.5px/1.4 var(--sans);
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: var(--shadow-1, 0 1px 2px rgba(20, 18, 12, 0.12));
  pointer-events: none;
}

/* ---- AI-is-filling banner ------------------------------------------------ */
.rt-ai-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--accent-edge);
  color: var(--ink-2, var(--ink));
  font: 450 12.5px/1.3 var(--sans);
  overflow: hidden;
  /* Collapsed by default; .rt-on reveals it. The layout props (max-height,
     padding, margin, border) toggle instantly — animating them would be layout-
     tier (D). The *visible* reveal is opacity + transform only (compositor, S):
     the banner fades and slides in while its box snaps to size underneath. */
  max-height: 0;
  margin-block: 0;
  padding-block: 0;
  border-width: 0;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.rt-ai-banner.rt-on {
  max-height: 60px;
  padding-block: 8px;
  margin-block: 0 10px;
  border-width: 1px;
  opacity: 1;
  transform: none;
}
.rt-ai-spark {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--accent);
  animation: rt-spin 1.4s linear infinite;
}
@keyframes rt-spin { to { transform: rotate(360deg); } }
/* A pulsing ellipsis (opacity, compositor S-tier) rather than animating `content`
   through "·"→"··"→"···" (each step repaints the text, paint-tier). */
.rt-ai-dots::after {
  content: "···";
  animation: rt-dots 1.4s ease-in-out infinite;
}
@keyframes rt-dots {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .rt-ai-spark { animation: none; }
  .rt-ai-dots::after { animation: none; }
  .rt-ai-banner { transition: opacity 0.2s ease; }
}
