/* PVV v5 — Scenarios widget ("What changes if…?" Mode 3).
 *
 * Layout notes:
 *   - Side-by-side comparison table uses CSS grid with one column per
 *     scenario (baseline + each variant). On narrow screens (<720px)
 *     the grid collapses to a single stacked column per row.
 *   - Delta highlighting uses coloured left-borders:
 *       amber  = benefit amount changed
 *       red    = eligibility flipped
 *       slate  = no material change
 *   - The widget respects the plain-language toggle (pvv-standard /
 *     pvv-simplified) and caregiver mode (pronoun swaps happen after
 *     our render pass, via pvv-caregiver.js's DOM walker).
 */

.pvv-scenarios {
  margin: 2rem 0;
  padding: 1.2rem 1.3rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
}

.pvv-sc-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  color: #0f172a;
}
.pvv-sc-dek {
  margin: 0 0 1rem;
  color: #475569;
}

/* ─── Base-inputs accordion ──────────────────────────────────────── */
.pvv-sc-base {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 1rem;
}
.pvv-sc-base > summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: #1e293b;
  list-style: none;
}
.pvv-sc-base > summary::-webkit-details-marker { display: none; }
.pvv-sc-base > summary::after {
  content: '▾';
  float: right;
  color: #64748b;
  transition: transform 150ms;
}
.pvv-sc-base[open] > summary::after { transform: rotate(180deg); }
.pvv-sc-base-body {
  padding: 0 1rem 1rem;
}
.pvv-sc-base-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem 0.8rem;
}
.pvv-sc-base-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.9rem;
  color: #334155;
}
.pvv-sc-base-grid input,
.pvv-sc-base-grid select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  font: inherit;
}

/* ─── Variant builder rows ───────────────────────────────────────── */
.pvv-sc-variants {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  padding: 0.8rem 1rem 1rem;
  margin: 0 0 1rem;
}
.pvv-sc-variants legend {
  padding: 0 0.4rem;
  font-weight: 600;
  color: #1e293b;
}
.pvv-sc-hint {
  margin: 0 0 0.6rem;
  color: #64748b;
  font-size: 0.88rem;
}
.pvv-sc-variant {
  display: block;
  padding: 0.7rem 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 0.6rem;
  background: #fafafa;
  transition: border-color 120ms, background 120ms;
}
.pvv-sc-variant.is-active {
  border-color: #2563eb;
  background: #eff6ff;
}
.pvv-sc-variant-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 600;
  color: #1e293b;
}
.pvv-sc-variant-title { font-size: 0.98rem; }
.pvv-sc-variant-hint {
  margin: 0.3rem 0 0.4rem 1.6rem;
  color: #64748b;
  font-size: 0.85rem;
}
.pvv-sc-variant-controls {
  margin: 0.3rem 0 0 1.6rem;
}
.pvv-sc-sub {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.88rem;
  color: #334155;
  margin-top: 0.3rem;
}
.pvv-sc-sub input[type="range"] { width: 100%; }
.pvv-sc-val {
  font-weight: 600;
  color: #1e293b;
  align-self: flex-end;
}
.pvv-sc-note {
  margin: 0.3rem 0 0;
  padding: 0.5rem 0.7rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 5px;
  color: #78350f;
  font-size: 0.85rem;
}

/* ─── Actions + bookmark strip ──────────────────────────────────── */
.pvv-sc-actions {
  display: flex;
  gap: 0.6rem;
  margin: 0 0 0.8rem;
  flex-wrap: wrap;
}
.pvv-sc-run,
.pvv-sc-bookmark {
  padding: 0.55rem 1rem;
  border: 1px solid #2563eb;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms;
}
.pvv-sc-bookmark {
  background: #fff;
  color: #2563eb;
}
.pvv-sc-run:hover    { background: #1d4ed8; border-color: #1d4ed8; }
.pvv-sc-bookmark:hover { background: #eff6ff; }
.pvv-sc-run:disabled { opacity: 0.6; cursor: wait; }

.pvv-sc-bookmarks {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0 0 1rem;
}
.pvv-sc-bookmarks h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: #334155;
}
.pvv-sc-bookmarks ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pvv-sc-bookmarks li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 0.2rem 0.5rem 0.2rem 0.2rem;
}
.pvv-sc-bm-restore {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: #2563eb;
  font: inherit;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
}
.pvv-sc-bm-restore:hover { text-decoration: underline; }
.pvv-sc-bookmarks small { color: #64748b; font-size: 0.78rem; }
.pvv-sc-bm-del {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: #991b1b;
  font-size: 1rem;
  padding: 0 0.3rem;
  line-height: 1;
}

/* ─── Results: side-by-side comparison table ────────────────────── */
.pvv-sc-results { margin-top: 0.8rem; }
.pvv-sc-loading,
.pvv-sc-empty,
.pvv-sc-error {
  padding: 1rem;
  border-radius: 6px;
  text-align: center;
  font-style: italic;
  color: #475569;
}
.pvv-sc-error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-style: normal;
}

.pvv-sc-compare {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.pvv-sc-compare-head,
.pvv-sc-row {
  display: grid;
  /* label column + N equal scenario columns: each variant adds --cols.
     Default is two-column (baseline + 1 variant); widget sets --cols
     inline if it decides a different shape is needed. */
  grid-template-columns: 160px repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
}
.pvv-sc-compare-head {
  background: #0f172a;
  color: #fff;
  font-weight: 600;
}
.pvv-sc-col-head {
  padding: 0.7rem 0.9rem;
  border-left: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.pvv-sc-col-head.is-base { background: #1e293b; }
.pvv-sc-col-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: #94a3b8;
  letter-spacing: 0.03em;
}
.pvv-sc-col-head strong { font-size: 0.95rem; }

/* First column of head is empty label spacer */
.pvv-sc-compare-head::before {
  content: '';
  padding: 0.7rem 0.9rem;
  background: #0f172a;
}

.pvv-sc-row {
  border-top: 1px solid #e2e8f0;
}
.pvv-sc-row-label {
  padding: 0.7rem 0.9rem;
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  font-size: 0.9rem;
  border-right: 1px solid #e2e8f0;
}
.pvv-sc-cell {
  padding: 0.7rem 0.9rem;
  border-left: 1px solid #e2e8f0;
  font-size: 0.92rem;
  color: #0f172a;
  background: #fff;
  word-break: break-word;
}
.pvv-sc-cell.is-delta-benefit {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
}
.pvv-sc-cell.is-delta-flip {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
}
.pvv-sc-cell ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.86rem;
}
.pvv-sc-cell ul li { margin-bottom: 0.2rem; }
.pvv-sc-na { color: #94a3b8; }
.pvv-sc-calc li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.pvv-sc-calc span { color: #475569; }
.pvv-sc-calc strong { color: #0f172a; }

.pvv-sc-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.pvv-sc-badge-ok   { background: #d1fae5; color: #065f46; }
.pvv-sc-badge-bad  { background: #fee2e2; color: #991b1b; }
.pvv-sc-badge-warn { background: #fef3c7; color: #92400e; }

/* ─── "What specifically changed" summary cards ─────────────────── */
.pvv-sc-summary {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
.pvv-sc-summary h3 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
  color: #1e293b;
}
.pvv-sc-card {
  border-left: 3px solid #cbd5e1;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.6rem;
  background: #f8fafc;
  border-radius: 4px;
}
.pvv-sc-card h4 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  color: #0f172a;
}
.pvv-sc-card-need-info { border-left-color: #f59e0b; background: #fffbeb; }
.pvv-sc-no-change { color: #64748b; font-style: italic; margin: 0; }
.pvv-sc-change-list { list-style: none; padding: 0; margin: 0; }
.pvv-sc-change-list li {
  padding: 0.2rem 0 0.2rem 1rem;
  position: relative;
  font-size: 0.9rem;
}
.pvv-sc-change-list li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #94a3b8;
}
.pvv-sc-change-high   { color: #991b1b; }
.pvv-sc-change-high::before { color: #dc2626 !important; }
.pvv-sc-change-medium { color: #92400e; }
.pvv-sc-change-medium::before { color: #f59e0b !important; }
.pvv-sc-change-low    { color: #475569; }

.pvv-sc-disclaimer {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: #64748b;
  font-style: italic;
}

/* ─── Mobile: stack comparison columns into rows ─────────────────── */
@media (max-width: 720px) {
  .pvv-sc-compare-head { display: none; }
  .pvv-sc-row {
    display: block;
    padding: 0.4rem 0;
  }
  .pvv-sc-row-label {
    background: #0f172a;
    color: #fff;
    border-right: 0;
    border-radius: 4px;
    margin: 0.3rem 0.5rem;
    padding: 0.5rem 0.7rem;
  }
  .pvv-sc-cell {
    border-left: 0;
    padding: 0.5rem 1rem;
    position: relative;
  }
  /* Before each cell, show the scenario label from its column head. */
  .pvv-sc-cell::before {
    content: attr(data-col-label);
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 0.2rem;
  }
  .pvv-sc-cell.is-delta-benefit,
  .pvv-sc-cell.is-delta-flip {
    border-left: 3px solid;
    margin: 0 0.5rem;
    border-radius: 0 4px 4px 0;
  }
  .pvv-sc-actions { flex-direction: column; align-items: stretch; }
  .pvv-sc-run,
  .pvv-sc-bookmark { width: 100%; }
}

/* ─── Plain-language variant visibility ──────────────────────────── */
html:not(.pvv-simplified-content) .pvv-scenarios .pvv-simplified { display: none; }
html.pvv-simplified-content     .pvv-scenarios .pvv-standard    { display: none; }

/* ─── Caregiver-mode callout (banner injected by pvv-caregiver.js) ── */
.pvv-mode-caregiver .pvv-scenarios .pvv-sc-header::after {
  content: 'Caregiver mode — swapping pronouns in labels.';
  display: block;
  margin-top: 0.4rem;
  padding: 0.3rem 0.5rem;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #78350f;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* ─── Reduce motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pvv-sc-base > summary::after,
  .pvv-sc-variant { transition: none; }
}

/* ─── Dark mode hook (optional theme) ───────────────────────────── */
html[data-pvv-theme="dark"] .pvv-scenarios {
  background: #0f172a;
  border-color: #1e293b;
  color: #e2e8f0;
}
html[data-pvv-theme="dark"] .pvv-scenarios .pvv-sc-base,
html[data-pvv-theme="dark"] .pvv-scenarios .pvv-sc-variants,
html[data-pvv-theme="dark"] .pvv-scenarios .pvv-sc-compare,
html[data-pvv-theme="dark"] .pvv-scenarios .pvv-sc-summary {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
html[data-pvv-theme="dark"] .pvv-scenarios .pvv-sc-cell {
  background: #0f172a;
  color: #e2e8f0;
}
