/* ==========================================================================
   Decoded Reactions — Fixed right-edge rail with reaction dots
   Green dots = agree, Red dots = disagree
   ========================================================================== */

/* ---------- Vertical Rail — fixed, just right of the sidebar ---------- */
.reaction-rail {
  position: fixed;
  top: 120px;
  /* Sidebar ends at center + 550px (half of 1100px max-width) + 24px padding */
  left: calc(50% + 550px + 8px);
  width: 14px;
  bottom: 40px;
  z-index: 1000;
  display: none;
}

.reaction-rail.visible {
  display: block;
}

@media (max-width: 900px) {
  .reaction-rail { display: none !important; }
}

/* ---------- Rail Segments ---------- */
.rail-segment {
  position: absolute;
  left: 0;
  width: 100%;
  border-radius: 7px;
  background: #ebebeb;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  overflow: visible;
  cursor: pointer;
}

.rail-segment:hover {
  background: #ddd;
}

.rail-segment.active {
  background: #d4d0ff;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.25);
}

/* ---------- Reaction Dots ---------- */
.reaction-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.reaction-dot.agree { background: #22c55e; }
.reaction-dot.disagree { background: #ef4444; }

/* ---------- Hover popup (buttons pop LEFT of rail) ---------- */
.rail-hover-popup {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1001;
  white-space: nowrap;
}

.rail-segment:hover .rail-hover-popup {
  opacity: 1;
  pointer-events: auto;
}

.rail-popup-label {
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #555;
  background: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-vote-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  transition: transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.rail-vote-btn:active { transform: scale(0.85); }
.rail-vote-btn.agree { background: #f0fdf4; color: #16a34a; }
.rail-vote-btn.agree:hover { background: #dcfce7; transform: scale(1.15); }
.rail-vote-btn.disagree { background: #fef2f2; color: #dc2626; }
.rail-vote-btn.disagree:hover { background: #fee2e2; transform: scale(1.15); }

.rail-voted-badge {
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  display: none;
}

.rail-voted-badge.agree-badge { color: #16a34a; }
.rail-voted-badge.disagree-badge { color: #dc2626; }
.rail-segment.voted .rail-voted-badge { display: block; }
.rail-segment.voted .rail-vote-btn { display: none; }
.rail-segment.voted .rail-popup-label { display: none; }

/* ---------- Pulse ---------- */
@keyframes vote-pulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.4); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.rail-vote-btn.pulse { animation: vote-pulse 0.35s ease; }

/* ---------- Mobile FAB ---------- */
.reaction-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.reaction-fab.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.reaction-fab.voted { opacity: 0; transform: translateY(20px); pointer-events: none; }

.fab-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.fab-btn:active { transform: scale(0.9); }
.fab-btn.agree { background: #f0fdf4; color: #16a34a; }
.fab-btn.disagree { background: #fef2f2; color: #dc2626; }
.fab-btn.pulse { animation: vote-pulse 0.35s ease; }

.fab-section-label {
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #666;
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: center;
  background: rgba(255,255,255,0.9);
  padding: 2px 8px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

@media (min-width: 901px) {
  .reaction-fab { display: none !important; }
}

/* ---------- Results Bar ---------- */
.reaction-results-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 999;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.reaction-results-bar.visible { transform: translateY(0); }

.results-ratio-bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: #f3f4f6; overflow: hidden; position: relative;
}

.results-ratio-fill {
  position: absolute; left: 0; top: 0; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.results-text { font-size: 13px; font-weight: 500; color: #374151; white-space: nowrap; }
.results-count { font-size: 12px; color: #9ca3af; white-space: nowrap; }

.results-dismiss {
  background: none; border: none; color: #9ca3af;
  font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1;
}

@media (min-width: 901px) {
  .reaction-results-bar {
    left: auto; right: 32px; bottom: 32px; width: 320px;
    border-radius: 12px; border: 1px solid #e5e7eb;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  }
}

/* ---------- Section Pills ---------- */
.section-reaction-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #6b7280; margin-top: 8px; padding: 4px 10px;
  background: #f9fafb; border-radius: 12px;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.section-reaction-pill.visible { opacity: 1; transform: translateY(0); }

.pill-dots { display: flex; gap: 2px; align-items: center; }
.pill-dot { width: 5px; height: 5px; border-radius: 50%; }
.pill-dot.agree { background: #22c55e; }
.pill-dot.disagree { background: #ef4444; }

/* ---------- Social Proof ---------- */
.reaction-social-proof {
  position: fixed; bottom: 80px; right: 24px;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #9ca3af; background: rgba(255,255,255,0.95);
  padding: 6px 12px; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  opacity: 0; transition: opacity 0.3s ease;
  pointer-events: none; z-index: 998;
}

.reaction-social-proof.visible { opacity: 1; }

body.has-reaction-bar { padding-bottom: 56px; }
@media (min-width: 901px) { body.has-reaction-bar { padding-bottom: 0; } }
