/* Temperature scales: two chart panels (side-by-side rulers, then slope lines) plus a converter,
   a legend, and the historical notes. All colors come from theme tokens; the only additions are
   the eight series colors below, which the slope controller reads back with getComputedStyle. */

.ts-tool {
    /* Categorical palette for the eight scales, in SCALES order (Celsius first). Tuned for the
       light theme; the dark overrides below lift them off the darker surface. Celsius reuses the
       accent so it reads as the reference everywhere it appears. */
    --ts-series-1: var(--accent);
    --ts-series-2: #0f8f80;
    --ts-series-3: #c2660f;
    --ts-series-4: #7b52c8;
    --ts-series-5: #9a7b10;
    --ts-series-6: #b9457f;
    --ts-series-7: #4b8a1f;
    --ts-series-8: #c93b3b;
}
[data-theme="dark"] .ts-tool {
    --ts-series-2: #6fd3c4;
    --ts-series-3: #e8934a;
    --ts-series-4: #a98be8;
    --ts-series-5: #d8bf4a;
    --ts-series-6: #e07bb0;
    --ts-series-7: #8fcf5f;
    --ts-series-8: #ef5a5a;
}

.ts-panel { margin: 32px 0 12px; }
.ts-panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; }
.ts-panel-title { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 26px; line-height: 1.2; }
.ts-panel-sub { color: var(--muted); font-size: 15px; max-width: 56ch; }

.ts-readout { display: flex; align-items: baseline; gap: 8px; }
.ts-readout-num { font-family: "Fraunces", Georgia, serif; font-size: 40px; line-height: 1; font-variant-numeric: tabular-nums; }
.ts-readout-cap { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ---------- shared controls row ---------- */
.ts-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 16px 0 12px; }
.ts-controls .seg { flex-wrap: wrap; }
.ts-zoom { margin-left: auto; display: flex; gap: 6px; }
.ts-zoom-btn { width: 38px; padding: 6px 0; font-size: 18px; line-height: 1; }
.ts-mode { margin-left: auto; font-size: 14px; padding: 8px 14px; }
.ts-mode[aria-pressed="true"] { background: var(--accent-weak); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }

.ts-hint {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px;
    margin: 8px 2px 0; font-size: 12.5px; color: var(--muted);
}

/* Both charts are drawn by a lazily-loaded controller, so until it connects the SVGs are empty.
   Reserving their height keeps the page from jumping, and the placeholder says why it is blank.
   The controller sets data-ts-ready once it has drawn, which removes both. */
.ts-chart { min-height: 420px; }  /* matches the controller's minimum chart height */
.ts-plot { min-height: 320px; }
.ts-panel:not([data-ts-ready]) .ts-chart,
.ts-panel:not([data-ts-ready]) .ts-plot { display: grid; place-items: center; }
/* Collapse the empty panes so the message is the only grid item, and therefore centred. */
.ts-panel:not([data-ts-ready]) .ts-chart > *,
.ts-panel:not([data-ts-ready]) .ts-plot > * { display: none; }
.ts-panel:not([data-ts-ready]) .ts-chart::after,
.ts-panel:not([data-ts-ready]) .ts-plot::after {
    content: "Loading the chart\2026"; color: var(--muted); font-size: 14px;
}

/* ---------- section 1: the rulers ---------- */
.ts-chart {
    display: flex; align-items: stretch; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    touch-action: pan-x pan-y; cursor: crosshair;
    /* Dragging pans the range, so the axis labels must not turn into a text selection. */
    -webkit-user-select: none; user-select: none;
}
.ts-chart.is-panning { cursor: grabbing; }
.ts-chart-fixed { flex: 0 0 auto; border-right: 1px solid var(--border); }
.ts-chart-scroll { flex: 1 1 auto; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.ts-chart svg { display: block; }

/* SVG text is styled here rather than with per-node font attributes, so it tracks the page. */
.ts-svg-eyebrow { font-size: 9.5px; letter-spacing: .16em; font-family: "Hanken Grotesk", system-ui, sans-serif; }
.ts-svg-unit { font-size: 12.5px; font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; }
.ts-svg-label { font-size: 12px; font-family: "Hanken Grotesk", system-ui, sans-serif; }
.ts-svg-tick { font-size: 11px; font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-variant-numeric: tabular-nums; }
.ts-svg-tick--primary { font-size: 12px; }

/* ---------- converter ---------- */
.ts-converter {
    margin-top: 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.ts-cell { background: var(--surface); padding: 10px 12px 12px; }
.ts-cell--primary { background: var(--accent-weak); }
.ts-cell-label { display: block; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.ts-cell-input {
    width: 100%; background: transparent; border: 0; padding: 0; color: var(--text);
    font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
    font-size: 18px; font-variant-numeric: tabular-nums;
}
.ts-cell--primary .ts-cell-input { color: var(--accent-strong); }
.ts-cell-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- section 2: the slope plot ---------- */
.ts-plot {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    -webkit-user-select: none; user-select: none;
}
.ts-plot svg { display: block; max-width: 100%; touch-action: pan-y; }

.ts-read { margin-top: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.ts-read-at { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ts-read-vals {
    display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 6px;
    font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace;
    font-size: 14px; font-variant-numeric: tabular-nums;
}
.ts-read-val b { font-weight: 400; color: var(--muted); margin-right: 6px; font-size: 12px; }

.ts-legend {
    margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.ts-lg {
    display: block; text-align: left; font: inherit; color: var(--text);
    background: var(--surface); border: 0; padding: 12px 13px 13px; cursor: pointer;
    transition: background .2s, opacity .2s;
}
.ts-lg:hover { background: var(--accent-weak); }
.ts-lg[aria-pressed="false"] { opacity: .4; }
.ts-lg-top { display: flex; align-items: center; gap: 9px; }
.ts-lg-swatch { width: 20px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.ts-lg-name { font-family: "Fraunces", Georgia, serif; font-size: 19px; }
.ts-lg-unit { font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-size: 12px; color: var(--muted); }
.ts-lg-eq, .ts-lg-cross {
    display: block; font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-size: 12.5px;
}
.ts-lg-eq { margin-top: 7px; }
.ts-lg-cross { margin-top: 3px; font-size: 11.5px; color: var(--muted); }

/* ---------- section 3: the historical notes ---------- */
.ts-notes-title { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 26px; margin: 44px 0 4px; }
.ts-notes-sub { color: var(--muted); font-size: 15px; margin-bottom: 18px; max-width: 68ch; }
.ts-notes {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.ts-note { background: var(--surface); padding: 16px; }
.ts-note-meta { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-strong); }
.ts-note-name { font-family: "Fraunces", Georgia, serif; font-weight: 500; font-size: 21px; margin: 2px 0; }
.ts-note-unit { font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-size: 13px; color: var(--muted); }
.ts-note-text { font-size: 14.5px; color: var(--muted); }
.ts-note-formula {
    margin-top: 11px; padding-top: 9px; border-top: 1px dashed var(--border);
    font-family: ui-monospace, "SFMono-Regular", "Menlo", "Consolas", monospace; font-size: 13px;
}
.ts-footnote { margin-top: 16px; font-size: 12.5px; color: var(--muted); }

@media (max-width: 720px) {
    .ts-panel-title, .ts-notes-title { font-size: 22px; }
    .ts-readout-num { font-size: 32px; }
    .ts-zoom, .ts-mode { margin-left: 0; }
    .ts-controls .seg button { font-size: 13px; padding: 7px 10px; }
    .ts-converter { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .ts-lg { transition: none; }
}
