/* PVV v5 — Eligibility widget (Mode 1).
 * Matches existing widget design language: amber gradient header,
 * bordered cards, dashed-underline citations, 44x44 tap targets,
 * html.pvv-high-contrast + html.pvv-reduced-motion compatible. */

/* ───── Shell ───── */
.pvv-elig {
  margin: 28px 0;
  padding: 0;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #0f172a;
}
.pvv-elig * { box-sizing: border-box; }

/* ───── Header — amber gradient ───── */
.pvv-elig-header {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fffbeb;
  padding: 20px 24px;
}
.pvv-elig-header h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: #fffbeb;
  border: 0;
  padding: 0;
}
.pvv-elig-dek {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 251, 235, 0.92);
}

/* ───── Program picker ───── */
.pvv-elig-programs {
  padding: 12px 24px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.pvv-elig-programs-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #92400e;
  font-weight: 600;
  margin-right: 4px;
}
.pvv-elig-program-chip {
  min-height: 32px;
  padding: 6px 12px;
  border: 1px solid #fbbf24;
  border-radius: 999px;
  background: #fffbeb;
  color: #78350f;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.pvv-elig-program-chip:hover { background: #fef3c7; }
.pvv-elig-program-chip.is-active {
  background: #f59e0b;
  color: #fff;
  border-color: #d97706;
  font-weight: 600;
}

/* ───── Progress ───── */
.pvv-elig-progress {
  height: 4px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.pvv-elig-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  transition: width 200ms ease;
}
.pvv-elig-progress-label {
  font-size: 12px;
  color: #64748b;
  margin: 6px 0 18px;
  text-align: right;
}

/* ───── Form ───── */
.pvv-elig-form {
  padding: 20px 24px 24px;
}
.pvv-elig-stage {
  display: grid;
  gap: 18px;
}
.pvv-elig-field {
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}
.pvv-elig-label-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.pvv-elig-label {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  flex: 1;
  line-height: 1.4;
}
.pvv-elig-req {
  color: #dc2626;
  font-weight: 700;
  margin-left: 2px;
}
.pvv-elig-plain {
  display: block;
  margin: -2px 0 10px;
  font-size: 13px;
  color: #475569;
  font-style: italic;
}

/* ───── Tooltip bubble trigger (? button) ───── */
.pvv-elig-tip {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #ffffff;
  color: #64748b;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}
.pvv-elig-tip:hover { background: #f1f5f9; color: #0f172a; }
.pvv-elig-tip-body {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fef3c7;
  border-left: 3px solid #f59e0b;
  border-radius: 4px;
  font-size: 13px;
  color: #78350f;
  line-height: 1.45;
}

/* ───── Inputs (44x44 tap targets) ───── */
.pvv-elig-text,
.pvv-elig-number,
.pvv-elig-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.pvv-elig-text:focus,
.pvv-elig-number:focus,
.pvv-elig-select:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}
.pvv-elig-radio-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.pvv-elig-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  font-size: 14px;
  color: #334155;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.pvv-elig-radio:has(input:checked) {
  border-color: #f59e0b;
  background: #fef3c7;
  color: #78350f;
  font-weight: 600;
}
.pvv-elig-radio input { width: 18px; height: 18px; accent-color: #f59e0b; }

/* ───── Skip ───── */
.pvv-elig-skip {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: #64748b;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  min-height: 32px;
}
.pvv-elig-skip:hover { color: #0f172a; }

/* ───── Controls ───── */
.pvv-elig-controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pvv-elig-back,
.pvv-elig-next,
.pvv-elig-submit {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 120ms ease, border-color 120ms ease, transform 100ms ease;
}
.pvv-elig-back {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
}
.pvv-elig-back:hover { background: #f1f5f9; }
.pvv-elig-next,
.pvv-elig-submit {
  border: 1px solid #d97706;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fffbeb;
}
.pvv-elig-next:hover,
.pvv-elig-submit:hover { filter: brightness(1.05); }
.pvv-elig-next:active,
.pvv-elig-submit:active { transform: translateY(1px); }

/* ───── Privacy line ───── */
.pvv-elig-privacy {
  margin: 16px 0 0;
  font-size: 12px;
  color: #64748b;
  text-align: center;
}
.pvv-elig-clear {
  background: none;
  border: 0;
  color: #475569;
  text-decoration: underline;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

/* ───── Result card ───── */
.pvv-elig-result {
  padding: 24px;
  border-top: 1px solid #e2e8f0;
}
.pvv-elig-result-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pvv-elig-result-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: #ffffff;
}
.pvv-elig-result-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  flex: 1 1 auto;
  min-width: 0;
}
.pvv-elig-result-summary {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.55;
  color: #334155;
}

/* Result buckets */
.pvv-elig-result-eligible .pvv-elig-result-icon { background: #16a34a; }
.pvv-elig-result-eligible .pvv-elig-result-title { color: #14532d; }

.pvv-elig-result-probably .pvv-elig-result-icon { background: #f59e0b; }
.pvv-elig-result-probably .pvv-elig-result-title { color: #78350f; }

.pvv-elig-result-need-info .pvv-elig-result-icon { background: #0284c7; }
.pvv-elig-result-need-info .pvv-elig-result-title { color: #075985; }

.pvv-elig-result-ineligible .pvv-elig-result-icon { background: #dc2626; }
.pvv-elig-result-ineligible .pvv-elig-result-title { color: #7f1d1d; }

/* Confidence badge */
.pvv-elig-conf {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid currentColor;
}
.pvv-elig-conf-high   { color: #166534; background: #dcfce7; border-color: #86efac; }
.pvv-elig-conf-medium { color: #78350f; background: #fef3c7; border-color: #fde68a; }
.pvv-elig-conf-low    { color: #7f1d1d; background: #fee2e2; border-color: #fecaca; }

/* ───── Section details ───── */
.pvv-elig-section {
  margin: 16px 0;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}
.pvv-elig-section > summary {
  cursor: pointer;
  font-weight: 600;
  color: #0f172a;
  font-size: 14px;
  margin-bottom: 10px;
  list-style: none;
  padding-right: 20px;
  position: relative;
}
.pvv-elig-section > summary::after {
  content: "▾";
  position: absolute;
  right: 0;
  top: 0;
  color: #94a3b8;
  font-size: 12px;
}
.pvv-elig-section[open] > summary::after { content: "▴"; }
.pvv-elig-section > summary::-webkit-details-marker { display: none; }

/* ───── Calculation table ───── */
.pvv-elig-calc {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 6px;
}
.pvv-elig-calc thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 8px;
  background: transparent;
}
.pvv-elig-calc tbody td {
  padding: 8px;
  border-bottom: 1px solid #eef2f7;
  color: #1e293b;
  vertical-align: top;
}
.pvv-elig-calc-step {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
}
.pvv-elig-calc-val {
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

/* ───── Citation chip ───── */
.pvv-elig-cite {
  border: 0;
  background: transparent;
  padding: 0;
  color: #1d4ed8;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-bottom: 1px dashed #94a3b8;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.pvv-elig-cite:hover {
  background-color: #fef3c7;
  border-bottom-color: #f59e0b;
  color: #0f172a;
}
.pvv-elig-cite:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}
.pvv-elig-cite-ext {
  font-size: 12px;
  color: #475569;
  text-decoration: underline;
  margin-left: 6px;
}
.pvv-elig-cites {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pvv-elig-cites li {
  padding: 6px 0;
  border-bottom: 1px solid #eef2f7;
}
.pvv-elig-cites li:last-child { border-bottom: 0; }

/* ───── What to watch ───── */
.pvv-elig-watch {
  margin: 0;
  padding-left: 18px;
  color: #334155;
  font-size: 14px;
  line-height: 1.55;
}
.pvv-elig-watch li { margin: 4px 0; }

/* ───── Next-step actions ───── */
.pvv-elig-next-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #1e293b;
}
.pvv-elig-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}
.pvv-elig-action {
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.pvv-elig-action:hover { background: #f1f5f9; }
.pvv-elig-action-secondary { color: #475569; }

/* ───── Escape-valve card ───── */
.pvv-elig-escape {
  background: #fef2f2;
  border-top: 3px solid #dc2626;
}
.pvv-elig-escape-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.pvv-elig-escape-head h3 {
  margin: 0;
  font-size: 18px;
  color: #7f1d1d;
}
.pvv-elig-escape-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #ffffff;
  font-weight: 700;
  font-size: 22px;
}
.pvv-elig-escape-msg {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.55;
  color: #7f1d1d;
}
.pvv-elig-escape-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
}
.pvv-elig-escape-link {
  display: inline-block;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid #dc2626;
  border-radius: 8px;
  background: #ffffff;
  color: #7f1d1d;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  line-height: 22px;
}
.pvv-elig-escape-link:hover { background: #fee2e2; }
.pvv-elig-escape-fallback {
  margin: 10px 0 0;
  font-size: 12px;
  color: #7f1d1d;
  font-style: italic;
}

/* ───── Offline/fallback shell ───── */
.pvv-elig-offline {
  padding: 24px;
  font-size: 14px;
  color: #475569;
}

/* ───── High-contrast mode (toggled by html.pvv-high-contrast) ───── */
html.pvv-high-contrast .pvv-elig {
  background: #ffffff;
  border-color: #000000;
}
html.pvv-high-contrast .pvv-elig-header {
  background: #000000;
  color: #ffffff;
}
html.pvv-high-contrast .pvv-elig-header h2,
html.pvv-high-contrast .pvv-elig-dek {
  color: #ffffff;
}
html.pvv-high-contrast .pvv-elig-field,
html.pvv-high-contrast .pvv-elig-section {
  background: #ffffff;
  border-color: #000000;
}
html.pvv-high-contrast .pvv-elig-text,
html.pvv-high-contrast .pvv-elig-number,
html.pvv-high-contrast .pvv-elig-select,
html.pvv-high-contrast .pvv-elig-radio {
  border-color: #000000;
  color: #000000;
}
html.pvv-high-contrast .pvv-elig-next,
html.pvv-high-contrast .pvv-elig-submit {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
}
html.pvv-high-contrast .pvv-elig-cite {
  color: #000080;
  border-bottom-color: #000000;
}

/* ───── Reduced motion (toggled by html.pvv-reduced-motion) ───── */
html.pvv-reduced-motion .pvv-elig-progress-bar,
html.pvv-reduced-motion .pvv-elig-program-chip,
html.pvv-reduced-motion .pvv-elig-text,
html.pvv-reduced-motion .pvv-elig-number,
html.pvv-reduced-motion .pvv-elig-select,
html.pvv-reduced-motion .pvv-elig-next,
html.pvv-reduced-motion .pvv-elig-submit,
html.pvv-reduced-motion .pvv-elig-action,
html.pvv-reduced-motion .pvv-elig-cite {
  transition: none !important;
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .pvv-elig-progress-bar,
  .pvv-elig-program-chip,
  .pvv-elig-next,
  .pvv-elig-submit,
  .pvv-elig-cite {
    transition: none !important;
  }
}

/* ───── Print ───── */
@media print {
  .pvv-elig-controls,
  .pvv-elig-actions,
  .pvv-elig-programs,
  .pvv-elig-privacy,
  .pvv-elig-skip,
  .pvv-elig-tip { display: none !important; }
  .pvv-elig {
    border: 1px solid #000;
    box-shadow: none;
  }
  .pvv-elig-header {
    background: #ffffff !important;
    color: #000000 !important;
    border-bottom: 2px solid #000;
  }
  .pvv-elig-header h2,
  .pvv-elig-dek { color: #000000 !important; }
  .pvv-elig-section[open],
  .pvv-elig-section { break-inside: avoid; }
}

/* ───── Small screens ───── */
@media (max-width: 560px) {
  .pvv-elig-header { padding: 16px 18px; }
  .pvv-elig-form { padding: 16px 18px 20px; }
  .pvv-elig-controls { justify-content: space-between; }
  .pvv-elig-controls .pvv-elig-back,
  .pvv-elig-controls .pvv-elig-next,
  .pvv-elig-controls .pvv-elig-submit { flex: 1 1 auto; }
  .pvv-elig-calc { font-size: 12px; }
  .pvv-elig-calc thead th { font-size: 10px; }
}

/* ───── Simplified/plain-language (html.pvv-simplified-content) ───── */
html.pvv-simplified-content .pvv-elig-result-summary {
  font-size: 16px;
  line-height: 1.65;
}
html.pvv-simplified-content .pvv-elig-section {
  font-size: 15px;
}
