/* A replica of Blender's geometry-nodes editor.

   Every colour here is read out of the running Blender's own theme rather
   than sampled off a screenshot: node_backdrop, the per-category header
   colours, wire and wire_inner. Socket colours are Blender's built-in
   per-type constants. Sizes are in Blender's node units, which the renderer
   treats as CSS pixels at zoom 1. */

.ng {
  --ng-bg: #1d1d1d;
  --ng-grid: #282828;
  --ng-node: #303030;
  --ng-node-outline: #0f0f0f;
  --ng-selected: #ed5700;
  --ng-text: #e5e5e5;
  --ng-text-dim: #9a9a9a;
  --ng-field: #545454;
  --ng-field-dark: #232323;
  --ng-blue: #4772b3;

  --ng-cat-input: #82354c;
  --ng-cat-output: #3e232a;
  --ng-cat-geometry: #1d725e;
  --ng-cat-vector: #3c3c83;
  --ng-cat-texture: #79461d;
  --ng-cat-converter: #246283;
  --ng-cat-group: #374725;

  position: relative;
  height: 460px;
  border: 0.5px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--ng-bg);
  /* Blender's own UI font is a plain sans; the site's mono would read as
     "code sample" rather than "application window". */
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  line-height: 1;
  color: var(--ng-text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.ng-viewport {
  position: absolute;
  inset: 0;
  cursor: grab;
  background-image:
    linear-gradient(var(--ng-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--ng-grid) 1px, transparent 1px);
  background-size: 40px 40px;
}

.ng-viewport.is-panning { cursor: grabbing; }

.ng-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.ng-wires { position: absolute; pointer-events: none; }

/* ---- frames ----
   The labelled boxes Blender groups nodes into. They take no pointer events,
   so dragging over one still pans rather than catching on the box. */

.ng-frames { position: absolute; top: 0; left: 0; pointer-events: none; }

.ng-frame {
  position: absolute;
  background: rgba(15, 15, 15, 0.8);
  border: 1px solid #3a3a3a;
  border-radius: 4px;
}

/* Each level of nesting sits a step lighter than the one holding it —
   otherwise a frame inside a frame is invisible against its parent. */
.ng-frame[data-depth="1"] { background: rgba(48, 48, 48, 0.75); border-color: #464646; }
.ng-frame[data-depth="2"] { background: rgba(72, 72, 72, 0.72); border-color: #545454; }
.ng-frame[data-depth="3"] { background: rgba(94, 94, 94, 0.70); border-color: #626262; }

.ng-frame-label {
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  text-align: center;
  color: #c8c8c8;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

/* ---- reroute ----
   Blender's little pass-through dot; it has no box of its own, just the
   socket sitting on the wire. */

.ng-node[data-cat="reroute"] {
  width: 0 !important;
  height: 0;
  background: none;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

.ng-sock-mid {
  left: -5.5px;
  top: -5.5px;
  margin-top: 0;
}

/* ---- node ---- */

.ng-node {
  position: absolute;
  background: var(--ng-node);
  border: 1px solid var(--ng-node-outline);
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: grab;
}

.ng-node.is-dragging { cursor: grabbing; }

.ng-node.is-selected {
  border-color: var(--ng-selected);
  box-shadow: 0 0 0 1px var(--ng-selected), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.ng-head {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 4px 4px 0 0;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}

.ng-head-title { overflow: hidden; text-overflow: ellipsis; }

/* the drawn chevrons: sized here, centred by flex rather than by baseline */
.ng-head-caret,
.ng-menu-caret,
.ng-idsel-caret {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.ng-head-caret { color: rgba(255, 255, 255, 0.7); }
.ng-head-caret svg { width: 12px; height: 12px; display: block; }
.ng-menu-caret { color: var(--ng-text-dim); }
.ng-menu-caret svg { width: 11px; height: 11px; display: block; }
.ng-idsel-caret { color: var(--ng-text-dim); }
.ng-idsel-caret svg { width: 10px; height: 10px; display: block; }

.ng-node[data-cat="input"]     .ng-head { background: var(--ng-cat-input); }
.ng-node[data-cat="output"]    .ng-head { background: var(--ng-cat-output); }
.ng-node[data-cat="geometry"]  .ng-head { background: var(--ng-cat-geometry); }
.ng-node[data-cat="vector"]    .ng-head { background: var(--ng-cat-vector); }
.ng-node[data-cat="texture"]   .ng-head { background: var(--ng-cat-texture); }
.ng-node[data-cat="converter"] .ng-head { background: var(--ng-cat-converter); }
.ng-node[data-cat="group"]     .ng-head { background: var(--ng-cat-group); }

/* the strip Blender floats above a node listing its named attributes */
.ng-banner {
  position: absolute;
  left: -1px;
  right: -1px;
  bottom: 100%;
  margin-bottom: 2px;
  height: 18px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border-radius: 4px;
  background: #252525;
  border: 1px solid var(--ng-node-outline);
  color: var(--ng-text-dim);
  font-size: 10px;
  white-space: nowrap;
}

.ng-banner-icon {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: #7a7a7a;
  flex-shrink: 0;
}

.ng-body { padding: 3px 0 6px; }

/* ---- rows ---- */

.ng-row {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  white-space: nowrap;
}

.ng-row-out { justify-content: flex-end; }

.ng-label { overflow: hidden; text-overflow: ellipsis; }

/* ---- sockets ----
   Blender draws three shapes and they carry meaning: a bar for a plain
   single value, a circle for a shader-style socket, and a diamond for one
   that can take a field. */

.ng-sock {
  position: absolute;
  top: 50%;
  box-sizing: border-box;
  border: 1px solid #0f0f0f;
}

.ng-sock-circle {
  width: 11px;
  height: 11px;
  margin-top: -5.5px;
  border-radius: 50%;
}

.ng-sock-circle.ng-sock-in { left: -5.5px; }
.ng-sock-circle.ng-sock-out { right: -5.5px; }

.ng-sock-diamond {
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border-radius: 1px;
  transform: rotate(45deg);
}

.ng-sock-diamond.ng-sock-in { left: -5px; }
.ng-sock-diamond.ng-sock-out { right: -5px; }

/* a slim upright bar, not a square: this is the shape Blender gives a plain
   single-value socket, and it is much narrower than it is tall */
.ng-sock-line {
  width: 5px;
  height: 12px;
  margin-top: -6px;
  border-radius: 2px;
}

.ng-sock-line.ng-sock-in { left: -2.5px; }
.ng-sock-line.ng-sock-out { right: -2.5px; }

.ng-sock-virtual { background: transparent !important; border-color: #6e6e6e; }

/* ---- value widgets ---- */

.ng-field {
  flex: 1;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--ng-field);
  font-size: 10px;
  overflow: hidden;
  min-width: 0;
}

.ng-field-name { overflow: hidden; text-overflow: ellipsis; }
.ng-field-val { color: #fff; flex-shrink: 0; }

.ng-menu {
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 6px;
  border-radius: 3px;
  background: var(--ng-field);
  font-size: 10px;
  overflow: hidden;
  min-width: 0;
}

.ng-menu-prefix { color: var(--ng-text); flex-shrink: 0; }
.ng-menu-label { overflow: hidden; text-overflow: ellipsis; }
.ng-menu-caret { color: var(--ng-text-dim); flex-shrink: 0; }

/* the two-button segmented control: Points|Radius, Round|Custom */
.ng-toggle {
  flex: 1;
  height: 16px;
  display: flex;
  border-radius: 3px;
  overflow: hidden;
  font-size: 10px;
  min-width: 0;
}

.ng-toggle-opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ng-field);
  color: var(--ng-text);
  overflow: hidden;
}

.ng-toggle-opt.is-active { background: var(--ng-blue); color: #fff; }

.ng-check {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--ng-field);
  flex-shrink: 0;
  position: relative;
}

.ng-check.is-on { background: var(--ng-blue); }

.ng-check.is-on::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 1px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

/* a vector's components carry no axis label in Blender — just the number */
.ng-field-centre { justify-content: center; }

/* the ID picker: icon, name, and either a clear button or an eyedropper */
.ng-id {
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--ng-field);
  font-size: 10px;
  overflow: hidden;
  min-width: 0;
}

.ng-id-icon {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: linear-gradient(135deg, #d8d8d8, #8a8a8a);
  flex-shrink: 0;
}

.ng-id-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.ng-id-tool {
  color: var(--ng-text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.ng-id-tool svg { width: 9px; height: 9px; display: block; }

/* an empty slot is drawn hollow, with its type name as a placeholder */
.ng-id.is-empty { background: #3f3f3f; }
.ng-id.is-empty .ng-id-name { color: #7b7b7b; }
.ng-id.is-empty .ng-id-icon { background: #5a5a5a; }

/* the tree selector Blender puts at the top of a group node */
.ng-idsel {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  padding: 0 3px;
  border-radius: 3px;
  background: var(--ng-field);
  flex-shrink: 0;
}

.ng-idsel-icon {
  width: 10px;
  height: 9px;
  border-radius: 1px;
  background: #d0d0d0;
  flex-shrink: 0;
}

.ng-idname {
  flex: 1;
  height: 16px;
  display: flex;
  align-items: center;
  padding: 0 5px;
  border-radius: 3px;
  background: var(--ng-field);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ng-idbtn {
  width: 17px;
  height: 16px;
  border-radius: 3px;
  background: var(--ng-blue);
  flex-shrink: 0;
}

/* ---- group-node panels ---- */

.ng-panel {
  position: relative;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
}

.ng-panel-caret {
  border: 4px solid transparent;
  border-left-color: var(--ng-text-dim);
  margin-left: 1px;
  flex-shrink: 0;
}

.ng-panel.is-open .ng-panel-caret {
  border-left-color: transparent;
  border-top-color: var(--ng-text-dim);
  transform: translateY(2px);
}

/* ---- chrome ---- */

.ng-toolbar {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.ng-toolbar button {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--ng-text);
  background: rgba(48, 48, 48, 0.92);
  border: 1px solid #0f0f0f;
  border-radius: 3px;
  padding: 0.35em 0.6em;
  cursor: pointer;
  line-height: 1;
}

.ng-toolbar button:hover { background: #3d3d3d; }

/* same chrome as the zoom buttons, parked in the opposite corner */
.ng-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  color: var(--ng-text);
  background: rgba(48, 48, 48, 0.92);
  border: 1px solid #0f0f0f;
  border-radius: 3px;
  cursor: pointer;
}

.ng-expand:hover { background: #3d3d3d; }
.ng-expand svg { width: 14px; height: 14px; display: block; }

/* filling the viewport where the Fullscreen API isn't available.

   margin: 0 matters here and is easy to miss: with position: fixed and both
   top and bottom set (inset: 0 sets both), the panel's own margin-top still
   pushes its border-box down from that line — a fixed element ignores its
   normal-flow position but not its box model. .node-graph-details .ng carries
   a 0.8rem margin-top for the inline layout, which otherwise survives into
   the maximized state and eats exactly that much off the bottom. */
.ng.is-maximized {
  position: fixed;
  inset: 0;
  z-index: 1000;
  margin: 0;
  height: auto;
  border: 0;
  border-radius: 0;
}

.ng:fullscreen {
  margin: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.ng-corner {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: #6e6e6e;
  pointer-events: none;
}

@media (max-width: 720px) {
  .ng { height: 340px; }
}
