/* Workshop tool, not a website: quiet steel chrome, the plan is the only
   thing allowed to be bright. Numbers are set in a mono face because on a
   shop drawing the dimension IS the content. */

:root {
  --steel-900: #1B2025;
  --steel-800: #242B31;
  --steel-700: #2F373E;
  --steel-600: #3C454D;
  --steel-500: #556069;
  --steel-300: #8C98A2;
  --steel-100: #C8D0D6;
  --paper:     #EDEFEA;
  --top-fill:  #DCE2E6;
  --amber:     #E0A62B;
  --amber-dim: #8A6613;
  --alert:     #C2593C;

  --ui: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--ui);
  font-size: 13.5px;
  color: var(--steel-100);
  background: var(--steel-900);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 46px auto 1fr;
  height: 100vh;
}

button { font: inherit; cursor: pointer; }
input:focus-visible, button:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

/* --- title bar --- */

.bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 14px;
  background: var(--steel-900);
  border-bottom: 1px solid #0F1317;
}

.bar h1 { margin: 0; font-size: 13.5px; font-weight: 600; color: #fff; }

.bar-actions { margin-left: auto; display: flex; gap: 6px; }

.bar-actions button {
  padding: 5px 11px;
  color: var(--steel-100);
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
}

.bar-actions button:hover { background: var(--steel-600); }

/* Output actions. Colour-coded because these are the four things the
   estimator reaches for, and they're destinations rather than edits. */
.bar-outputs {
  display: flex;
  gap: 6px;
  padding-left: 14px;
  margin-left: 14px;
  border-left: 1px solid var(--steel-600);
}

.out {
  padding: 5px 11px;
  color: #fff;
  border: 1px solid transparent;
  border-radius: 3px;
}

.out-save  { background: #A63F34; }
.out-load  { background: #38784F; }
.out-quote { background: #2F6296; }
.out-files { background: #1E6F71; }
.out-myob  { background: #654A94; }

.out:hover { filter: brightness(1.16); }

/* --- feature ribbon --- */

.ribbon {
  grid-column: 1 / -1;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 8px 12px 10px;
  overflow-x: auto;
  background: var(--steel-800);
  border-bottom: 1px solid #0F1317;
}

.rib-group { padding: 0 16px; }
.rib-group + .rib-group { border-left: 1px solid var(--steel-600); }
.rib-group:first-child { padding-left: 0; }

.rib-label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--steel-500);
}

.rib-blocks { display: flex; gap: 6px; }

.block {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--steel-100);
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
  cursor: grab;
  touch-action: none;
}

.block:hover { border-color: var(--amber-dim); background: var(--steel-600); }
.block:active { cursor: grabbing; }
.block svg { width: 17px; height: 17px; flex: none; }

.block.unavailable { opacity: .38; cursor: not-allowed; }

/* Icons get pasted in from whatever set you like, so normalise them here.
   Shapes carrying no fill or stroke of their own are drawn as amber
   outlines; shapes that bring their own keep their nature but get
   recoloured, so a solid icon stays solid. */
:is(.block, .cmp-title) svg *:not([fill]):not([stroke]) {
  fill: none;
  stroke: var(--amber);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:is(.block, .cmp-title) svg [fill]:not([fill="none"]) { fill: var(--amber); }
:is(.block, .cmp-title) svg [stroke]:not([stroke="none"]) { stroke: var(--amber); }

/* Greyed out when the feature has nothing to attach to yet. Written at the
   same specificity as the rules above so it actually wins. */
.block.unavailable svg *:not([fill]):not([stroke]) { stroke: var(--steel-300); }
.block.unavailable svg [fill]:not([fill="none"]) { fill: var(--steel-300); }
.block.unavailable svg [stroke]:not([stroke="none"]) { stroke: var(--steel-300); }

.ghost {
  position: fixed;
  top: 0; left: 0;
  z-index: 20;
  padding: 5px 10px;
  font-size: 12.5px;
  color: #141A1F;
  background: var(--amber);
  border-radius: 3px;
  pointer-events: none;
}

/* --- component sidebar --- */

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--steel-800);
  border-right: 1px solid #0F1317;
}

.sidebar {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 24px;
}

/* Pinned to the bottom of the column: the number the estimator is actually
   working towards stays in view however long the component list gets. */
.price {
  padding: 10px 12px 12px;
  background: var(--steel-900);
  border-top: 1px solid #0F1317;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-row span { flex: 1; color: var(--steel-300); }

.price-row input {
  width: 104px;
  font-family: var(--mono);
  font-size: 14px;
  text-align: right;
  color: var(--amber);
}

.price-row input:read-only {
  color: var(--steel-100);
  background: var(--steel-700);
  border-color: var(--steel-700);
}

.price .check { margin-top: 8px; font-size: 12px; color: var(--steel-500); }

.sidebar .empty { margin: 14px 4px; line-height: 1.55; color: var(--steel-500); }

.cmp {
  margin-bottom: 6px;
  background: var(--steel-700);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
}

.cmp.is-open { border-color: var(--amber-dim); }

.cmp > header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
}

.cmp-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  padding: 0;
  color: var(--steel-100);
  background: none;
  border: 0;
  text-align: left;
}

.cmp-title svg { width: 15px; height: 15px; flex: none; }
.cmp-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The item number, shown the same way on the block and on the plan. */
.cmp-title .ref {
  flex: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--amber);
}

.cmp .sum {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--steel-300);
}

.cmp .x {
  padding: 0 4px;
  font-size: 15px;
  line-height: 1;
  color: var(--steel-500);
  background: none;
  border: 0;
}

.cmp .x:hover { color: var(--alert); }

.cmp > .fields { display: none; }

.cmp.is-open > .fields {
  display: block;
  padding: 4px 9px 10px;
  border-top: 1px solid var(--steel-600);
}

.cmp-children {
  padding: 2px 0 4px 10px;
  margin-left: 8px;
  border-left: 1px solid var(--steel-600);
}

.cmp-children .cmp { background: var(--steel-800); }

/* A join isn't a placed thing, so it reads as a note between components. */
.cmp-join { border-style: dashed; }
.cmp-join > header { padding-right: 10px; }
.cmp-join .cmp-title { gap: 8px; }

/* --- fields --- */

.field { margin-top: 8px; }
.field[hidden] { display: none; }

.field .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field .row > span { flex: 1; color: var(--steel-300); }
.field .row.stack { flex-direction: column; align-items: stretch; gap: 4px; }
.field .row em { font-style: normal; font-size: 11px; color: var(--steel-500); }

.field-label { margin: 0 0 4px; color: var(--steel-300); }

.field-note {
  margin: 10px 0 -2px;
  font-size: 11px;
  color: var(--steel-500);
}

input[type="number"], input[type="text"], select {
  width: 92px;
  padding: 4px 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #fff;
  background: var(--steel-800);
  border: 1px solid var(--steel-600);
  border-radius: 3px;
}

.field .row.stack input[type="text"] { width: 100%; }
select { width: 128px; font-family: var(--ui); }

.opts { display: flex; flex-direction: column; gap: 3px; }

.opt, .check {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.opt input, .check input { accent-color: var(--amber); }

/* --- stage --- */

.stage { position: relative; background: var(--paper); overflow: hidden; }

#plan { display: block; width: 100%; height: 100%; touch-action: none; }

.hud, .toast {
  position: absolute;
  bottom: 12px;
  margin: 0;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #6C7A85;
}

.hud { right: 14px; }

.toast {
  left: 14px;
  padding: 6px 10px;
  font-family: var(--ui);
  color: #fff;
  background: var(--alert);
  border-radius: 3px;
  opacity: 0;
  transition: opacity .18s;
}

.toast.show { opacity: 1; }

/* --- plan view --- */

.grid-minor { stroke: #DDE1DB; stroke-width: 1; }
.grid-major { stroke: #C6CCC3; stroke-width: 1; }
.wall { stroke: #5B6771; }

.door-gap { fill: var(--paper); stroke: none; }
.door-swing { fill: none; stroke: #9C7C33; stroke-width: 1.25; stroke-dasharray: 5 4; }

.node { cursor: move; }
.top-body { stroke-width: 2; }
.child-body { stroke-width: 1.75; }

/* Direct children only, so highlighting a bench top doesn't light up every
   cutout sitting on it. */
.is-selected > .top-body,
.is-selected > .child-body,
.is-selected > .door-gap { stroke: var(--amber); stroke-width: 3; }

/* Feature icon drawn inside its own footprint on the plan. */
.glyph { pointer-events: none; }

.glyph *:not([fill]):not([stroke]) {
  fill: none;
  stroke: #8A96A0;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.glyph [fill]:not([fill="none"]) { fill: #8A96A0; }
.glyph [stroke]:not([stroke="none"]) { stroke: #8A96A0; vector-effect: non-scaling-stroke; }

.is-selected > .glyph *:not([fill]):not([stroke]) { stroke: var(--amber-dim); }

/* Painted over a united seam in the body colour. Must match the bench top
   fill in benchtop.json for the joint to vanish cleanly. */
.seam-union {
  stroke: var(--top-fill);
  stroke-width: 3.5;
  stroke-linecap: butt;
}

/* The filled inside corner of a union, and the radiused edge over it. */
.fillet-fill { fill: var(--top-fill); stroke: none; }
.fillet-edge { stroke: #55636E; stroke-width: 2; }

.dim { fill: #55616B; font-family: var(--mono); }

.ref-label {
  fill: #46525C;
  font-family: var(--mono);
  pointer-events: none;
}

.is-selected > .ref-label { fill: #8A6613; }
.origin-mark { stroke: var(--amber); stroke-width: 2; }
.centre-mark { stroke: var(--amber); stroke-width: 1.5; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
