/* Plan Takeoff. Graphite chrome on white; colour belongs to the measurements, in chalk-line
   pigments. Quantities are set in osifont (ISO 3098 technical lettering) so they read as part
   of the drawing. */

@font-face { font-family: "osifont"; src: url("fonts/osifont.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 400; src: url("fonts/Barlow-Regular.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 500; src: url("fonts/Barlow-Medium.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Barlow"; font-weight: 600; src: url("fonts/Barlow-SemiBold.woff") format("woff"); font-display: swap; }

:root {
  --paper: #ffffff;
  --board: #dde2e6;
  --graphite: #262a2e;
  --pencil: #5f676f;
  --rule: #ccd2d7;
  --wash: #f3f5f6;
  --floor: #1f5fd6;
  --wall: #d02a2a;
  --roof: #1f8a4c;
  --count: #e8b400;
  --measure: #7b3fb0;
  --selection: #ff6a13;
  --selection-wash: #fff1e7;
  --lettering: "osifont", "Barlow", sans-serif;
  --text: "Barlow", system-ui, sans-serif;
  --toolbar-height: 52px;
}

* { box-sizing: border-box; }

/* Buttons set their own display, which would otherwise show hidden ones. */
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }

body {
  font: 400 15px/1.45 var(--text);
  color: var(--graphite);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---- Controls ---- */

/* Buttons and labels set their own display below; the hidden attribute must still win. */
[hidden] { display: none !important; }

button, .button, select, input {
  font: inherit;
  color: inherit;
}

button, .button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 11px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
  cursor: pointer;
  white-space: nowrap;
}

button:hover:not(:disabled), .button:hover { border-color: var(--graphite); }
button:disabled { color: var(--pencil); opacity: 0.55; cursor: default; }

.primary { background: var(--graphite); border-color: var(--graphite); color: var(--paper); }
.primary:hover:not(:disabled) { background: #000000; }

.quiet { border-color: transparent; background: transparent; color: var(--pencil); }
.quiet:hover:not(:disabled) { color: var(--graphite); border-color: var(--rule); }

select, input[type="text"], input[type="number"] {
  min-height: 32px;
  padding: 3px 7px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper);
}

input[type="number"] { width: 6.5em; }

:focus-visible { outline: 2px solid var(--selection); outline-offset: 2px; }

kbd {
  font: 500 11px/1 var(--text);
  color: var(--pencil);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 2px 4px;
}

.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { margin: 0; accent-color: var(--graphite); }

.note { color: var(--pencil); font-size: 13px; margin: 6px 0; }

.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---- Layout ---- */

body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--toolbar-height);
  padding: 8px 14px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.brand {
  font: 400 19px/1 var(--lettering);
  text-decoration: none;
  letter-spacing: 0.01em;
  padding-right: 6px;
}

.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-group.end { margin-left: auto; }

.tools { gap: 0; padding: 0 8px; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }

.tool { border-color: transparent; position: relative; padding: 4px 9px; }
/* Key hints only where there is room; the Keys dialog lists them all. */
@media (max-width: 1500px) { .tool kbd { display: none; } }
.tool[aria-pressed="true"] { border-color: var(--graphite); }
/* The active drawing tool is underlined in the colour it will draw with. */
.tool[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -1px;
  height: 3px;
  background: var(--graphite);
}
.tool[data-kind="floor"][aria-pressed="true"]::after { background: var(--floor); }
.tool[data-kind="wall"][aria-pressed="true"]::after { background: var(--wall); }
.tool[data-kind="roof"][aria-pressed="true"]::after { background: var(--roof); }
.tool[data-kind="count"][aria-pressed="true"]::after { background: var(--count); }
.tool[data-kind="measure"][aria-pressed="true"]::after { background: var(--measure); }

.scale-badge { font-family: var(--lettering); font-size: 15px; }
.scale-badge.missing { border-color: var(--selection); color: var(--selection); font-family: var(--text); }

.language { display: flex; }
.language button { min-height: 28px; padding: 2px 8px; border-radius: 0; color: var(--pencil); }
.language button:first-child { border-radius: 3px 0 0 3px; }
.language button:last-child { border-radius: 0 3px 3px 0; margin-left: -1px; }
.language button[aria-pressed="true"] { color: var(--graphite); border-color: var(--graphite); position: relative; }

.page-picker { max-width: 14em; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 410px; }

/* ---- Drawing board ---- */

.stage { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--board); }

canvas { flex: 1; min-height: 0; width: 100%; display: block; cursor: crosshair; touch-action: none; }
canvas[data-tool="select"] { cursor: default; }
canvas[data-panning] { cursor: grab; }

.stage.dragging { outline: 3px dashed var(--graphite); outline-offset: -10px; }

.statusbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 40px;
  padding: 4px 12px;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  font-size: 13.5px;
}

.status { flex: 1; min-width: 0; color: var(--pencil); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.readout { font: 400 15px/1 var(--lettering); white-space: pre; }
.view-controls { display: flex; align-items: center; gap: 4px; }
.view-controls button { min-height: 28px; padding: 2px 9px; }
.view-controls .check { margin-right: 8px; }

/* The first screen is laid out like a drawing's title block. */
.empty {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  width: min(40rem, calc(100% - 32px));
  background: var(--paper);
  border: 2px solid var(--graphite);
}

.empty h1 {
  font: 400 28px/1.15 var(--lettering);
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--graphite);
}

.empty ol { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.empty li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 3rem 1fr;
  column-gap: 14px;
  align-items: center;
  min-height: 46px;
  padding-right: 16px;
  border-bottom: 1px solid var(--rule);
}
.empty li::before {
  content: counter(step);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 400 20px/1 var(--lettering);
  border-right: 1px solid var(--rule);
}

.empty-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 18px 24px 8px; }
.drop-hint { color: var(--pencil); font-size: 13px; }
.privacy { margin: 0; padding: 4px 24px 18px; color: var(--pencil); font-size: 13px; }

/* ---- Side panel ---- */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-left: 1px solid var(--rule);
  background: var(--paper);
}

.panel > section { padding: 16px 18px; border-bottom: 1px solid var(--rule); }
.panel h2 { font-size: 16px; }

.takeoff > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.takeoff .check { font-size: 13px; color: var(--pencil); }

.group + .group { margin-top: 10px; }
.group > header { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0 4px; border-bottom: 1px solid var(--graphite); }
.group h3 { font-size: 14px; }
.subtotal { font: 400 14px/1.2 var(--lettering); white-space: pre; }
.group ul { list-style: none; margin: 0; padding: 0; }

.element { display: flex; align-items: center; border-bottom: 1px solid var(--wash); }
.element .pick {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  column-gap: 10px;
  align-items: baseline;
  border: 0;
  border-radius: 0;
  padding: 7px 4px;
  text-align: left;
  background: transparent;
}
.element .page { grid-column: 2; font-size: 12px; color: var(--pencil); }
.element .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.element .quantity { font: 400 15px/1 var(--lettering); text-align: right; }
.element .visibility { align-self: center; border-color: transparent; color: var(--pencil); font-size: 12.5px; min-height: 26px; padding: 2px 7px; }
.element.selected { background: var(--selection-wash); box-shadow: inset 3px 0 var(--selection); }
.element.hidden .name, .element.hidden .quantity { color: var(--pencil); text-decoration: line-through; }

.swatch { width: 12px; height: 12px; border: 1px solid rgba(38, 42, 46, 0.35); align-self: center; }
.element[data-kind="floor"] .swatch { background: var(--floor); }
.element[data-kind="wall"] .swatch { background: var(--wall); }
.element[data-kind="roof"] .swatch { background: var(--roof); }
.element[data-kind="count"] .swatch { background: var(--count); border-radius: 50%; }
/* A measurement is a line, not a surface: its swatch is a bar. */
.element[data-kind="measure"] .swatch { background: var(--measure); height: 3px; border: 0; }

.editor { background: var(--wash); }
.editor h2 { margin-bottom: 10px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fields label, .field { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--pencil); }
.fields input, .fields select { color: var(--graphite); width: 100%; }
.fields label:first-child, .fields label:nth-child(2) { grid-column: 1 / -1; }
.fields label.check { flex-direction: row; color: var(--graphite); }
.fields .check input { width: auto; }

table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13.5px; }
th { font-weight: 500; color: var(--pencil); text-align: right; padding: 4px 5px; border-bottom: 1px solid var(--graphite); }
td { text-align: right; padding: 4px 5px; border-bottom: 1px solid var(--wash); }
th:first-child, td:first-child { text-align: left; }
td:nth-child(2), td:nth-child(5), tfoot td:last-child { font-family: var(--lettering); font-size: 15px; white-space: nowrap; }
td input[type="number"] { width: 5.2em; text-align: right; min-height: 28px; padding: 2px 5px; }
tfoot td { border-bottom: 0; padding-top: 6px; }
tfoot tr:first-child td { border-top: 1px solid var(--graphite); }
tfoot .grand td { font-weight: 600; }
tfoot .grand td:last-child { font-size: 18px; }
#vat-rate { width: 4em; min-height: 26px; }

.legal { display: flex; flex-wrap: wrap; gap: 14px; padding: 14px 18px; margin-top: auto; font-size: 13px; color: var(--pencil); }

/* ---- Dialogs ---- */

dialog {
  width: min(30rem, calc(100% - 32px));
  border: 1px solid var(--graphite);
  border-radius: 4px;
  padding: 20px 22px;
  color: var(--graphite);
}
dialog::backdrop { background: rgba(38, 42, 46, 0.35); }
dialog h2 { font-size: 18px; margin-bottom: 8px; }
dialog section { margin: 14px 0; }
dialog form { margin-top: 14px; }
.offers { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.offers button { justify-content: center; min-height: 40px; }
.length-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.keys { padding-left: 18px; margin: 8px 0; }
.keys li { margin: 6px 0; }

/* ---- Narrow screens ---- */

@media (max-width: 900px) {
  body.app { height: auto; overflow: auto; }
  .workspace { grid-template-columns: 1fr; }
  .stage { height: 70vh; }
  .panel { border-left: 0; }
  .tools { border: 0; padding: 0; flex-wrap: wrap; }
  .tool { padding: 4px 7px; }
  .tool kbd { display: none; }
}

/* ---- Printed report ---- */

.report { display: none; }

@media print {
  body.app { display: block; height: auto; overflow: visible; }
  .toolbar, .workspace, dialog { display: none !important; }
  .report { display: block; font-size: 11pt; }
  .report header { border-bottom: 2px solid var(--graphite); margin-bottom: 12pt; padding-bottom: 6pt; }
  .report h1 { font: 400 20pt/1.2 var(--lettering); }
  .report h2 { margin: 14pt 0 4pt; font-size: 13pt; }
  .report p { margin: 2pt 0; }
  .report figure { margin: 0 0 12pt; break-inside: avoid; }
  .report img { width: 100%; border: 1px solid var(--rule); }
  .report figcaption { color: var(--pencil); font-size: 9pt; }
  .report table { break-inside: auto; }
  .report tr { break-inside: avoid; }
}

/* ---- Document pages (privacy, terms, company, security) ---- */

body.doc { max-width: 44rem; margin: 0 auto; padding: 0 20px; }
.doc-header { padding: 18px 0; border-bottom: 1px solid var(--rule); }
body.doc main { padding: 24px 0 8px; }
body.doc h1 { font: 400 30px/1.2 var(--lettering); margin-bottom: 14px; }
body.doc h2 { font-size: 17px; margin: 26px 0 6px; }
body.doc p, body.doc li { line-height: 1.6; }
body.doc ul { padding-left: 20px; }
body.doc dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
body.doc dl > div { display: contents; }
body.doc dt { color: var(--pencil); }
body.doc dd { margin: 0; }
body.doc .legal { padding: 22px 0; border-top: 1px solid var(--rule); margin-top: 24px; }
