/* Copyright 2026 David Pettersson
   SPDX-License-Identifier: Apache-2.0 */

/* A drafting table: white sheets on a pale board, inked in drumlin's warm
   black with a fine pen for rules and a medium pen for frames. */

:root {
  --ink: #22201c;
  --ink-soft: #6b665d;
  --rule: #d8d4ca;
  --board: #f4f2ec;
  --grid: #e9e6dd;
  --sheet: #fff;
  --error: #9b2c1f;
  --fine: 0.75px;
  --medium: 1.25px;
  --sans: Helvetica, Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--board);
  color: var(--ink);
  font: 13px/1.4 var(--sans);
}

body { display: flex; flex-direction: column; }

/* Title strip */
.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--sheet);
  border-bottom: var(--medium) solid var(--ink);
}

.bar h1 {
  margin: 0 12px 0 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.bar h1 span { font-weight: 400; color: var(--ink-soft); }

.version {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
  font: 11px var(--mono);
  text-decoration: none;
}

.version svg { display: block; }
.version:hover { color: var(--ink); }
.version:hover span { text-decoration: underline; }

.grow { flex: 1; }

.field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

select, button {
  font: 12px var(--sans);
  color: var(--ink);
  background: var(--sheet);
  border: var(--fine) solid var(--ink);
  border-radius: 0;
  padding: 3px 8px;
  height: 24px;
}

select { padding-right: 4px; text-transform: none; letter-spacing: 0; }

button { cursor: pointer; }
button:hover, select:hover { background: var(--board); }
button:active { background: var(--grid); }
button:focus-visible, select:focus-visible { outline: var(--medium) solid var(--ink); outline-offset: 1px; }
button.done { background: var(--ink); color: var(--sheet); }
button:disabled { opacity: 0.4; cursor: default; }

/* Two sheets side by side */
.panes {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 2fr) 3fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--sheet);
  border: var(--medium) solid var(--ink);
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 10px;
  border-bottom: var(--fine) solid var(--ink);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pane-head .quiet {
  margin-left: auto;
  color: var(--ink-soft);
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.zoom { display: flex; gap: 0; margin-left: 8px; }
.zoom button { height: 22px; min-width: 26px; padding: 0 6px; font-size: 11px; }
.zoom button + button { border-left: none; }
#zoom-level { min-width: 48px; font-variant-numeric: tabular-nums; }

/* Editor */
#editor { flex: 1; min-height: 0; }
#editor .cm-editor { height: 100%; font-size: 13px; }
#editor .cm-editor.cm-focused { outline: none; }
#editor .cm-scroller { font-family: var(--mono); line-height: 1.55; }
#editor .cm-gutters { background: var(--sheet); border-right: var(--fine) solid var(--rule); color: #a8a296; }
#editor .cm-activeLine { background: #faf9f5; }
#editor .cm-activeLineGutter { background: #faf9f5; color: var(--ink); }
#editor .cm-selectionBackground, #editor .cm-focused .cm-selectionBackground { background: #e6e1d3 !important; }
#editor .cm-cursor { border-left: 1.5px solid var(--ink); }
#editor .cm-matchingBracket { background: none; outline: var(--fine) solid var(--ink-soft); }
#editor .cm-lintRange-error { background-image: none; text-decoration: underline wavy var(--error); text-decoration-thickness: 1px; text-underline-offset: 3px; }
#editor .cm-tooltip { border: var(--fine) solid var(--ink); background: var(--sheet); font: 12px var(--sans); }
#editor .cm-diagnostic-error { border-left: 3px solid var(--error); }

/* Drawing board: faint drafting grid behind a white sheet */
#board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background-color: var(--board);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
}

#sheet {
  display: inline-block;
  margin: 24px;
  background: var(--sheet);
  box-shadow: 0 0 0 var(--fine) var(--rule);
  transition: opacity 120ms ease;
}

#sheet:empty { display: none; }
#sheet.stale { opacity: 0.45; }
#sheet svg { display: block; }

#message {
  padding: 8px 12px;
  border-top: var(--fine) solid var(--ink);
  font: 12px/1.45 var(--mono);
  color: var(--error);
  white-space: pre-wrap;
  max-height: 30%;
  overflow: auto;
}

@media (max-width: 760px) {
  .bar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; padding: 10px 16px; }
}
