/* style.css, part 5 of 13: direct manipulation on the stage (src/interact.js) and the organic sketch controls.
   A contiguous range of the pre-M7 style.css, linked from index.html in
   source order so the cascade is unchanged; see src/tokens.css. */

/* ============================================================
   Phase F0 — direct-manipulation UI (interact.js)
   ============================================================ */

/* Live value bubble that follows the cursor while dragging an accessory. */
.viewport-readout {
    position: absolute;
    display: none;
    pointer-events: none;
    z-index: 30;
    background: var(--c-white);
    border: 2px solid #ffb3c6;
    border-radius: var(--radius-chip);
    padding: 0.3rem var(--space-air);
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: var(--fs-sm);
    color: var(--accent-text);
    box-shadow: 0 4px 14px rgba(210, 61, 109, 0.18);
    white-space: nowrap;
}

/* Viewport component menu. Opened by right-click, by the Menu key, by
   Shift+F10, or by Enter on the focused viewport — one menu, one item list,
   four ways in (see the keyboard section of src/interact.js). */
.ctx-menu {
    position: fixed;
    z-index: 1000;
    min-width: 210px;
    max-width: min(340px, calc(100vw - 16px));
    background: var(--c-white);
    border: 2px solid #dfdce2;
    border-radius: var(--radius-dialog);
    padding: 0.35rem;
    box-shadow: 0 10px 30px rgba(180, 120, 170, 0.25);
    font-family: var(--font-ui);
    max-height: calc(100vh - 16px);
    overflow-y: auto;
}
.ctx-menu-header {
    padding: 0.35rem 0.75rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
}
.ctx-menu button {
    display: block;
    width: 100%;
    min-height: 32px;
    text-align: left;
    border: none;
    background: none;
    border-radius: var(--radius-control);
    padding: var(--space-field) 0.75rem;
    font-family: inherit;
    font-weight: var(--fw-strong);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    cursor: pointer;
}
.ctx-menu button:hover,
.ctx-menu button:focus-visible {
    background: var(--c-pink-50);
    color: var(--accent-text);
}
/* Empty alt text: aria-checked already makes NVDA say "checked", so without
   the `/ ''` the tick is announced a second time as a glyph. */
.ctx-menu button[aria-checked="true"]::after {
    content: ' ✓' / '';
    color: var(--ok-text);
    font-weight: var(--fw-display);
}
/* The keyboard hint at the foot of every menu. */
.ctx-menu-hint {
    padding: 0.4rem 0.75rem 0.25rem;
    margin-top: var(--space-hug);
    border-top: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 0.68rem;
    font-weight: var(--fw-strong);
    line-height: var(--lh-tight);
}

/* Phase F1 - sliders scrub quickly; paired numbers provide exact input. */
.number-control {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-top: var(--space-field);
}
.exact-number {
    width: 6.4rem;
    min-height: 34px;
    border: 2px solid var(--border-control);
    border-radius: var(--radius-control);
    background: var(--c-white);
    color: var(--text-primary);
    padding: 0.35rem 0.5rem;
    font: 700 var(--fs-sm) var(--font-ui);
    text-align: right;
}
.exact-number:focus {
    border-color: var(--icon-accent, #a466da);
    box-shadow: 0 0 0 3px var(--c-pink-a18);
}
.number-unit {
    min-width: 1.8rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

/* Viewport selection and its matching sidebar control are one surface. */
.control-group.viewport-linked {
    transition: border-color var(--dur-160) ease, box-shadow var(--dur-160) ease, transform var(--dur-160) ease;
}
.control-group.viewport-selected {
    border-color: var(--icon-accent, #a466da);
    box-shadow: 0 0 0 3px var(--c-pink-a18), 0 8px 22px rgba(180, 120, 170, 0.16);
    transform: translateX(2px);
}
#canvas-wrapper:focus-visible {
    outline: 3px solid rgba(255, 143, 184, 0.65);
    outline-offset: -3px;
}

/* Visible per-edge geometry validation panel */
.edge-summary { padding: 0.7rem 0.8rem; border-radius: var(--radius-card); font-size: 0.78rem; font-weight: 700; line-height: var(--lh-tight); background: #f2eefb; border: 1px solid var(--border-soft); }
.edge-summary.ok { background: #e6f7ef; border-color: rgba(70,180,135,.45); }
.edge-summary.warn { background: #fdf1de; border-color: rgba(220,145,35,.5); }
.edge-summary.fail { background: #fdeaee; border-color: rgba(220,65,95,.5); }
.edge-card { padding: var(--space-air); border-radius: var(--radius-card); background: var(--c-white); border: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 0.55rem; transition: border-color var(--dur-160) ease, box-shadow var(--dur-160) ease; }
/* Same surface as .control-group.viewport-selected above — a click on this
   card's edge in the viewport lands here, and this is how the landing shows. */
.edge-card.viewport-selected {
    border-color: var(--icon-accent, #a466da);
    box-shadow: 0 0 0 3px var(--c-pink-a18), 0 8px 22px rgba(180, 120, 170, 0.16);
}
.edge-card-head { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.edge-status { padding:var(--space-hug) .48rem; border-radius:var(--radius-chip); font-size:.68rem; font-weight:var(--fw-display); white-space:nowrap; background:var(--bg-2); color:var(--text-secondary); }
.edge-status.ok { background:#dff5ea; color:var(--ok-text); }
.edge-status.warn { background:#fdeed6; color:var(--warn-text); }
.edge-status.fail { background:#fde3e8; color:var(--fail-text); }
.edge-status.checking { background:#ece7fa; color:#544495; }
.edge-field { display:grid; grid-template-columns: 1fr 1.25fr; gap:.55rem; align-items:center; font-size:.78rem; font-weight:700; }
.edge-number { margin-top:-.25rem; }
.edge-presets { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.32rem; }
.edge-preset { min-height:30px; border:1px solid var(--border-soft); background:var(--c-white); color:var(--text-primary); border-radius:var(--radius-inset); padding:.34rem .15rem; font-size:.67rem; font-weight:700; cursor:pointer; }
.edge-preset:hover { border-color:var(--accent-color); background:#fff5f9; }
.edge-preset.selected { background:#ffe7f0; border-color:var(--accent-color); }
.edge-preset.above-safe { border-style:dashed; color:var(--warn-text); background:#fdf3e2; }
.edge-preset.failed { border-color:#d44b67; color:var(--fail-text); background:#fdeaee; }
.edge-metrics { display:grid; grid-template-columns:repeat(3,1fr); gap:.35rem; font-size:.65rem; color:var(--text-secondary); }
.edge-metrics span { display:flex; flex-direction:column; gap:.12rem; padding:.35rem; border-radius:var(--radius-inset); background:#f6f2fc; }
.edge-metrics b { color:var(--text-primary); font-size:.7rem; }
/* `opacity` here would have dimmed the labels below the contrast floor; the
   sharp mode is signalled by the disabled controls themselves. */
.edge-card.sharp-mode input[type="range"]::-webkit-slider-runnable-track,
.edge-card.sharp-mode input[type="range"]::-moz-range-track { background:#ece7f2; }
.edge-card.sharp-mode .edge-presets .edge-preset { border-style:dotted; }

/* Organic orthographic sketch editor */
.organic-sketch-panel {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: var(--space-air);
    border-radius: var(--radius-card);
    background: var(--bg-1);
    border: 1.5px solid rgba(179, 155, 255, 0.34);
}

/* v2.7 UX: numbered workflow strip + switch-position row */
.organic-step-strip {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    list-style: none;
}
.org-step {
    flex: 1;
    text-align: center;
    padding: 0.3rem var(--space-hug);
    border-radius: var(--radius-control);
    font: 700 0.68rem var(--font-ui);
    color: var(--text-secondary);
    background: var(--c-white);
    border: 1.5px solid rgba(179, 155, 255, 0.22);
}
.org-step.done {
    color: var(--ok-text);
    background: #e2f6ec;
    border-color: rgba(102, 214, 158, 0.6);
}
.org-step.active {
    color: #5b2ba3;
    background: #ede7fb;
    border-color: rgba(179, 155, 255, 0.7);
}
.organic-anchor-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.6rem;
    border-radius: var(--radius-card);
    background: var(--bg-1);
    border: 1.5px solid rgba(179, 155, 255, 0.28);
}
.control-group, .slider-container, .organic-sketch-panel,
.organic-anchor-row, .organic-recess-strategy { min-width: 0; }
.control-group small, .organic-sketch-panel small { overflow-wrap: anywhere; }

.organic-anchor-row .anchor-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.organic-anchor-row .anchor-controls label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font: var(--fw-strong) 0.7rem var(--font-ui);
}
.organic-anchor-row .anchor-controls input[type="number"] {
    width: 3.9rem;
    min-height: 32px;
    border-radius: var(--radius-inset);
    border: 1px solid rgba(179, 155, 255, 0.4);
    background: var(--c-white);
    color: var(--text-primary);
    padding: 0.15rem 0.3rem;
}
.organic-fast-mode {
    display: flex;
    flex-direction: column;
    gap: var(--space-hug);
    padding: 0.55rem 0.65rem;
    border-radius: var(--radius-control);
    background: #e6f7ef;
    border: 1.5px solid rgba(66, 170, 128, 0.4);
}
.organic-fast-mode strong { font-size: 0.78rem; color: var(--ok-text); }
.organic-fast-mode small { line-height: var(--lh-tight); }

.organic-recess-strategy {
    display: flex;
    flex-direction: column;
    gap: var(--space-field);
    padding: 0.65rem;
    border-radius: var(--radius-card);
    background: var(--c-white);
    border: 1.5px solid rgba(179, 155, 255, 0.28);
}
.organic-recess-strategy .sketch-button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* The view-relative nudge pad. The arrows keep .mini-action's 36 px target (and
   mobile.css's 44) — this rule only lays them out and stops them stretching to
   the full row width the way a flex:1 action button does. */
.organic-anchor-row .anchor-nudge {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}
.organic-anchor-row .anchor-nudge .anchor-nudge-label {
    font: var(--fw-strong) 0.7rem var(--font-ui);
}
.organic-anchor-row .anchor-nudge .mini-action {
    flex: 0 1 2.75rem;
    font-size: var(--fs-base);
    line-height: 1;
}
.organic-anchor-row .mini-action.active {
    background: #ece2fb;
    border-color: rgba(122, 63, 209, 0.65);
    color: #5b2ba3;
}
.organic-sketch-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-field);
}
.organic-sketch-section > strong {
    font-size: var(--fs-sm);
    color: var(--text-primary);
}
.sketch-button-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
}
.sketch-tool-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
}
/* Auto-edge (Bambu-style) row: magnetic snap toggle + one-click trace. */
.auto-edge-row {
    grid-template-columns: repeat(2, 1fr) !important;
    margin-top: 0.15rem;
}
.auto-edge-row .sketch-btn span { margin-left: 0.3rem; }
.sketch-btn {
    min-height: 34px;
    border: 1.5px solid var(--border-soft);
    border-radius: var(--radius-control);
    padding: 0.48rem 0.35rem;
    background: var(--c-white);
    color: var(--text-primary);
    font: 700 0.72rem var(--font-ui);
    cursor: pointer;
    transition: all var(--dur-150) ease;
}
.sketch-btn:hover:not(:disabled) {
    border-color: var(--icon-accent);
    transform: translateY(-1px);
}
.sketch-btn.active {
    background: #f1e7f9;
    border-color: var(--icon-accent);
    color: var(--accent-text);
    box-shadow: 0 3px 10px var(--icon-shadow);
}
.sketch-btn:disabled {
    background: #f1eef4;
    color: var(--text-secondary);
    border-style: dotted;
    cursor: not-allowed;
}

/* The drawn marks that replaced this panel's raw glyphs (↖ ╱ ⌁ ▭ ○ 〰 🖌 and
   Trace outline's ⤳). There was no `.sketch-btn svg` rule AT ALL before this,
   so #organicMagnetToggle's inline <svg> — which carries only a viewBox, no
   intrinsic width — fell back to the replaced-element default and rendered
   110.7 x 110.7 px: a horseshoe magnet the size of the whole button, measured
   2026-08-25. 1.4em is the same ratio .preset-btn svg uses against its own
   font-size rather than a fixed pixel count, so the mark tracks .sketch-btn's
   0.72rem type the way .chrome-icon tracks a heading's; -0.28em drops it from
   its own box-bottom onto the label's baseline, which is what the text glyphs
   it replaced were doing for free. */
.sketch-btn svg {
    width: 1.4em;
    height: 1.4em;
    vertical-align: -0.28em;
    flex: none;
}
/* The Draw grid puts the mark and the word on one line, the same shape the
   auto-edge row and the add/subtract pair already use. */
.sketch-tool-grid .sketch-btn span + span { margin-left: 0.3rem; }
.organic-sketch-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}
.primary-mini {
    background: linear-gradient(135deg, var(--c-rose-600), var(--c-indigo-600)) !important;
    color: var(--c-white) !important;
    border-color: transparent !important;
}

/* v2.6 · imported-asset colour + intersected three-plane sketches */
.organic-import-info {
    margin-top: 0.7rem;
    padding: 0.65rem;
    border: 1px solid rgba(160, 125, 190, 0.22);
    border-radius: var(--radius-card);
    background: var(--c-white);
}
.organic-palette-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: var(--space-field) 0 0.25rem;
}
.organic-palette-swatches span {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-inset);
    border: 2px solid rgba(255,255,255,0.85);
    box-shadow: 0 0 0 1px rgba(65,45,80,0.18);
}
/* `opacity: 0.62` here dropped this label to 2.7:1. A small caption that
   already sits under a heading does not need to be faded as well. */
.plane-state {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.6rem;
    line-height: 1;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.plane-state.ready { color: var(--ok-text); }
.plane-state.invalid { color: var(--fail-text); }
.sketch-btn.active .plane-state { color: var(--accent-text); }
.viewer-progress {
    width: min(310px, 72vw);
    height: 10px;
    overflow: hidden;
    border-radius: var(--radius-chip);
    background: var(--c-white);
    box-shadow: inset 0 0 0 1px rgba(80,60,100,0.28);
}
.viewer-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-color), var(--accent-2));
    transition: width var(--dur-160) ease;
}
/* The service computing has no number to show: a full-width moving stripe. */
.viewer-progress.indeterminate .viewer-progress-fill {
    width: 100% !important;
    background: repeating-linear-gradient(135deg, var(--accent-color) 0 10px, var(--accent-2) 10px 20px);
    background-size: 28.28px 28.28px;
    animation: viewer-progress-stripe 800ms linear infinite;
    transition: none;
}
@keyframes viewer-progress-stripe {
    to { background-position: 28.28px 0; }
}
@media (prefers-reduced-motion: reduce) {
    .viewer-progress.indeterminate .viewer-progress-fill { animation: none; }
}
.viewer-progress-meta {
    width: min(310px, 72vw);
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.76rem;
}
.viewer-progress-meta span { text-align: right; color: var(--text-secondary); }
.loading-overlay.complete .spinner { display: none; }
.loading-overlay.complete #loadingStage::before { content: '✓ ' / ''; color: var(--ok-text); }
/* `--text-color` was never defined, so this chip has been inheriting the body
   colour by accident since it was written. */
.viewer-build-status {
    position: absolute;
    right: 14px;
    top: 14px;
    z-index: 8;
    max-width: min(360px, 70vw);
    padding: 0.42rem 0.65rem;
    border-radius: var(--radius-chip);
    background: var(--c-white);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 700;
    box-shadow: 0 5px 18px rgba(50,30,70,0.13);
    pointer-events: none;
}
.viewer-build-status[data-state="working"] { color: var(--warn-text); }
.viewer-build-status[data-state="ready"] { color: var(--ok-text); }
.viewer-build-status[data-state="error"] { color: var(--fail-text); }
