/* Retirement Plan (US): js/ui/us.js. Under .us so nothing here touches the other tools. Colours come from tokens.css (Night and Day).
   © In-Transit LLC. All rights reserved. */
[data-tool="us"] { --h: var(--c-1); }
/* The tool's results sit in the shared results column (css/app.css), so the cards inherit its spacing */
.results [data-top] { display: contents; }
.us-head { display: grid; gap: 8px; padding: 16px 18px; }
.us-head-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.us-big { font: 750 clamp(28px, 4vw, 40px)/1.05 var(--font-display); letter-spacing: -.02em; }
.us-big small { font: 500 14px var(--font); color: var(--ink-2); letter-spacing: 0; }
.us-sub { color: var(--ink-2); font-size: 13.5px; }
.us-sub b { color: var(--ink); }
.us-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.us-tile { display: grid; gap: 8px; align-content: start; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); }
.us-tile p { color: var(--ink-2); font-size: 12.5px; }
.us-tile .mono, .us-head-top .mono { font: 600 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.us-tile .btn { justify-self: start; }
.us-chart { width: 100%; height: auto; display: block; }
.us-chart .g { stroke: var(--grid); stroke-width: 1; }
.us-chart .t { fill: var(--ink-3); font: 10px var(--mono); paint-order: stroke; stroke: var(--bg-2); stroke-width: 4px; stroke-linejoin: round; }
.us-chart .mk { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 3 5; opacity: .7; }
.us-chart polyline { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.us-chart .p { stroke: var(--accent); stroke-width: 2.5; }
.us-chart .p2 { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 6 4; }
.us-legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12px; margin-top: 6px; align-items: center; }
.us-legend i { display: inline-block; width: 18px; height: 0; border-top: 3px solid var(--accent); vertical-align: middle; margin-right: 5px; }
.us-legend i.p2 { border-top: 3px dashed var(--bad); }
.us-fine { color: var(--ink-3); font-size: 12px; margin-top: 8px; }
.us-limits { margin-top: 4px; }
.us-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.us-table th { text-align: right; font: 600 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 6px 8px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.us-table td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.us-table th:first-child, .us-table td:first-child { text-align: left; }
.us-table tr.on td { background: var(--accent-soft); }
.us-table tr.bad td { background: var(--bad-bg); color: var(--bad); }
.us-seg { min-width: 260px; }

/* The offer of the US version, at the top of a home page (js/lib/region.js) */
.rg-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--accent); border-radius: var(--r); background: var(--accent-soft); font-size: 13.5px; }
.rg-act { display: flex; gap: 8px; }
.us-tile .pill { justify-self: start; }

/* Tidy spacing inside the results cards: the shared paragraph margins left gaps */
.us-head p, .us-tile p, .us-fine, .us-sub, .us-legend { margin: 0; }
.us-head { gap: 10px; }
.us-tile { align-content: start; }
.us-why { margin: 2px 2px 0; }

/* A table with a note under it: the shared table margin pulls the card's bottom edge up under the table, so give it room */
.us-claim .table-scroll, .us-year .table-scroll { margin-bottom: 12px; }
.us-claim .us-fine, .us-year .us-fine { margin-top: 0; }

/* Phone: the US tables wrap their headings and tighten up so the key columns stay in view */
@media (max-width: 520px) { .us-table { font-size: 12px; } .us-table th { white-space: normal; letter-spacing: 0; font-size: 9.5px; padding: 6px 4px; vertical-align: bottom; } .us-table td { padding: 6px 4px; } }
@media (max-width: 560px) { .us-chart .t { font-size: 10.5px; } }

/* The verdict: one plain sentence above everything else */
.us-verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-sm); border-left: 4px solid var(--ink-3); background: var(--surface-2); color: var(--ink); font: 600 15px/1.4 var(--font); }
.us-verdict.good { border-left-color: var(--good); background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.us-verdict.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.us-verdict.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.us-verdict p { margin: 0; flex: 1 1 240px; } .us-verdict .btn { flex: none; }

/* What changed, input warnings, the stacked balances chart and the compare card */
.us-delta { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; }
.us-issues { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-sm); border-left: 4px solid var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); font-size: 13.5px; }
.us-issues ul { margin: 6px 0 0; padding-left: 18px; } .us-issues li + li { margin-top: 4px; }
.us-stack .s { stroke: var(--bg-2); stroke-width: .6; fill-opacity: .9; }
.s-cash { fill: var(--c-p); background: var(--c-p); } .s-bonds { fill: var(--c-1); background: var(--c-1); }
.s-cds { fill: color-mix(in srgb, var(--c-p) 55%, var(--bg-2)); background: color-mix(in srgb, var(--c-p) 55%, var(--bg-2)); }
.s-tax { fill: var(--c-3); background: var(--c-3); } .s-trad { fill: var(--c-2); background: var(--c-2); } .s-roth { fill: var(--c-4); background: var(--c-4); }
.s-bk { fill: color-mix(in srgb, var(--c-2) 60%, var(--c-4)); background: color-mix(in srgb, var(--c-2) 60%, var(--c-4)); }
.us-keys span { display: inline-flex; align-items: center; gap: 6px; } .us-keys .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 0; margin: 0; }
.us-compare .us-table { font-size: 12px; }
.us-compare .us-table th, .us-compare .us-table td { padding: 6px 5px; }
.us-compare .us-table td:first-child { max-width: 11em; }
.us-compare .us-actions { margin: 8px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }

.us-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.us-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: 12.5px; color: var(--ink); background: transparent; cursor: pointer; }
.us-chip i, .us-cmp .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.us-cmp .sw { margin-right: 6px; }
.us-chip:not(.on) { color: var(--ink-2); }   /* not faded: at 60% opacity an unticked chip read as switched off, and was hard to read */
button.us-chip:hover { border-color: var(--accent); }
.us-cmp { font-size: 12px; }
.us-cmp th, .us-cmp td { padding: 6px 5px; }
.us-cmp th { white-space: normal; letter-spacing: 0; font-size: 10px; max-width: 8em; overflow-wrap: anywhere; vertical-align: bottom; }
.us-cmp { table-layout: fixed; width: 100%; }
.us-cmp th:first-child, .us-cmp td:first-child { width: 30%; white-space: normal; padding-right: 8px; }
.us-cmp td { overflow-wrap: anywhere; white-space: normal; }
.us-cmp tr.cmp-sec td { width: auto; white-space: nowrap; overflow-wrap: normal; }
.us-cmp td.best { background: var(--good-bg); color: var(--good); font-weight: 600; }
.us-cmp td.short { color: var(--bad); font-weight: 600; }
.us-cmp tr.diff td:first-child::after { content: " \2022"; color: var(--accent); }
.us-cmp tr.cmp-sec td { font: 600 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); padding-top: 12px; text-align: left; }
.us-compare .us-chart { margin-top: 12px; }
.us-chart .dot { stroke: var(--surface); stroke-width: 2; }

.us-fix .card-head { margin-bottom: 8px; }
.us-fixgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.us-fixcard { display: grid; gap: 4px; align-content: start; border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 10px 12px; background: var(--surface); }
.us-fixcard b { font-size: 14px; }
.us-fixcard small { color: var(--ink-3); font-size: 12px; }
.us-fixcard p { margin: 2px 0 6px; color: var(--ink-2); font-size: 12.5px; }
.us-fixcard .btn { justify-self: start; }
.us-fix .us-fine { margin-top: 8px; }

.in-view { margin: 0 0 6px; align-items: center; }
.us-chip-label { font: 600 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin-right: 4px; }
[data-in-view] .us-fine { margin: 0 0 10px; }

.us-stress .card-head { margin-bottom: 8px; }
.us-stressgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; }   /* two to a row (four make a square, never three and one over) */
.us-stressgrid > .us-stressrow:last-child:nth-child(odd) { grid-column: 1 / -1; }
@container (max-width: 519px) { .us-stressgrid { grid-template-columns: minmax(0, 1fr); } }
@container (min-width: 1100px) { .us-stressgrid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } .us-stressgrid > .us-stressrow:last-child:nth-child(odd) { grid-column: auto; } }
.us-stressrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.us-stress .us-fine { margin-top: 8px; }

.us-fate { font: 600 10.5px var(--mono); letter-spacing: .06em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.us-fate.good { color: var(--good); background: var(--good-bg); }
.us-fate.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.us-fate.bad { color: var(--bad); background: var(--bad-bg); }

.us-chip.add { border-style: dashed; color: var(--ink-2); }

/* Compare scenarios: the graph is optional (the Show graph chip) and kept plain */
.cmp-graph { margin-top: 14px; padding: 12px 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.cmp-graph[hidden] { display: none; }
.cmp-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 6px 6px; font: 600 12px var(--mono); color: var(--ink-2); }
.cmp-legend span { display: inline-flex; align-items: center; gap: 7px; }
.us-compare .cmp-graph .us-chart { margin-top: 0; }
.cmp-chart .g { stroke-dasharray: 2 5; opacity: .75; }
.cmp-chart .cmp-area { fill-opacity: .09; }
.cmp-chart .cmp-end { font-weight: 700; font-size: 11px; }
.cmp-chart polyline { stroke-linejoin: round; stroke-linecap: round; }

/* The year-by-year headings may wrap (Spending and health, Required distributions) so the table fits its card without a sideways scrollbar */
.us-table th { white-space: normal; vertical-align: bottom; line-height: 1.25; }

/* The smallest phones: the year-by-year table gives up a little padding so it fits */
@media (max-width: 380px) { .us-table { font-size: 11.5px; } .us-table th, .us-table td { padding: 6px 3px; } .us-table th { font-size: 9px; letter-spacing: 0; } }

/* Compare table: the section row ("Result") is a plain full-width line (its row class was once "sec", which is the Inputs panel's section class and squeezed it into a small box); the table shows in full, with no inner scroll */
.us-cmp tr.cmp-sec td { position: static; background: none; }
.us-compare .table-scroll { max-height: none; }
