@font-face {
  font-family: "Chivo Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("fonts/chivo-mono/chivo-mono-latin-wght-normal.woff2") format("woff2");
}

/* werk's world with the house's red: graphit ground, weiss walls, mist machines, one red square */

:root {
  color-scheme: dark;
  --graphit: #1e2226;
  --night: #2a2f34;
  --weiss: #f6f6f3;
  --mist: #a0a7ae;
  --stahl: #5c636b;
  --rot: #ef3e24;
  --mono: "Chivo Mono", ui-monospace, Menlo, Consolas, monospace;
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --pad-x: 48px;
  --pad-y: 40px;
  --wall: 6px;
  --wall-gap: 3px;
}

@media (max-width: 719px) {
  :root {
    --pad-x: 16px;
    --pad-y: 24px;
    --wall: 5px;
    --wall-gap: 2.5px;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--graphit);
  color: var(--weiss);
}

body {
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.sheet {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: var(--pad-y) var(--pad-x);
  /* equipment can extend beyond the sheet */
  overflow: clip;
}

.frame {
  margin: 0;
}

.plan {
  display: block;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  stroke-miterlimit: 8;
}

/* a wall in plan view is two lines: a wide weiss stroke with a graphit one inside it */
.plan .outer {
  stroke: var(--weiss);
  stroke-width: var(--wall);
}

/* the current: a red line laid between the wall's two lines, grown and drained by main.js */
.plan .charge {
  stroke: var(--rot);
  stroke-width: var(--wall);
}

.plan .inner {
  stroke: var(--graphit);
  stroke-width: var(--wall-gap);
}

.plan .tiles {
  stroke: var(--night);
  stroke-width: 1px;
}

.plan .axis {
  stroke: var(--stahl);
  stroke-width: 1px;
  stroke-dasharray: 14 4 2 4;
  opacity: 0.55;
}

.plan .bubble {
  stroke: var(--stahl);
  stroke-width: 1px;
}

.plan text {
  fill: var(--mist);
  stroke: none;
  font-family: var(--mono);
  font-size: var(--type, 9px);
  letter-spacing: 0.04em;
  text-anchor: middle;
  dominant-baseline: central;
}

.plan .dim {
  stroke: var(--mist);
  stroke-width: 1px;
}

.plan .dim-label {
  fill: var(--stahl);
}

/* a door: the leaf, the hairline trace of its swing, and a red knob that says it can be handled */
.plan .door .leaf {
  fill: var(--graphit);
  stroke: var(--mist);
  stroke-width: 1px;
  transition: stroke 200ms var(--out);
}

.plan .door .swing {
  stroke: var(--stahl);
  stroke-width: 1px;
}

.plan .door .knob {
  fill: var(--rot);
}

.plan .door.hot .leaf {
  stroke: var(--weiss);
}

/* a built stretch of HAUS wall: solid like WERK's, laid over the hairlines as deliveries arrive;
   it turns red with its hall when the wall is charged */
.plan .built {
  stroke: var(--weiss);
  transition: stroke 200ms var(--out);
}

.plan .built.hot {
  stroke: var(--rot);
}

/* HAUS's sites, marked in place: a dashed boundary and a small label */
.plan .site-edge {
  stroke: var(--stahl);
  stroke-width: 1px;
  stroke-dasharray: 3 3;
}

.plan .site-label {
  fill: var(--mist);
  font-size: calc(var(--type, 9px) * 0.9);
  text-anchor: start;
}

.plan .site-tag {
  fill: var(--graphit);
}

/* the truck's planned route: a faint dashed hairline over the street grid */
.plan .route {
  stroke: var(--stahl);
  stroke-width: 1px;
  stroke-dasharray: 2 4;
}

/* a site's work zone round its crane, hatched wide */
.plan .site-edge.work {
  fill: url(#zone);
}

.plan .zone-line {
  stroke: var(--stahl);
  stroke-width: 1px;
  opacity: 0.55;
}

/* the built zone: a grey band beside what is built of HAUS */
.plan .built-shade {
  stroke: #000;
  opacity: 0.4;
}

/* the top of a WERK wall going up at load: its outline lifts off the plan and fades */
.plan .ghost {
  stroke: var(--weiss);
  stroke-width: 1px;
  opacity: 0;
  pointer-events: none;
}

/* a finished site: its crane gone, its boundary and tag cleared away */
.plan .site-edge,
.plan .sites g {
  transition: opacity 2400ms var(--out);
}

.plan .site-edge.done,
.plan .sites g.done {
  opacity: 0;
}

/* equipment: mist lines, and faces filled with the ground so what stands behind is hidden */
.plan .icon {
  stroke: var(--mist);
  stroke-width: var(--pen, 1.1px);
  stroke-linejoin: round;
  transition: stroke 1400ms var(--out);
}

.plan .face {
  fill: var(--graphit);
}

/* fine members (lattice, lacing, cables, mirrors) in a lighter pen */
.plan .icon .fine {
  stroke-width: calc(var(--pen, 1.1px) * 0.6);
}

/* working (a truck or a pala driving, a loader or a crane lifting) is drawn in the pen's red; it
   settles back to mist when the work stops */
.plan .icon.active {
  stroke: var(--rot);
  transition: none;
}

/* a charged hall lights its machines, each with a short cold-start flicker */
.plan .icon.lit {
  stroke: var(--weiss);
  transition-duration: 160ms;
}

.plan .icon.lit path {
  animation: flicker 520ms linear var(--lag, 0ms) both;
}

@keyframes flicker {
  0% {
    stroke: var(--mist);
  }
  10% {
    stroke: var(--weiss);
  }
  18% {
    stroke: var(--stahl);
  }
  34% {
    stroke: var(--weiss);
  }
  42% {
    stroke: var(--mist);
  }
  56%,
  100% {
    stroke: var(--weiss);
  }
}

/* a drafting crosshair for the mouse: hairlines across the sheet, a pickbox, a red snap square when
   it is close enough to a wall to take it, and a red ring over a door */
@media (hover: hover) {
  .plan {
    cursor: none;
  }
}

.plan .cad {
  pointer-events: none;
}

.plan .hair {
  stroke: var(--stahl);
  stroke-width: 1px;
  opacity: 0.7;
}

.plan .pick {
  stroke: var(--weiss);
  stroke-width: 1px;
}

.plan .snap {
  stroke: var(--rot);
  stroke-width: 1.5px;
}

.plan .hand {
  stroke: var(--rot);
  stroke-width: 1.5px;
}

/* the bottom bar: the sound switch, flush with the plan's last wall */
.tools {
  display: flex;
  justify-content: flex-end;
  margin: 8px var(--inset-r, 0px) 0 0;
}

/* the sound control is a switch, not a link: a hairline track with a knob */
.mute {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-height: 32px;
  padding: 0;
  background: none;
  border: none;
  color: var(--mist);
  font-family: var(--mono);
  font-size: var(--bar, 12px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 240ms var(--out);
}

/* the track sits on the text baseline, about as tall as the capitals */
.mute .switch {
  align-self: baseline;
  position: relative;
  width: 18px;
  height: 9px;
  border: 1px solid var(--stahl);
}

.mute .knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 5px;
  height: 5px;
  background: var(--stahl);
  transition:
    left 200ms var(--out),
    background-color 200ms var(--out);
}

.mute[aria-pressed="true"] .knob {
  left: 10px;
  background: var(--rot);
}

.mute:hover,
.mute:focus-visible {
  color: var(--weiss);
}

.mute:focus-visible {
  outline: 1px solid var(--weiss);
  outline-offset: 4px;
}

/* working beats lit: a machine at work stays red under a charged wall */
.plan .icon.active.lit {
  stroke: var(--rot);
}

.plan .icon.active.lit path {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .plan .icon.lit path {
    animation: none;
  }

  .plan .icon,
  .plan .icon.lit,
  .mute,
  .mute .knob {
    transition: none;
  }
}

.plan .parking {
  fill: none;
  stroke: var(--stahl);
  stroke-width: 0.8px;
}

.plan .parking .wheel-stop {
  stroke-width: 2px;
}

/* the company block: the sheet's title block, as real text at about the drawing's own type size,
   right under the dimension line and flush with the last wall. it is as wide as the plan (main.js
   sets --plan-w), so it wraps inside the plan and never widens the sheet */
.company {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  width: var(--plan-w, auto);
  margin-top: 6px;
  padding-right: var(--inset-r, 0px);
  background: var(--graphit);
  color: var(--mist);
  font-size: 11px;
  line-height: 15px;
  letter-spacing: 0.04em;
}

.company .lines {
  min-width: 0;
  text-align: end;
}

.company dl {
  display: grid;
  grid-template-columns: max-content auto;
  column-gap: 2ch;
  margin: 0;
}

.company dt {
  text-align: start;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.company dd {
  margin: 0;
  color: var(--weiss);
  overflow-wrap: anywhere;
}

.company p {
  margin: 0;
}

/* the copyright line wraps, if it must, only after "LLC." */
.company .phrase {
  white-space: nowrap;
}

/* a link is what can be handled, so it is underlined in the knob's red */
.company a,
.spec a {
  color: var(--weiss);
  text-decoration: underline 1px var(--rot);
  text-underline-offset: 3px;
}

.company a:hover,
.spec a:hover {
  text-decoration-thickness: 2px;
}

.company a:focus-visible,
.spec a:focus-visible {
  outline: 1px solid var(--weiss);
  outline-offset: 2px;
}

.company p a {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* the load: a thin arc turns in the middle of the screen until the drawing starts, and the company
   block waits, invisible, until the house stands. the inline script in the head sets .js, so
   without scripts nothing is hidden; main.js sets .drawing and .stood. if it never gets that far,
   both give up at 7 s from the first paint: the slowest measured wait for the drawing (1.5 s), the
   load-in (4.8 s) and a margin */
.js body::after {
  content: "";
  position: fixed;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 1px solid transparent;
  border-top-color: var(--stahl);
  border-radius: 50%;
  pointer-events: none;
  animation:
    turn 1200ms linear infinite,
    gone 300ms ease 7000ms forwards;
}

/* no fade out: when main.js draws before the first paint, a fade would show an arc never needed */
.js.drawing body::after {
  content: none;
}

.js:not(.stood) .company {
  opacity: 0;
  animation: shown 800ms ease 7000ms forwards;
}

.js .company {
  transition: opacity 800ms ease;
}

/* the sound switch waits for the drawing too, so it never stands alone in the middle; out of sight
   its knob takes the real state (off) at once, instead of sliding there in view */
.js:not(.drawing) .tools {
  visibility: hidden;
  opacity: 0;
  animation: shown 800ms ease 7000ms forwards;
}

.js:not(.drawing) .mute .knob {
  transition: none;
}

.js .tools {
  transition: opacity 700ms var(--out);
}

@keyframes turn {
  to {
    transform: rotate(1turn);
  }
}

@keyframes gone {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes shown {
  to {
    opacity: 1;
    visibility: visible;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js body::after {
    content: none;
  }

  .js .company {
    transition: none;
  }

  .js:not(.stood) .company {
    animation-duration: 0s;
  }

  .js .tools {
    transition: none;
  }

  .js:not(.drawing) .tools {
    animation-duration: 0s;
  }
}

/* the specifications: the set's notes sheet, still, on the plan's ground and floor tiles */
.spec {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 24px;
  min-height: 100svh;
  padding: var(--pad-y) var(--pad-x);
  background-image:
    linear-gradient(var(--night) 1px, transparent 1px),
    linear-gradient(90deg, var(--night) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center;
}

.spec .notes {
  width: min(100%, 640px);
  padding: 24px;
  border: 1px solid var(--stahl);
  background: var(--graphit);
}

.spec h1 {
  margin: 0;
  color: var(--weiss);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.spec h2 {
  margin: 20px 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--stahl);
  color: var(--mist);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.spec ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  line-height: 22px;
}

/* the note numbers hang in their own column */
.spec li {
  padding-left: 4ch;
  overflow-wrap: anywhere;
}

.spec .n {
  float: left;
  width: 4ch;
  margin-left: -4ch;
}

.spec .n,
.spec .k {
  color: var(--mist);
}

.spec .k {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.spec .back {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* the same sheet opened over the plan (specs.js), while the yard runs on under it */
.specs {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--graphit);
  color: var(--weiss);
  opacity: 0;
}

.specs[open] {
  animation: shown 300ms ease forwards;
}

.specs:focus {
  outline: none;
}

.specs::backdrop {
  background: none;
}

@media (prefers-reduced-motion: reduce) {
  .specs[open] {
    animation-duration: 0s;
  }
}
