/* ---------- the reply note over an open app, and its history (ui/js/stage/replies.js) ---------- */

#reply-note {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 11; /* over the app and the chatter box */
  width: min(640px, 100%);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow), 0 2px 10px rgba(0, 0, 0, 0.06);
  color: var(--fg);
  font-size: 14px;
  cursor: default;
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.98);
  transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}
#reply-note[hidden] { display: none; }
#reply-note.show { opacity: 1; transform: translate(-50%, 0); }
#reply-note.ask { border-left-color: var(--fg); }

#reply-note .rn-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 10px 14px;
}
#reply-note .rn-text {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  font-weight: 500;
}
#reply-note button {
  display: inline-flex;
  align-items: center;
  flex: none;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  border-radius: 8px;
}
#reply-note button:hover, #reply-note button:focus-visible { color: var(--fg); background: var(--surface-2); outline: none; }
#reply-note button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#reply-note .rn-more { padding: 4px 6px 4px 8px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; font-size: 11px; }
#reply-note .rn-more[hidden] { display: none; }
#reply-note .rn-more svg { transition: transform 0.2s var(--ease); }
#reply-note .rn-more[aria-expanded="true"] svg { transform: rotate(90deg); }
#reply-note .rn-close { width: 26px; height: 26px; justify-content: center; }

#reply-note .rn-body {
  max-height: 34vh;
  overflow: auto;
  padding: 0 14px 12px;
  color: var(--fg);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
#reply-note .rn-body[hidden] { display: none; }
#reply-note .rn-body p { margin: 0 0 0.5em; }
#reply-note .rn-body > :last-child { margin-bottom: 0; }

/* How long the note has left: a thin line that runs out along its bottom edge. */
#reply-note .rn-timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  transform-origin: left;
  animation: rn-run var(--rn-ms, 8000ms) linear forwards;
}
#reply-note.paused .rn-timer { animation-play-state: paused; }
#reply-note.pinned .rn-timer { display: none; }
@keyframes rn-run {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* The badge by the menu button: replies that faded unread, and the way back to them. */
#replies-btn {
  position: absolute;
  left: 34px;
  top: -7px;
  z-index: 10;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid var(--surface);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  animation: rn-pop 0.3s var(--ease);
}
#replies-btn[hidden] { display: none; }
#replies-btn.quiet { min-width: 12px; width: 12px; height: 12px; padding: 0; top: -4px; left: 37px; background: var(--muted); opacity: 0.55; }
#replies-btn.quiet:hover, #replies-btn:focus-visible { opacity: 1; outline: none; }
@keyframes rn-pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#replies {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 12;
  width: min(560px, 100%);
  max-height: 50vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
#replies[hidden] { display: none; }
#replies.show { opacity: 1; transform: none; }
#replies .rp-title {
  padding: 12px 16px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
#replies .rp-list { margin: 0; padding: 0 8px 8px; list-style: none; overflow: auto; }
#replies li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
}
#replies li:first-child { border-top: 0; }
#replies li time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; padding-top: 1px; }
#replies li.unseen time { color: var(--accent); font-weight: 600; }
#replies li .md p { margin: 0 0 0.4em; }
#replies li .md > :last-child { margin-bottom: 0; }
/* Open, the full reply reads on its own: the one-liner would only repeat its start. */
#reply-note.open .rn-text { visibility: hidden; }
#reply-note.open .rn-head { padding-bottom: 4px; }
#reply-note.open .rn-body { border-top: 0; padding-top: 0; }
