/* ==========================================================================
   Poll Builder — page-scoped styles (H1)

   Scoped to `body.poll-builder`. Extends the tokens defined in /css/app.css
   (--rally-green, --gray-*, --rally-lightest, etc.) so the look matches the
   rest of the app without re-declaring a second palette.

   Hard-rule compliance:
     - 14pt / 14px minimum body text (WCAG 2.1 AA)
     - 4.5:1 contrast against the surface for every copy color
     - Immovable amber frame-label banner for convenience samples (Panel 7)
     - Disabled channel cards are visibly inert and tooltip-hinted via
       native `title` + an inline .pb-coming-soon pill
   ========================================================================== */

body.poll-builder {
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;       /* >= 14pt min */
  line-height: 1.55;
  color: #0F1A14;
  background: #FAFAF7;
  margin: 0;
}

/* ---------- Topbar ---------- */

.pb-topbar {
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
  position: sticky;
  top: 0;
  z-index: 10;
}
.pb-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.pb-wordmark {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: #0F1A14;
  text-decoration: none;
}
.pb-nav {
  display: flex;
  gap: 20px;
  margin-left: auto;
}
.pb-nav a {
  color: #374151;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}
.pb-nav a:hover { color: #35644F; }
.pb-nav a[aria-current="page"] {
  color: #35644F;
  border-bottom-color: #35644F;
}
.pb-user-button {
  background: transparent;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 16px;
  cursor: pointer;
  color: #374151;
}
.pb-user-button:hover { border-color: #35644F; color: #35644F; }

/* ---------- Main layout ---------- */

.pb-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.pb-wizard-progress { margin-bottom: 20px; }
.pb-progress-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 20px;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
}
.pb-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6B7280;
}
.pb-step-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  line-height: 1.15;
  color: #0F1A14;
  margin: 4px 0 0;
}
.pb-step-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.pb-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #E5E7EB;
  color: #6B7280;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pb-dot.is-active { background: #35644F; color: #fff; }
.pb-dot.is-done   { background: #35644F; color: #fff; opacity: 0.75; }

/* ---------- Frame-label banner (immovable; Panel 7 condition) ---------- */

.pb-frame-banner {
  background: #FEF3C7;               /* amber-100 */
  border: 1px solid #F59E0B;         /* amber-500 */
  color: #78350F;                    /* amber-900 */
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  line-height: 1.5;
  /* No close button: Panel 7 hard condition. The banner is part of the
     poll's methodology footprint and exports carry it for life. */
}
.pb-frame-banner-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: #B45309;
}
.pb-frame-banner-body { flex: 1 1 auto; }
.pb-frame-banner-title {
  font-weight: 700;
  color: #78350F;
  margin: 0 0 4px;
}

/* ---------- Two-column layout ---------- */

.pb-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 1099px) {
  .pb-layout { grid-template-columns: minmax(0, 1fr); }
}

.pb-form-col, .pb-preview-col {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 24px;
}

/* ---------- Form group patterns ---------- */

.pb-field { margin-bottom: 18px; }
.pb-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.pb-field-label .pb-required {
  color: #DC2626;
  margin-left: 2px;
}
.pb-field-hint {
  display: block;
  font-size: 13px;
  color: #6B7280;
  margin-top: 4px;
}
.pb-input, .pb-select, .pb-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  color: #111827;
  background: #fff;
  box-sizing: border-box;
}
.pb-input:focus, .pb-select:focus, .pb-textarea:focus {
  outline: 2px solid #35644F;
  outline-offset: 1px;
  border-color: #35644F;
}
.pb-textarea { resize: vertical; min-height: 64px; }

.pb-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.pb-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 640px) {
  .pb-grid-2, .pb-grid-3 { grid-template-columns: minmax(0, 1fr); }
}

.pb-inline-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 8px 0;
}
.pb-inline-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #374151;
}

.pb-section-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: #111827;
  margin: 0 0 4px;
}
.pb-section-hint {
  font-size: 14px;
  color: #6B7280;
  margin: 0 0 14px;
}
.pb-section {
  padding: 16px 0;
  border-top: 1px solid #F3F4F6;
}
.pb-section:first-child { padding-top: 0; border-top: 0; }

/* ---------- Wizard nav ---------- */

.pb-wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid #F3F4F6;
  gap: 12px;
}
.pb-wizard-nav-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}
.pb-block-reason {
  margin-top: 10px;
  padding: 10px 12px;
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  color: #7F1D1D;
  border-radius: 6px;
  font-size: 14px;
}

/* ---------- Button primitives (fall back if app.css tokens aren't loaded) ---------- */

.pb-form-col .btn, .pb-preview-col .btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.2;
}
.pb-form-col .btn-primary {
  background: #35644F;
  color: #fff;
  border-color: #35644F;
}
.pb-form-col .btn-primary:hover { background: #2D4A35; border-color: #2D4A35; }
.pb-form-col .btn-primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  background: #9CA3AF;
  border-color: #9CA3AF;
}
.pb-form-col .btn-secondary {
  background: #fff;
  color: #35644F;
  border-color: #35644F;
}
.pb-form-col .btn-secondary:hover { background: #EEF3EF; }
.pb-form-col .btn-ghost {
  background: transparent;
  color: #374151;
  border-color: transparent;
}
.pb-form-col .btn-ghost:hover { background: #F3F4F6; }

/* ---------- Channel picker (step 2) ---------- */

.pb-channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.pb-channel-card {
  position: relative;
  background: #fff;
  border: 2px solid #E5E7EB;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: #111827;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pb-channel-card:hover {
  border-color: #35644F;
}
.pb-channel-card[aria-pressed="true"] {
  border-color: #35644F;
  background: #EEF3EF;
}
.pb-channel-card:focus-visible {
  outline: 3px solid #35644F;
  outline-offset: 2px;
}
.pb-channel-card[disabled],
.pb-channel-card[aria-disabled="true"] {
  opacity: 0.58;
  cursor: not-allowed;
  background: #F9FAFB;
  border-color: #E5E7EB;
}
.pb-channel-card[disabled]:hover,
.pb-channel-card[aria-disabled="true"]:hover {
  border-color: #E5E7EB;
}
.pb-channel-card .pb-channel-icon {
  font-size: 20px;
  line-height: 1;
}
.pb-channel-card .pb-channel-label {
  font-weight: 600;
  font-size: 15px;
}
.pb-channel-card .pb-channel-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #374151;
}
.pb-channel-card .pb-coming-soon {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #7F1D1D;
  background: #FEE2E2;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

/* ---------- Sample-size readout ---------- */

.pb-sample-card {
  background: #EEF3EF;
  border: 1px solid #CEE2D4;
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.pb-sample-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #35644F;
  margin-bottom: 6px;
}
.pb-sample-number {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-size: 40px;
  line-height: 1;
  color: #0F1A14;
}
.pb-sample-formula {
  font-size: 13px;
  color: #35644F;
  margin-top: 8px;
}

.pb-preview-card {
  background: #fff;
  border: 1px dashed #D1D5DB;
  border-radius: 10px;
  padding: 18px 20px;
}
.pb-preview-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6B7280;
  margin-bottom: 8px;
}
.pb-preview-body { font-size: 14px; color: #374151; }
.pb-preview-placeholder { color: #9CA3AF; margin: 0; }
.pb-preview-title {
  font-weight: 600;
  font-size: 16px;
  color: #111827;
  margin: 0 0 6px;
}
.pb-preview-question {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  line-height: 1.35;
  color: #0F1A14;
  margin: 0 0 10px;
}
.pb-preview-meta {
  font-size: 13px;
  color: #6B7280;
  margin-top: 8px;
}
.pb-preview-meta dt {
  display: inline;
  font-weight: 600;
  color: #374151;
}
.pb-preview-meta dd {
  display: inline;
  margin: 0 8px 0 4px;
}

/* ---------- Screen-reader utility ---------- */

.pb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Footer ---------- */

.pb-footer { background: #fff; border-top: 1px solid #E5E7EB; margin-top: 40px; padding: 24px 0; }
.pb-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.pb-footer-meta { font-size: 13px; color: #6B7280; font-family: 'JetBrains Mono', monospace; }

/* ---------- Methodology statement block (step 3) ---------- */

.pb-methodology {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
}
.pb-methodology-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #92400E;
  background: #FEF3C7;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
}

/* ---------- Cost estimate card (step 2) ----------
   Panel 1 Ops, Session J (Andy 2026-04-18): pass-through cost + transparent
   markup shown in the builder before send. No inline styles — the card is
   scoped by `.pb-cost-card`, so it works in the step-body (inline) and in
   the sidebar host (#pb-cost-card-host).
-------------------------------------------------------------------------- */

.pb-cost-card {
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 16px;
}
.pb-cost-card-inline {
  /* Wrapper used when the card is rendered inline in the step body. */
  margin-top: 16px;
}
.pb-cost-header { margin-bottom: 10px; }
.pb-cost-title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18px;
  font-weight: 500;
  color: #111827;
  margin: 0 0 4px;
}
.pb-cost-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin: 0;
  line-height: 1.5;
}
.pb-cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 10px;
}
.pb-cost-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6B7280;
  padding: 8px 10px 6px;
  border-bottom: 1px solid #E5E7EB;
}
.pb-cost-table thead th:not(:first-child),
.pb-cost-table tbody .pb-cost-cell,
.pb-cost-table tfoot .pb-cost-cell {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}
.pb-cost-table tbody th {
  text-align: left;
  font-weight: 600;
  color: #111827;
  padding: 10px;
  border-bottom: 1px solid #F3F4F6;
}
.pb-cost-count {
  font-weight: 400;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #6B7280;
  margin-left: 4px;
}
.pb-cost-table tbody td {
  padding: 10px;
  color: #374151;
  border-bottom: 1px solid #F3F4F6;
}
.pb-cost-row-empty td {
  color: #9CA3AF;
  text-align: center;
  font-style: italic;
}
.pb-cost-cell-total {
  font-weight: 700;
  color: #0F1A14;
}
.pb-cost-table tfoot th,
.pb-cost-table tfoot td {
  padding: 12px 10px;
  border-top: 2px solid #E5E7EB;
  color: #0F1A14;
  font-weight: 700;
}
.pb-cost-grand-label {
  font-family: inherit;
  text-align: left;
}
.pb-cost-grand-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  color: #35644F;
}
.pb-cost-disclosure {
  font-size: 13px;
  color: #6B7280;
  line-height: 1.55;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px dashed #E5E7EB;
}
.pb-channel-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

/* ---------- Error-recovery banner for 409 (idempotency conflict) ---------- */

.pb-recovery-banner {
  background: #FFFBEB;
  border: 1px solid #F59E0B;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 12px 0;
}
.pb-recovery-banner h4 {
  margin: 0 0 8px;
  color: #92400E;
  font-size: 15px;
}
.pb-recovery-banner .pb-recovery-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
