/* Distill-style article with one large interactive figure. */
:root {
    --text: rgba(0, 0, 0, 0.8);
    --muted: rgba(0, 0, 0, 0.55);
    --faint: rgba(0, 0, 0, 0.35);
    --rule: rgba(0, 0, 0, 0.1);
    --panel: #f6f6f6;
    --bg: #fff;
    --plus: #2a7ab0;
    --minus: #c0563a;
    --select: #1f1f1f;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
    --serif: Georgia, "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --text: rgba(255, 255, 255, 0.85);
        --muted: rgba(255, 255, 255, 0.6);
        --faint: rgba(255, 255, 255, 0.4);
        --rule: rgba(255, 255, 255, 0.14);
        --panel: #1c1c1c;
        --bg: #121212;
        --plus: #6fb3e0;
        --minus: #e08a6f;
        --select: #f0f0f0;
    }
}

:root[data-theme="dark"] {
    --text: rgba(255, 255, 255, 0.85);
    --muted: rgba(255, 255, 255, 0.6);
    --faint: rgba(255, 255, 255, 0.4);
    --rule: rgba(255, 255, 255, 0.14);
    --panel: #1c1c1c;
    --bg: #121212;
    --plus: #6fb3e0;
    --minus: #e08a6f;
    --select: #f0f0f0;
}

* { box-sizing: border-box; }

html { font-size: 16px; line-height: 1.6; }

body {
    margin: 0;
    padding: 0 16px 80px;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
}

.l-text { max-width: 704px; margin-left: auto; margin-right: auto; }
.l-page { max-width: 1120px; margin-left: auto; margin-right: auto; }

/* Title and byline, as in Distill's d-title and d-byline. */
.d-title { padding: 72px 0 24px; }
.d-title h1 { font-size: 48px; line-height: 1.1; font-weight: 700; margin: 0 0 20px; letter-spacing: -0.01em; }
.d-title p { font-size: 20px; line-height: 1.5; font-weight: 300; margin: 0; color: var(--muted); }

.d-byline {
    display: flex;
    gap: 48px;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
    padding: 16px 0;
    margin-bottom: 40px;
    font-size: 13px;
}
.d-byline h3 {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 4px;
}
.d-byline p { margin: 0; }

/* Article text. */
.d-article { font-size: 18px; line-height: 1.7; }
.d-article h2 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    margin: 48px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--rule);
}
.d-article p { margin: 0 0 1em; }
.d-article a { color: inherit; text-decoration: none; border-bottom: 1px solid var(--faint); }

.d-article sup a { border: none; color: var(--muted); font-size: 0.75em; }

.d-appendix { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13px; line-height: 1.6; }
.d-appendix h3 { font-size: 13px; font-weight: 600; color: var(--text); margin: 0 0 10px; }
.d-appendix a { color: inherit; }
.references { padding-left: 20px; margin: 0 0 12px; }
.references li { margin-bottom: 6px; }

figcaption, .small { color: var(--muted); font-size: 12.5px; line-height: 1.5; }
figcaption { margin-top: 16px; }

/* The explorer figure. */
.explorer { margin-top: 0; margin-bottom: 40px; }
.explorer-top { display: grid; grid-template-columns: minmax(0, 448px) minmax(0, 1fr); gap: 32px; }

.photo-wrap { position: relative; }
#photo {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    background: var(--panel);
    border-radius: 2px;
    cursor: crosshair;
    touch-action: none;
}
.status {
    position: absolute;
    inset: auto 12px 12px 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 13px;
    border-radius: 3px;
    pointer-events: none;
}
.status:empty { display: none; }
.photo-hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 10px; }

.photo-tools { display: flex; flex-wrap: wrap; gap: 8px; }
button, .button {
    font: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 6px 12px;
    cursor: pointer;
}
button:hover:not(:disabled), .button:hover { border-color: var(--faint); }
button:disabled { color: var(--faint); cursor: default; }

#search {
    width: 100%;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    padding: 8px 10px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    margin-bottom: 16px;
}

.prediction { margin-bottom: 18px; }
.prediction .says { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.prediction .answer { font-size: 26px; font-weight: 600; line-height: 1.2; margin: 2px 0 8px; }
.prediction .answer span { font-weight: 300; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    font-size: 12.5px;
    padding: 3px 9px;
    border-radius: 12px;
    border: 1px solid var(--rule);
    background: var(--bg);
}
.chip.on { background: var(--select); color: var(--bg); border-color: var(--select); }

.list-head h4 { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.list-head p { font-size: 12.5px; color: var(--muted); margin: 2px 0 10px; }

.concept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px 10px; }
.against-head { margin-top: 20px; }
.concept {
    all: unset;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.concept img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 2px;
    background: var(--panel);
    outline: 2px solid transparent;
    outline-offset: 1px;
}
.concept.on img { outline-color: var(--select); }
.concept:focus-visible img { outline-color: var(--faint); }
.concept .name { font-size: 11.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.concept .value { font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.concept .value.plus { color: var(--plus); }
.concept .value.minus { color: var(--minus); }

/* The picked concept. */
.detail {
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 28px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--rule);
}
.detail[hidden] { display: none; }
.detail-render img { width: 100%; aspect-ratio: 1; border-radius: 2px; background: var(--panel); display: block; }
.detail-render p { margin: 8px 0 0; }
.detail h4 { font-size: 20px; font-weight: 600; margin: 0; line-height: 1.3; }
.detail h4 .id { font-weight: 300; color: var(--muted); }
.detail h5 { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
#detail-stats { margin: 2px 0 14px; }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.example { all: unset; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.example canvas { width: 76px; height: 76px; border-radius: 2px; background: var(--panel); display: block; }
.example span { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.examples .gap { width: 10px; }

.detail-rows { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
#pushes { font-size: 13.5px; margin: 0; }
.neighbours { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.neighbours .concept .name { font-size: 10.5px; }

@media (max-width: 860px) {
    .d-title { padding-top: 40px; }
    .d-title h1 { font-size: 34px; }
    .d-title p { font-size: 17px; }
    .d-byline { gap: 24px; }
    .explorer-top { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .detail { grid-template-columns: minmax(0, 1fr); }
    .detail-render { max-width: 200px; }
    .detail-rows { grid-template-columns: minmax(0, 1fr); }
    /* The approved phone layout: concept lists become rows you swipe. */
    .side-column .concept-grid {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 92px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-bottom: 6px;
    }
    .side-column .concept { scroll-snap-align: start; }
    .d-article { font-size: 17px; }
}
