/* Tokens mirrored from my-website (app/theme.ts, app/blog/theme.ts) so these
   pages sit in the same visual language as the rest of the site. */
:root {
  --paper: #f4efe6;
  --paper-elevated: #f4efe5;
  --ink: #262019;
  --ink-title: #282219;
  --muted: #877d6c;
  --secondary: #857b6b;
  --rule: #a2977f;
  --faint: #c0b6a0;
  --hairline: rgba(30, 24, 14, .26);

  --serif: var(--font-serif, "Piazzolla"), Georgia, "Times New Roman", serif;
  --sans: var(--font-sans, "Inter"), ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --side: 44px;
  --top: 44px;
  --maxw: 768px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--side); }

/* ------------------------------------------------------------- typography */
h1, h2, h3 { font-family: var(--serif); font-weight: 500; color: var(--ink-title); margin: 0; }
h1 { font-size: 38px; line-height: 1.18; letter-spacing: -0.015em; }
h2 { font-size: 26px; line-height: 1.3; letter-spacing: -0.01em; margin: 44px 0 4px; }
h3 { font-size: 21px; line-height: 1.35; margin: 28px 0 2px; }

p, li { font-family: var(--serif); font-size: 17px; font-weight: 400; line-height: 1.7; color: var(--ink); }
p { margin: 0 0 20px; }

.subtitle { font-family: var(--serif); font-size: 18px; line-height: 1.5; color: var(--secondary); margin: 0; }

/* Small tracked sans labels — the site's date/badge treatment. */
.label {
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--rule);
}

a { color: var(--ink-title); text-decoration: underline; text-underline-offset: 2px; }
a.plain { text-decoration: none; }

code {
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-title);
  background: var(--paper-elevated); border-radius: 3px; padding: 1px 5px;
  box-shadow: inset 0 0 0 1px rgba(30, 24, 14, .08);
}

hr { border: 0; border-top: 1px solid var(--rule); margin: 44px 0; opacity: .5; }

/* --------------------------------------------------------------- layout */
.page-head { padding-top: var(--top); }
.page-head .meta { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.page-head h1 { text-wrap: pretty; margin-bottom: 10px; }
.links { display: flex; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.links a { font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; }

main { padding-bottom: 72px; }

figure { margin: 28px 0; }
/* Photos are cropped to the 3:2 the rest of the site uses for project imagery;
   the interesting half of the breadboard sits above centre. */
figure img {
  width: 100%; display: block; border-radius: 3px;
  aspect-ratio: 3 / 2; object-fit: cover; object-position: center 42%;
}
figcaption { font-family: var(--sans); font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-top: 8px; }
/* The exported drawio SVGs choose their own background via light-dark(); pin
   them to light so they stay on paper. */
figure.diagram img {
  background: #fff; padding: 12px; color-scheme: light;
  aspect-ratio: auto; height: auto; object-fit: contain;
}

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pair figure { margin: 28px 0 0; }

table.spec { border-collapse: collapse; width: 100%; margin: 8px 0 20px; }
table.spec th, table.spec td {
  text-align: left; vertical-align: top; padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
}
table.spec th {
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--rule); font-weight: 400;
  width: 34%; padding-right: 18px; padding-top: 12px;
}
table.spec td { font-family: var(--serif); font-size: 15.5px; line-height: 1.6; }

/* ============================================================= SIMULATOR */
.sim-page { display: flex; flex-direction: column; min-height: 100vh; }

.sim-bar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 18px var(--side);
}
.sim-bar .title { font-family: var(--serif); font-size: 19px; font-weight: 500; color: var(--ink-title); margin-right: auto; }
.sim-bar button, .sim-bar a {
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--ink-title); text-decoration: underline; text-underline-offset: 2px;
}
.sim-bar button:hover, .sim-bar a:hover { color: var(--muted); }

.bench {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 34px; padding: 40px var(--side) 56px;
}

.rack { display: flex; gap: 34px; align-items: center; justify-content: center; flex-wrap: wrap; }
.controls-row { display: flex; gap: 46px; align-items: flex-start; justify-content: center; flex-wrap: wrap; }

.pin-tag {
  font-family: var(--sans); font-size: 10.5px; letter-spacing: .1em;
  color: var(--muted); text-align: center; margin-top: 12px; line-height: 1.7;
}
.pin-tag b { color: var(--secondary); font-weight: 500; }

.keyhint { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; }
kbd {
  font-family: var(--sans); font-size: 10px; letter-spacing: .04em; line-height: 1;
  border: 1px solid var(--hairline); border-radius: 3px;
  padding: 4px 5px; color: var(--secondary); background: var(--paper-elevated);
}

/* The modules keep their real colours - that is the point of the page. Only
   the shadows are warmed so they sit on paper rather than on a dark bench. */
.st7735 {
  background: linear-gradient(160deg, #c0332b, #96201a);
  padding: 13px 13px 26px; border-radius: 3px;
  box-shadow: 0 10px 26px rgba(60, 44, 24, .22), inset 0 1px 0 rgba(255, 255, 255, .16);
  position: relative;
}
.st7735::after {
  content: "1.44\" TFT  ST7735";
  position: absolute; left: 0; right: 0; bottom: 8px; text-align: center;
  font-family: var(--sans); font-size: 9px; letter-spacing: .12em; color: rgba(255, 255, 255, .6);
}
.st7735 .glass { background: #05070c; padding: 7px; border-radius: 2px; box-shadow: inset 0 0 0 1px #2a2f38; }
#tft {
  /* integer scale (128 x 3) so every ST7735 pixel stays an exact square */
  display: block; width: 384px; height: 384px;
  image-rendering: pixelated; background: #000;
}

.lcd1602 {
  background: linear-gradient(160deg, #1d7a45, #10592f);
  padding: 14px; border-radius: 3px;
  box-shadow: 0 10px 26px rgba(60, 44, 24, .22), inset 0 1px 0 rgba(255, 255, 255, .14);
  position: relative;
}
.lcd1602 .header-pins {
  position: absolute; top: 5px; left: 14px; right: 14px; height: 7px;
  background: repeating-linear-gradient(90deg, #d8b25a 0 5px, transparent 5px 11px);
  border-radius: 2px; opacity: .85;
}
.lcd1602 .bezel { margin-top: 8px; background: #0b0c0e; padding: 12px 10px; border-radius: 2px; }
#hd44780 {
  /* integer scale (96 x 4, 18 x 4) so the character dots stay square */
  display: block; width: 384px; height: 72px;
  image-rendering: pixelated; background: #1436c8;
}

.joystick-mod {
  width: 168px; padding: 14px 14px 10px; border-radius: 3px;
  background: linear-gradient(160deg, #1b2230, #0f141d);
  box-shadow: 0 10px 24px rgba(60, 44, 24, .22), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.joystick-mod .silk {
  font-family: var(--sans); font-size: 9px; letter-spacing: .16em;
  color: rgba(255, 255, 255, .48); text-align: center; margin-bottom: 9px;
}
.gimbal {
  width: 140px; height: 140px; margin: 0 auto; border-radius: 5px;
  background: linear-gradient(150deg, #2b2b2b, #131313);
  box-shadow: inset 0 0 0 1px #3a3a3a;
  display: grid; place-items: center; touch-action: none; cursor: grab;
}
.gimbal:active { cursor: grabbing; }
.gimbal .well {
  width: 104px; height: 104px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #0a0a0a, #1c1c1c 72%, #262626);
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, .85);
  display: grid; place-items: center;
}
.knob {
  width: 74px; height: 74px; border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #55565a 0%, #2c2d31 46%, #101114 100%);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(255, 255, 255, .09);
  position: relative; will-change: transform;
}
.knob::before {
  content: ""; position: absolute; inset: 13px; border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .055) 0 2px, transparent 2px 5px);
}
.knob::after {
  content: ""; position: absolute; inset: 26px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #3a3b40, #17181b);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, .12);
}
.joystick-mod .pins {
  margin-top: 11px; height: 8px; border-radius: 2px; opacity: .8;
  background: repeating-linear-gradient(90deg, #d8b25a 0 6px, transparent 6px 13px);
}

.button-mod { display: flex; flex-direction: column; align-items: center; padding-top: 30px; }
.tactile {
  width: 92px; height: 92px; border-radius: 4px; border: 0; padding: 0;
  background: linear-gradient(160deg, #cfd4da, #8d949c);
  box-shadow: 0 8px 20px rgba(60, 44, 24, .22), inset 0 1px 0 rgba(255, 255, 255, .7);
  display: grid; place-items: center; position: relative; cursor: pointer; touch-action: none;
}
.tactile .plunger {
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #4a4d52, #17181b 78%);
  box-shadow: 0 4px 0 #4b5057, 0 6px 10px rgba(0, 0, 0, .4);
  transition: transform .04s ease, box-shadow .04s ease;
}
.tactile.down .plunger { transform: translateY(4px); box-shadow: 0 0 0 #4b5057, 0 2px 5px rgba(0, 0, 0, .4); }
.tactile::before, .tactile::after {
  content: ""; position: absolute; top: 12px; bottom: 12px; width: 7px; border-radius: 2px;
  background: linear-gradient(180deg, #b7bcc3, #7d838a);
}
.tactile::before { left: -6px; }
.tactile::after { right: -6px; }

/* --------------------------------------------------------- hood panel */
.hood { width: 100%; max-width: 820px; }
.hood > summary {
  cursor: pointer; list-style: none;
  font-family: var(--sans); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--rule); padding: 14px 0; border-top: 1px solid var(--hairline);
}
.hood > summary::-webkit-details-marker { display: none; }
.hood > summary::after { content: " +"; }
.hood[open] > summary::after { content: " –"; }
.hood > summary:hover { color: var(--muted); }

.hood-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 32px; padding: 4px 0 16px; }
.scope h4 {
  margin: 0 0 10px; font-family: var(--sans); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--rule); font-weight: 400;
}
table.regs { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 12px; font-variant-numeric: tabular-nums; }
table.regs td { padding: 4px 0; color: var(--secondary); white-space: nowrap; border-bottom: 1px solid rgba(30, 24, 14, .07); }
table.regs td:last-child { text-align: right; color: var(--ink-title); }
table.regs td.period { text-align: right; color: var(--faint); }
table.regs tr.stalled td:last-child { color: #b0651c; }
.scope p { font-size: 14px; line-height: 1.6; color: var(--secondary); }

@media (max-width: 760px) {
  :root { --side: 24px; }
  h1 { font-size: 30px; }
  #tft { width: 256px; height: 256px; }
  #hd44780 { width: 288px; height: 54px; }
  .pair { grid-template-columns: 1fr; }
  .controls-row { gap: 26px; }
  .bench { gap: 26px; padding: 26px var(--side) 40px; }
}
