/* WANDERERS Sky Survey page (survey.html). Uses the brand tokens from brand.css; the few new colours are tokens below,
 * defined for Day, Night and "no JavaScript, dark operating system" like brand.css does. */
:root {
  --sv-gal: rgba(128, 72, 190, .55);
  --sv-ecl: rgba(196, 120, 20, .6);
  --sv-scrim: rgba(11, 20, 34, .42);
  --sv-track: #C77700;
  --sv-sx: #0B7A75;
  --sv-sx-ch4: rgba(196, 120, 20, .16);
}
:root[data-theme="dark"] {
  --sv-gal: rgba(190, 140, 255, .6);
  --sv-ecl: rgba(255, 175, 70, .6);
  --sv-scrim: rgba(0, 0, 0, .58);
  --sv-track: #FFB547;
  --sv-sx: #4FD1C5;
  --sv-sx-ch4: rgba(255, 175, 70, .2);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { --sv-gal: rgba(190, 140, 255, .6); --sv-ecl: rgba(255, 175, 70, .6); --sv-scrim: rgba(0, 0, 0, .58); --sv-track: #FFB547; --sv-sx: #4FD1C5; --sv-sx-ch4: rgba(255, 175, 70, .2); }
}

.survey main { overflow-x: clip; }
.survey [hidden] { display: none !important; }   /* .btn and friends set display, which would beat the hidden attribute */
.sv-main { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) 24px; }
.survey h2 { font: 700 clamp(1.5rem, 3vw, 2.3rem)/1.15 var(--f-display); letter-spacing: -.02em; margin: 8px 0 0; max-width: 30ch; text-wrap: balance; }
.survey h3 { font: 700 1.05rem/1.3 var(--f-display); margin: 0 0 8px; }
.survey h4 { font: 500 .72rem/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: .86rem; }
.num { text-align: right; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.btn.tiny { padding: 8px 12px; font-size: .85rem; }

/* ---------- banners ---------- */
.sv-banners:empty { display: none; }
.sv-banners { padding-top: 16px; display: grid; gap: 8px; }
.sv-banner { margin: 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); font-size: .92rem; }
.sv-banner.demo { border-color: color-mix(in srgb, var(--cand) 55%, transparent); background: color-mix(in srgb, var(--cand) 9%, var(--surface)); }
.sv-banner.err { border-color: color-mix(in srgb, var(--warn) 60%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); }
.sv-banner.run { border-color: color-mix(in srgb, var(--accent) 50%, transparent); background: var(--accent-soft); }
.sv-retry { margin: 8px 0 0; }
.sv-retry:has(> [hidden]) { display: none; }

/* ---------- hero ---------- */
.sv-hero { padding: clamp(28px, 5vw, 64px) 0 8px; }
.sv-title { font: 800 clamp(2rem, 5.6vw, 4.4rem)/1.02 var(--f-display); letter-spacing: -.035em; margin: 14px 0 18px; max-width: 18ch; text-wrap: balance; }
.sv-title .hl { color: var(--accent); white-space: nowrap; }
.sv-lede { color: var(--muted); font-size: 1.04rem; max-width: 68ch; margin: 0 0 28px; }
.sv-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin: 0; border-top: 1px solid var(--line); }
.sv-stats div { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.sv-stats div:last-child:nth-child(3n+1) { grid-column: 1 / -1; }   /* a lone last stat fills its row */
.sv-stats dt { font: 500 .66rem/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sv-stats dd { margin: 6px 0 0; font: 500 clamp(1rem, 2.2vw, 1.6rem)/1.2 var(--f-mono); letter-spacing: -.01em; overflow-wrap: break-word; }
.sv-stats .sub { display: block; font: 400 .78rem/1.4 var(--f-ui); color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.sv-funnel { list-style: none; padding: 0; margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 6px; counter-reset: f; }
.sv-funnel li { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); font-size: .8rem; color: var(--muted); min-width: 0; position: relative; }
.sv-funnel li b { color: var(--text); font-size: .95rem; font-weight: 500; }
.sv-funnel li:not(:last-child)::after { content: "→"; position: absolute; right: -6px; top: 50%; transform: translate(50%, -50%); color: var(--muted); font-size: .8rem; }
.sv-funnel li:not(:last-child) { margin-right: 10px; }
.sv-funnel li.you { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- sections ---------- */
.sv-sec { padding-top: clamp(44px, 7vw, 96px); }
.sv-head { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 18px; padding-top: 16px; border-top: 1px solid var(--text); margin-bottom: 24px; }
.sv-no { font-size: .82rem; color: var(--accent); letter-spacing: .1em; padding-top: 2px; }
.sv-no::before { content: "§ "; color: var(--muted); }
.sv-sub { color: var(--muted); max-width: 70ch; margin: 10px 0 0; }
.sv-empty { color: var(--muted); padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); margin: 8px 0; }

/* ---------- all-sky map ---------- */
.sv-map { position: relative; width: 100%; aspect-ratio: 2 / 1; }
.sv-map canvas, .sv-map .sv-grid { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sv-map canvas { cursor: crosshair; }
.sv-grid { pointer-events: none; }
.sv-grid .g-edge { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.sv-grid .g-line { fill: none; stroke: var(--line-strong); stroke-width: .7; stroke-dasharray: 2 4; }
.sv-grid .g-line.eq { stroke-dasharray: none; }
.sv-grid .g-gal { fill: none; stroke: var(--sv-gal); stroke-width: 1.6; stroke-dasharray: 7 5; }
.sv-grid .g-ecl { fill: none; stroke: var(--sv-ecl); stroke-width: 1.4; stroke-dasharray: 2 4; }
.sv-grid .g-lab { font: 500 11px var(--f-mono); fill: var(--muted); }
.sv-tip { position: absolute; margin: 0; transform: translate(10px, 10px); max-width: min(320px, 70vw); padding: 6px 9px; font-size: .74rem;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: var(--shadow); pointer-events: none; z-index: 2; }
.sv-legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .82rem; color: var(--muted); }
.sv-legend li { display: inline-flex; align-items: center; gap: 7px; }
.sv-legend .sw { width: 13px; height: 13px; border-radius: 2px; display: inline-block; }
.sv-legend .sw-none { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.sv-legend .sw-mov { background: var(--accent); }
.sv-legend .sw-unex { background: var(--cand); }
.sv-legend .sw-sky { background: var(--surface-2); border: 1px solid var(--line-strong); }
.sv-legend .ln { width: 22px; height: 0; display: inline-block; border-top: 2px dashed var(--sv-gal); }
.sv-legend .ln-ecl { border-top: 2px dotted var(--sv-ecl); }
.sv-tile { margin: 6px 0; }
.sv-tile:empty { display: none; }

/* ---------- validation ---------- */
.sv-val { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.sv-val-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.sv-val-card.wide { grid-column: 1 / -1; }
.sv-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sv-bars li { display: grid; grid-template-columns: minmax(0, 7.5em) minmax(0, 1fr) 3.2em; align-items: center; gap: 8px; font-size: .84rem; }
.sv-bars .bl { font-family: var(--f-mono); color: var(--muted); overflow-wrap: anywhere; }
.sv-bars .bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.sv-bars .bar i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.sv-bars b { text-align: right; font-weight: 500; }
.sv-bars small { grid-column: 2 / -1; color: var(--muted); font-size: .74rem; margin-top: -4px; }
.sv-fp b { font-size: 1.5rem; }
.sv-scroll { overflow-x: auto; max-width: 100%; }
.sv-known { border-collapse: collapse; width: 100%; font-size: .88rem; }
.sv-known th, .sv-known td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.sv-known thead th { font: 500 .66rem/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sv-known td.num { text-align: right; }
.sv-known .found td:nth-child(2) { color: var(--known); }
.sv-known .missed td:nth-child(2) { color: var(--warn); }
.sv-known small { display: block; color: var(--muted); font-size: .76rem; }

/* ---------- filters and table ---------- */
.sv-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.sv-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--muted); min-width: 0; }
.sv-filters label.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: .9rem; padding-bottom: 8px; }
.sv-filters label.chk .hint { font-size: .74rem; }
.sv-filters label.grow { flex: 1 1 12em; }
.sv-filters input, .sv-filters select, .sv-pager select { font: 400 .92rem var(--f-ui); color: var(--text); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: 4px; padding: 7px 9px; min-width: 0; max-width: 100%; }
.sv-filters input[type="number"] { width: 7.5em; }
.sv-filters input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.sv-hide { display: flex; flex-wrap: wrap; gap: 0 14px; align-items: center; margin: 0; padding: 0 0 0 10px; border: 0; border-left: 1px solid var(--line); min-width: 0; }
.sv-hide legend { float: left; padding: 0 10px 8px 0; font-size: .78rem; color: var(--muted); }
.sv-filters .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sv-note { margin: 8px 0 0; max-width: 80ch; }
.sv-export { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 10px; }
.sv-export .hint { font-size: .82rem; }
.sv-export button:disabled { opacity: .45; cursor: default; }
.sv-count { color: var(--muted); font-size: .88rem; margin: 12px 0 8px; }
.sv-table-wrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.sv-table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.sv-table th, .sv-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.sv-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; padding: 0; }
.sv-table thead th.num .sorter { justify-content: flex-end; }
.sv-table .sorter { width: 100%; display: flex; gap: 4px; align-items: center; background: none; border: 0; color: var(--muted); cursor: pointer;
  font: 500 .68rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; padding: 10px; text-align: left; }
.sv-table th[aria-sort="ascending"] .sorter, .sv-table th[aria-sort="descending"] .sorter { color: var(--text); }
.sv-table .arrow { font-size: .6rem; }
.sv-table tbody tr { cursor: pointer; }
.sv-table tbody tr:hover { background: var(--accent-soft); }
.sv-table tbody tr.is-unex th { box-shadow: inset 3px 0 0 var(--cand); }
.sv-table tbody th { font-weight: 400; }
.sv-table td.red { color: var(--warn); }
.cid { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: .88rem; text-decoration: underline; text-underline-offset: 3px; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.badge { display: inline-block; font: 500 .66rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; padding: 4px 7px; border-radius: 3px; border: 1px solid; white-space: nowrap; }
.badge.b-sx { color: var(--sv-sx); border-color: color-mix(in srgb, var(--sv-sx) 55%, transparent); background: color-mix(in srgb, var(--sv-sx) 10%, transparent); white-space: nowrap; }
.d-sx .sx-verdict { margin: 0 0 .5rem; font-weight: 600; }
.d-sx .sx-ok { color: var(--sv-sx); }
.d-sx .sx-no { color: var(--sv-track); }
.d-spec { display: block; width: 100%; max-width: 100%; height: auto; margin: .5rem 0; }
.d-spec .sx-ch4 { fill: var(--sv-sx-ch4); }
.d-spec .sx-ch4t, .d-spec .sx-lab { fill: currentColor; opacity: .7; font-size: 10px; }
.d-spec .sx-grid { stroke: currentColor; opacity: .12; }
.d-spec .sx-axis { stroke: currentColor; opacity: .5; }
.d-spec .sx-err { stroke: var(--sv-sx); stroke-width: 1.2; opacity: .7; }
.d-spec .sx-pt { fill: var(--sv-sx); }
.d-sx .sx-words, .d-sx .sx-notes { margin: .25rem 0; padding-left: 1.1rem; overflow-wrap: anywhere; }
.sv-lede-note { max-width: 70ch; }
.badge.b-unex { color: var(--cand); border-color: color-mix(in srgb, var(--cand) 55%, transparent); background: color-mix(in srgb, var(--cand) 9%, transparent); }
.badge.b-known { color: var(--known); border-color: color-mix(in srgb, var(--known) 45%, transparent); }
.badge.b-art { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge.b-nc { color: var(--muted); border-color: var(--line-strong); }
.sv-pager { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 12px; }
.sv-pager label { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); font-size: .84rem; margin-left: auto; }
.sv-pager button:disabled { opacity: .45; cursor: default; }

/* ---------- limits and credits ---------- */
.sv-lim { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: clamp(20px, 4vw, 56px); }
.sv-limits { margin: 0 0 12px; padding-left: 18px; color: var(--muted); display: grid; gap: 8px; max-width: 70ch; }
.sv-method { margin: 12px 0; color: var(--muted); }
.sv-method summary { cursor: pointer; color: var(--text); }
.sv-credits { margin: 0; display: grid; gap: 10px; }
.sv-credits dt { font-weight: 600; font-size: .92rem; }
.sv-credits dd { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }

/* ---------- candidate drawer ---------- */
.sv-scrim { position: fixed; inset: 0; background: var(--sv-scrim); z-index: 60; }
.sv-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 100%); z-index: 70; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); padding: 18px clamp(16px, 3vw, 28px) 32px; animation: sv-in .22s ease-out; }
@keyframes sv-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
body.sv-locked { overflow: hidden; }
.sv-drawer section { margin-top: 22px; }
.d-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.d-head h2 { font-size: 1.5rem; margin: 2px 0 6px; overflow-wrap: anywhere; }
.d-head p { margin: 0; }
.d-close { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1rem; }
.d-reasons { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.d-track { width: 100%; max-width: 440px; height: auto; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.d-track .tbg { fill: none; }
.d-track .tg { stroke: var(--line); stroke-width: 1; }
.d-track .tl, .d-track .ta { font: 400 10px var(--f-mono); fill: var(--muted); }
.d-track .ty { font: 500 10px var(--f-mono); fill: var(--text); }
.d-track .tp { fill: var(--sv-track); stroke: var(--surface); stroke-width: 1; }
.d-track .fit { stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 6 4; }
.d-track .fit-head { fill: var(--accent); }
.d-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.d-row h3 { margin: 0; }
.d-switch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.d-switch button { border: 0; background: transparent; color: var(--muted); padding: 7px 12px; cursor: pointer; font: 500 .82rem var(--f-ui); }
.d-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.d-sky { margin-top: 10px; width: 100%; height: min(340px, 70vw); background: var(--viewer); border-radius: var(--radius); overflow: hidden; position: relative; }
.d-nums { display: grid; gap: 0; margin: 0; }
.d-nums div { display: grid; grid-template-columns: minmax(0, 8.5em) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.d-nums dt { color: var(--muted); font-size: .84rem; }
.d-nums dd { margin: 0; overflow-wrap: anywhere; font-size: .9rem; }
.d-nums small { display: block; color: var(--muted); font-size: .78rem; }
.d-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.d-actions .btn { padding: 11px 14px; font-size: .88rem; }
.d-arch { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.d-arch li { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.d-arch a { color: var(--accent); font-weight: 600; }
.d-arch small { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.d-when dt small { display: inline; font-family: var(--f-mono); }
.sv-drawer code { font: .8rem var(--f-mono); background: var(--surface-2); padding: 1px 5px; border-radius: 3px; overflow-wrap: anywhere; }
.d-coords { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 12px 0 0; }
.d-coords .mono { font-size: .84rem; overflow-wrap: anywhere; min-width: 0; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .sv-lim { grid-template-columns: 1fr; }
  .sv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sv-stats div:last-child:nth-child(3n+1) { grid-column: auto; }
  .sv-stats div:last-child:nth-child(2n+1) { grid-column: 1 / -1; }
  .sv-head { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 600px) {
  .sv-table .hide-sm { display: none; }
  .sv-table th, .sv-table td { padding: 7px 6px; }
  .sv-table .sorter { padding: 9px 6px; }
  .sv-funnel li:not(:last-child)::after { display: none; }
  .sv-funnel li:not(:last-child) { margin-right: 0; }
  .sv-pager label { margin-left: 0; }
  .sv-hide { border-left: 0; padding-left: 0; }
  .d-nums div { grid-template-columns: 1fr; gap: 2px; }
  .sv-grid .g-lab { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .sv-drawer { animation: none; }
}
