/* =========================================================
   Interactive project pages (portfolio optimisation, bakery simulation, US used-car map).
   Loaded only on those pages. Uses the site's variables; chart colours are set in viz-common.js.
   ========================================================= */

.crumb { margin-bottom: 22px; }
.crumb a { display: inline-flex; align-items: center; gap: 10px; color: var(--on-navy); text-decoration: none; font-size: .9375rem; font-weight: 600; }
.crumb a::before { content: ""; width: 8px; height: 8px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
.crumb a:hover { color: #fff; text-decoration: underline; text-underline-offset: 4px; }

.band__meta { margin-top: 22px; font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--mint); }

/* Summary strip under the band */
.glance { display: grid; gap: 40px; align-items: start; }
@media (min-width: 960px) { .glance { grid-template-columns: 5fr 7fr; gap: 80px; } }
.glance .outcomes { margin-top: 32px; padding-top: 0; border-top: 0; }
.glance p { color: var(--ink); max-width: 60ch; margin-top: 14px; line-height: 1.6; }
.glance .proj__label { margin-bottom: 4px; }

/* Panels */
.viz-panel { margin-top: 56px; }
.viz-panel:first-of-type { margin-top: 40px; }
.viz-panel h3 { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.viz-panel__lead { margin-top: 8px; color: var(--muted); max-width: 66ch; font-size: 1rem; line-height: 1.55; }
.viz-card { margin-top: 22px; background: #fff; border: 1px solid var(--line); padding: clamp(16px, 2.4vw, 28px); }
.section--paper .viz-card { background: #fff; }
.viz-wrap { position: relative; }
.viz-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz-svg text { font-family: var(--font); fill: var(--ink); }
.viz-svg .t-muted { fill: var(--muted); }
.viz-svg .t-axis { fill: var(--muted); font-size: 11px; }
.viz-svg .grid { stroke: #E7E9EE; stroke-width: 1; }
.viz-svg .axis { stroke: #B9C0CC; stroke-width: 1; }
.viz-svg [data-hit] { cursor: pointer; }
.viz-svg [data-hit]:focus { outline: none; }
.viz-svg [data-hit]:focus-visible .ring, .viz-svg [data-hit]:hover .ring { stroke: var(--ink); stroke-width: 2; }
.viz-svg .ring { fill: none; stroke: transparent; pointer-events: none; }

/* Controls */
.viz-controls { display: flex; flex-wrap: wrap; gap: 18px 32px; align-items: end; margin-top: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.viz-ctl { display: grid; gap: 8px; min-width: 0; }
.viz-ctl > label, .viz-ctl > .viz-ctl__label { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink); }
.viz-ctl output { font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; margin-left: 8px; letter-spacing: 0; text-transform: none; font-size: .9375rem; }
.viz-ctl input[type="range"] { width: min(320px, 100%); accent-color: var(--navy); min-height: 28px; }
.viz-ctl select { font: 500 .9375rem var(--font); padding: 10px 12px; border: 1px solid #B9C0CC; background: #fff; color: var(--ink); border-radius: 0; min-height: 44px; }
.viz-ctl__hint { font-size: .8125rem; color: var(--muted); max-width: 40ch; line-height: 1.4; }

.seg { justify-self: start; width: fit-content; max-width: 100%; display: inline-flex; flex-wrap: wrap; border: 1px solid var(--navy); }
.seg button { font: 600 .875rem var(--font); background: #fff; color: var(--navy); border: 0; padding: 11px 16px; cursor: pointer; min-height: 44px; border-right: 1px solid var(--navy); }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: #EAF0F8; }
.seg button[aria-pressed="true"] { background: var(--navy); color: #fff; }
.seg button:focus-visible, .viz-btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
.viz-btn { font: 600 .875rem var(--font); background: var(--navy); color: #fff; border: 0; padding: 11px 18px; cursor: pointer; min-height: 44px; }
.viz-btn:hover { background: var(--navy-deep); }
.viz-btn--ghost { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
.viz-btn--ghost:hover { background: #EAF0F8; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 22px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tiles--3 { }
@media (min-width: 720px) { .tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { border: 1px solid var(--line); border-top: 3px solid var(--navy); background: #fff; padding: 14px 16px 12px; min-width: 0; }
.tile strong { display: block; font-size: clamp(1.375rem, 3vw, 1.875rem); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; color: var(--navy); font-variant-numeric: tabular-nums; }
.tile span { display: block; margin-top: 4px; font-size: .8125rem; color: var(--muted); line-height: 1.35; }
.tile small { display: block; margin-top: 6px; font-size: .75rem; color: var(--green-dark); font-weight: 600; line-height: 1.35; }

/* Legends */
.viz-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: .8125rem; color: var(--muted); align-items: center; }
.viz-legend span { display: inline-flex; align-items: center; gap: 8px; }
.viz-legend i { display: inline-block; width: 12px; height: 12px; flex: none; }
.viz-legend i.line { height: 3px; width: 18px; }
.viz-legend i.round { border-radius: 50%; }
.scalebar { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: .75rem; color: var(--muted); }
.scalebar__bar { height: 10px; width: min(260px, 50%); flex: none; }

/* Tooltip (one, shared per chart host) */
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: #fff; border: 1px solid #B9C0CC; box-shadow: 0 6px 20px rgba(12, 26, 51, .14); padding: 10px 12px; min-width: 150px; max-width: 260px; font-size: .8125rem; line-height: 1.4; }
.viz-tip[hidden] { display: none; }
.viz-tip__title { font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.viz-tip__row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.viz-tip__row b { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

/* Notes and table views */
.viz-note { margin-top: 16px; padding: 14px 16px; border-left: 3px solid var(--green); background: var(--paper); color: var(--muted); font-size: .9375rem; line-height: 1.55; max-width: 76ch; }
.viz-note strong { color: var(--ink); font-weight: 600; }
.viz-check { margin-top: 14px; font-size: .875rem; color: var(--muted); line-height: 1.5; max-width: 76ch; }
.viz-check strong { color: var(--ink); }
details.viz-table { margin-top: 16px; border: 0; }
details.viz-table > summary { font-size: .9375rem; font-weight: 600; color: var(--navy); padding: 10px 40px 10px 0; display: inline-block; }
details.viz-table > summary::after { font-size: 1.5rem; }
details.viz-table:not([open]) > summary::after { content: "+"; }
details.viz-table[open] > summary::after { content: "\2212"; }
.viz-table__scroll { overflow-x: auto; margin-top: 8px; max-height: 420px; border: 1px solid var(--line); }
.viz-table table { border-collapse: collapse; width: 100%; font-size: .8125rem; font-variant-numeric: tabular-nums; background: #fff; }
.viz-table th, .viz-table td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.viz-table th:first-child, .viz-table td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.viz-table thead th { position: sticky; top: 0; background: var(--paper); font-weight: 700; color: var(--ink); z-index: 1; }
.viz-table thead th:first-child { z-index: 2; background: var(--paper); }

/* Two-up grids */
.viz-two { display: grid; gap: 28px; }
@media (min-width: 960px) { .viz-two { grid-template-columns: 1fr 1fr; gap: 36px; } }
.viz-two .viz-card { margin-top: 18px; }

/* Method / limits lists */
.mlist { display: grid; gap: 20px; margin-top: 32px; }
@media (min-width: 880px) { .mlist { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; } }
.mlist h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.01em; }
.mlist p, .mlist li { margin-top: 8px; color: var(--muted); font-size: .9375rem; line-height: 1.55; }
.mlist ul { list-style: none; padding: 0; }
.mlist li { padding-left: 16px; position: relative; }
.mlist li::before { content: ""; position: absolute; left: 0; top: .62em; width: 6px; height: 6px; background: var(--green); }

/* US map extras */
.map-layout { display: grid; gap: 28px; margin-top: 22px; }
@media (min-width: 1040px) { .map-layout { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 36px; align-items: start; } }
.detail { border: 1px solid var(--line); background: #fff; padding: 20px 22px; }
.detail h4 { font-size: 1.5rem; font-weight: 500; letter-spacing: -0.025em; line-height: 1.15; }
.detail__sub { margin-top: 4px; color: var(--muted); font-size: .875rem; }
.detail dl { margin: 16px 0 0; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: .9375rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.detail__badge { display: inline-flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--green-dark); }
.detail__badge::before { content: ""; width: 8px; height: 8px; background: var(--green); }

@media (prefers-reduced-motion: no-preference) {
  .viz-svg rect, .viz-svg circle { transition: opacity .15s; }
}
@media print { .viz-controls, .pf-btns { display: none; } }

/* Legend shapes */
.viz-legend i.sq { border-radius: 0; }
.viz-legend i.tri { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.viz-legend i.dia { transform: rotate(45deg) scale(.78); }
.viz-legend i.hollow { background: #fff !important; border: 1.5px solid var(--muted); border-radius: 50%; }
.viz-legend i.dot { width: 5px; height: 5px; border-radius: 50%; opacity: .4; }
.scalebar__bar { border: 1px solid var(--line); }

.viz-split { display: grid; gap: 28px; align-items: start; }
@media (min-width: 960px) { .viz-split { grid-template-columns: minmax(0, 580px) minmax(280px, 1fr); gap: 48px; } }
.viz-side .viz-note { margin-top: 18px; }
.viz-side .scalebar { margin-top: 20px; }

.viz-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.recs { list-style: none; padding: 0; display: grid; gap: 14px; }
.recs li { position: relative; padding-left: 20px; color: var(--muted); line-height: 1.55; max-width: 76ch; }
.recs li::before { content: ""; position: absolute; left: 0; top: .6em; width: 7px; height: 7px; background: var(--green); }
.recs strong { color: var(--ink); font-weight: 600; }
#car-facts { margin-top: 32px; }
#car-map svg g[data-hit]:focus-visible rect:first-child { stroke: var(--ink); }

.seg { background: #fff; }
@media (max-width: 480px) { .seg button { padding: 11px 11px; font-size: .8125rem; } }
