/* Retirement Monte Carlo (js/explorers/monte-carlo.js) — v2 route styles.
   Everything here is additive; no existing selector is overridden globally.
   Components that already exist in css/styles.css (.card, .form-row,
   .form-grid, .btn, .kpi, .grid, .rp-tabs, table.data, .tag) are reused as-is
   so this route inherits both themes from css/theme.css.

   PROMOTED FROM PROTOTYPE (css/mc-proto.css, worktree lym-mc-redesign,
   visually approved). Selectors and values are unchanged; only this header
   comment and the mcp-page max-width/padding differ (they now sit inside the
   app shell's .content wrapper instead of a standalone page). */

.mcp-page { max-width: 1180px; margin: 0 auto; padding: 0 0 140px; }

/* Missing site-wide a11y helper (currently only in marketing.css) — local copy. */
.mcp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- layout -- */
.mcp-cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.mcp-rail { position: sticky; top: 14px; }

/* --------------------------------------------------------------- stepper -- */
.mcp-steps { display: flex; flex-direction: column; gap: 8px; }

.mcp-step { border: 1px solid var(--border); border-radius: 12px; background: var(--card);
  box-shadow: var(--shadow); overflow: hidden; }
.mcp-step.is-open { border-color: var(--brand-blue); }

.mcp-step-head { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 12px 14px; background: none; border: 0; cursor: pointer; font: inherit; color: var(--text); }
.mcp-step-head:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: -2px; }

.mcp-step-num { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 999px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.mcp-step.is-done .mcp-step-num { background: var(--green); border-color: var(--green); color: #fff; }
.mcp-step.is-open .mcp-step-num { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }

.mcp-step-text { flex: 1 1 auto; min-width: 0; }
.mcp-step-title { display: block; font-weight: 600; font-size: 14px; }
.mcp-step-sum { display: block; font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-step.is-open .mcp-step-sum { display: none; }

.mcp-step-chev { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.mcp-step-body { padding: 2px 14px 14px; border-top: 1px solid var(--border); }
.mcp-step-body > .mcp-q:first-child { margin-top: 12px; }

/* One question, one line of help. Replaces the long prose subtitles. */
.mcp-q { margin-bottom: 12px; }
.mcp-q > .help-text { margin-top: 2px; }

.mcp-why { margin: 6px 0 0; }
.mcp-why > summary { cursor: pointer; font-size: 12px; color: var(--brand-blue); list-style: none; }
.mcp-why > summary::-webkit-details-marker { display: none; }
.mcp-why > summary::before { content: '▸ '; }
.mcp-why[open] > summary::before { content: '▾ '; }
.mcp-why > div { font-size: 12px; color: var(--muted); padding: 8px 10px; margin-top: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }

.mcp-err { font-size: 12px; color: var(--red); margin-top: 3px; }
.mcp-input-bad { border-color: var(--red) !important; }

/* --------------------------------------------------- segmented choice -- */
.mcp-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.mcp-seg button { font: inherit; font-size: 13px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); }
.mcp-seg button[aria-pressed="true"] { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.mcp-seg button:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }

/* ------------------------------------------------------- income rows -- */
.mcp-rows { display: flex; flex-direction: column; gap: 6px; }
.mcp-row { border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.mcp-row-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.mcp-row-label { flex: 1 1 auto; min-width: 0; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcp-row-amt { flex: 0 0 auto; font-size: 13px; font-variant-numeric: tabular-nums; }
.mcp-row-body { padding: 0 10px 10px; border-top: 1px dashed var(--border); margin-top: 2px; }
.mcp-row-body > .form-grid { margin-top: 10px; }

/* ----------------------------------------------------------- summary rail -- */
.mcp-rail .card { padding: 12px 14px; }
.mcp-sum-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.mcp-sum-list li { display: flex; justify-content: space-between; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border); }
.mcp-sum-list li:last-child { border-bottom: 0; }
.mcp-sum-list .k { color: var(--muted); }
.mcp-sum-list .v { font-variant-numeric: tabular-nums; text-align: right; }
.mcp-sum-list .v.warn { color: var(--red); }

/* ------------------------------------------------------- sticky run bar -- */
/* Appended as a child of the route's own root element (js/explorers/
   monte-carlo.js), NOT document.body — js/router.js only clears #content on
   navigation, so anything attached to document.body would never be removed.
   position:fixed still anchors to the viewport: no ancestor (#app, .content)
   establishes a new containing block via transform. */
.mcp-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .10); }
.mcp-bar-in { max-width: 1180px; margin: 0 auto; padding: 10px 18px;
  display: flex; align-items: center; gap: 14px; }
.mcp-bar-status { flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--muted); }
.mcp-bar-status.bad { color: var(--red); }
.mcp-bar .btn { flex: 0 0 auto; }
.mcp-bar progress { width: 120px; height: 6px; }

/* Below 900px the site's own fixed-bottom .mobile-nav (css/styles.css,
   z-index:50) takes over the bottom edge — the same breakpoint .content
   already reserves 72px for via padding-bottom. Sit above it instead of
   underneath/behind it, or the two fixed-bottom bars overlap and the site
   nav wins every click. */
@media (max-width: 900px) {
  .mcp-bar { bottom: calc(64px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------- results -- */
.mcp-results { margin-top: 22px; scroll-margin-top: 14px; }

/* The shared .rp-tabs (css/styles.css) is a fixed 5-col flex row that overflows
   the viewport edge on narrow phones — the rightmost tab became unreachable.
   Scoped to this route's results only: let the tab row scroll horizontally
   inside its own container rather than pushing past the screen. Desktop is
   unaffected (content fits, so no scrollbar appears). */
.mcp-results .rp-tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
.mcp-results .rp-tab { flex: 0 0 auto; white-space: nowrap; }
.mcp-headline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mcp-read { font-size: 14px; line-height: 1.5; }
.mcp-next { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.mcp-next button { text-align: left; padding: 10px 12px; font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); }
.mcp-next button:hover { border-color: var(--brand-blue); }
.mcp-next button:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.mcp-next .t { font-weight: 600; display: block; margin-bottom: 2px; }
.mcp-next .d { color: var(--muted); font-size: 12px; }

.mcp-fan { width: 100%; height: 300px; display: block; }
.mcp-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.mcp-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  margin-right: 5px; vertical-align: -2px; }

.mcp-note { font-size: 12px; color: var(--muted); }
.mcp-disc { font-size: 12px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; background: var(--bg); }

/* ------------------------------------------------------------- responsive -- */
@media (max-width: 980px) {
  .mcp-cols { grid-template-columns: minmax(0, 1fr); }
  .mcp-rail { position: sticky; top: 0; z-index: 30; order: -1; }
  .mcp-headline, .mcp-next { grid-template-columns: minmax(0, 1fr); }

  /* The rail is a 6-row table on desktop. Stacked above the questions on a
     phone that costs ~500px before the first field, so collapse it to a
     wrapping chip row — still persistent, roughly two lines tall. */
  .mcp-rail .card { padding: 8px 10px; }
  .mcp-rail h3, .mcp-rail .help-text:last-child { display: none; }
  .mcp-sum-list { display: flex; flex-wrap: wrap; gap: 4px 6px; }
  .mcp-sum-list li { display: inline-flex; gap: 4px; padding: 2px 8px; border-bottom: 0;
    background: var(--bg); border: 1px solid var(--border); border-radius: 999px; font-size: 11px; }
  .mcp-sum-list .v { text-align: left; font-weight: 600; }
}

@media (max-width: 700px) {
  .mcp-page { padding: 0 0 150px; }
  /* .form-grid in css/styles.css is a fixed 2-col with no breakpoint. */
  .mcp-page .form-grid { grid-template-columns: minmax(0, 1fr); }
  .mcp-bar-in { padding: 8px 12px; gap: 10px; flex-wrap: wrap; }
  .mcp-bar .btn { width: 100%; order: -1; }
  .mcp-fan { height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .mcp-page * { transition: none !important; animation: none !important; }
}

/* ------------------------------------------- migration confirmation -- */
.mcp-confirm { border-left: 3px solid var(--brand-yellow); }
.mcp-confirm h3 { margin-bottom: 6px; }
.mcp-recovered { border-left: 3px solid var(--green); }
.mcp-recovered p { font-size: 13px; color: var(--muted); }
.mcp-overflow { border-left: 3px solid var(--brand-blue); }
.mcp-overflow-list { list-style: none; margin: 0; padding: 0; display: flex;
  flex-wrap: wrap; gap: 6px; font-size: 13px; }
.mcp-overflow-list li { display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 4px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; }
