/* ═══════════════════════════════════════════════
   Lumen — the figure and its legend.
   One plate (canvas) with a live caption under it, and its legend to the
   right, ruled off by a hairline and read top to bottom: the specimen, the
   conditions as a sentence whose values are the controls, the enzyme last
   touched, and Fig. 2. No cards, shadows or rounded panels. On phones the
   legend becomes a sheet over the lower scene.
   ═══════════════════════════════════════════════ */

#reference-overlay { z-index: 9999; }

/* ─── Stage ─── */
.lu-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(280px, 22vw, 320px);
    height: 100vh;
    height: 100dvh;
}
.lu-closed .lu-stage { grid-template-columns: minmax(0, 1fr) 0; }

.lu-figure {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    margin: 0;
}

.lu-scene {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    touch-action: none;
}

#sim-canvas { display: block; }

.lu-capbar {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 9px 20px 11px;
    border-top: 1px solid var(--border);
}
.lu-capbar .caption { flex: 1; min-width: 0; margin: 0; }

.lu-zoom { display: flex; align-items: baseline; gap: 2px; flex-shrink: 0; }
.lu-zoom-level {
    min-width: 3.2em;
    text-align: center;
    font-size: var(--font-sm);
    color: var(--text-muted);
    font-variant-numeric: lining-nums tabular-nums;
}

/* ─── Buttons: text on the ground, a hairline underline on hover ─── */
.lu-btn {
    padding: 2px 6px;
    border: 0;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--font-base);
    cursor: pointer;
    text-decoration: underline transparent;
    text-underline-offset: 0.22em;
    text-decoration-thickness: 1px;
    transition: color 0.15s var(--ease-out), text-decoration-color 0.15s var(--ease-out);
}
.lu-btn:hover { color: var(--text); text-decoration-color: var(--border-strong); }
.lu-btn[aria-pressed="true"] { color: var(--text); text-decoration-color: var(--text); }
/* Taps pulse or inhibit: only where taps are the pointer */
.lu-mode { display: none; flex-shrink: 0; }
@media (pointer: coarse) { .lu-mode { display: inline; } }

/* A word that acts, inside the legend's running text */
.lu-word {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    transition: color 0.15s var(--ease-out), text-decoration-color 0.15s var(--ease-out);
}
.lu-word:hover { text-decoration-color: var(--text); }
.lu-word:disabled { color: var(--text-muted); text-decoration: line-through; text-decoration-thickness: 1px; cursor: not-allowed; }
.lu-word[aria-pressed="true"] { text-decoration-color: var(--text); text-decoration-thickness: 1.5px; }
.lu-views .lu-word[aria-pressed="false"] { color: var(--text-muted); text-decoration-color: transparent; }
.lu-views .lu-word[aria-pressed="false"]:hover { color: var(--text); }
.lu-word:focus-visible { outline: 1.5px solid var(--text); outline-offset: 2px; }

.lu-open {
    position: absolute;
    top: 16px;
    right: 18px;
    z-index: 5;
    padding: 4px 2px;
    border: 0;
    border-bottom: 1px solid var(--border-strong);
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: var(--font-base);
    cursor: pointer;
    display: none;
}
.lu-open:hover { color: var(--text); border-bottom-color: var(--text); }
.lu-closed .lu-open { display: block; }

/* ─── The legend ─── */
.lu-legend {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    border-left: 1px solid var(--border);
    background: var(--bg-canvas);
    user-select: text;
}
.lu-closed .lu-legend { visibility: hidden; border-left: 0; }
.lu-close { position: absolute; top: 8px; right: 6px; z-index: 2; font-size: 1.15rem; line-height: 1; color: var(--text-muted); }
.lu-legend-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; scrollbar-width: thin; }

.lu-sec { padding: 12px 0 11px; border-bottom: 1px solid var(--border); }
.lu-sec:last-child { border-bottom: 0; }
.lu-label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 7px;
    font-size: var(--font-base);
    font-weight: 400;
    font-style: italic;
    color: var(--text-muted);
}
.lu-label-row { justify-content: space-between; gap: 10px; }
.lu-label-row > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.lu-fig-n { font-style: normal; font-weight: 600; color: var(--text); }
.lu-views { font-size: var(--font-sm); color: var(--text-muted); }
.lu-views .lu-word { font-style: italic; }

/* Readouts: label–value pairs, the values in the text colour */
.lu-read, .lu-readings { font-size: var(--font-sm); line-height: 1.45; color: var(--text-secondary); font-variant-numeric: lining-nums tabular-nums; }
.lu-read { margin: 6px 0 0; }
.lu-read b, .lu-readings b { font-weight: 400; color: var(--text); }
.lu-pair { white-space: nowrap; }

/* Specimens: the six locator drawings in one row, the chosen one in its inks */
.lu-specimens { display: flex; justify-content: space-between; align-items: center; gap: 2px; margin-right: 18px; }
.lu-specimens button {
    display: block;
    padding: 2px 0 5px;
    border: 0;
    border-bottom: 1px solid transparent;
    background: none;
    cursor: pointer;
    transition: border-color 0.15s var(--ease-out), opacity 0.15s var(--ease-out);
}
.lu-spec-icon { display: block; width: 40px; height: 22px; }
.lu-specimens button:hover { border-bottom-color: var(--border-strong); }
.lu-specimens button[aria-checked="true"] { border-bottom-color: var(--text); }
.lu-specimens button:focus-visible { outline: 1.5px solid var(--text); outline-offset: 1px; }
.lu-spec-name { margin: 8px 0 0; font-size: var(--font-lg); color: var(--text); }

/* The conditions: label–value rows whose values are the controls */
.lu-conds { display: grid; grid-template-columns: max-content 1fr; gap: 2px 16px; align-items: baseline; font-size: var(--font-base); line-height: 1.5; }
.lu-k { color: var(--text-secondary); }
.lu-v {
    font-variant-numeric: lining-nums tabular-nums;
    color: var(--text);
    white-space: nowrap;
    cursor: ew-resize;
    border-bottom: 1px dotted var(--text-muted);
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    transition: color 0.15s var(--ease-out), border-color 0.15s var(--ease-out);
}
.lu-v:hover, .lu-v.drag, .lu-v.open { color: var(--accent); border-bottom-color: var(--accent); }
.lu-v.tog { cursor: pointer; }
.lu-v:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }
.lu-dialbox { margin: 8px 0 2px; }
.lu-acts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 9px 0 0; font-size: var(--font-base); color: var(--text-muted); }
.lu-act-group { white-space: nowrap; }

/* Dials: a hairline track, a dot, the value */
.lu-dial { display: grid; grid-template-columns: 6.2em 1fr 5.4em; align-items: center; gap: 8px; min-height: 26px; font-size: var(--font-base); color: var(--text); }
.lu-dial output { font-size: var(--font-sm); color: var(--text-secondary); font-variant-numeric: lining-nums tabular-nums; text-align: right; }
.lu-dial input[type=range] {
    --slider-color: var(--accent);
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer;
}
.lu-dial input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--border-strong); }
.lu-dial input[type=range]::-moz-range-track { height: 1px; background: var(--border-strong); }
.lu-dial input[type=range]::-moz-range-progress { height: 1px; background: var(--slider-color); }
.lu-dial input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -5px; border-radius: 50%; border: 2px solid var(--bg-canvas); background: var(--slider-color); }
.lu-dial input[type=range]::-moz-range-thumb { width: 7px; height: 7px; border-radius: 50%; border: 2px solid var(--bg-canvas); background: var(--slider-color); }
.lu-dial input[type=range]:focus-visible { outline: none; }
.lu-dial input[type=range]:focus-visible::-webkit-slider-thumb { outline: 1.5px solid var(--accent); outline-offset: 1px; }

/* The enzyme: the rate as a budget, capacity times each factor on a log scale */
.lu-select { max-width: 9.5em; padding: 1px 0; font: inherit; font-size: var(--font-sm); font-style: normal; color: var(--text-secondary); background: transparent; border: 0; border-bottom: 1px solid var(--border-strong); border-radius: 0; cursor: pointer; }
.lu-select:focus-visible { outline: 1.5px solid var(--text); outline-offset: 2px; }
.lu-card { min-height: 8.6em; }
.lu-card-name { margin: 0; font-size: var(--font-lg); line-height: 1.3; color: var(--text); }
.lu-card-rate { margin: 2px 0 8px; font-size: var(--font-sm); line-height: 1.4; color: var(--text-secondary); font-variant-numeric: lining-nums tabular-nums; }
.lu-budget { display: grid; grid-template-columns: 8.4em 1fr 3em; gap: 1px 8px; align-items: center; font-size: var(--font-sm); font-variant-numeric: lining-nums tabular-nums; }
.lu-budget .k { color: var(--text-secondary); white-space: nowrap; }
.lu-budget .v { text-align: right; color: var(--text); }
.lu-budget .tot { color: var(--text); font-weight: 600; }
.lu-budget .b { position: relative; height: 7px; border-bottom: 1px solid var(--border); }
.lu-budget .b > span { position: absolute; left: 0; top: 0; height: 7px; background: var(--ink); transition: width 0.25s var(--ease-out), left 0.25s var(--ease-out); }
/* What a factor took away is hatched, so the bar reads without colour */
.lu-budget .b > .cut { background: repeating-linear-gradient(135deg, var(--ink) 0 1.5px, transparent 1.5px 4px); }
.lu-card-reg { margin: 6px 0 0; font-size: var(--font-sm); line-height: 1.42; color: var(--text-secondary); font-variant-numeric: lining-nums tabular-nums; }
.lu-card-reg:empty, .lu-card-rate:empty { display: none; }
.lu-card-acts { margin-top: 8px; }

/* Fig. 2: the trace, or the ladder */
.lu-trace { display: block; width: 100%; height: 204px; }
.lu-ladder { display: block; width: 100%; height: 300px; }
.lu-readings { margin: 8px 0 0; display: grid; gap: 3px; }

/* The reference pages, one word each */
.lu-ref-list { margin: 0; font-size: var(--font-sm); line-height: 1.7; color: var(--text-muted); }

/* ─── The reference overlay ─── */
.lu-ref-title { margin: 0; padding: 6px 0 9px; font-size: var(--font-lg); font-weight: 400; }
.lu-ref-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 0 20px; border-bottom: 1px solid var(--border); }
.lu-ref-head .lu-close { position: static; }
#reference-overlay .sim-overlay-panel {
    width: min(640px, calc(100vw - 32px));
    max-height: min(80vh, 760px);
    display: flex;
    flex-direction: column;
    background: var(--bg-canvas);
    border: 1px solid var(--border-strong);
}
#reference-overlay .sim-overlay-body { overflow-y: auto; padding: 12px 20px 20px; }

/* ─── Theme button: sun, moon, or the half-disc for "follows sunlight" ─── */
#theme-btn .icon-auto { display: none; }
#theme-btn[data-mode="sun"] .icon-auto { display: block; }
#theme-btn[data-mode="sun"] .icon-sun, #theme-btn[data-mode="sun"] .icon-moon { display: none !important; }

/* ─── Canvas tooltip ─── */
.sim-tooltip.canvas-tip { white-space: normal; max-width: 280px; font: var(--font-base)/1.45 var(--font-text); }
.sim-tooltip.canvas-tip strong { font-size: var(--font-base); font-weight: 500; color: var(--text); }
.sim-tooltip.canvas-tip .ct-full { font-size: var(--font-sm); color: var(--text-secondary); }
.sim-tooltip.canvas-tip .ct-eq { font-size: var(--font-sm); color: var(--text); }
.sim-tooltip.canvas-tip em { font-size: var(--font-sm); color: var(--text-muted); }

/* The knockouts' checkboxes are for the keyboard and screen readers; the plate's key is their face */
.lu-knockouts { min-inline-size: 0; }
.lu-knockouts:focus-within { position: static; width: auto; height: auto; margin: 9px 0 0; clip: auto; overflow: visible; white-space: normal; border: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--font-sm); }
.lu-knockouts:focus-within legend { font-style: italic; color: var(--text-muted); padding: 0; margin-bottom: 2px; width: 100%; }

/* ─── Phones: a folio. The page scrolls through the figure in reading order, and each
   part of the legend follows the register it describes: the specimen, panel a (panned
   sideways), the caption and the conditions, panel b, the enzyme, Fig. 2 ─── */
.lu-scene-map { display: none; }
@media (max-width: 760px) {
    html:has(> .lu-body) { overflow: auto; }
    .sim-body.lu-body { overflow: visible; height: auto; }
    .lu-body > .colophon { position: sticky; top: 0; left: 0; z-index: 100; width: 100%; box-sizing: border-box; margin: 0; padding: 10px 16px; background: var(--bg-canvas); border-bottom: 1px solid var(--border); }
    .lu-stage, .lu-closed .lu-stage { display: flex; flex-direction: column; height: auto; }
    .lu-figure, .lu-legend, .lu-closed .lu-legend, .lu-legend-body { display: contents; visibility: visible; }
    .lu-open, #close-legend { display: none !important; }
    .lu-sec-spec { order: 1; }
    #sim-container { order: 2; }
    .lu-capbar { order: 3; }
    .lu-sec-cond { order: 4; }
    #map-container { order: 5; }
    .lu-sec-enz { order: 6; }
    .lu-fig2 { order: 7; }
    .lu-refs { order: 8; }
    .lu-sec { padding: 12px 16px; }
    .lu-sec-spec { border-bottom: 0; }
    .lu-scene { flex: none; touch-action: pan-y; }
    .lu-scene-map { display: block; border-top: 1px solid var(--border); }
    .lu-capbar { padding: 8px 16px 10px; gap: 8px; border-bottom: 1px solid var(--border); }
    .lu-capbar .caption { font-size: 0.86rem; line-height: 1.4; }
    .lu-zoom { display: none; }
    .lu-specimens { margin-right: 0; }
    .lu-dial { min-height: 40px; }
    .lu-trace { height: 220px; }
}
