/* design tokens, loosely after ibm carbon (gray 100): ibm plex sans, an 8px grid, square-ish corners,
   one type scale. two accent colours only, one per person. */
:root {
    --bg: #161616;
    --panel: #1c1c1c;
    --layer: #262626;
    --line: #393939;
    --text: #f4f4f4;
    --muted: #a8a8a8;
    --p: #ff832b;
    /* the person picked first */
    --q: #78a9ff;
    /* the person picked second */
    --ok: #42be65;

    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-md: 13px;
    --fs-lg: 16px;
    --fs-xl: 24px;
    --fs-xxl: 32px;

    --s1: 4px;
    --s2: 8px;
    --s3: 12px;
    --s4: 16px;
    --s5: 24px;
    --s6: 32px;
    --s7: 48px;

    --radius: 2px;
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 var(--fs-md) / 1.5 "IBM Plex Sans", system-ui, sans-serif;
    letter-spacing: 0.01em;
}

button,
select {
    font: inherit;
    color: inherit;
}

a {
    color: var(--muted);
    text-underline-offset: 2px;
}

a:hover {
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--s4) 0;
}

/* ---- the question + pickers ---- */

.top,
main,
.footer {
    max-width: 1200px;
    margin: 0 auto;
    padding-left: var(--s5);
    padding-right: var(--s5);
}

.top {
    padding-top: var(--s6);
    padding-bottom: var(--s2);
}

.ask {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s4);
    align-items: center;
    font-size: var(--fs-xxl);
    font-weight: 300;
    letter-spacing: 0;
}

.ask-text {
    color: var(--muted);
}

.pick-error {
    min-height: 1.5em;
    margin: var(--s2) 0 0;
    color: #ff8389;
    font-size: var(--fs-sm);
}

.picker {
    position: relative;
}

.pick-btn {
    display: flex;
    gap: var(--s4);
    align-items: center;
    justify-content: space-between;
    min-width: 220px;
    height: 48px;
    padding: 0 var(--s4);
    background: var(--layer);
    border: 0;
    border-bottom: 1px solid var(--muted);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: var(--fs-lg);
    font-weight: 400;
    letter-spacing: 0;
    color: var(--muted);
    cursor: pointer;
}

.pick-btn.has-value {
    color: var(--text);
}

.pick-btn:hover {
    background: #333;
}

.pick-caret {
    font-size: var(--fs-xs);
}

.pick-list {
    position: absolute;
    z-index: 20;
    top: 100%;
    left: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 340px;
    background: var(--layer);
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.pick-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: var(--s3);
    align-items: center;
    height: 40px;
    padding: 0 var(--s3);
    font-size: var(--fs-md);
    cursor: pointer;
}

.pick-item:hover,
.pick-item:focus {
    background: #333;
    outline: none;
}

.pick-item[aria-selected="true"] .pick-name::after {
    content: " ✓";
    color: var(--muted);
}

.pick-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pick-party {
    padding: 0 var(--s2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.pick-wiki {
    font-size: var(--fs-xs);
}

#go {
    height: 48px;
    padding: 0 var(--s6);
    background: var(--text);
    color: var(--bg);
    border: 0;
    border-radius: var(--radius);
    font-size: var(--fs-lg);
    font-weight: 500;
    cursor: pointer;
}

#go:disabled {
    background: var(--layer);
    color: #6f6f6f;
    cursor: not-allowed;
}

/* ---- intro + footer ---- */

main {
    padding-top: var(--s4);
    padding-bottom: var(--s6);
    min-height: 60vh;
}

.intro {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--s5) var(--s5) 0;
}

.intro > * {
    max-width: 68ch;
}

.intro[hidden] {
    display: none;
}

/* the introduction is ordinary body text: the picker above it is the biggest thing on the page */
.intro-lead {
    margin: 0;
    font-weight: 400;
}

.intro-body {
    margin: 0;
    color: var(--muted);
}

.footer {
    padding-top: var(--s4);
    padding-bottom: var(--s6);
    border-top: 1px solid var(--line);
    /* the rule runs the width of the content column, not the whole window */
    margin-top: var(--s5);
}

.footer p {
    max-width: 80ch;
    margin: 0;
    color: var(--muted);
    font-size: var(--fs-sm);
}

/* ---- loader ---- */

.loader {
    display: grid;
    place-items: center;
    min-height: 50vh;
}

.loader[hidden] {
    display: none;
}

.loader-inner {
    display: grid;
    gap: var(--s4);
    justify-items: center;
}

.loader-spin {
    width: 24px;
    height: 24px;
    border: 2px solid var(--line);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-log {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: var(--fs-sm);
    text-align: center;
}

.loader-log li {
    animation: rise 0.35s ease both;
}

.loader-ticks {
    color: var(--text);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* ---- result ---- */

.result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--s5);
    margin-top: var(--s4);
}

.result[hidden] {
    display: none;
}

.headline h1 {
    margin: 0;
    font-size: var(--fs-xl);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: 0;
}

.pct {
    display: inline-block;
    min-width: 2.4ch;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.sub {
    margin: var(--s1) 0 0;
    color: var(--muted);
    font-size: var(--fs-md);
}

.stage {
    position: relative;
    margin-top: var(--s3);
    background: var(--panel);
    border: 1px solid var(--line);
    overflow: hidden;
}

.stage-svg {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 720 / 640;
}

.stage-3d {
    width: 100%;
    aspect-ratio: 720 / 640;
}

.stage-3d[hidden] {
    display: none;
}

.stage-3d canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

.stage-empty {
    margin: 0;
    padding: 80px var(--s6);
    text-align: center;
    color: var(--muted);
}

.scene {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.scene.in {
    opacity: 1;
}

.guide.faint {
    stroke-dasharray: 3 6;
}

.guide {
    fill: none;
    stroke: var(--line);
    stroke-width: 1.5;
}

.axis {
    stroke: #6f6f6f;
    stroke-width: 2;
}

.axis.faint {
    stroke: var(--line);
    stroke-width: 1.5;
}

.spoke {
    stroke: #525252;
    stroke-width: 1.5;
}

.spoke-tip {
    fill: #6f6f6f;
}

.spoke-hit {
    stroke: transparent;
    stroke-width: 22;
    cursor: help;
}

.spoke-hit:hover {
    stroke: rgba(255, 255, 255, 0.06);
}

.tip {
    position: absolute;
    z-index: 5;
    width: 250px;
    padding: var(--s2) var(--s3);
    background: #0b0b0b;
    border: 1px solid var(--line);
    font-size: var(--fs-sm);
    pointer-events: none;
}

.tip[hidden] {
    display: none;
}

.tip p {
    margin: var(--s1) 0 0;
}

.tip-poles {
    color: var(--muted);
}

.lbl {
    fill: var(--text);
    font-size: var(--fs-sm);
}

.lbl.faint-t,
.lbl.axis-name {
    fill: var(--muted);
}

.question {
    fill: var(--text);
    font-size: var(--fs-lg);
    font-weight: 400;
}

.link {
    stroke: rgba(255, 255, 255, 0.45);
    stroke-width: 2;
    stroke-dasharray: 5 5;
}

.dot-c {
    stroke: var(--panel);
    stroke-width: 3;
}

.dot.p .dot-c {
    fill: var(--p);
}

.dot.q .dot-c {
    fill: var(--q);
}

.dot-t {
    font-size: var(--fs-sm);
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--panel);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.dot.p .dot-t {
    fill: var(--p);
}

.dot.q .dot-t {
    fill: var(--q);
}

.legend {
    display: flex;
    gap: var(--s5);
    margin-top: var(--s3);
    font-size: var(--fs-sm);
}

.key {
    display: inline-flex;
    gap: var(--s2);
    align-items: center;
}

.key i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.key.p i {
    background: var(--p);
}

.key.q i {
    background: var(--q);
}

.caption {
    margin: var(--s2) 0 0;
    max-width: 72ch;
    color: var(--muted);
    font-size: var(--fs-sm);
}

.notice {
    margin: var(--s3) 0 0;
    padding: var(--s2) var(--s3);
    max-width: 72ch;
    border-left: 3px solid var(--muted);
    background: var(--layer);
    color: var(--muted);
    font-size: var(--fs-sm);
}

/* ---- sidebar ---- */

.sidebar {
    align-self: start;
    position: sticky;
    top: var(--s3);
    max-height: calc(100vh - 24px);
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
}

.sidebar[hidden] {
    display: none;
}

.side-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s2);
    padding: var(--s3) var(--s4) 0;
}

.side-title {
    margin: 0;
    font-size: var(--fs-md);
    font-weight: 600;
}

.side-sortlabel {
    font-size: var(--fs-xs);
    color: var(--muted);
}

.side-sort {
    background: var(--layer);
    border: 0;
    border-bottom: 1px solid var(--muted);
    padding: 2px var(--s1);
    font-size: var(--fs-xs);
}

.side-hint {
    margin: var(--s1) var(--s4) var(--s3);
    color: var(--muted);
    font-size: var(--fs-xs);
}

.dim-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dim {
    padding: var(--s3) var(--s4);
    border-top: 1px solid var(--line);
    border-left: 3px solid transparent;
}

.dim.on {
    border-left-color: var(--text);
    background: var(--layer);
}

.dim.hot {
    background: var(--layer);
}

.dim.locked {
    opacity: 0.55;
}

.dim-head {
    display: flex;
    gap: var(--s2);
    align-items: center;
    cursor: pointer;
    font-size: var(--fs-md);
    font-weight: 500;
}

.dim-head input {
    accent-color: var(--text);
}

.dim.locked .dim-head {
    cursor: not-allowed;
}

.dim-track {
    position: relative;
    height: 16px;
    margin: var(--s2) 4px 0;
}

.track-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 7px;
    height: 2px;
    background: var(--line);
}

.track-gap {
    position: absolute;
    top: 6px;
    height: 4px;
    background: rgba(255, 255, 255, 0.18);
}

.track-dot {
    position: absolute;
    top: 2px;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    border-radius: 50%;
    border: 2px solid var(--panel);
}

.track-dot.p {
    background: var(--p);
}

.track-dot.q {
    background: var(--q);
}

.dim-poles {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    font-size: var(--fs-xs);
    color: var(--muted);
}

.dim-poles span:last-child {
    text-align: right;
}

/* where each stance comes from: always visible, one line per person */
.stances {
    margin: var(--s2) 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--s1);
    font-size: var(--fs-xs);
}

.stance {
    display: flex;
    flex-wrap: wrap;
    gap: 2px var(--s2);
    align-items: baseline;
}

.stance-who {
    display: inline-flex;
    gap: var(--s1);
    align-items: center;
    color: var(--text);
    font-weight: 500;
}

.stance-who i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stance.p i {
    background: var(--p);
}

.stance.q i {
    background: var(--q);
}

.stance-score {
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.stance-src {
    color: var(--muted);
}

.dim-more {
    margin-top: var(--s2);
    padding: 0;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: var(--fs-xs);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.dim-more:hover {
    color: var(--text);
}

.dim-evidence {
    margin-top: var(--s2);
    font-size: var(--fs-sm);
}

.dim-evidence[hidden] {
    display: none;
}

.ev-question {
    margin: 0 0 var(--s2);
    font-weight: 500;
}

.ev-person {
    margin-top: var(--s3);
    padding-left: var(--s3);
    border-left: 2px solid var(--line);
}

.ev-person.p {
    border-color: var(--p);
}

.ev-person.q {
    border-color: var(--q);
}

.ev-who {
    display: flex;
    gap: var(--s1);
    align-items: center;
}

.ev-reason {
    margin: 2px 0 var(--s2);
    color: var(--muted);
}

.ev-quote {
    margin: var(--s2) 0;
    padding: 0;
}

.ev-quote p {
    margin: 0;
}

.ev-quote footer {
    margin-top: 2px;
    font-size: var(--fs-xs);
    color: var(--muted);
}

.ev-models {
    margin: var(--s3) 0 0;
    font-size: var(--fs-xs);
    color: var(--muted);
}

@media (max-width: 960px) {
    .result {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
    }

    .pick-list {
        min-width: min(340px, 80vw);
    }

    .ask {
        font-size: var(--fs-xl);
    }
}

@media (prefers-reduced-motion: reduce) {

    .scene,
    .loader-log li,
    .loader-spin {
        transition: none;
        animation: none;
    }
}
