/* FL3 bench study. A 1960s Italian two-ink print: ivory offset stock,
   arancio + celeste (the tractor's own colours) and black. */

:root {
  --paper: #eee9dc;
  --paper-deep: #e3dccb;
  --diazo: #e6e6dc;
  --ink: #1c1b19;
  --ink-2: #47433c;
  --ink-3: #7c766a;
  --rule: rgba(28, 27, 25, 0.26);
  --arancio: #e0561c;
  --arancio-soft: #ef8a5d;
  --celeste: #58aed6;
  --celeste-ink: #2c79a6;
  --blueline: #27408b;
  --display: "Bodoni Moda", "Didot", "Bodoni 72", Georgia, serif;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;
  --pad-x: clamp(20px, 2.8vw, 44px);
  --pad-y: clamp(18px, 3.2vh, 34px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ---------- paper ---------- */
.paper {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-color: var(--paper);
  background-image:
    radial-gradient(1200px 700px at 62% 46%, rgba(255, 252, 244, 0.65), rgba(255, 252, 244, 0) 70%),
    radial-gradient(900px 600px at 8% 100%, rgba(150, 128, 92, 0.10), rgba(150, 128, 92, 0) 70%),
    radial-gradient(700px 500px at 100% 0%, rgba(150, 128, 92, 0.08), rgba(150, 128, 92, 0) 70%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .11  0 0 0 0 .1  0 0 0 0 .08  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.32'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='f'><feTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='4' seed='7'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .48  0 0 0 0 .36  0 0 0 .5 -.12'/></filter><rect width='100%' height='100%' filter='url(%23f)' opacity='.22'/></svg>");
}
.numeral {
  position: absolute;
  font-family: var(--display);
  font-weight: 900;
  font-variation-settings: "opsz" 96;
  line-height: 0.8;
  color: var(--celeste);
  opacity: 0.17;
  transform: translate(-50%, -50%);
  user-select: none;
  white-space: nowrap;
  /* the second ink is never quite in register */
  text-shadow: 6px 4px 0 rgba(224, 86, 28, 0.06);
}
.reg { position: absolute; width: 22px; height: 22px; color: var(--ink-3); opacity: 0.75; }
.reg-tl { top: 6px; left: 6px; } .reg-tr { top: 6px; right: 6px; }
.reg-bl { bottom: 6px; left: 6px; } .reg-br { bottom: 6px; right: 6px; }
.colorbar { position: absolute; bottom: 9px; left: 50%; transform: translateX(-50%); display: flex; gap: 0; }
.colorbar i { width: 13px; height: 9px; display: block; }
.colorbar .c1 { background: var(--arancio); } .colorbar .c2 { background: var(--arancio-soft); }
.colorbar .c3 { background: var(--celeste); } .colorbar .c4 { background: #9ccbe4; }
.colorbar .c5 { background: var(--ink); } .colorbar .c6 { background: #6d6a63; } .colorbar .c7 { background: #bdb7aa; }

#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 1; pointer-events: none; display: block; }

/* ---------- plate grid ---------- */
.plate {
  position: relative; z-index: 2;
  height: 100vh;
  padding: var(--pad-y) var(--pad-x) calc(var(--pad-y) - 4px);
  display: grid;
  grid-template-columns: minmax(300px, 25vw) 1fr minmax(250px, 19vw);
  grid-template-rows: auto auto 1fr clamp(150px, 22vh, 222px);
  grid-template-areas:
    "run run run"
    "mast stage inst"
    "console stage inst"
    "draw draw draw";
  column-gap: clamp(16px, 2vw, 32px);
  pointer-events: none;
}
.plate > * { pointer-events: auto; }
.plate::before {
  content: ""; position: absolute; inset: calc(var(--pad-y) * 0.42) calc(var(--pad-x) * 0.45);
  border: 1px solid var(--rule); pointer-events: none;
}
.plate::after {
  content: ""; position: absolute; inset: calc(var(--pad-y) * 0.42 + 4px) calc(var(--pad-x) * 0.45 + 4px);
  border: 0.5px solid rgba(28, 27, 25, 0.12); pointer-events: none;
}

.runhead {
  grid-area: run;
  display: flex; justify-content: space-between; align-items: baseline;
  font: 600 9.5px/1 var(--sans); font-stretch: 125%; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--ink-2);
  padding-bottom: 8px; margin-bottom: 4px;
  border-bottom: 1px solid var(--ink);
  pointer-events: none;
}
.runhead em, .kicker em { font-family: var(--display); font-style: italic; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; font-stretch: normal; }
.runhead-mid { color: var(--ink-3); }

/* ---------- masthead ---------- */
.mast { grid-area: mast; padding-top: clamp(6px, 1.4vh, 16px); pointer-events: none; }
.kicker {
  margin: 0 0 6px;
  font: 600 10px/1.2 var(--sans); font-stretch: 125%; letter-spacing: 0.22em; text-transform: uppercase; color: var(--celeste-ink);
}
.title { margin: 0; font-family: var(--display); font-weight: 400; line-height: 1; }
.title-make {
  display: block; font-style: italic; font-weight: 500;
  font-size: clamp(28px, min(3.1vw, 4.6vh), 46px); letter-spacing: -0.01em;
  font-variation-settings: "opsz" 48;
}
.title-type {
  display: block;
  font-weight: 800; font-variation-settings: "opsz" 96;
  font-size: clamp(80px, min(10.6vw, 13.2vh), 168px); line-height: 0.8; letter-spacing: -0.035em;
  margin: 2px 0 0 -0.04em;
}
.title-type b { font-weight: 800; color: var(--arancio); }
.deck {
  margin: clamp(8px, 1.4vh, 14px) 0 0;
  font-family: var(--display); font-style: italic; font-size: clamp(18px, 1.6vw, 23px); line-height: 1.2;
  padding-top: 10px; border-top: 1px solid var(--ink); display: inline-block;
}
.lede { margin: 8px 0 0; max-width: 52ch; font-size: clamp(12px, min(0.92vw, 1.5vh), 14px); line-height: 1.48; color: var(--ink-2); }

/* ---------- console ---------- */
.console { grid-area: console; align-self: end; padding: 10px 0 12px; display: flex; flex-direction: column; gap: clamp(7px, 1.2vh, 12px); }
.console-row { display: flex; align-items: center; gap: 18px; }

.key {
  flex: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.key-face {
  width: 78px; height: 78px; border-radius: 50%; position: relative; display: block;
  background:
    radial-gradient(circle at 50% 50%, #2a2826 0 52%, transparent 53%),
    radial-gradient(circle at 38% 30%, #f6f3ec, #a9a59b 46%, #6c6860 70%, #c9c5bb 100%);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 3px 7px rgba(40, 32, 20, 0.28), 0 0 0 1px rgba(28,27,25,.5);
}
.key-face::before {   /* engraved positions */
  content: "0   I   II"; position: absolute; left: 0; right: 0; top: -15px; text-align: center;
  font: 600 8.5px/1 var(--sans); font-stretch: 125%; letter-spacing: 0.2em; color: var(--ink-3);
}
.key-slot {
  position: absolute; left: 50%; top: 50%; width: 30px; height: 8px; margin: -4px 0 0 -15px; border-radius: 4px;
  background: linear-gradient(#d9d5cc, #8d887e); box-shadow: 0 0 0 2px #121110;
  transform: rotate(-45deg); transition: transform 0.35s cubic-bezier(.3,1.6,.5,1);
}
.key-slot::after { content: ""; position: absolute; right: -3px; top: 2px; width: 6px; height: 4px; border-radius: 2px; background: var(--arancio); }
.key[aria-pressed="true"] .key-slot { transform: rotate(0deg); }
.key.cranking .key-slot { transform: rotate(32deg); }
.key-label { font: 700 10px/1 var(--sans); font-stretch: 125%; letter-spacing: 0.22em; text-transform: uppercase; }
.key:focus-visible .key-face { outline: 2px solid var(--arancio); outline-offset: 3px; }

.levers { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lever { display: block; }
.lever-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px;
  font: 600 9.5px/1.2 var(--sans); font-stretch: 125%; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2);
}
.lever-head em, .modes em, .inst em, .dwg em, .card-head em {
  font-family: var(--display); font-style: italic; text-transform: none; letter-spacing: 0; font-weight: 500; font-stretch: normal;
}
.lever-head em { font-size: 12px; color: var(--ink-3); margin-left: 4px; }
.lever-head output { font: 500 11px/1 var(--mono); letter-spacing: 0; text-transform: none; color: var(--ink); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10%) 0 0 / 100% 5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 7px / 100% 1px no-repeat;
}
input[type="range"]::-moz-range-track {
  height: 10px;
  background:
    repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10%) 0 0 / 100% 5px no-repeat,
    linear-gradient(var(--ink), var(--ink)) 0 7px / 100% 1px no-repeat;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 22px; margin-top: -6px; border-radius: 3px 3px 6px 6px;
  background: linear-gradient(90deg, #c2461a, var(--arancio) 45%, #f07a45); border: 1px solid #6a2a10;
  box-shadow: 0 2px 3px rgba(40, 20, 10, 0.35);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 22px; border-radius: 3px 3px 6px 6px;
  background: linear-gradient(90deg, #c2461a, var(--arancio) 45%, #f07a45); border: 1px solid #6a2a10;
}
input[type="range"]:focus-visible { outline: 2px solid var(--celeste-ink); outline-offset: 2px; }

.story {
  margin: 0; min-height: 2.76em; max-width: 60ch;
  font-family: var(--display); font-size: clamp(13.5px, min(1.02vw, 1.65vh), 16px); line-height: 1.38; font-style: italic;
  padding-left: 14px; position: relative;
}
.story::before { content: ""; position: absolute; left: 0; top: 0.5em; width: 7px; height: 7px; border-radius: 50%; background: var(--arancio); }

.modes { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--ink); }
.modes button {
  border: 0; border-left: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer;
  padding: 6px 2px 5px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  font: 700 9.5px/1.1 var(--sans); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase;
}
.modes button:first-child { border-left: 0; }
.modes button em { font-size: 11px; color: var(--ink-3); }
.modes button[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.modes button[aria-checked="true"] em { color: var(--arancio-soft); }
.modes button:focus-visible, .toggles button:focus-visible { outline: 2px solid var(--arancio); outline-offset: 2px; }

.toggles { display: flex; gap: 16px; flex-wrap: wrap; }
.toggles button {
  border: 0; background: none; padding: 2px 0; cursor: pointer; color: var(--ink);
  font: 700 9.5px/1.4 var(--sans); font-stretch: 125%; letter-spacing: 0.18em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink);
}
.toggles button span { color: var(--ink-3); font-weight: 500; letter-spacing: 0.1em; margin-left: 3px; }
.toggles button[aria-pressed="true"] span { color: var(--arancio); }
.help { margin: 0; font-size: 11px; color: var(--ink-3); line-height: 1.4; max-width: 46ch; font-style: italic; font-family: var(--display); }

/* ---------- stage ---------- */
.stage { grid-area: stage; position: relative; cursor: grab; touch-action: none; min-height: 200px; }
.stage:active { cursor: grabbing; }

/* ---------- instruments ---------- */
.instruments {
  grid-area: inst; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: min-content; min-width: 0;
  align-content: start; gap: clamp(8px, 1.4vh, 16px) 14px; padding-top: clamp(10px, 1.6vh, 18px);
}
.inst { margin: 0; min-width: 0; }
.inst:nth-child(n+3) { grid-column: span 2; }
.inst figcaption {
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
  font: 700 9px/1.2 var(--sans); font-stretch: 125%; letter-spacing: 0.18em; text-transform: uppercase;
  border-bottom: 1px solid var(--ink); padding-bottom: 3px; margin-bottom: 4px;
}
.inst figcaption em { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst:nth-child(-n+2) figcaption { flex-direction: column; align-items: flex-start; gap: 0; }
.inst:nth-child(-n+2) figcaption em { font-size: 10.5px; line-height: 1.1; }
.inst canvas { display: block; width: 100%; max-width: 100%; height: auto; }

/* ---------- drawings ---------- */
.drawings {
  grid-area: draw; display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(230px, 1.25fr);
  gap: 0 14px; padding-top: 10px; border-top: 1px solid var(--ink); min-height: 0;
}
.dwg { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.dwg-view {
  flex: 1; min-height: 0; position: relative;
  /* the diazo paper and its grid are printed by the drawing shader */
  background: transparent;
  border: 1px solid rgba(39, 64, 139, 0.45);
}
.dwg-view::before, .dwg-view::after {
  content: ""; position: absolute; width: 9px; height: 9px; border-color: var(--blueline); border-style: solid;
}
.dwg-view::before { left: 3px; top: 3px; border-width: 1px 0 0 1px; }
.dwg-view::after { right: 3px; bottom: 3px; border-width: 0 1px 1px 0; }
.dwg figcaption {
  margin-top: 5px; display: flex; justify-content: space-between; align-items: baseline;
  font: 700 9px/1.2 var(--sans); font-stretch: 125%; letter-spacing: 0.2em; text-transform: uppercase; color: var(--blueline);
}
.dwg figcaption em { font-size: 11px; color: var(--ink-3); }

.card { border: 1px solid var(--ink); padding: 10px 12px 8px; display: flex; flex-direction: column; min-height: 0; background: rgba(255, 252, 244, 0.35); }
.card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font: 700 9.5px/1.2 var(--sans); font-stretch: 125%; letter-spacing: 0.2em; text-transform: uppercase;
  padding-bottom: 5px; border-bottom: 1px solid var(--ink);
}
.card-head em { font-size: 11px; color: var(--ink-3); }
.readings { margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; }
.readings div { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px dotted var(--rule); padding: 2px 0; }
.readings dt { font: 600 9px/1.2 var(--sans); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); }
.readings dd { margin: 0; font: 500 13px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.readings dd small { font-size: 9.5px; color: var(--ink-3); }
.fine { margin: auto 0 0; padding-top: 6px; font: italic 11px/1.35 var(--display); color: var(--ink-3); }

/* ---------- exploded-view callouts ---------- */
.callouts { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0; transition: opacity 0.4s; }
.callouts.on { opacity: 1; }
#leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.callout {
  position: absolute; white-space: nowrap; transform: translate(-50%, -50%);
  font: 700 9px/1.15 var(--sans); font-stretch: 112%; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink);
  text-align: center;
  padding: 2px 6px 3px; background: rgba(238, 233, 220, 0.86); border-radius: 2px;
}
.callout em { display: block; font: italic 500 11.5px/1.1 var(--display); letter-spacing: 0; text-transform: none; color: var(--celeste-ink); }

/* ---------- narrow screens: the sheet becomes a scroll ---------- */
@media (max-width: 960px), (max-height: 620px) {
  body { overflow: auto; }
  .plate {
    height: auto; display: flex; flex-direction: column; gap: 14px;
    padding: 18px 16px 34px;
  }
  .runhead-mid { display: none; }
  .stage { height: 62vh; min-height: 320px; order: 2; touch-action: pan-y; }
  .mast { order: 1; }
  .console { order: 3; }
  .instruments { order: 4; grid-template-columns: 1fr 1fr; }
  .drawings { order: 5; grid-template-columns: 1fr 1fr; gap: 14px; }
  .dwg-view { height: 170px; flex: none; }
  .card { grid-column: span 2; }
  .numeral { opacity: 0.12; }
}
@media (prefers-reduced-motion: reduce) {
  .key-slot { transition: none; }
}
