/* Shared styles for pages on static/js/lib/viz-runtime.js: generated controls, and ?embed=part layouts. */

/* ---- controls ---- */
.viz-controls { display: flex; flex-direction: column; gap: 0.4em; }
.vc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4em 1em; }
.vc { display: inline-flex; align-items: center; gap: 0.4em; margin: 0; }
.vc[hidden] { display: none; }
.vc label, .vc .vc-label { margin: 0; font-weight: 600; font-size: 0.8em; color: var(--viz-text); white-space: nowrap; }
.vc-select select { width: auto; min-width: 7em; }
.vc-stepper-box { display: inline-flex; align-items: center; border: 1px solid var(--viz-border); border-radius: 4px; overflow: hidden; }
.vc-stepper-box .btn { border: 0; border-radius: 0; min-width: 2em; font-weight: 700; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.vc-value { display: inline-block; min-width: 2.2em; text-align: center; font-family: var(--viz-mono-font); font-size: 0.85em; padding: 0 0.2em; color: var(--viz-text); }
.vc-toggle { font-weight: 400; font-size: 0.8em; cursor: pointer; }
.vc-toggle input { margin: 0; }
.vc-swatch { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; vertical-align: middle; }
.vc-seg-label { margin-left: 0.3em; }
.vc-slider input[type=range] { width: clamp(5em, 12vw, 9em); }
.vc-step-label { font-family: var(--viz-mono-font); font-size: 0.75em; color: var(--viz-text-muted); min-width: 6em; }
.vc .btn { touch-action: manipulation; }

/* Bigger targets for fingers and the Pencil, and in slide embeds */
@media (pointer: coarse) {
    .vc .btn, .vc select, .vc-stepper-box .btn { min-height: 44px; min-width: 44px; font-size: 1em; }
    .vc-value { font-size: 1.05em; min-width: 2.6em; }
    .vc-toggle { min-height: 44px; font-size: 0.95em; }
    .vc-toggle input { width: 1.3em; height: 1.3em; }
    .vc input[type=range] { height: 44px; }
}
[data-embed="part"] .vc .btn, [data-embed="part"] .vc select, [data-embed="part"] .vc-stepper-box .btn { min-height: 40px; min-width: 40px; font-size: 0.95em; }
[data-embed="part"] .vc-toggle { min-height: 40px; font-size: 0.9em; }

/* ---- ?embed=part ---- */
[data-embed="part"] body { padding: 0; }
[data-embed="part"] .container { width: 100%; max-width: none; padding: 0; }
[data-embed="part"] .container > .row { margin: 0; }
[data-embed="part"] .container > :not(#main-content),
[data-embed="part"] #main-content > :not(.viz-parts),
[data-embed="part"] #share-btn,
[data-embed="part"] footer, [data-embed="part"] .page-header, [data-embed="part"] hr { display: none !important; }
.viz-parts { display: flex; flex-direction: column; gap: 0.5em; padding: 0.4em; }
.viz-parts[data-layout="row"] { flex-direction: row; align-items: flex-start; }
.viz-parts[data-layout="row"] > .viz-part-slot:first-child { flex: 1 1 60%; min-width: 0; }
.viz-parts[data-layout="row"] > .viz-part-slot:not(:first-child) { flex: 1 1 40%; min-width: 0; }
.viz-part-slot > [data-viz-part] { display: block !important; }

/* the figure's canvas fills what the other parts leave of the frame (the view keeps its own aspect inside) */
/* …but never under half the frame: when the other parts are taller than the frame, the page scrolls instead */
[data-embed="part"] [data-viz-figure] canvas { max-height: max(50vh, calc(100vh - var(--viz-rest, 0px))); }

/* ?readonly=1: a mirrored copy. Inputs are inert but drawn at full strength, so a projector shows them clearly. */
[data-readonly] [data-viz-part], [data-readonly] [data-viz-part] * { cursor: default !important; }
[data-readonly] .vc .btn[disabled], [data-readonly] .vc select[disabled], [data-readonly] .vc input[disabled] { opacity: 1; }
[data-readonly] .vc .btn.active { box-shadow: inset 0 0 0 2px var(--book-navy); }
