/* nv/sheet — SVG sheet view (spec 029). Sheet colours are SVG attributes and stay the same in both
   themes; the stage around the sheet follows :root[data-theme="dark"], where the whole drawing is
   dimmed 10 % (D2-13). Classes here add the interactive states (hover, selection, conflicts, drag,
   saw focus) and the display toggles. */

/* --nv-sheet-stage: the stage colour; the shell sets the dark one (nesting_viewer.css, one place —
   REV-C-13). */
.nv-sheet-host {
  --nv-sheet-stage: #e7e8ea;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background: var(--nv-sheet-stage);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* The cream board is the brightest surface of a dark page: dim the drawing, keep its colours. */
:root[data-theme="dark"] .nv-sheet-host .nv-world,
:root[data-theme="dark"] .nv-group-preview-svg,
:root[data-theme="dark"] .nv-legend-swatch { filter: brightness(0.9); }

/* Sheet size labels sit on the stage, outside the sheet, so they follow the theme (the group
   preview's stock labels too). */
.nv-sheet-host .nv-lbl-sheet text,
.nv-group-preview-svg .nv-lbl-sheet text { fill: #2b2b2b; }
:root[data-theme="dark"] .nv-sheet-host .nv-lbl-sheet text,
:root[data-theme="dark"] .nv-group-preview-svg .nv-lbl-sheet text { fill: #d4d7dc; }

.nv-sheet-svg {
  display: block;
  width: 100%;
  height: 100%;
}
.nv-sheet-svg:focus { outline: none; }
.nv-sheet-svg:focus-visible {
  outline: 2px dashed var(--nv-text, #1d1f23);
  outline-offset: -4px;
}

.nv-sheet-svg,
.nv-sheet-static {
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  text-rendering: geometricPrecision;
}

.nv-sheet-static {
  display: block;
  overflow: visible;
}

/* ---- cursors per mode ---- */
.nv-sheet-host.nv-mode-select .nv-part { cursor: pointer; }
.nv-sheet-host.nv-mode-select.nv-drag-enabled .nv-part { cursor: move; }
.nv-sheet-host.nv-mode-rotate .nv-part { cursor: alias; }
.nv-sheet-host.nv-mode-pan,
.nv-sheet-host.nv-mode-pan .nv-part,
.nv-sheet-host.nv-space-pan,
.nv-sheet-host.nv-space-pan .nv-part { cursor: grab; }
.nv-sheet-host.nv-panning,
.nv-sheet-host.nv-panning .nv-part { cursor: grabbing; }
.nv-sheet-host.nv-dragging .nv-part { cursor: grabbing; }

/* ---- part states (U-01, D2 §4.1) ----
   The wood colour stays; states are outlines. Hover: a soft blue edge. Selection: a 3 px blue band
   outside the part with a white line inside (.nv-selection / .nv-selection-inner in the overlay).
   Focused grain group: a light blue veil over the cells (.nv-group-tint) and a blue edge. Warning:
   a brown edge and a 「!」 badge; error: a red edge, a red hatch where it overlaps and a 「×」 badge. */
.nv-sheet-host .nv-part:hover .nv-part-body {
  stroke: #0b5cc4;
  stroke-opacity: 0.6;
  stroke-width: 1.5px;
}
.nv-sheet-host .nv-part.nv-in-focus .nv-part-body {
  stroke: #2f7fe0;
  stroke-width: 2px;
}
.nv-sheet-host.nv-dragging .nv-part.nv-moving { opacity: 0.88; }
.nv-sheet-host .nv-part.nv-conf-warning .nv-part-body {
  stroke: #a84c00;
  stroke-opacity: 1;
  stroke-width: 2.5px;
}
.nv-sheet-host .nv-part.nv-conf-error .nv-part-body {
  stroke: #c62f3a;
  stroke-opacity: 1;
  stroke-width: 2.5px;
}
/* Badges take the pointer (their title says why); the hatch does not. */
.nv-sheet-host .nv-conf-badge { cursor: help; }
.nv-sheet-host.nv-dragging .nv-layer-conflicts .nv-conf-badge { pointer-events: none; }

/* ---- panel-saw cuts: badges answer the pointer (U-05); saw:focus thickens one cut ---- */
.nv-sheet-host .nv-layer-cut-badges { pointer-events: none; }
.nv-sheet-host .nv-layer-cut-badges .nv-cut-badge { pointer-events: visiblePainted; cursor: help; }
.nv-sheet-host.nv-saw-focused .nv-layer-cuts .nv-cut-band:not(.is-focused) { stroke-opacity: 0.16; }
.nv-sheet-host.nv-saw-focused .nv-layer-cuts .nv-cut-line:not(.is-focused) { stroke-opacity: 0.35; }
.nv-sheet-host .nv-layer-cuts .nv-cut-band.is-focused { stroke-opacity: 0.62; }
.nv-sheet-host .nv-layer-cuts .nv-cut-line.is-focused { stroke-width: 3.2px; }
.nv-sheet-host .nv-layer-cut-badges .nv-lbl-cut.is-focused circle { stroke: #111827; stroke-width: 2px; }

/* ---- display toggles (shell 「표시」 settings) ---- */
.nv-hide-features .nv-feat,
.nv-hide-features .nv-lbl-back,
.nv-hide-bottom .nv-hole-bottom,
.nv-hide-bottom .nv-path-bottom,
.nv-hide-bottom .nv-dots-bottom,
.nv-hide-bottom .nv-lbl-back,
.nv-hide-side .nv-side-hole,
.nv-hide-side .nv-dots-side,
.nv-hide-numbers .nv-lbl-num,
.nv-hide-group-labels .nv-lbl-group,
.nv-hide-grain .nv-grain,
.nv-hide-grain .nv-lbl-grain,
.nv-hide-origins .nv-origin,
.nv-hide-origins .nv-lbl-axes,
.nv-hide-trim .nv-trim,
.nv-hide-trim .nv-trim-band,
.nv-hide-seams .nv-layer-seams,
.nv-hide-cuts .nv-layer-cuts,
.nv-hide-cuts .nv-layer-cut-badges .nv-lbl-cut { display: none; }

/* ---- level of detail ----
   Zoomed out (nv-lod-fine) small holes and side holes become 2.5 px dots instead of vanishing
   (U-03); far out (nv-lod-coarse) all machining and the grain hide. */
.nv-hole-dots { display: none; }
.nv-lod-fine .nv-hole-dots { display: inline; }
.nv-lod-fine .nv-fine,
.nv-lod-coarse .nv-feat,
.nv-lod-coarse .nv-grain,
.nv-lod-coarse .nv-origin { display: none; }

/* ---- part tooltip (nv/sheet hover card) ---- */
.nv-sheet-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  max-width: 340px;
  padding: 6px 9px;
  border-radius: 6px;
  background: rgba(30, 32, 36, 0.94);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  color: #eef0f3;
  font: 12px/1.45 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  pointer-events: none;
  white-space: nowrap;
}
.nv-sheet-tip[hidden] { display: none; }
.nv-sheet-tip-title { font-weight: 600; }
/* REV-FU-09: the title stays on one line; the lines under it wrap inside the box. */
.nv-sheet-tip > div + div { white-space: normal; overflow-wrap: anywhere; }
.nv-sheet-tip-error { color: #ff9aa2; font-weight: 600; }
.nv-sheet-tip-warning { color: #ffc27a; }
:root[data-theme="dark"] .nv-sheet-tip {
  background: rgba(244, 245, 247, 0.96);
  color: #1d1f23;
}
:root[data-theme="dark"] .nv-sheet-tip-error { color: #b3261e; }
:root[data-theme="dark"] .nv-sheet-tip-warning { color: #8a3d00; }

/* ---- grain-group preview: front view and the sheet view side by side (or stacked) (U-07) ---- */
.nv-group-preview-pair {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.nv-group-preview-pair[data-layout="row"] {
  flex-direction: row;
  align-items: flex-start;
}
.nv-group-preview-pane {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.nv-group-preview-caption {
  font-size: 12px;
  font-weight: 600;
  color: var(--nv-text-dim, #566377);
}
.nv-group-preview-turn {
  font-size: 12px;
  font-weight: 600;
  color: var(--nv-text, #1d1f23);
  text-align: center;
  white-space: nowrap;
}
.nv-group-preview-pair[data-layout="row"] .nv-group-preview-turn {
  align-self: center;
  width: 64px;
  white-space: normal;
}

/* ---- legend swatches (U-06: sheet.legendSwatch) ---- */
.nv-legend-swatch { flex: none; overflow: hidden; }

/* ---- remnants (F2, nv-layer-remnants) and the two-pass 「2」 (F1) ----
   A remnant answers the pointer (its tooltip says what it is); its label and separating cuts do not.
   The job summary's 「잔재」 table lights one (setRemnantFocus → .is-focused). */
.nv-sheet-host .nv-remnant { cursor: help; }
.nv-sheet-host .nv-remnant:hover .nv-remnant-body { stroke-width: 2.4px; }
.nv-sheet-host .nv-remnant.is-focused .nv-remnant-body {
  stroke: #0b5cc4;
  stroke-width: 3.2px;
}
.nv-sheet-host .nv-lbl-remnant,
.nv-sheet-host .nv-lbl-remnant-cut { pointer-events: none; }
.nv-sheet-host.nv-dragging .nv-remnant { pointer-events: none; }
/* Far out the hatch would be noise: the teal piece and its border stay. */
.nv-lod-coarse .nv-remnant-hatch { display: none; }

@media print {
  .nv-sheet-static { break-inside: avoid; }
  .nv-sheet-tip { display: none; }
}

/* ---- 시뮬레이션 (nv/simview; machining replay) ----
   While a timeline is set the host has .nv-sim and every part one state class (pending, current,
   skinned, done, freed). The simulation's own marks (labeler, labels, router, travel, kerf, saw) are
   SVG attributes in .nv-layer-sim; the rules here restyle the sheet's parts and panel-saw cuts. The
   programs' holes and grooves stay faint throughout (the Skipper's, never machined on the sheet).
   Shape tells the states apart, not colour alone: not cut = pale with a dashed outline, the router or
   the labeler on it = yellow-and-black outline (drawn by the layer), cut = the part's
   own colour with a filled green number box. Conflict outlines (.nv-conf-*) win over the
   simulation's part outlines. Sheet colours stay the same in both themes. */

.nv-sheet-host.nv-sim .nv-layer-focus,
.nv-sheet-host.nv-sim .nv-layer-overlay { display: none; }
/* The sheet's own conflict hatch and ×/! badges hide too: the layer outlines a problem part while the
   tool is on it. */
.nv-sheet-host.nv-sim .nv-layer-conflicts { display: none; }
/* The sheet's remnants and their ✂ separating cuts hide; the layer shows each one when its separating
   cut or the panel saw frees it, in the same teal. */
.nv-sheet-host.nv-sim .nv-layer-remnants,
.nv-sheet-host.nv-sim .nv-layer-remnant-cuts { display: none; }

/* A click on a part goes to its step. */
.nv-sheet-host.nv-sim .nv-part { cursor: pointer; }
.nv-sheet-host.nv-sim.nv-mode-pan .nv-part,
.nv-sheet-host.nv-sim.nv-space-pan .nv-part { cursor: grab; }
.nv-sheet-host.nv-sim.nv-panning .nv-part { cursor: grabbing; }

.nv-sheet-host.nv-sim .nv-part .nv-part-body { transition: fill 120ms ease-out; }

/* Not cut yet: still part of the board. */
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending .nv-part-body { fill: #f5deba; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending:not(.nv-conf-error):not(.nv-conf-warning) .nv-part-body {
  stroke: #6b4a2b;
  stroke-width: 1px;
  stroke-dasharray: 5 3;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending .nv-grain { display: none; }
/* Machining shows faint until the tool has cut it (the layer draws each hole and groove as it is machined). */
/* The programs' holes, grooves and pockets are the Skipper's, after the sheet: faint in every state (never machined here). */
.nv-sheet-host.nv-sim .nv-part .nv-feat { opacity: 0.35; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending .nv-part-labels > .nv-lbl:not(.nv-lbl-num) { opacity: 0.55; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending .nv-lbl-num rect {
  fill: #fffaf0;
  fill-opacity: 1;
  stroke: #8a7a62;
  stroke-width: 0.9;
  stroke-dasharray: 2 1.4;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-pending .nv-lbl-num text { fill: #6b5a45; }

/* Being cut, cut, freed: the part's own colour (no selection, hover or group-focus tint). */
.nv-sheet-host.nv-sim .nv-part.nv-sim-current .nv-part-body,
.nv-sheet-host.nv-sim .nv-part.nv-sim-done .nv-part-body,
.nv-sheet-host.nv-sim .nv-part.nv-sim-freed .nv-part-body { fill: var(--nv-sim-part, #e3b98a); }
.nv-sheet-host.nv-sim .nv-part.nv-sim-current:not(.nv-conf-error):not(.nv-conf-warning) .nv-part-body,
.nv-sheet-host.nv-sim .nv-part.nv-sim-done:not(.nv-conf-error):not(.nv-conf-warning) .nv-part-body,
.nv-sheet-host.nv-sim .nv-part.nv-sim-freed:not(.nv-conf-error):not(.nv-conf-warning) .nv-part-body {
  stroke: var(--nv-sim-part-stroke, #6b4a2b);
  stroke-width: 0.9px;
  stroke-dasharray: none;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-current .nv-lbl-num rect {
  fill: #f5b700;
  fill-opacity: 1;
  stroke: #111827;
  stroke-width: 1.2;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-current .nv-lbl-num text { fill: #111827; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-current .nv-lbl-num text[stroke] { stroke: #f5b700; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-done .nv-lbl-num rect,
.nv-sheet-host.nv-sim .nv-part.nv-sim-freed .nv-lbl-num rect {
  fill: #0b6b2c;
  fill-opacity: 1;
  stroke: none;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-done .nv-lbl-num text,
.nv-sheet-host.nv-sim .nv-part.nv-sim-freed .nv-lbl-num text { fill: #ffffff; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-done .nv-lbl-num text[stroke],
.nv-sheet-host.nv-sim .nv-part.nv-sim-freed .nv-lbl-num text[stroke] { stroke: #0b6b2c; }

/* F1 · cut round once (1차), still held by its skin: the part's own colour (its outline is cut), no
   shadow (it has not come off), a white number box with a dashed green border — half way to the
   filled green box of a cut part. */
.nv-sheet-host.nv-sim .nv-part.nv-sim-skinned .nv-part-body { fill: var(--nv-sim-part, #e3b98a); }
.nv-sheet-host.nv-sim .nv-part.nv-sim-skinned:not(.nv-conf-error):not(.nv-conf-warning) .nv-part-body {
  stroke: var(--nv-sim-part-stroke, #6b4a2b);
  stroke-width: 0.9px;
  stroke-dasharray: none;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-skinned .nv-lbl-num rect {
  fill: #ffffff;
  fill-opacity: 1;
  stroke: #0b6b2c;
  stroke-width: 1;
  stroke-dasharray: 2 1.4;
}
.nv-sheet-host.nv-sim .nv-part.nv-sim-skinned .nv-lbl-num text { fill: #0b6b2c; }
.nv-sheet-host.nv-sim .nv-part.nv-sim-skinned .nv-lbl-num text[stroke] { stroke: #ffffff; }

/* The violet 「2」 of a two-pass part (nv/sheet .nv-two-pass) keeps its colours in every state. */
.nv-sheet-host.nv-sim .nv-part .nv-lbl-num .nv-two-pass rect {
  fill: #6d3b9e;
  fill-opacity: 1;
  stroke: #ffffff;
  stroke-width: 0.8;
  stroke-dasharray: none;
}
.nv-sheet-host.nv-sim .nv-part .nv-lbl-num .nv-two-pass text { fill: #ffffff; }

/* Pointing at a part while simulating outlines it. */
.nv-sheet-host.nv-sim .nv-part:not(.nv-conf-error):not(.nv-conf-warning):hover .nv-part-body {
  stroke: #111827;
  stroke-width: 1.8px;
  stroke-dasharray: none;
}

/* Panel saw: finished cuts as drawn, the current one drawn by the layer (yellow saw line and
   badge), the ones still to come faint and dashed. */
.nv-sheet-host.nv-sim .nv-cut-band.nv-sim-cut-pending,
.nv-sheet-host.nv-sim .nv-cut-band.nv-sim-cut-current,
.nv-sheet-host.nv-sim .nv-cut-line.nv-sim-cut-current { display: none; }
.nv-sheet-host.nv-sim .nv-cut-line.nv-sim-cut-pending {
  stroke-opacity: 0.25;
  stroke-dasharray: 6 4;
}
.nv-sheet-host.nv-sim .nv-lbl-cut.nv-sim-cut-pending { opacity: 0.35; }
.nv-sheet-host.nv-sim .nv-lbl-cut.nv-sim-cut-current .nv-cut-badge circle {
  fill: #f5b700;
  stroke: #111827;
  stroke-width: 1.4;
}
.nv-sheet-host.nv-sim .nv-lbl-cut.nv-sim-cut-current .nv-cut-badge text { fill: #111827; }

@media (prefers-reduced-motion: reduce) {
  .nv-sheet-host.nv-sim .nv-part .nv-part-body { transition: none; }
}

@media print {
  .nv-layer-sim,
  .nv-sim-shadow { display: none; }
}
