/* YieldChampion - result-panel.css
 * Layout for the standardized result panel (variant A: split inputs|outputs;
 * variant B: unified ledger). Plus chart styling. CSS custom properties only.
 *
 * Class taxonomy:
 *   .yc-result                  outer <section>
 *   .yc-result[data-variant="A|B"]
 *   .yc-result__heading
 *   .yc-result__grid            (variant A only; 2-col -> stacks at 640)
 *   .yc-result__table
 *   .yc-result__table--inputs / --outputs / --unified
 *   .yc-result__table-row--input / --output / --hero
 *   .yc-result__table-group     (variant B section header rows)
 *   .yc-result__chart           <figure>
 *   .yc-chart                   <svg>
 *   .yc-chart__hit              transparent overlay rect (touch target)
 *   .yc-chart__point-hit        per-point 44px touch circles
 *   .yc-result__chart-table-link
 *   .yc-result__chart-live      polite live region
 *   .yc-result__chart-fallback  shown when chart errors out
 *   .yc-result__story           1-3 line prose
 */

.yc-result {
  margin-top: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.yc-result__heading {
  margin: 0;
  font-size: 1.15rem;
  color: var(--ink);
}

/* Variant A — split layout */
.yc-result__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) {
  .yc-result__grid { grid-template-columns: 1fr; }
}

/* Tables */
.yc-result__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.yc-result__table thead th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.yc-result__table tbody th,
.yc-result__table tbody td {
  padding: 0.5rem 0.6rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.yc-result__table tbody tr:last-child th,
.yc-result__table tbody tr:last-child td {
  border-bottom: 0;
}
.yc-result__table tbody th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-muted);
  width: 60%;
}
.yc-result__table tbody td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-weight: 600;
}
.yc-result__table-row--input td { color: var(--ink); font-weight: 500; }
.yc-result__table-row--hero td {
  color: var(--accent);
  font-size: 1.15rem;
}
.yc-result__table-row--hero th { color: var(--ink); font-weight: 600; }

/* Variant B group header rows */
.yc-result__table-group th {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* Chart */
.yc-result__chart {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.yc-chart {
  width: 100%;
  height: 240px;
  display: block;
  color: var(--ink);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  /* iOS Safari: claim all gestures for chart interaction. Without this on
     the SVG itself (not just the hit rect), a touchstart that lands on a
     path/axis/text falls through to the browser's default scroll+select. */
  touch-action: none;
  /* Round 6: suppress iOS native text-selection, callout menu, and tap-
     highlight during chart drags. The chart is a gesture surface, not
     selectable text. Scoped strictly to the chart — the data table and
     story prose remain selectable for accessibility. */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.yc-chart * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.yc-chart:focus-visible {
  box-shadow: 0 0 0 2px var(--focus-ring);
}
@media (max-width: 640px) {
  .yc-chart { height: 200px; }
}
@media (max-width: 640px) {
  .yc-result { padding-inline: max(1rem, 20px); }
}
.yc-result__chart figcaption {
  font-size: 0.85rem;
  color: var(--ink-muted);
  line-height: 1.4;
}
.yc-result__chart-table-link {
  color: var(--accent);
  text-decoration: underline;
  margin-left: 0.25rem;
}
.yc-result__chart-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.yc-result__chart-fallback {
  margin: 0;
  padding: 0.75rem;
  background: var(--surface-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 0.9rem;
}

/* Story prose */
.yc-result__story {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
}
.yc-result__story strong { color: var(--accent); }

/* Notes slot — conditional caveat lines (sub-year, stale, actual-range, …)
   rendered between split tables and story per Phase B Completion design §2. */
.yc-result__note {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--ink-muted);
}

/* Supplementary sibling — content that lives OUTSIDE <section class="yc-result">
   but is logically continuation of the result (e.g. income-replacement allocation
   table). NOT inside the result aria-live region; its own heading provides the
   landmark for assistive tech. */
.yc-result__supplementary {
  margin-top: 1rem;
}
.yc-result__supplementary > h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--ink);
}

/* Print: hide ad slots, keep table + chart */
@media print {
  .yc-ad-slot,
  .yc-ad--leaderboard,
  .yc-ad--rect-medium { display: none; }
  .yc-chart { background: transparent; border-color: #999; }
  .yc-result__chart-table-link { display: none; }
}

/* Reduced motion: design states no animations; this is belt-and-suspenders. */
@media (prefers-reduced-motion: reduce) {
  .yc-result, .yc-chart { transition: none; animation: none; }
}
