/* The builds page. Colours, fonts and link styles match index.html; if you change them
   there, change them here too.
   Layout: a small galahwire link at the top, a thin copper line, the heading hung under it.
   Each build is a row: the drawing on the left, words on the right (stacked on a phone). */

@font-face { font-family: "Syne"; src: url("../fonts/syne.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url("../fonts/dm-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Mono"; src: url("../fonts/dm-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --mist: #EEEDF0; --surface: #F8F7F9; --ink: #1C1B1F; --muted: #5B5761;
  --pink: #E0688A; --pink-ink: #B23A5E; --crest: #F6C9D4; --wing: #77737E;
  --copper: #9A4F1C; --rule: #D9D7DD;
  --display: "Syne", "Arial Black", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, Consolas, monospace;
  --pad: clamp(20px, 6vw, 88px);
  --pad-l: max(var(--pad), env(safe-area-inset-left, 0px));
  --pad-r: max(var(--pad), env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --mist: #18171B; --surface: #232127; --ink: #EEEDF0; --muted: #A7A2AD;
    --pink: #EE8BA6; --pink-ink: #EE8BA6; --crest: #4A2532; --wing: #8E8B95;
    --copper: #DE8F52; --rule: #2F2D33;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--mist);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--copper);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
a:hover { color: var(--copper); }
a:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 5px; }

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 28px;
  padding: max(22px, env(safe-area-inset-top, 0px)) var(--pad-r) 20px var(--pad-l);
  border-bottom: 3px solid var(--copper);
}
.top .home {
  font-family: var(--display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -.03em;
  line-height: 1;
  text-decoration: none;
}
.top nav { display: flex; gap: 22px; font-family: var(--mono); font-size: 14px; }

.builds { flex: 1 0 auto; padding: 0 var(--pad-r) clamp(40px, 7vw, 96px) var(--pad-l); }
.builds h1 {
  margin: clamp(28px, 4vw, 52px) 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 1;
  letter-spacing: -.03em;
}

.build {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 64px);
  align-items: center;
  padding: clamp(28px, 5vw, 64px) 0;
  border-bottom: 1px solid var(--rule);
}
.build:last-child { border-bottom: 0; }

.build-stage { position: relative; }
.build-view {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  touch-action: pan-y;          /* a finger moving up or down scrolls the page */
  cursor: grab;
  outline: none;
}
.build-view.dragging { cursor: grabbing; }
.build-view:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 2px; }

.build-hint, .build-fallback, .build-stage::after {
  position: absolute;
  left: 0;
  bottom: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.build-hint { opacity: 0; transition: opacity .3s; pointer-events: none; }
.build.ready .build-hint { opacity: 1; }
.build.ready.touched .build-hint { opacity: 0; }
.build-fallback { display: none; position: static; padding: 28px 0; }
.build.loading .build-stage::after { content: "loading the model"; }

/* No 3D (the script did not run, or WebGL is missing or lost): keep the words and the parts
   list, drop the empty box and the controls. builds.js adds "js" to <html> when it starts. */
html:not(.js) .build-view, html:not(.js) .build-hint, html:not(.js) .apart-row,
.build.no-3d .build-view, .build.no-3d .build-hint, .build.no-3d .apart-row { display: none; }
html:not(.js) .build-fallback, .build.no-3d .build-fallback { display: block; }
html:not(.js) .parts button, .build.no-3d .parts button { pointer-events: none; cursor: default; }

.build-text h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: -.025em;
}
.build-cap { margin: 12px 0 0; max-width: 36ch; color: var(--muted); text-wrap: pretty; }

.build-facts { margin: 22px 0 0; display: grid; gap: 4px; font-family: var(--mono); font-size: 13px; }
.build-facts div { display: flex; gap: 14px; }
.build-facts dt { color: var(--muted); min-width: 13ch; }
.build-facts dd { margin: 0; }

.parts { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.parts button {
  appearance: none;
  margin: 0;
  padding: 4px 11px 5px;
  border: 1px solid var(--rule);
  border-radius: 99px;
  background: transparent;
  color: var(--ink);
  font: 400 13px/1.4 var(--mono);
  cursor: pointer;
}
.parts button:hover { border-color: var(--wing); }
.parts button:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 2px; }
.parts button[aria-pressed="true"] { background: var(--pink); border-color: var(--pink); color: #1C1B1F; }

.apart-row { display: flex; align-items: center; gap: 14px; margin: 24px 0 0; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.apart {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  max-width: 220px;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.apart::-webkit-slider-runnable-track { height: 2px; background: var(--copper); }
.apart::-moz-range-track { height: 2px; background: var(--copper); }
.apart::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border: 0; border-radius: 50%; background: var(--copper); }
.apart::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--copper); }
.apart:focus-visible { outline: 2px solid var(--pink-ink); outline-offset: 4px; }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 24px;
  padding: 18px var(--pad-r) max(22px, env(safe-area-inset-bottom, 0px)) var(--pad-l);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

@media (pointer: coarse) {
  .parts { gap: 8px; }
  .parts button { padding: 9px 14px 10px; }
  .apart { height: 44px; }
}

@media (max-width: 760px) {
  .build { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .build-view { aspect-ratio: 1 / 1; }
}
