/* public join page: emoji reaction buttons */

/* Grid, not flex-wrap: with 12 emoji a wrapping row leaves an unfinished
   last line depending on viewport width (5+5+2, etc). A fixed 4-column
   grid always fills evenly (4x3), regardless of how many are ever added. */

.emoji-btn-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.emoji-btn-form {
  margin: 0;
}

.emoji-btn {
  width: 100%;
  font-size: 1.9rem;
  line-height: 1;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.emoji-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}

.emoji-btn:active {
  transform: scale(0.9);
}

/* small icon-only buttons (question moderation, QR zoom) */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.btn-icon svg {
  width: 1rem;
  height: 1rem;
}

.btn-icon:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
  color: var(--text);
}

.btn-icon.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.btn-icon--danger:hover {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* board: full-screen live view */

.rw-board {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

.rw-body {
  flex: 1;
  max-width: 50rem;
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* corner badge: just the QR code, toggleable */

.rw-corner {
  position: fixed;
  top: 4.2rem;
  right: 1rem;
  z-index: 5;
  width: 9rem;
  height: 9rem;
}

.rw-corner.is-hidden {
  display: none;
}

/* reaction bursts: a full-viewport layer where emoji rise and drift
   through, appended by the board's 1s poll (see board.html /
   reactionwall.js). A gentle single-direction drift with a touch of
   rotation -- enough to not read as a flat vertical float, not so much
   that a handful arriving together look chaotic. */

.reaction-burst-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}

.burst-emoji {
  position: absolute;
  bottom: -2rem;
  font-size: 2.6rem;
  line-height: 1;
  opacity: 0;
  animation: rw-burst-rise 3s ease-out forwards;
  will-change: transform, opacity;
}

@keyframes rw-burst-rise {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(0.5);
    opacity: 0;
  }
  15% {
    transform: translate(calc(var(--rw-drift, 0) * 8px), -18vh) rotate(calc(var(--rw-drift, 0) * 4deg)) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--rw-drift, 0) * 30px), -95vh) rotate(calc(var(--rw-drift, 0) * 7deg)) scale(0.92);
    opacity: 0;
  }
}

/* questions list: a plain divided list, not boxed cards, so it reads
   cleanly at a distance without a wall of borders */

.rw-questions {
  margin-top: 0.5rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.question-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.question-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.1rem;
  border-bottom: 1px solid var(--border);
}

.question-row:last-child {
  border-bottom: none;
}

.question-row.is-answered {
  opacity: 0.45;
}

.question-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.15rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.question-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.question-actions form {
  margin: 0;
}

.question-empty {
  color: var(--text-faint);
  padding: 0.7rem 0.1rem;
}

/* vote score: a pill (not a fixed circle) so "+3" and "+123" both fit
   without clipping -- width grows with the content, height stays fixed
   so it still reads as a round badge for the common single-digit case */

.question-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 1.7rem;
  height: 1.7rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Feedback for a vote that changed a score without changing anyone's
   rank (see reactionwall.js's animateReorder) -- the row-slide alone
   wouldn't show anything in that case, so the badge itself pulses. */

.question-score.is-pulsing {
  animation: rw-score-pulse 420ms ease;
}

@keyframes rw-score-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
  }
  100% {
    transform: scale(1);
  }
}

/* Board's badge is a direct child of the row (no up/down controls, just
   a read-only tally); public's is nested inside .vote-controls -- this
   selector only matches the former, to nudge it down level with text. */
.question-row > .question-score {
  margin-top: 0.15rem;
}

.vote-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.vote-controls .btn-icon {
  width: 1.4rem;
  height: 1.4rem;
  border: none;
  background: none;
}

.vote-controls .btn-icon:hover {
  background: var(--surface-hover);
}

/* public page: a personal list on your own device, read up close --
   noticeably tighter than the board's at-a-distance sizing */

.rw-questions--compact .question-row {
  padding: 0.55rem 0.1rem;
  align-items: center;
}

.rw-questions--compact .question-text {
  font-size: 0.92rem;
}

.rw-questions--compact .question-score {
  height: 1.4rem;
  min-width: 1.4rem;
  font-size: 0.7rem;
}

/* Tactile press feedback, independent of network latency -- the vote
   registers visually the instant you press, not only once the response
   (and the score pulse above) comes back. */
.vote-controls .btn-icon:active {
  transform: scale(0.82);
}

/* mobile: shrink the corner badge rather than force the fixed layout to
   overflow the viewport */

@media (max-width: 640px) {
  /* The app-bar can wrap to 2+ lines on a narrow phone (brand + "Manage
     this board" + "Hide QR" all competing for width), so a fixed offset
     here would guess wrong and overlap it. Flowing in the document
     instead -- right after the app-bar in board.html's markup -- means
     it always lands below the bar however tall it happens to be. */
  .rw-corner {
    position: static;
    width: 5.5rem;
    height: 5.5rem;
    margin: 0.6rem auto 0;
  }

  .burst-emoji {
    font-size: 1.8rem;
  }
}
