/* ============================================================
   CoreConduit Engage Widgets — Survey + Comments
   Depends on: assets/css/style.css (brand tokens)
   ============================================================ */

/* ── Survey Widget ─────────────────────────────────────────── */

.survey-widget {
  font-family: var(--font-body);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  position: relative;
  /* Blue→orange gradient bar on top edge */
  border-top: 3px solid transparent;
  background-clip: padding-box;
  box-shadow: var(--shadow-card);
}

.survey-widget::before {
  content: "";
  position: absolute;
  inset: -3px -1px -1px;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--blue), var(--orange));
  z-index: -1;
}

.sw-loading,
.sw-error {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}

.sw-error { color: var(--red); }

.sw-question {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  line-height: 1.4;
}

/* ── Option buttons ── */
.sw-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sw-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-family: var(--font-body);
  min-height: var(--min-target);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.sw-option:hover {
  background: var(--blue-glow);
  border-color: var(--blue);
  color: var(--text-primary);
}

.sw-option:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-halo);
}

.sw-option:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.sw-option-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.sw-option:hover .sw-option-dot {
  border-color: var(--blue);
}

/* ── Results ── */
.sw-results { animation: sw-fade-in 0.3s ease; }

@keyframes sw-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sw-result-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.sw-result-row {
  display: grid;
  grid-template-columns: 1fr minmax(80px, 220px) 3.5rem;
  align-items: center;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .sw-result-row {
    grid-template-columns: 1fr minmax(60px, 120px) 3rem;
    gap: 0.5rem;
  }
}

.sw-result-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.sw-result-chosen .sw-result-label {
  color: var(--text-primary);
  font-weight: 600;
}

.sw-result-leading .sw-result-label {
  color: var(--text-primary);
  font-weight: 600;
}

.sw-checkmark {
  color: var(--blue);
  font-weight: 700;
}

.sw-result-bar-wrap {
  height: 12px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}

.sw-result-bar {
  height: 100%;
  width: 0;                  /* start at 0 — JS animates to target */
  background: linear-gradient(90deg, var(--blue), var(--blue-bright));
  border-radius: 99px;
  transition: width 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.sw-result-chosen .sw-result-bar,
.sw-result-leading .sw-result-bar {
  background: linear-gradient(90deg, var(--blue), var(--orange));
}

.sw-result-pct {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: right;
  font-family: var(--font-mono);
}

.sw-result-leading .sw-result-pct {
  color: var(--blue-dim);
}

.sw-total {
  display: inline-block;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.2rem 0.75rem;
  margin-top: 0.25rem;
}

.sw-voted-note {
  font-size: 0.85rem;
  color: var(--blue-dim);
  margin-top: 0.75rem;
  font-style: italic;
}

/* ── Inline article placement ── */
.sw-article-break {
  margin: 2.5rem 0;
}

.sw-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.25rem;
}

/* ── Comments Widget ───────────────────────────────────────── */

comments-widget,
survey-widget {
  display: block;
}

.comments-widget {
  font-family: var(--font-body);
  margin-top: 3rem;
}

.cw-heading {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.cw-moderation-note {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.cw-badge {
  display: inline-block;
  background: var(--orange-glow);
  border: 1px solid var(--orange);
  color: var(--orange-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Comment list ── */
.cw-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.cw-loading,
.cw-empty,
.cw-error {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 1rem 0;
}

.cw-error { color: var(--red); }

.cw-comment {
  padding: 1.1rem 1.25rem;
}

.cw-comment-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.cw-comment-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.92rem;
}

.cw-comment-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.cw-comment-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Submission form ── */
.cw-form {
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.cw-form-heading {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: -0.25rem;
}

.cw-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cw-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.cw-input {
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--text-primary);
  background: var(--bg-input, var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  min-height: var(--min-target);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.cw-input::placeholder { color: var(--text-muted); }

.cw-input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-halo);
  border-color: var(--blue);
}

.cw-textarea {
  min-height: 7rem;
  resize: vertical;
}

.cw-char-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  align-self: flex-end;
}

.cw-char-warn { color: var(--warning); font-weight: 600; }

.cw-form-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.cw-submit:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus-ring-halo);
}

.cw-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.25rem;
}

.cw-status-success {
  color: var(--green);
  font-weight: 600;
}

/* ── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .sw-results { animation: none; }
  .sw-result-bar { transition: none; }
}
