/* Emulator results (#/emulate, lower half) and How it works (#/how). */

/* ---------- head, status, controls ---------- */
.results { margin-top: var(--s12); }
.res-head { margin-bottom: var(--s4); align-items: end; }
.res-head-side { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.res-status { display: inline-flex; align-items: center; gap: var(--s2); margin: 0; font-size: var(--t-xs); color: var(--fg-3); font-variant-numeric: tabular-nums; min-height: 28px; }
.res-status svg { color: var(--ok); }
.res-status[data-tone="busy"] { color: var(--fg-2); }
.res-status[data-tone="error"] { color: var(--danger); }
.dot-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.1s var(--ease) infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.res-dl .btn span { white-space: nowrap; }

.res-controls { display: grid; grid-template-columns: minmax(260px, 1.6fr) auto auto minmax(150px, .7fr); gap: var(--s3) var(--s6); align-items: start; padding: var(--s4); margin-bottom: var(--s4); }
.res-ctl { display: grid; gap: var(--s2); min-width: 0; }
.res-ctl .seg { justify-self: start; }
.res-ind-def { margin: 0; min-height: 1.5em; }
.res-ind-def .badge { height: 18px; font-size: 10px; vertical-align: 1px; }
.select-sm { min-height: 36px; }
@media (max-width: 960px) { .res-controls { grid-template-columns: 1fr 1fr; } .res-ctl-ind { grid-column: 1 / -1; } }
@media (max-width: 520px) { .res-controls { grid-template-columns: 1fr; } .res-ctl .seg { justify-self: stretch; } .res-ctl .seg button { flex: 1; justify-content: center; } .res-ctl .seg { display: flex; } }

.res-support:empty { display: none; }
.res-support { margin-bottom: var(--s4); }
.res-flags { margin: var(--s1) 0 0; padding-left: 0; list-style: none; display: grid; gap: var(--s1); }
.res-flags li { font-size: var(--t-xs); color: var(--fg-2); }
.res-flag { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 500; }
.res-flag svg { width: 12px; height: 12px; }

/* ---------- body: map + country ---------- */
.res-body { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
@media (max-width: 1100px) { .res-body { grid-template-columns: minmax(0, 1fr); } }
.res-body > .fig { min-width: 0; padding: var(--s4); }
.res-map-head { flex-wrap: wrap; margin-bottom: var(--s3); }
.res-map-head > div:first-child { min-width: 0; flex: 1 1 220px; }
.res-map-ctl { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: flex-end; }
.res-pw-pick { display: inline-flex; align-items: center; gap: var(--s1); }
.res-minus { color: var(--fg-3); font-weight: 600; padding: 0 2px; }
.seg button[disabled] { opacity: .4; cursor: not-allowed; }
.pw-dot.sm { width: 20px; height: 20px; font-size: 11px; }
.pw-dot.xs { width: 16px; height: 16px; font-size: 9.5px; vertical-align: -3px; }
.res-map-wrap { position: relative; }
.res-map.is-loading .res-map-host { opacity: .35; filter: saturate(.3); transition: opacity var(--dur); }
.res-loading { position: absolute; inset: 0; display: grid; place-content: center; grid-auto-flow: column; gap: var(--s2); align-items: center; color: var(--fg-2); font-size: var(--t-sm); border-radius: var(--radius); background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--surface-2) 70%, transparent) 50%, transparent 70%) 0 0 / 300% 100%; animation: shimmer 1.6s linear infinite; pointer-events: none; }
.res-map-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s6); margin-top: var(--s3); }
.res-legend { flex: 1 1 260px; min-height: 44px; }
.res-play { flex: 1 1 260px; max-width: 420px; }
.res-map .method { margin-top: var(--s3); }

.res-c-head { margin-bottom: var(--s3); }
.res-c-title { min-width: 0; }
.res-c-pick { margin-bottom: var(--s3); }
.res-cv { margin-bottom: var(--s3); }
.res-c-legend { display: grid; gap: var(--s1); margin-bottom: var(--s2); }
.res-keys { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-xs); color: var(--fg-2); }
.res-keys-m { color: var(--fg-3); }
.res-key { display: inline-flex; align-items: center; gap: var(--s2); }
.swatch-band { display: inline-block; width: 18px; height: 10px; border-radius: 2px; background: color-mix(in srgb, var(--fg-2) 22%, transparent); }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; border: 1.5px solid; }
.leg-dot.up { background: var(--leg-up); border-color: var(--leg-up); }
.leg-dot.down { background: transparent; border-color: var(--leg-down); }
.leg-dot.flat { background: var(--fg-3); border-color: var(--fg-3); border-radius: 1px; transform: rotate(45deg) scale(.85); }
:root { --leg-up: #F08A5D; --leg-down: #72B4EA; }
:root[data-theme="light"] { --leg-up: #B4501E; --leg-down: #2668A6; }
.res-c-chart { min-height: 240px; }
.res-c-chart .empty { min-height: 240px; }

/* source cards (analogue transparency) */
.res-sources { margin-top: var(--s4); border-top: 1px solid var(--line); padding-top: var(--s4); }
.res-sources:empty { display: none; }
.res-src-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s1) var(--s3); margin-bottom: var(--s2); }
.res-src-head h4 { margin: 0; font-size: var(--t-sm); display: inline-flex; align-items: center; gap: var(--s2); }
.res-src-sum { font-size: var(--t-xs); color: var(--fg-2); margin: 0 0 var(--s3); }
.res-src-sum strong { color: var(--fg); }
.src-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s2); }
.src-card { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--s2) var(--s3); font-size: var(--t-xs); min-width: 0; }
.src-card.best { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: inset 3px 0 0 var(--accent); }
.src-model { font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src-run { color: var(--fg-2); margin-bottom: var(--s1); }
.src-dl { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--s2); margin: 0; color: var(--fg-3); }
.src-dl dd { margin: 0; text-align: right; color: var(--fg-2); }
.res-draws { margin: var(--s3) 0 0; }

/* ---------- How it works ---------- */
.how-hero { padding-bottom: var(--s6); }
.how-pick { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s6); align-items: end; padding: var(--s4); margin-bottom: var(--s6); }
.how-pick .field { min-width: 200px; flex: 1 1 220px; }
.how-pick .field.year { flex: 2 1 280px; }
.how-year { display: flex; align-items: center; gap: var(--s3); }
.how-year output { font: 600 var(--t-lg)/1 var(--font-display); min-width: 3em; text-align: right; }
.how-scrolly { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: var(--s10); align-items: start; }
.how-steps { display: grid; gap: 0; }
.how-step { min-height: 72vh; display: flex; align-items: center; padding: var(--s8) 0; }
.how-step:last-child { min-height: 60vh; }
.how-step .card { opacity: .5; transition: opacity var(--dur), border-color var(--dur), box-shadow var(--dur); width: 100%; }
.how-step.on .card { opacity: 1; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--glow); }
.how-step h2 { font-size: var(--t-xl); display: flex; gap: var(--s3); align-items: baseline; }
.how-step h2 .n { font: 700 var(--t-2xl)/1 var(--font-display); color: transparent; -webkit-text-stroke: 1px var(--fg-3); }
.how-step.on h2 .n { -webkit-text-stroke-color: var(--accent); }
.how-step p { color: var(--fg-2); font-size: var(--t-sm); }
.how-step .dl { font-size: var(--t-xs); }
.how-graphic { position: sticky; top: calc(var(--header-h) + var(--s4)); }
.how-graphic .fig { padding: var(--s4); }
.how-viz { min-height: 360px; position: relative; }
.how-viz .skeleton { height: 360px; }
.how-cap { min-height: 3em; }
.how-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: var(--t-xs); color: var(--fg-3); margin-top: var(--s2); }
.how-legend .res-key { color: var(--fg-2); }
.how-bars { display: grid; gap: var(--s2); }
.how-donors { width: 100%; border-collapse: collapse; font-size: var(--t-xs); font-variant-numeric: tabular-nums; }
.how-donors th, .how-donors td { padding: 5px var(--s2); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.how-donors th { color: var(--fg-3); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: 10.5px; }
.how-donors td.num, .how-donors th.num { text-align: right; }
.how-donors tr.on td { background: var(--accent-soft); }
.how-donors button { all: unset; cursor: pointer; color: var(--fg); border-bottom: 1px dotted var(--fg-3); }
.how-donors button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.wbar { display: inline-block; height: 8px; border-radius: 2px; background: var(--accent); vertical-align: middle; margin-right: var(--s2); }
.how-sub2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s4); }
@media (max-width: 960px) {
  .how-scrolly { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .how-graphic { order: -1; top: var(--header-h); z-index: 5; background: var(--bg); padding: var(--s2) 0; }
  .how-viz { min-height: 260px; }
  .how-viz .skeleton { height: 260px; }
  .how-step { min-height: 0; padding: var(--s6) 0; }
  .how-step:last-child { min-height: 0; }
  .how-step .card { opacity: 1; }
  .how-sub2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .how-graphic .fig { padding: var(--s2) var(--s3); }
  .how-graphic .fig-head { margin-bottom: var(--s1); }
  .how-graphic .fig-title { font-size: var(--t-sm); }
  .how-graphic .fig-sub { display: none; }
  .how-graphic .method { display: none; }
  .how-tabs button { min-height: 24px; padding: 0 var(--s2); }
  .how-legend { font-size: 11px; gap: 2px var(--s3); margin-top: var(--s1); }
  .how-legend .legend-plot, .how-legend .res-key:not(:first-child) { display: none; }
  .how-legend .seg button { min-height: 24px; }
  .how-viz { min-height: 0; }
  .how-viz .skeleton { height: 220px; }
  .how-sub2 .table-wrap + div .caption, .how-sub2 > .table-wrap, .how-top-h { display: none; }
  .how-donor-sel { display: block !important; margin-bottom: var(--s2); }
  .how-donors th, .how-donors td { padding: 3px var(--s2); }
}
.how-stack { display: grid; gap: var(--s2); }
.how-legend .map-legend { align-items: center; }
.how-map { margin-bottom: var(--s2); }
.how-donor-sel { display: none; }
.how-top-h { margin-bottom: var(--s2); }
@media (max-width: 640px) {
  .res-map-ctl { justify-content: flex-start; }
  .res-body > .fig { padding: var(--s3); }
  .src-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
