/* The Graph Lab: the stage on the left, the panel on the right. */

body.lab { overflow: hidden; background: #20202a; }

#stage { position: fixed; left: 0; top: 0; bottom: 0; right: min(470px, 42vw); }
#stage canvas#view { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage #hud { position: absolute; inset: 0; pointer-events: none; }

#lab-summary {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 8px 16px;
  font-weight: 700;
  box-shadow: 0 4px 0 var(--shadow);
  max-width: 90%;
  text-align: center;
}

#panel {
  position: fixed;
  right: 0; top: 0; bottom: 0;
  width: min(470px, 42vw);
  overflow-y: auto;
  background: var(--paper);
  border-left: 3px solid var(--ink);
  padding: 14px 16px 30px;
}
#panel h1 {
  margin: 0;
  font: 900 34px var(--display);
  text-transform: uppercase;
  color: var(--truck);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 0 3px 0 var(--ink);
}
#panel .subtitle { margin: 4px 0; font-size: 14px; }
#panel #back { font-size: 13px; color: var(--teal); font-weight: 700; }
#panel section { border-top: 2px dashed rgba(27, 27, 34, 0.2); padding-top: 10px; margin-top: 12px; }
#panel h2 { margin: 0 0 2px; font: 800 20px var(--display); text-transform: uppercase; }
#panel h3 { margin: 10px 0 2px; font: 800 15px var(--display); text-transform: uppercase; }
#panel .hint { font-size: 12.5px; color: #555; margin: 2px 0 6px; }
#panel .error { color: var(--red); font-weight: 700; font-size: 13px; min-height: 1em; }

.runbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.runbar .big { font-size: 17px; padding: 8px 14px; }
.runbar label { font-size: 12px; }
select { max-width: 100%; }
select, input { font: 600 14px var(--body); border: 2px solid var(--ink); border-radius: 8px; padding: 3px 6px; background: #fff; }

#graph-box { position: relative; height: 230px; background: var(--cream); border: 2px solid var(--ink); border-radius: 10px; }
#graph { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#graph .grid { stroke: rgba(27, 27, 34, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
#graph .axis { stroke: var(--ink); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
#graph .curve { fill: none; stroke: var(--teal); stroke-width: 3; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
#graph-labels { position: absolute; inset: 0; pointer-events: none; font: 600 10px var(--body); color: #555; }
#graph-labels span { position: absolute; transform: translate(-50%, 2px); }
#graph-labels span.y { transform: translate(-115%, -50%); }
.dot {
  position: absolute;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: var(--teal);
  cursor: ns-resize;
  pointer-events: auto;
  touch-action: none;
}
.dot:hover, .dot.dragging { background: #ffd166; }
.mark {
  position: absolute;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 3px solid #f4a261;
  background: rgba(255, 209, 102, 0.35);
  pointer-events: none;
}
.pen {
  position: absolute;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 3px;
  background: var(--red);
  border: 2px solid var(--ink);
  pointer-events: none;
}

#machine { width: 100%; border-collapse: collapse; font-size: 13px; }
#machine th { font-size: 11px; text-align: right; padding: 2px 4px; border-bottom: 2px solid var(--ink); }
#machine td { text-align: right; padding: 2px 4px; border-bottom: 1px solid rgba(27, 27, 34, 0.12); font-variant-numeric: tabular-nums; }
#machine td:nth-child(2) { font-weight: 800; }
#machine tr.next { background: #fff0b3; }

.formula { font: 800 18px var(--display); }
#formula { width: 220px; font: 700 18px ui-monospace, Menlo, monospace; }
#presets { display: flex; flex-wrap: wrap; gap: 4px; }
#presets button { font: 600 13px ui-monospace, Menlo, monospace; padding: 2px 8px; box-shadow: 0 2px 0 var(--ink); }
.domain { display: flex; gap: 10px; margin-top: 8px; font-size: 13px; align-items: center; flex-wrap: wrap; }

#tree { list-style: none; padding: 0; margin: 4px 0; font-size: 13px; }
#tree li { padding: 2px 6px; border-radius: 6px; margin: 1px 0; }
#tree li .kind { font-size: 10px; color: #777; margin-right: 6px; text-transform: uppercase; }
#tree li.lit { background: #ffd166; font-weight: 700; }
#tree li.d1 { margin-left: 16px; } #tree li.d2 { margin-left: 32px; } #tree li.d3 { margin-left: 48px; }
#log { font-size: 12.5px; padding-left: 18px; margin: 4px 0; }
#log li { margin: 2px 0; }
#log li:last-child { font-weight: 700; }
#ideas { font-size: 13px; padding-left: 18px; }
#ideas li { margin: 4px 0; }

@media (max-width: 800px) {
  #stage { right: 0; bottom: 45vh; }
  #panel { top: 55vh; width: 100%; border-left: 0; border-top: 3px solid var(--ink); }
}

#graph .interp { fill: none; stroke: #f77f00; stroke-width: 2.5; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
#graph .gap { fill: rgba(230, 57, 70, 0.22); stroke: none; }
.interp-error { font-size: 13px; font-weight: 700; color: #b5651d; min-height: 1em; }
.join { font-size: 13px; }

body[data-kind="0"] [data-kind]:not([data-kind="0"]),
body[data-kind="1"] [data-kind]:not([data-kind="1"]),
body[data-kind="2"] [data-kind]:not([data-kind="2"]) { display: none !important; }
#tabs { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
#tabs button { font-size: 13px; padding: 5px 10px; box-shadow: 0 2px 0 var(--ink); }
#tabs button.on { background: var(--truck); }
.graph-box { position: relative; height: 230px; background: var(--cream); border: 2px solid var(--ink); border-radius: 10px; margin: 8px 0; }
.graph-box svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.graph-labels { position: absolute; inset: 0; pointer-events: none; font: 600 10px var(--body); color: #555; }
.graph-labels span { position: absolute; transform: translate(-50%, 2px); }
.graph-labels span.y { transform: translate(-115%, -50%); }
#fly-graph .path { fill: none; stroke: #e76f51; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#fly-graph .bar { fill: #fff3c4; stroke: #b5651d; stroke-width: 1; vector-effect: non-scaling-stroke; }
#fly-graph .target { fill: none; stroke: var(--teal); stroke-width: 2.5; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }
#fly-graph .ledge { fill: #a47148; stroke: var(--ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#fly-graph .bed { stroke: #1d4ed8; stroke-width: 4; vector-effect: non-scaling-stroke; }
#fly-graph .axis, #jug-graph .axis { stroke: var(--ink); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
#fly-graph .grid { stroke: rgba(27, 27, 34, 0.12); stroke-width: 1; vector-effect: non-scaling-stroke; }
.sliders label { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 3px 0; }
.sliders input { flex: 1; }
#fly-arcs { font: 600 14px ui-monospace, Menlo, monospace; padding-left: 20px; }
#fly-arcs li span { display: block; font-weight: 400; color: #555; font-size: 13px; }
#fly-target, #jug-pattern { font: 700 18px ui-monospace, Menlo, monospace; width: 200px; }
#fly-log { font-size: 12.5px; padding-left: 18px; }
#fly-ideas, #jug-ideas { font-size: 13px; padding-left: 18px; }
.presets { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.presets button { font: 700 14px ui-monospace, Menlo, monospace; padding: 2px 9px; box-shadow: 0 2px 0 var(--ink); }
#jug-box { height: 170px; }
#jug-graph path { fill: none; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
#jug-graph path.bad { stroke-dasharray: 4 3; stroke-width: 3.5; }
.beat { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; }
.beat.h1 { background: #ddd; }
.digit { position: absolute; transform: translate(-50%, 0); font: 800 15px ui-monospace, Menlo, monospace; color: var(--ink); }

#panel #lang { margin-left: 10px; }
