/* chessbit.dev — the board seen from underneath, annotated like a fabrication drawing */

:root {
  color-scheme: light;
  --paper: #f2efe7;
  --square: #e2dccd;
  --ink: #16181a;
  --ink-mute: #5a5f63;
  --rule: #c3beb1;
  --flux: #b3321b;

  --pitch: clamp(2.5rem, 7vw, 4.5rem);
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: -apple-system, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #101214;
    --square: #171a1d;
    --ink: #e8e6e0;
    --ink-mute: #9aa0a6;
    --rule: #2a2f34;
    --flux: #ff6a3d;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; font-family: var(--mono); font-weight: 600; }
p { margin: 0; }
svg { display: block; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color .12s, text-decoration-color .12s;
}
a:hover { color: var(--flux); }

:focus-visible { outline: 2px solid var(--flux); outline-offset: 2px; }

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

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 9;
  padding: .5rem 1rem; background: var(--paper); border: 1px solid var(--rule);
  font-family: var(--mono); font-size: .75rem;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---- the sheet: eight columns, no gutters, hairlines do the dividing ---- */

.sheet {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 1rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

@media (max-width: 40rem) {
  .sheet { grid-template-columns: repeat(4, 1fr); }
}

/* ---- title block ---- */

.titleblock { border-bottom: 1px solid var(--rule); }

.titleblock .sheet { align-items: stretch; }

.tb-mark {
  grid-column: 1 / 4;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 1.125rem;
  letter-spacing: .02em;
  padding: .85rem 0;
}

.tb-data {
  grid-column: 4 / 9;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.tb-data > div {
  border-left: 1px solid var(--rule);
  padding: .85rem 1rem;
  display: flex;
  gap: .6rem;
  align-items: baseline;
}

.tb-data dt, .tb-data dd {
  margin: 0;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.tb-data dt { color: var(--ink-mute); }

/* ---- revision switch ---- */
/* Two radios at the top of the document drive it, so everything below can be
   reached with a plain sibling selector. Inside the figures the inactive
   revision is hidden with visibility, never display: an element that comes
   back from display:none restarts its animation, and the whole point is that
   switching revisions leaves the figures running. */

.revpick { display: flex; gap: .45rem; }
.revpick span { color: var(--rule); }
.revpick label { color: var(--ink-mute); cursor: pointer; }
.revpick label:hover { color: var(--ink); }

#rev-v1:checked ~ .titleblock label[for="rev-v1"],
#rev-v2:checked ~ .titleblock label[for="rev-v2"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}

#rev-v1:focus-visible ~ .titleblock label[for="rev-v1"],
#rev-v2:focus-visible ~ .titleblock label[for="rev-v2"] {
  outline: 2px solid var(--flux);
  outline-offset: 2px;
}

/* only ever hide: whichever revision is shown keeps the display value it was
   given elsewhere (the legend keys are inline-flex, for instance) */
#rev-v1:checked ~ #main .r2,
#rev-v2:checked ~ #main .r1 { display: none; }

#rev-v1:checked ~ #main .sr2,
#rev-v2:checked ~ #main .sr1 { visibility: hidden; }

/* The switch is printed again on every figure it governs, as a revision flag
   on the caption rule, keyed back to the rev cell in the title block: a
   fabrication drawing flags the detail, not the reader's window. It also puts
   the control in the same glance as the figure, which is the whole point of
   switching without a restart. */
.revstamp {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  margin: .9rem 0 .55rem;
  padding-top: .45rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.revstamp .rs-key { margin-right: auto; }
.revstamp span[aria-hidden] { color: var(--rule); }
.revstamp label {
  color: var(--ink-mute);
  cursor: pointer;
  padding: .5rem .35rem;      /* a thumb-sized target that leaves the baseline alone */
  margin: -.5rem -.35rem;
}
.revstamp label:hover { color: var(--ink); }

.hero-fig .revstamp + figcaption,
.band .revstamp + figcaption,
.bytefig .revstamp + figcaption { margin-top: 0; }

#rev-v1:checked ~ #main .revstamp label[for="rev-v1"],
#rev-v2:checked ~ #main .revstamp label[for="rev-v2"] {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}

#rev-v1:focus-visible ~ #main .revstamp label[for="rev-v1"],
#rev-v2:focus-visible ~ #main .revstamp label[for="rev-v2"] {
  outline: 2px solid var(--flux);
  outline-offset: 2px;
}

/* The labels now sit screens below the inputs they drive, and focusing an
   absolutely positioned input would scroll the sheet back to the top. Fixed
   keeps the hidden radio in the viewport wherever the reader is. */
input[name="rev"].sr-only { position: fixed; top: 0; left: 0; margin: 0; }

@media (max-width: 40rem) {
  .tb-mark { grid-column: 1 / 3; }
  .tb-data { grid-column: 3 / 5; grid-template-columns: 1fr; }
  .tb-data > div:nth-child(n+2) { display: none; }
}

/* ---- hero ---- */

.hero { padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2rem, 5vw, 4rem); row-gap: 2.5rem; }

.hero-copy { grid-column: 1 / 5; padding-right: 2rem; align-self: start; }

h1 {
  font-size: clamp(2rem, 4.6vw, 3.75rem);
  line-height: 1.03;
  letter-spacing: -.02em;
}
h1 span { display: block; }
h1 .l2 { padding-left: var(--pitch); }
h1 .l3 { padding-left: calc(var(--pitch) * 2); color: var(--ink-mute); }

.standfirst {
  margin-top: 1.75rem;
  max-width: 48ch;
  color: var(--ink-mute);
}

.hero-links {
  margin-top: 1.5rem;
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: .8125rem;
}

.hero-fig { grid-column: 5 / 9; margin: 0; align-self: start; }

@media (max-width: 62rem) {
  .hero-copy { grid-column: 1 / 9; padding-right: 0; }
  .hero-fig { grid-column: 1 / 9; }
  h1 .l3 { padding-left: var(--pitch); }
}

@media (max-width: 40rem) {
  .hero-copy, .hero-fig { grid-column: 1 / 5; }
  h1 .l2, h1 .l3 { padding-left: 1.75rem; }
}

/* ---- the board ---- */

.board { width: 100%; height: auto; overflow: visible; }

.board .sq { fill: var(--paper); }
.board .sq-dark { fill: var(--square); }
.board .frame { fill: none; stroke: var(--ink); stroke-width: 1; }

/* `use` copies live in a shadow tree, so the glyph is styled through
   inherited custom properties rather than class selectors. */
.board .glyphs {
  --g-line: var(--rule);
  --g-w: 1;
  --g-dash: none;
  --g-fill: var(--rule);
  --g-stroke: none;
  --g-dot: var(--ink-mute);
}

.board .occupied circle { fill: var(--ink); }

.board use.dead {
  --g-line: var(--flux);
  --g-w: 1.4;
  --g-dash: 3 2;
  --g-fill: none;
  --g-stroke: var(--flux);
  --g-dot: none;
}

.board .chain {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1.25;
  stroke-linejoin: round;
}

.board .chain-scan {
  fill: none;
  stroke: var(--flux);
  stroke-width: 1.75;
  stroke-linecap: round;
  /* the path carries pathLength="1000", so the dash is a fraction of the chain
     rather than a pixel count that has to be re-measured when the wire changes */
  stroke-dasharray: 15 985;
  animation: scan 1.28s linear infinite;
}

@keyframes scan {
  from { stroke-dashoffset: 15; }
  to { stroke-dashoffset: -985; }
}

@media (prefers-reduced-motion: reduce) {
  .board .chain-scan { animation: none; stroke-dashoffset: -500; }
}

.board .labels text {
  font-family: var(--mono);
  font-size: 12px;
  fill: var(--ink-mute);
}
.board .labels .lead { font-size: 11px; letter-spacing: .08em; }

@media (max-width: 62rem) {
  .board .labels .lead { display: none; }
  .board .chain, .board .chain-scan { clip-path: inset(4% 0 0 0); }
}

.hero-fig figcaption {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.5rem;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .06em;
  color: var(--ink-mute);
}

.key { display: inline-flex; align-items: center; gap: .5rem; }
.key i { width: 10px; height: 10px; display: inline-block; }
.k-empty { border: 1px solid var(--rule); }
.k-occ { background: var(--ink); border-radius: 50%; }
.k-dead { border: 1px dashed var(--flux); }

/* ---- bands ---- */

.band {
  border-top: 1px solid var(--rule);
  padding-block: clamp(2.5rem, 5vw, 4.5rem);
  row-gap: 2.5rem;
}

.band h2 {
  font-size: 1.5rem;
  letter-spacing: -.01em;
  margin-bottom: 1rem;
}

.band p { max-width: 58ch; }
.band .col-a p + p { margin-top: 1rem; }
.band .col-a p { color: var(--ink-mute); }

.col-a { grid-column: 1 / 4; padding-right: 2rem; }
.col-b { grid-column: 5 / 9; margin: 0; align-self: start; }
.band .fig { margin: 0; }
.band .fig + .fig { margin-top: 2.25rem; }

#chain .col-a { grid-column: 1 / 4; }
#node .col-a { grid-column: 6 / 9; order: 2; padding-right: 0; padding-left: 2rem; }
#node .col-b { grid-column: 1 / 5; order: 1; }

@media (max-width: 62rem) {
  .col-a, .col-b,
  #node .col-a, #node .col-b { grid-column: 1 / 9; padding: 0; order: 0; }
}

@media (max-width: 40rem) {
  .col-a, .col-b,
  #node .col-a, #node .col-b { grid-column: 1 / 5; }
}

.band figcaption {
  margin-top: .9rem;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .06em;
  color: var(--ink-mute);
  max-width: 46ch;
}

/* ---- byte figure ---- */

.bits {
  list-style: none;
  margin: 0 0 .5rem;
  padding: 0;
  display: flex;
}

.bits li {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  margin-left: -1px;
  font-family: var(--mono);
  font-size: .8125rem;
}
.bits li:first-child { margin-left: 0; }

.bits li.mark {
  border-color: var(--flux);
  color: var(--flux);
  position: relative;
  z-index: 1;
}

.bits-label {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--ink-mute);
  margin-bottom: 1.75rem !important;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.bitfig .bits-label:last-of-type { margin-bottom: 0; }

.leader {
  flex: 0 0 4.5rem;
  height: 1px;
  background: var(--flux);
  position: relative;
}
.leader::after {
  content: "";
  position: absolute;
  right: 0; top: -3px;
  width: 1px; height: 7px;
  background: var(--flux);
}

.bytefig figcaption { margin-top: .25rem; }

/* ---- spec and parts lists ---- */

.specs, .rev dl { margin: 1.5rem 0 0; border-top: 1px solid var(--rule); }

.specs > div, .rev dl > div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--rule);
}

.specs dt, .specs dd, .rev dt, .rev dd {
  margin: 0;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.5;
}
.specs dt, .rev dt {
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: .1em;
}

.parts {
  margin-top: 1.5rem;
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--rule);
}
.parts th, .parts td {
  text-align: left;
  padding: .55rem 1rem .55rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 400;
  vertical-align: top;
}
.parts th { white-space: nowrap; }
.parts td { color: var(--ink-mute); }

/* ---- timing and mechanical drawings ---- */

.shift, .timing, .mech { width: 100%; height: auto; }

/* --- the chain, step by step ---------------------------------------------
   One 9s cycle, three phases that each last long enough to read:
     0-22%   LOAD latches every node at the same instant
     22-78%  the clock shifts the bytes one node to the right per tick
     78-100% the frame is in; quiet, then it starts again
   The timing diagram below runs on the same clock, so the cursor there and
   the byte that moves up here are the same moment. ----------------------- */

.shift { margin-bottom: 2rem; }

.shift .sh-squares .sq-light { fill: var(--paper); stroke: var(--rule); stroke-width: 1; }
.shift .sh-squares .sq-dark { fill: var(--square); stroke: var(--rule); stroke-width: 1; }
.shift .sh-squares .piece { fill: var(--ink); }

.shift .sh-wire path { stroke: var(--rule); stroke-width: 1.25; fill: none; }
.shift .sh-nodes rect { fill: var(--paper); stroke: var(--rule); stroke-width: 1; }
.shift .sh-master rect { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.shift .sh-master text { font-family: var(--mono); font-size: 10px; fill: var(--ink); }
.shift .sh-latch path { stroke: var(--rule); stroke-width: 1; fill: none; }

.shift text { font-family: var(--mono); font-size: 10px; fill: var(--ink-mute); }
.shift .sh-side, .shift .sh-load {
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.shift .sh-idx text { font-size: 8px; letter-spacing: .04em; fill: var(--ink-mute); }
.shift .sh-bytes text { fill: var(--ink); }
.shift .sh-out text { fill: var(--ink); }
.shift .sh-phase text { font-size: 9.5px; letter-spacing: .04em; fill: var(--ink-mute); }

/* phase 1 — every node latches at once */
.shift .sh-latch path { animation: latch 9s linear infinite; }
.shift .sh-nodes rect { animation: latchflash 9s linear infinite; }
.shift .sh-squares .piece { animation: piecepulse 9s linear infinite; }

@keyframes latch {
  0%, 16%   { stroke: var(--flux); }
  22%, 100% { stroke: var(--rule); }
}

@keyframes latchflash {
  0%, 16%   { stroke: var(--flux); stroke-width: 1.6; }
  22%, 100% { stroke: var(--rule); stroke-width: 1; }
}

@keyframes piecepulse {
  0%, 16%   { fill: var(--flux); }
  22%, 100% { fill: var(--ink); }
}

/* phase 2 — the mechanism: on every tick each register hands its byte to the
   next one. The bytes rest between ticks and slide across the gap on the tick,
   because that handover is the point of the figure; the chevrons in the gaps
   light up at the same instant, all eight of them, so the chain reads as moving
   together rather than one node at a time. */
.shift .sh-bytes { animation: shift 9s linear infinite; }
.shift .sh-hop path {
  fill: none;
  stroke: var(--flux);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .12;
  animation: hop 9s linear infinite;
}

@keyframes shift {
  0% { transform: translateX(0px); }
  22% { transform: translateX(0px); }
  26.2% { transform: translateX(0px); }
  29% { transform: translateX(50px); }
  33.2% { transform: translateX(50px); }
  36% { transform: translateX(100px); }
  40.2% { transform: translateX(100px); }
  43% { transform: translateX(150px); }
  47.2% { transform: translateX(150px); }
  50% { transform: translateX(200px); }
  54.2% { transform: translateX(200px); }
  57% { transform: translateX(250px); }
  61.2% { transform: translateX(250px); }
  64% { transform: translateX(300px); }
  68.2% { transform: translateX(300px); }
  71% { transform: translateX(350px); }
  75.2% { transform: translateX(350px); }
  78% { transform: translateX(400px); }
  100% { transform: translateX(400px); }
}

@keyframes hop {
  0% { opacity: .12; }
  26.2% { opacity: .12; }
  27.6% { opacity: 1; }
  29% { opacity: .12; }
  33.2% { opacity: .12; }
  34.6% { opacity: 1; }
  36% { opacity: .12; }
  40.2% { opacity: .12; }
  41.6% { opacity: 1; }
  43% { opacity: .12; }
  47.2% { opacity: .12; }
  48.6% { opacity: 1; }
  50% { opacity: .12; }
  54.2% { opacity: .12; }
  55.6% { opacity: 1; }
  57% { opacity: .12; }
  61.2% { opacity: .12; }
  62.6% { opacity: 1; }
  64% { opacity: .12; }
  68.2% { opacity: .12; }
  69.6% { opacity: 1; }
  71% { opacity: .12; }
  75.2% { opacity: .12; }
  76.6% { opacity: 1; }
  78% { opacity: .12; }
  100% { opacity: .12; }
}

/* the master's readout fills up, last node first */
.shift .sh-out text[class^="b"] { opacity: 0; animation: arrive1 9s step-end infinite; }
.shift .sh-out text.b1 { animation-name: arrive1; }
.shift .sh-out text.b2 { animation-name: arrive2; }
.shift .sh-out text.b3 { animation-name: arrive3; }
.shift .sh-out text.b4 { animation-name: arrive4; }
.shift .sh-out text.b5 { animation-name: arrive5; }
.shift .sh-out text.b6 { animation-name: arrive6; }
.shift .sh-out text.b7 { animation-name: arrive7; }
.shift .sh-out text.b8 { animation-name: arrive8; }

@keyframes arrive1 { 0%, 29%   { opacity: 0; } 29.1%, 100% { opacity: 1; } }
@keyframes arrive2 { 0%, 36%   { opacity: 0; } 36.1%, 100% { opacity: 1; } }
@keyframes arrive3 { 0%, 43%   { opacity: 0; } 43.1%, 100% { opacity: 1; } }
@keyframes arrive4 { 0%, 50%   { opacity: 0; } 50.1%, 100% { opacity: 1; } }
@keyframes arrive5 { 0%, 57%   { opacity: 0; } 57.1%, 100% { opacity: 1; } }
@keyframes arrive6 { 0%, 64%   { opacity: 0; } 64.1%, 100% { opacity: 1; } }
@keyframes arrive7 { 0%, 71%   { opacity: 0; } 71.1%, 100% { opacity: 1; } }
@keyframes arrive8 { 0%, 78%   { opacity: 0; } 78.1%, 100% { opacity: 1; } }

/* all three steps stay on screen; only the one happening now is lit */
.shift .ph { opacity: .5; animation: phase1 9s step-end infinite; }
.shift text.ph-2 { animation-name: phase2; }
.shift text.ph-3 { animation-name: phase3; }

@keyframes phase1 {
  0%        { fill: var(--flux); opacity: 1; }
  22%, 100% { fill: var(--ink-mute); opacity: .5; }
}
@keyframes phase2 {
  0%        { fill: var(--ink-mute); opacity: .5; }
  22%       { fill: var(--flux); opacity: 1; }
  78%, 100% { fill: var(--ink-mute); opacity: .5; }
}
@keyframes phase3 {
  0%        { fill: var(--ink-mute); opacity: .5; }
  78%       { fill: var(--flux); opacity: 1; }
  100%      { fill: var(--ink-mute); opacity: .5; }
}

/* --- timing diagram, same cycle ---------------------------------------- */

.timing .trace path { fill: none; stroke: var(--ink); stroke-width: 1; }

/* the data trace is revealed by a clip rectangle, so its right edge and the
   cursor are the same x at every moment */
.timing .t-live path { fill: none; stroke: var(--flux); stroke-width: 1.8; }
.timing .burst-rect { transform: translateX(-376px); animation: reveal 9s linear infinite; }
.timing .t-cursor path {
  fill: none;
  stroke: var(--flux);
  stroke-width: 1;
  opacity: .6;
  animation: cursor 9s linear infinite;
}

/* the frame opens when LOAD goes low, so the cursor starts on that edge and
   crosses the pulse during the latch; from 22% on it walks the eight bytes */
@keyframes reveal {
  0%          { transform: translateX(-376px); }
  22%         { transform: translateX(-360px); }
  78%         { transform: translateX(0); }
  78.1%, 100% { transform: translateX(-376px); }
}

@keyframes cursor {
  0%          { transform: translateX(0); opacity: .6; }
  22%         { transform: translateX(16px); opacity: .6; }
  78%         { transform: translateX(376px); opacity: .6; }
  78.1%, 100% { transform: translateX(376px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .shift .sh-bytes,
  .shift .sh-latch path,
  .shift .sh-nodes rect,
  .shift .sh-squares .piece,
  .shift .ph,
  .shift .sh-out text[class^="b"],
  .shift .sh-hop path,
  .timing .burst-rect,
  .timing .tape,
  .timing .t-cursor path { animation-play-state: paused; }
}

.timing .tick path { stroke: var(--rule); stroke-width: 1; }
.timing .tr-label text,
.timing .ann text, .timing .dim text, .timing .repeat text {
  font-family: var(--mono); font-size: 10px; fill: var(--ink-mute);
}
.timing .tr-label text { font-size: 11px; fill: var(--ink); }
.timing .tr-sub text { font-family: var(--mono); font-size: 8px; letter-spacing: .04em; fill: var(--ink-mute); }
.timing .lead { font-family: var(--mono); font-size: 9px; letter-spacing: .06em; fill: var(--ink-mute); }
.timing .bits text { font-family: var(--mono); font-size: 7.5px; fill: var(--ink-mute); }
.timing .dim path, .timing .repeat path { stroke: var(--rule); stroke-width: 1; fill: none; }

/* The bit row is the chain itself, not a caption on it: read left to right it
   is the whole register with the mouth end first, because where a bit sits in
   the chain is exactly how late it leaves. So it is a tape -- one jump left per
   clock, a bit spilled at the mouth -- and nothing refills behind it until the
   next LOAD. It steps rather than glides, on the same beat as the bytes above. */
.timing .mouth path { fill: none; stroke: var(--flux); stroke-width: 1.2; }
.timing .tape { animation: drain 9s linear infinite; }

/* the same 22%-78% window the cursor walks, in sixty-four equal pushes */
@keyframes drain {
  0%        { transform: translateX(0); }
  22%       { transform: translateX(0); animation-timing-function: steps(64, end); }
  78%, 100% { transform: translateX(-360px); }
}
}

.mech .part { fill: none; stroke: var(--ink); stroke-width: 1.2; }
.mech .rule { stroke: var(--rule); stroke-width: 1; fill: none; }
.mech .dim { stroke: var(--rule); stroke-width: 1; fill: none; }
.mech .cross { stroke: var(--ink-mute); stroke-width: .8; fill: none; }
.mech .pads { stroke: var(--rule); stroke-width: 1; fill: none; }
.mech .ic { fill: none; stroke: var(--rule); stroke-width: 1; }
.mech .hall { fill: var(--ink); }
.mech .ghost { fill: none; stroke: var(--rule); stroke-width: 1; stroke-dasharray: 4 3; }
.mech .hatch { fill: none; stroke: var(--flux); stroke-width: 1.2; }
.mech .flux path { fill: none; stroke: var(--flux); stroke-width: 1; opacity: .45; }
.mech .flux path:nth-child(2), .mech .flux path:nth-child(4) { opacity: .2; }
.mech text { font-family: var(--mono); fill: var(--ink-mute); }
.mech .ann { font-size: 10px; }
.mech .hd { font-size: 10px; letter-spacing: .16em; fill: var(--ink-mute); }
.mech .ghost-t { font-size: 10px; }

/* ---- revisions ---- */

.band-head { grid-column: 1 / 4; }
.band-note { grid-column: 4 / 9; color: var(--ink-mute); align-self: end; padding-bottom: .2rem; }

.rev {
  grid-column: span 4;
  border-top: 1px solid var(--ink);
  padding-top: 1rem;
  margin-top: 1.5rem;
}
.rev:first-of-type { padding-right: 2rem; }
.rev:last-of-type { padding-left: 2rem; border-left: 1px solid var(--rule); }

.rev h3 { font-size: 1.0625rem; }

/* the plate: both sides of both boards, unfolded about a hinge, and shown at
   true relative scale -- 24 mm against 20 mm, so the 1.2 ratio holds at every
   viewport width */

.plate { grid-column: 1 / 9; margin: 2.25rem 0 0; }

.views { display: flex; flex-wrap: wrap; gap: 2.5rem 3rem; align-items: flex-start; }

.vgroup { flex: 0 1 auto; min-width: 0; }
.vgroup + .vgroup { border-left: 1px solid var(--rule); padding-left: 3rem; }

.vname {
  display: flex;
  gap: .9rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ink);
  padding-bottom: .45rem;
}
.vname span + span { color: var(--ink-mute); letter-spacing: .06em; }

.vpair { display: flex; align-items: flex-start; margin-top: 1rem; }

.vside { min-width: 0; width: clamp(8.25rem, 21.3vw, 16.75rem); }
.vg2 .vside { width: clamp(6.875rem, 17.75vw, 13.96rem); }

.vside img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: var(--square);
}
.vtag {
  margin-top: .55rem;
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .06em;
  color: var(--ink-mute);
}

/* the hinge: the fold line the two views are unfolded about */
.vhinge {
  position: relative;
  flex: 0 0 3.5rem;
  align-self: stretch;
  color: var(--ink-mute);
}
.vhinge::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 1.9rem;
  border-left: 1px dashed currentColor;
  opacity: .6;
}
.vhinge svg {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: .35rem 0;
}
.vhinge span {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%) translateY(1.4rem);
  writing-mode: vertical-rl;
  background: var(--paper);
  padding: .45rem 0;
  font-family: var(--mono);
  font-size: .625rem;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.plate figcaption {
  margin-top: 1.5rem;
  padding-top: .7rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .6875rem;
  line-height: 1.7;
  letter-spacing: .04em;
  color: var(--ink-mute);
  max-width: 68ch;
}
.rev dl { margin-top: 1rem; }
.rev .rev-status {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.6;
  color: var(--ink);
  max-width: 34ch;
}

.band-foot {
  grid-column: 1 / 7;
  margin-top: 2.5rem;
  color: var(--ink-mute);
}

@media (max-width: 62rem) {
  .band-head, .band-note, .band-foot { grid-column: 1 / 9; }
  .band-note { padding-bottom: 0; }
  .rev { grid-column: 1 / 9; }
  .rev:first-of-type, .rev:last-of-type { padding-inline: 0; border-left: 0; }

  .vgroup { flex: 1 1 100%; }
  .vgroup + .vgroup { border-left: 0; padding-left: 0; }
  .vg1 .vside { width: 48%; }
  .vg2 .vside { width: 40%; }
  .vhinge { flex: 1 1 auto; }
}

@media (max-width: 40rem) {
  .band-head, .band-note, .band-foot, .rev, .plate { grid-column: 1 / 5; }
  /* at this width the views are too short for the vertical label to sit beside
     them; the arrow alone carries the hinge */
  .vhinge span { display: none; }
}

/* ---- log ---- */

.term-label {
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--rule);
}

.log {
  margin: 0;
  padding: 1rem 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-top: 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .75rem;
  line-height: 1.9;
  color: var(--ink-mute);
}
.log code { font: inherit; }
.log .bad { color: var(--flux); }

/* ---- footer ---- */

footer.sheet {
  border-top: 1px solid var(--rule);
  padding-block: 2rem 2.5rem;
  row-gap: 1.5rem;
}

.f-left { grid-column: 1 / 5; padding-right: 2rem; }
.f-left p { font-size: .875rem; }
.f-mute { color: var(--ink-mute); font-size: .8125rem !important; margin-top: .4rem !important; }

.f-right {
  grid-column: 7 / 9;
  font-family: var(--mono);
  font-size: .8125rem;
  display: grid;
  gap: .35rem;
  align-content: start;
}

.f-mark {
  grid-column: 1 / 9;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .6875rem;
  letter-spacing: .14em;
  color: var(--ink-mute);
}

@media (max-width: 40rem) {
  .f-left { grid-column: 1 / 5; padding-right: 0; }
  .f-right { grid-column: 1 / 5; }
  .f-mark { grid-column: 1 / 5; }
}

/* the figures scale down with the viewport, so their lettering scales up */
@media (max-width: 40rem) {
  .shift text { font-size: 13px; }
  .shift .sh-side, .shift .sh-load { font-size: 11px; }
  .shift .sh-idx text { font-size: 10px; }
  .shift .sh-phase text { font-size: 10.5px; }
  .timing .tr-label text { font-size: 14px; }
  .timing .ann text, .timing .dim text { font-size: 12px; }
  .timing .bits text { font-size: 9px; }
  .revstamp { font-size: .75rem; }
  .mech .ann, .mech .hd, .mech .ghost-t { font-size: 13px; }
}
