/* Drawing sheet: the drawing area, components on it, lines, ports, names and flow balls. */

#sheetArea {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--bg)
}

#sheetSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
  user-select: none;
  -webkit-user-select: none
}

.symbol {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round
}

.symbol .fill {
  fill: currentColor
}

/* Walls that move as an actuator inflates (the ring actuators) */
.symbol .gray {
  stroke: #8c8c8c
}

.symbol .liquid {
  fill: #3b8bd4;
  fill-opacity: .3;
  stroke: none
}

/* A running pump's arrows: dark red (lighter in the dark theme, to stay visible) */
.symbol .runarrow {
  fill: var(--runarrow)
}

/* A running pump is shaded red, like the flow leaving it. */
.symbol .run {
  fill: var(--runFill);
  fill-opacity: var(--runOpacity);
  stroke: none
}

.component {
  cursor: move;
  color: var(--text)
}

.component.selected {
  color: var(--selected)
}

.hit {
  fill: transparent;
  stroke: none
}

.portDot {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0;
  cursor: crosshair
}

.component:hover .portDot,
.component.selected .portDot,
.drawingLine .portDot {
  opacity: 1
}

.portDot.highlighted {
  fill: var(--accent)
}

/* The grab area around a port dot: invisible, but it takes the pointer. */
.portGrab {
  fill: transparent;
  stroke: none;
  cursor: crosshair
}

#sheetSvg[data-mode=pan] .portGrab {
  pointer-events: none
}

.line {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.6;
  stroke-linejoin: round;
  pointer-events: none
}

.line.dashed {
  stroke-dasharray: 7 4
}

.line.selected {
  stroke: var(--selected);
  stroke-width: 2.6
}

.segmentHit {
  fill: none;
  stroke: transparent;
  stroke-width: 12;
  cursor: pointer
}

/* A line's segments can be dragged in Select mode. */
#sheetSvg[data-mode=select] .segmentHit.horizontalSegment {
  cursor: ns-resize
}

#sheetSvg[data-mode=select] .segmentHit.verticalSegment {
  cursor: ew-resize
}

.junctionDot {
  fill: var(--text);
  pointer-events: none
}

.componentLabel {
  font: 500 13px Inter, sans-serif;
  fill: var(--text);
  cursor: move;
  user-select: none
}

.componentLabel.selected {
  fill: var(--selected)
}

.selectionOutline {
  fill: none;
  stroke: var(--selected);
  stroke-dasharray: 4 3;
  stroke-width: 1;
  pointer-events: none
}

#linePreview {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-dasharray: 4 3;
  pointer-events: none
}

#labelEditor {
  position: fixed;
  z-index: 25;
  font-family: Inter, sans-serif;
  font-weight: 500;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--bg);
  color: var(--text);
  outline: none
}

#flowLayer circle {
  fill: var(--ballred);
  stroke: var(--bg);
  stroke-width: var(--ballring);
  /* The ring goes round the ball, outside it, so the ball keeps its size. */
  paint-order: stroke;
  pointer-events: none
}

#flowLayer circle.suction {
  fill: var(--ballblue)
}

#sheetSvg[data-mode=pan],
#sheetSvg[data-mode=pan] .component,
#sheetSvg.spacePanning,
#sheetSvg.spacePanning .component,
#sheetSvg.spacePanning .segmentHit {
  cursor: grab
}

#sheetSvg.panning,
#sheetSvg.panning .component {
  cursor: grabbing
}

#sheetSvg[data-mode=pan] .segmentHit {
  cursor: inherit
}

/* No port dots while panning: in Pan mode, or while Space is held to pan. */
#sheetSvg[data-mode=pan] .portDot,
#sheetSvg.spacePanning .portDot,
#sheetSvg.panning .portDot {
  opacity: 0
}

.selectBox {
  fill: var(--accent);
  fill-opacity: .08;
  stroke: var(--accent);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  pointer-events: none
}

.selectBox.crossingSelection {
  fill: #1f9d55;
  stroke: #1f9d55;
  fill-opacity: .1;
  stroke-dasharray: 5 4
}

@media(prefers-reduced-motion:no-preference) {
  .portDot {
    transition: opacity .12s
  }
}

/* Where two lines run on top of each other: an outlined, diagonally hatched
   box (as EAGLE shows design-rule errors), so it is seen without color. */
.overlap {
  fill: url(#hatch);
  stroke: var(--overlap);
  stroke-width: 1.5;
  stroke-dasharray: 3 1.5;
  pointer-events: none /* the line underneath can still be grabbed */
}

.overlapLine {
  stroke: var(--overlap);
  stroke-width: 3;
  stroke-linecap: square;
  pointer-events: none
}
