/*
 * Shared page components used by every model panel (UI decisions D10 and P05).
 *
 * Panels keep their own layout files for what is unique to them; anything that
 * appears in more than one panel (headline cards, metric tiles, story steps, chart
 * pairs, explanation lists, value steppers, remove buttons, the Eco helper, and the
 * (i) popovers) is styled once here so every page reads the same way. Loaded last.
 */

/* ---------- Eco helper (D04, D05) ---------- */
/* Header: menu button, tab rail (Home first), models button, Eco helper. */
.workspace-header { grid-template-columns: 46px minmax(0, 1fr) auto auto; }
.eco-toggle { display: inline-flex; gap: 8px; align-items: center; min-height: 46px; padding: 0 16px; border: 1px solid var(--model-border); border-radius: 14px; background: white; color: var(--model-strong); font-size: .85rem; font-weight: 650; cursor: pointer; box-shadow: 0 3px 9px #173f720a; transition: background 220ms ease, color 220ms ease, box-shadow 220ms ease, transform 220ms ease; }
.eco-toggle:hover { transform: translateY(-1px); box-shadow: 0 5px 12px #173f7215; }
.eco-toggle-icon { font-size: 1rem; }
.eco-toggle[aria-pressed="true"] { border-color: var(--model-accent); background: linear-gradient(135deg, var(--model-accent), var(--model-accent-pressed)); color: var(--model-on-accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--model-accent) 20%, transparent); }
.eco-help { display: none; }
.eco-help[hidden] { display: none !important; }
/* Switching the helper on or off is animated in navigation.js (animateEcoBlock), which
   grows or folds each block so the content below slides instead of jumping. */
[data-eco="on"] .eco-help { display: block; margin: 10px 0 0; padding: 8px 0 8px 12px; border-left: 3px solid var(--model-helper); color: #3b4f69; font-size: .92rem; line-height: 1.6; }
[data-eco="on"] span.eco-help { display: inline; margin: 0; padding: 0; border: 0; }
@media (max-width: 600px) {
    .eco-toggle { padding: 0 13px; }
    .eco-toggle-label { display: none; }
}

/* ---------- (i) explanations shown beside the side panel ---------- */
.info-toggle[aria-expanded="true"] { background: var(--primary); color: #fff; }
.info-popover { position: fixed; inset: auto; margin: 0; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 20px 22px; border: 1px solid #c9d9ea; border-radius: 16px; background: white; color: #33475f; font-size: 1rem; line-height: 1.7; box-shadow: 0 22px 50px #14305233; }
.info-popover::backdrop { background: transparent; }
.info-popover h3 { margin: 0 0 10px; color: #172b48; font-size: 1.05rem; font-weight: 700; }
.info-popover p { margin: 0; }
.info-popover p + p { margin-top: 12px; }
.info-popover:popover-open { animation: popover-in 220ms ease-out both; }
@keyframes popover-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* ---------- Side panels ---------- */
.input-board-heading { margin-bottom: 18px; }
.board-rule { margin: 10px 0 14px; color: #586b83; font-size: .85rem; line-height: 1.5; }
.input-board .board-heading { margin: 24px 0 12px; color: #172b48; font-size: .95rem; font-weight: 700; }

/* ---------- Headline card at the top of the results ---------- */
/* Every panel's headline card: a model-coloured strip and a faint wash (D09). One
   rule here, after .card, so no panel's own border or background can hide it. */
.result-hero { padding: 26px; border-top: 3px solid var(--model-accent); background: linear-gradient(120deg, var(--model-page), var(--card) 70%); }
.result-hero .eyebrow { margin-bottom: 8px; }
.result-hero h3 { margin: 0; color: #172b48; font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 650; line-height: 1.3; }
.result-hero .hero-text { max-width: 760px; margin: 12px 0 0; color: #3f526d; font-size: 1.1rem; line-height: 1.7; }
.hero-status { display: block; margin: 12px 0 0; font-size: clamp(1.5rem, 2.6vw, 2.1rem); font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.hero-status.status-above { color: #a5521a; background: none; }
.hero-status.status-below { color: #1e5aa0; background: none; }
.hero-status.status-near { color: #138667; background: none; }
.hero-highlight-time { color: #b25a1e; font-weight: 800; }
.hero-highlight-share { color: #1e5aa0; font-weight: 800; }

/* A thin line marks the start of a new section. */
.section-rule { height: 0; margin: 4px 0; border: 0; border-top: 1px solid #ccd9e7; }
.section-title { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 14px; }
.section-title h3 { margin: 0; color: #172b48; font-size: 1.25rem; font-weight: 650; }
.section-title p { max-width: 420px; margin: 0; color: var(--muted); font-size: .9rem; text-align: right; }

/* ---------- Metric tiles: label, a large centered number, optional comparison ---------- */
.metric-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.metric-tile { display: flex; min-width: 0; padding: 20px 16px; flex-direction: column; align-items: center; justify-content: flex-start; text-align: center; }
.metric-tile h4 { margin: 0; color: #52647c; font-size: .88rem; font-weight: 650; line-height: 1.35; }
.metric-tile > strong { display: block; margin: 10px 0 4px; color: var(--model-strong); font-size: clamp(1.7rem, 2.8vw, 2.3rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.metric-tile .metric-unit { color: #6a7a8f; font-size: .85rem; }
.metric-compare { display: flex; gap: 28px; justify-content: center; margin-top: 10px; }
.metric-compare div { display: grid; gap: 2px; }
.metric-compare span { color: #6a7a8f; font-size: .8rem; }
.metric-compare b { font-size: 1.2rem; }
.metric-compare .is-baseline { color: #326eaf; }
.metric-compare .is-scenario { color: #b75c20; }
.metric-tile .eco-help { align-self: stretch; text-align: left; }

/* ---------- Story steps ("What drives the result?") ---------- */
.story-card { padding: 24px; min-width: 0; }
.story-card > h3 { margin: 0; color: #172b48; font-size: 1.25rem; font-weight: 650; }
.story-step { display: grid; grid-template-columns: 30px 1fr; gap: 14px; margin-top: 20px; }
.story-step > span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--model-soft); color: var(--model-strong); font-size: .85rem; font-weight: 700; }
.story-step h4 { margin: 4px 0 6px; color: #1d3554; font-size: 1.05rem; font-weight: 700; }
.story-step p { margin: 0; color: #43566f; font-size: 1rem; line-height: 1.7; }

/* ---------- Explanation lists with visible bullets ---------- */
.explain-list { margin: 14px 0 0; padding-left: 1.3rem; color: #43566f; font-size: 1rem; line-height: 1.7; list-style: disc; }
.explain-list li { padding-left: 4px; }
.explain-list li + li { margin-top: 10px; }
.explain-list li::marker { color: var(--model-accent); }
.explain-card { padding: 24px; min-width: 0; }
.explain-card > h3 { margin: 0; color: #172b48; font-size: 1.25rem; font-weight: 650; }
.assumptions-card { padding: 20px 24px; color: #43566f; font-size: 1rem; line-height: 1.7; }
.assumptions-card summary { cursor: pointer; color: #22426a; font-size: 1.05rem; font-weight: 700; }
.assumptions-card p { margin: 14px 0 0; }
.assumptions-card .lab-equations { margin-top: 14px; padding: 10px 16px; border-radius: 10px; background: #f1f5fa; overflow-wrap: anywhere; }
.assumptions-card .lab-equations p { margin: 6px 0; }

/* ---------- Two charts side by side ---------- */
.chart-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chart-card { min-width: 0; padding: 20px; }
.chart-card > h3 { margin: 0 0 4px; color: #172b48; font-size: 1.1rem; font-weight: 650; }
.chart-card .chart-area { width: 100%; min-width: 0; height: 340px; }
@media (max-width: 1100px) { .chart-pair { grid-template-columns: 1fr; } }

/* ---------- A target chosen with a slider and one-point steps ---------- */
.value-stepper { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 10px; align-items: center; margin-top: 10px; }
.value-stepper button { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border: 1px solid #c7d6e6; border-radius: 50%; background: white; color: var(--model-strong); font-size: 1.25rem; font-weight: 700; line-height: 1; cursor: pointer; transition: background 160ms ease, transform 160ms ease; }
.value-stepper button:hover:not(:disabled) { background: var(--model-soft); transform: translateY(-1px); }
.value-stepper input[type="range"] { width: 100%; height: auto; padding: 0; border: 0; background: transparent; accent-color: var(--model-accent); }
.target-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.target-figures span { display: block; color: #586b83; font-size: .78rem; }
.target-figures strong { display: block; padding: 4px 0; font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; }
.target-figures .is-baseline { color: #245d9f; }
.target-figures .is-scenario { color: #b0561c; }

/* ---------- Remove buttons on charts and saved results ---------- */
.remove-button { display: grid; flex: 0 0 auto; width: 32px; height: 32px; padding: 0; place-items: center; border: 1px solid #d5e0ea; border-radius: 50%; background: #ffffffe6; color: #6b7888; font-size: 1.15rem; line-height: 1; cursor: pointer; transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease; }
.remove-button:hover { border-color: #e2b4ae; background: #fff4f2; color: #9b342c; transform: rotate(90deg); }

@media (prefers-reduced-motion: reduce) {
    .info-popover:popover-open { animation: none; }
    .eco-toggle, .value-stepper button, .remove-button { transition: none; }
}
@media (max-width: 650px) {
    .result-hero, .story-card, .explain-card, .assumptions-card, .chart-card { padding: 16px; }
    .section-title { flex-direction: column; align-items: start; }
    .section-title p { text-align: left; }
}

/* One calm selection board, with Apply beside the context it commits. */
.shared-selection { display: block; padding: 22px 26px 18px; margin: 18px 0 24px; background: linear-gradient(120deg, #fff 55%, #f4faf8); }
.shared-selection[hidden] { display: none; }
.selection-fields { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(280px, 1fr); gap: 28px; align-items: end; }
.shared-selection .input-field { min-width: 0; margin: 0; }
.shared-selection label { display: block; margin-bottom: 8px; color: #43566f; font-size: .85rem; font-weight: 600; }
.shared-selection select { width: 100%; min-height: 48px; border: 1px solid #cedde3; border-radius: 12px; padding: 10px 14px; background-color: #fff; color: #243f54; transition: border-color 180ms ease, box-shadow 180ms ease; }
.shared-selection select:focus-visible { border-color: var(--model-accent); }
.selection-period { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; align-items: end; border: 0; padding: 0; margin: 0; min-width: 0; }
.selection-period legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.selection-to { align-self: end; padding-bottom: 12px; color: #7e9990; }
.selection-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding-top: 16px; border-top: 1px solid #e4eeea; }
.selection-context { min-width: 0; font-size: .88rem; color: #415a50; }
.selection-context p { margin: 0 0 3px; }
.selection-context small { color: #6b7c78; }
#selectionPending { color: #925c12; }
.shared-selection #applySelection { display: inline-flex; align-items: center; justify-content: center; gap: 18px; flex: 0 0 auto; min-height: 48px; min-width: 190px; padding: 12px 22px; border: 1px solid var(--model-accent); border-radius: 14px; background: var(--model-accent); color: white; font-weight: 650; cursor: pointer; box-shadow: 0 4px 10px color-mix(in srgb, var(--model-accent) 9%, transparent); transition: background 180ms ease, transform 180ms ease, box-shadow 180ms ease; }
.shared-selection #applySelection:hover:not(:disabled) { background: var(--model-accent-hover); transform: translateY(-1px); box-shadow: 0 6px 14px color-mix(in srgb, var(--model-accent) 15%, transparent); }
.shared-selection #applySelection:active:not(:disabled) { background: var(--model-accent-pressed); }
.shared-selection #applySelection:disabled { opacity: .5; cursor: wait; }
.shared-selection .lab-error { margin: 14px 0 0; }
.shared-selection #selectionRetry { margin-top: 10px; }
.summary-empty { min-height: 540px; background: radial-gradient(ellipse at top, var(--model-page), white 70%); }
.summary-empty p { line-height: 1.65; }
@media (max-width: 650px) {
    .shared-selection { padding: 18px; }
    .selection-fields { grid-template-columns: 1fr; gap: 16px; }
    .selection-footer { align-items: stretch; flex-direction: column; gap: 14px; }
    .shared-selection #applySelection { width: 100%; }
    .summary-empty { min-height: 340px; }
}
@media (prefers-reduced-motion: reduce) {
    .shared-selection select, .shared-selection #applySelection { transition: none; }
}

/* Metadata-driven slider rows (metadataSlider() in common.js), used by Portfolio and Money & Banking. */
.slider-field label { display: block; color: #22324a; font-size: .84rem; font-weight: 600; line-height: 1.35; }
.slider-field output { color: var(--model-strong); font-weight: 700; font-variant-numeric: tabular-nums; }
.slider-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 8px; margin-top: 4px; }
.slider-range { width: 100%; accent-color: var(--model-accent); }
.slider-step { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 1px solid #c7d6e6; border-radius: 50%; background: white; color: var(--model-strong); font-size: 1.1rem; font-weight: 700; line-height: 1; cursor: pointer; }
.slider-step:hover { background: var(--model-soft); }
.slider-help { margin: 3px 0 0; color: #586b83; font-size: .72rem; line-height: 1.45; }
/* ---------- Lab navigation (docs/implemented/lab-navigation-plan.md) ----------
   Home is the first item of the tab rail; the models button beside the Eco helper
   names the open model and opens the models drop-down; each model has a footer.
   Elements with data-for-model show only for the open model, and each model's
   name in the drop-down and footer takes that model's colour; main.html writes
   those per-model rules from the model list, so a new model needs no CSS here. */
.rail-home { display: inline-grid; place-items: center; flex-shrink: 0; width: 42px; min-height: 42px; margin-right: 3px; border-radius: 13px; color: #4a5a72; transition: background 220ms ease, color 220ms ease; }
.rail-home svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail-home:hover { background: #ffffffb0; color: var(--model-strong); }
.models-button { display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 14px; border: 1px solid var(--model-border); border-radius: 14px; background: white; color: var(--model-strong); font: inherit; font-size: .85rem; font-weight: 700; white-space: nowrap; cursor: pointer; box-shadow: 0 3px 9px #173f720a; transition: background 220ms ease, transform 220ms ease; }
.models-button:hover, .models-button[aria-expanded="true"] { background: var(--model-soft); }
.models-dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--model-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--model-accent) 20%, transparent); }
.models-caret { color: #4a5a72; font-size: .75rem; }
.models-menu { padding: 14px; }
.models-menu ul { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.models-menu-title { margin: 0 4px 8px; color: #4a5a72; font-size: .74rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.models-menu-item { display: flex; align-items: center; gap: 8px; border: 1px solid #e4ebf3; border-radius: 14px; }
.models-menu-open { flex: 1; display: grid; gap: 2px; min-width: 0; padding: 10px 12px; border-radius: 13px; }
.models-menu-open:hover { background: #f4f7fb; }
.models-menu-name { color: #172b45; font-weight: 750; }
.models-menu-meta { color: #4a5a72; font-size: .82rem; line-height: 1.4; }
.models-menu-overview { flex-shrink: 0; margin-right: 8px; padding: 8px 10px; border-radius: 10px; color: var(--model-strong); font-size: .82rem; font-weight: 700; }
.models-menu-overview:hover { background: var(--model-soft); }
.models-menu-later { margin: 12px 4px 0; color: #4a5a72; font-size: .8rem; line-height: 1.5; }
.models-menu-later span { margin-right: 4px; padding: 2px 8px; border-radius: 999px; background: #eef2f8; font-weight: 700; }

.lab-footer { margin-top: 40px; border: 1px solid var(--model-border); border-radius: 22px; background: linear-gradient(160deg, var(--model-soft), #ffffff 55%); color: #4a5a72; font-size: .88rem; overflow: hidden; }
.lab-footer p { margin: 0; }
.lab-footer-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 1.7fr); gap: 24px 40px; padding: 26px 28px 22px; }
.lab-footer-about { display: grid; align-content: start; gap: 6px; }
.lab-footer-name { display: flex; align-items: center; gap: 10px; color: var(--model-strong); font-size: 1.15rem; font-weight: 750; letter-spacing: -.01em; }
.lab-footer-scale { justify-self: start; padding: 2px 10px; border-radius: 999px; background: #ffffffcc; border: 1px solid var(--model-border); color: var(--model-strong); font-size: .72rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.lab-footer-question { max-width: 34em; line-height: 1.55; }
.lab-footer-heading { margin-bottom: 8px !important; color: #4a5a72; font-size: .72rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.lab-footer-column ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.lab-footer-column li a { display: inline-flex; min-height: 32px; align-items: center; color: #172b45; font-weight: 600; }
.lab-footer-column li a:hover { color: var(--model-strong); text-decoration: underline; text-underline-offset: 3px; }
/* Other models sit two per row, so five models do not make a tall stack. */
.lab-footer-column:last-child { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; gap: 8px; }
.lab-footer-column:last-child > p { grid-column: 1 / -1; }
.lab-footer-model { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 12px; padding: 10px 14px; border: 1px solid #dce6f0; border-radius: 14px; background: white; transition: border-color 200ms ease, transform 200ms ease; }
.lab-footer-model:hover { transform: translateY(-1px); border-color: currentColor; }
.lab-footer-model-name { font-weight: 750; }
.lab-footer-model-scale { grid-row: 2; color: #4a5a72; font-size: .78rem; }
.lab-footer-model-arrow { grid-row: 1 / span 2; grid-column: 2; font-weight: 700; }
.lab-footer-references { margin-top: 12px !important; font-size: .78rem; line-height: 1.5; }
.lab-footer-references span { color: #172b45; font-weight: 750; }
.lab-footer-later { margin-top: 10px !important; font-size: .78rem; line-height: 1.5; }
.lab-footer-data { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; padding: 12px 28px; border-top: 1px solid #e4ebf3; background: #ffffffb3; font-size: .78rem; line-height: 1.5; }
.lab-footer-data > span:first-child { color: #172b45; font-weight: 750; }
.lab-footer-data small { padding: 1px 6px; border-radius: 6px; background: #eef2f8; font-size: .7rem; font-weight: 650; }
.lab-footer-note { margin-left: auto; }
@media (max-width: 900px) {
    .lab-footer-grid { grid-template-columns: 1fr 1fr; }
    .lab-footer-about { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .workspace-header { gap: 8px; }
    .models-button { gap: 4px; min-width: 44px; padding: 0 10px; }
    .models-current { display: none; }
    .lab-footer-grid { grid-template-columns: 1fr; padding: 22px 18px 18px; }
    .lab-footer-data { padding: 12px 18px; }
    .lab-footer-note { margin-left: 0; }
@media (prefers-reduced-motion: reduce) {
    .rail-home, .models-button, .lab-footer-model { transition: none; }
