/* Nebraska OSP Basemap Builder
 *
 * The page is dressed as the thing it produces: a plotted drawing sheet.
 * Sheet border with corner ticks, faint drafting grid, drafting-style callout
 * headers, and a title block along the bottom that mirrors the real one the
 * builder writes into every layout - it fills in live from the form.
 * Palette and typefaces are inherited from blakeagjones.com so this reads as
 * part of that site rather than a bolted-on tool.
 */

:root {
  --primary: #c8102e;          /* Nebraska red - actions, sheet number */
  --primary-dim: #7d0a1d;
  --secondary: #00ff88;        /* plotter green - OK states, live values */
  --accent: #f5d130;           /* drafting yellow - warnings */
  --bg: #0a0a0a;
  --surface: #111111;
  --surface2: #1a1a1a;
  --text: #e8e8e8;
  --text-dim: #888888;
  --border: #2a2a2a;
  --rule: #3a3a3a;             /* drafting line weight */
  --grid: rgba(255, 255, 255, .028);

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  /* Drafting grid: 1/4" minor squares over a heavier 1" major. */
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 96px 96px, 96px 96px;
}

/* ---------- sheet frame ---------- */
.sheet {
  position: relative;
  max-width: 1020px;
  margin: 26px auto 40px;
  border: 1px solid var(--rule);
  background: linear-gradient(180deg, rgba(17,17,17,.92), rgba(10,10,10,.92));
}
/* Corner registration ticks, like a plotted sheet. */
.sheet::before, .sheet::after {
  content: ""; position: absolute; width: 16px; height: 16px; pointer-events: none;
}
.sheet::before { top: 6px;    left: 6px;  border-top: 2px solid var(--primary); border-left: 2px solid var(--primary); }
.sheet::after  { bottom: 6px; right: 6px; border-bottom: 2px solid var(--primary); border-right: 2px solid var(--primary); }

.sheet-inner { padding: 30px 34px 0; }

/* ---------- header ---------- */
.masthead {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 2px solid var(--rule);
}
.masthead h1 {
  margin: 0; font-size: 25px; line-height: 1.15; font-weight: 700;
  letter-spacing: -.015em;
}
.masthead h1 .accent { color: var(--primary); }
.masthead .sub {
  margin: 7px 0 0; font-family: var(--mono); font-size: 11.5px;
  color: var(--text-dim); letter-spacing: .1em; text-transform: uppercase;
}
.sheet-id {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em;
  color: var(--text-dim); border: 1px solid var(--rule); padding: 4px 9px;
  align-self: flex-start;
}
.sheet-id b { color: var(--primary); font-weight: 700; }

/* plotter status LED */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .09em;
  text-transform: uppercase; padding: 7px 12px;
  border: 1px solid var(--rule); background: var(--surface2); color: var(--text-dim);
  white-space: nowrap;
}
.status::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; box-shadow: 0 0 8px currentColor;
}
.status.ok   { color: var(--secondary); border-color: #14532d; }
.status.warn { color: var(--accent);    border-color: #4a3d10; }
.status.err  { color: var(--primary);   border-color: var(--primary-dim); }
.status.wait::before { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- drafting callout section headers ---------- */
.step { padding: 26px 0; border-bottom: 1px dashed var(--border); }
.step:last-of-type { border-bottom: 0; }
.step > h2 {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 20px; font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: .17em; text-transform: uppercase; color: var(--text);
}
.step > h2 .num {
  display: grid; place-items: center; width: 24px; height: 24px; flex: none;
  border: 1px solid var(--primary); color: var(--primary);
  font-size: 11px; border-radius: 50%;
}
.step > h2::after {
  content: ""; flex: 1 1 auto; height: 1px; background: var(--rule);
}

/* ---------- dropzone as a placement window ---------- */
.drop {
  position: relative; border: 1px dashed var(--rule); background: rgba(0,0,0,.28);
  padding: 34px 20px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over {
  border-color: var(--primary); background: rgba(200,16,46,.05); outline: none;
}
/* crosshair marks at each corner of the window */
.drop span.tick { position: absolute; width: 9px; height: 9px; border: 0; }
.drop span.tick.tl { top: -1px; left: -1px;  border-top: 2px solid var(--rule); border-left: 2px solid var(--rule); }
.drop span.tick.tr { top: -1px; right: -1px; border-top: 2px solid var(--rule); border-right: 2px solid var(--rule); }
.drop span.tick.bl { bottom: -1px; left: -1px;  border-bottom: 2px solid var(--rule); border-left: 2px solid var(--rule); }
.drop span.tick.br { bottom: -1px; right: -1px; border-bottom: 2px solid var(--rule); border-right: 2px solid var(--rule); }
.drop.has-file { padding: 18px; cursor: default; }
.drop.has-file .drop-inner { display: none; }
.drop-icon {
  width: 26px; height: 26px; fill: none; stroke: var(--primary);
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 10px;
}
.drop-title { margin: 0 0 5px; font-weight: 600; font-size: 15px; }
.drop-hint {
  margin: 0; font-family: var(--mono); font-size: 11px; color: var(--text-dim);
  letter-spacing: .06em;
}
.link { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

.chip {
  display: inline-flex; align-items: center; gap: 12px; max-width: 100%;
  background: var(--surface2); border: 1px solid var(--rule);
  padding: 9px 10px 9px 14px; font-family: var(--mono); font-size: 12.5px;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--secondary); }
.chip button {
  background: none; border: 0; color: var(--text-dim); font-size: 18px;
  line-height: 1; cursor: pointer; padding: 0 3px;
}
.chip button:hover { color: var(--primary); }

/* ---------- fields ---------- */
.grid > .wide { grid-column: span 2; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(216px, 1fr)); gap: 16px; }
label {
  display: block; font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
  font-weight: 500; letter-spacing: .13em; text-transform: uppercase;
}
label small {
  display: block; margin-top: 5px; font-size: 10px; letter-spacing: .04em;
  text-transform: none; line-height: 1.5;
}
input[type=text], input[type=number], input:not([type]), select {
  width: 100%; margin-top: 7px; padding: 10px 11px;
  background: rgba(0,0,0,.4); color: var(--text);
  border: 1px solid var(--rule); border-radius: 0;
  font: 14px var(--mono); letter-spacing: .02em;
}
input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}
input::placeholder { color: #555; }

.dual { display: flex; gap: 8px; margin-top: 7px; }
.dual select { flex: 2 1 60%; margin-top: 0; min-width: 0; }
.dual input  { flex: 1 1 34%; margin-top: 0; min-width: 0; }
#size_derived {
  color: var(--secondary); font-family: var(--mono); font-size: 11px;
  letter-spacing: .05em; text-transform: none; display: block; margin-top: 6px;
}

/* ---------- layer toggles as a legend ---------- */
.toggles { border: 1px solid var(--rule); padding: 16px 18px 18px; margin: 22px 0 0; background: rgba(0,0,0,.22); }
.toggles legend {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .17em;
  text-transform: uppercase; color: var(--primary); padding: 0 8px;
}
.check {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 13px;
  color: var(--text); font-size: 14px; cursor: pointer; font-family: var(--sans);
  /* `label` above is styled as a CAD field caption (mono, uppercase, tracked);
     checkbox rows are prose, so they opt back out of all three. */
  text-transform: none; letter-spacing: normal; font-weight: 500;
}
.check input {
  margin: 2px 0 0; width: 15px; height: 15px; flex: none;
  accent-color: var(--primary);
}
.check em {
  display: block; font-style: normal; color: var(--text-dim);
  font-size: 12px; margin-top: 4px; line-height: 1.55;
  text-transform: none; letter-spacing: normal;
}
.check strong { font-weight: 600; }
.toggles .check:first-of-type { margin-top: 4px; }

.subgrid { margin: 12px 0 6px 27px; gap: 12px; }
.subgrid label { font-size: 10px; }
.subgrid.solo { grid-template-columns: minmax(240px, 420px); }
.subgrid.disabled { opacity: .35; pointer-events: none; }

/* ---------- actions ---------- */
.actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 26px 0 30px; }
.primary {
  background: var(--primary); color: #fff; border: 0;
  padding: 13px 26px; font: 700 12px var(--mono); letter-spacing: .15em;
  text-transform: uppercase; cursor: pointer; text-decoration: none;
  display: inline-block; transition: background .15s, box-shadow .15s;
}
.primary:hover { background: #e01536; box-shadow: 0 0 18px rgba(200,16,46,.45); }
.primary:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.ghost {
  background: none; color: var(--text-dim); border: 1px solid var(--rule);
  padding: 10px 18px; font: 600 11px var(--mono); letter-spacing: .13em;
  text-transform: uppercase; cursor: pointer; margin-top: 16px;
}
.ghost:hover { color: var(--text); border-color: var(--primary); }
.note { margin: 0; font-family: var(--mono); font-size: 11px; color: var(--text-dim); letter-spacing: .04em; }

/* ---------- run panel: a plotter console ---------- */
.run { border-top: 2px solid var(--rule); padding: 26px 0 30px; }
.run-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.run-head h2 {
  margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: .17em;
  text-transform: uppercase;
}
.bar { height: 3px; background: var(--surface2); overflow: hidden; margin-bottom: 16px; }
#bar-fill { height: 100%; width: 0; background: var(--primary); transition: width .4s ease; }
#bar-fill.indeterminate { width: 30%; animation: sweep 1.5s ease-in-out infinite; }
@keyframes sweep { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

.log {
  background: #050505; border: 1px solid var(--rule);
  padding: 15px 17px; max-height: 330px; overflow: auto; margin: 0;
  font: 12px/1.7 var(--mono); color: #9fb3a6;
  white-space: pre-wrap; word-break: break-word;
}
.log .l-warn { color: var(--accent); }
.log .l-err  { color: var(--primary); }

.warnings {
  margin-top: 16px; border-left: 3px solid var(--accent); background: rgba(245,209,48,.06);
  padding: 13px 16px; font-size: 13px; color: #e8d69a;
}
.warnings p { margin: 0 0 7px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; }
.warnings ul { margin: 0; padding-left: 18px; }
.warnings li { margin-bottom: 6px; word-break: break-word; }

/* result reads as an approval stamp */
.result {
  margin-top: 18px; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  border: 2px solid var(--secondary); background: rgba(0,255,136,.05); padding: 18px 20px;
}
.result-title {
  margin: 0; font-family: var(--mono); font-size: 12px; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--secondary);
}
.result-meta { margin: 6px 0 0; font-family: var(--mono); font-size: 11px; color: var(--text-dim); word-break: break-word; }
.result .primary { background: var(--secondary); color: #04210f; }
.result .primary:hover { background: #4dffab; box-shadow: 0 0 18px rgba(0,255,136,.4); }

.failure {
  margin-top: 16px; border-left: 3px solid var(--primary); background: rgba(200,16,46,.07);
  padding: 14px 16px; color: #f0a8a8; font: 12.5px/1.7 var(--mono);
  white-space: pre-wrap; word-break: break-word;
}

/* ---------- title block ---------- */
.titleblock {
  border-top: 2px solid var(--rule);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  background: rgba(0,0,0,.35);
}
.tb-cell { padding: 11px 14px; border-right: 1px solid var(--border); min-width: 0; }
.tb-cell:last-child { border-right: 0; }
.tb-cell .k {
  font-family: var(--mono); font-size: 9px; letter-spacing: .17em;
  text-transform: uppercase; color: var(--text-dim);
}
.tb-cell .v {
  font-family: var(--mono); font-size: 12.5px; color: var(--text); margin-top: 5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-cell .v.green { color: var(--secondary); }
.tb-cell .v.red { color: var(--primary); font-weight: 700; }

footer {
  max-width: 1020px; margin: 0 auto 44px; padding: 0 34px;
  font-family: var(--mono); font-size: 10.5px; color: #666;
  letter-spacing: .07em; display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
footer a { color: var(--text-dim); text-decoration: none; border-bottom: 1px solid var(--border); }
footer a:hover { color: var(--primary); border-color: var(--primary); }

@media (max-width: 620px) {
  .sheet { margin: 12px; }
  .sheet-inner { padding: 22px 18px 0; }
  .masthead h1 { font-size: 21px; }
  .result { flex-direction: column; align-items: stretch; }
  .result .primary { text-align: center; }
  footer { padding: 0 18px; }
}
