/* Machine Civilization Institute. One scrolling page in the order of the argument: each plate
   pairs a drawing in ink and red chalk with the text it illustrates. White page, Garamond
   throughout, one look in every viewer theme. */
:root {
  --paper: #ffffff;
  --ink: #1d1d1b;
  --ink-2: #5d5a55;
  --head: #111110;
  --chalk: #9a3322;
  --rule: rgba(17, 17, 16, 0.18);
  --serif: "EB Garamond", Garamond, "Iowan Old Style", Georgia, serif;
  --bar: 54px;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar) + 12px); }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 1rem + 0.28vw, 1.2rem);
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--chalk); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.16em; }
:focus-visible { outline: 1.5px solid var(--chalk); outline-offset: 3px; }
::selection { background: rgba(165, 69, 45, 0.18); }
p { hyphens: auto; -webkit-hyphens: auto; }

/* ---------- Title page ---------- */
.title-page { max-width: 66rem; margin: 0 auto; padding: max(9vh, 4.5rem) 16px 0; text-align: center; }
.rule { height: 2px; background: var(--head); }
.rule.thin { height: 1px; background: var(--rule); }
.title-page .name { margin: 1.4rem 0 1.3rem; font-weight: 500; text-transform: uppercase; font-size: clamp(1.55rem, 0.9rem + 2.4vw, 2.6rem); line-height: 1.15; letter-spacing: 0.14em; color: var(--head); text-wrap: balance; }
.title-page .by { margin: 1.2rem 0 0; font-style: italic; font-size: 1.1em; color: var(--ink-2); }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2rem 1.5rem; }
.title-page .links { margin-top: 1.2rem; }
.links a { color: var(--ink); }
.links a:hover, .links a[aria-current="true"] { color: var(--chalk); }

/* ---------- Bar: slides in once the title page has scrolled away ---------- */
.bar {
  position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: var(--bar);
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--rule);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  transform: translateY(-105%); transition: transform 0.35s ease;
}
html.scrolled .bar { transform: none; }
.bar .mark { font-weight: 500; text-transform: uppercase; font-size: 0.9rem; letter-spacing: 0.14em; color: var(--head); white-space: nowrap; }
.bar .mark:hover { text-decoration: none; color: var(--chalk); }
.bar .links { flex-wrap: nowrap; gap: 0 1.25rem; font-size: 0.98rem; }

/* ---------- Rail: the plates, in the margin ---------- */
.rail { display: none; }
@media (min-width: 1240px) {
  .rail { display: block; position: fixed; z-index: 15; left: 22px; top: 50%; transform: translateY(-50%); }
  .rail ol { list-style: none; margin: 0; padding: 0; position: relative; }
  .rail ol::before { content: ""; position: absolute; left: 0.62rem; top: 0.5rem; bottom: 0.5rem; width: 1px; background: var(--rule); }
  .rail li { position: relative; margin: 0.15rem 0; }
  .rail a { display: flex; align-items: center; gap: 0.7rem; padding: 0.18rem 0; color: var(--ink-2); font-size: 0.82rem; letter-spacing: 0.08em; line-height: 1.2; }
  .rail a:hover { text-decoration: none; color: var(--chalk); }
  .rail .n { display: inline-block; min-width: 1.3rem; text-align: center; background: var(--paper); position: relative; opacity: 0.6; transition: opacity 0.3s, color 0.3s, transform 0.3s; }
  .rail .t { opacity: 0; transform: translateX(-4px); transition: opacity 0.25s, transform 0.25s; white-space: nowrap; background: rgba(255, 255, 255, 0.96); padding: 0 0.35rem; font-style: italic; letter-spacing: 0; font-size: 0.95rem; }
  .rail a:hover .t, .rail a:focus-visible .t { opacity: 1; transform: none; }
  .rail a[aria-current="true"] { color: var(--chalk); }
  .rail a[aria-current="true"] .n { opacity: 1; transform: scale(1.25); }
}

/* ---------- Drawings ---------- */
.art {
  display: block; margin-inline: auto;
  width: min(100%, calc(var(--maxh, 74vh) * var(--ar, 1)));
  height: auto; aspect-ratio: var(--ar, 1);
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}
.art.grab { cursor: grab; } .art.grabbing { cursor: grabbing; }
html.no-js .art { display: none; }

/* ---------- Text ---------- */
.plate-no { margin: 0 0 0.6rem; color: var(--chalk); font-size: 0.78rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.18em; }
h1, h2, h3 { color: var(--head); text-wrap: balance; }
h1 { font-weight: 600; font-size: clamp(1.8rem, 1.15rem + 2.2vw, 2.7rem); line-height: 1.14; margin: 0 0 1.1rem; }
h2 { font-weight: 600; font-size: clamp(1.55rem, 1.1rem + 1.4vw, 2.15rem); line-height: 1.16; margin: 0 0 1rem; }
h3 { font-weight: 600; font-size: 1.12em; line-height: 1.3; margin: 1.5rem 0 0.35rem; }
.text p, .lede p { margin: 0 0 0.95em; }

/* ---------- Plate I ---------- */
.hero { padding-top: 1.5rem; }
.hero-art { width: 100%; height: clamp(360px, 76vh, 880px); aspect-ratio: auto; }
.lede { max-width: 41rem; margin: 0 auto; padding: 1.5rem 16px 0; }
.lede .plate-no, .lede h1 { text-align: center; }

/* ---------- Plates II–IX ---------- */
.plate {
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: clamp(2rem, 5vw, 5.5rem); align-items: start;
  max-width: 80rem; margin: 0 auto; padding: clamp(5rem, 14vh, 10rem) clamp(16px, 4vw, 3.5rem) 0;
}
.plate .fig { margin: 0; position: sticky; top: calc(var(--bar) + 3vh); }
.plate .text { max-width: 36rem; padding-top: 6vh; }
.plate.flip .fig { order: 2; }
.plate.wide { grid-template-columns: minmax(0, 1fr); max-width: 74rem; }
.plate.wide .fig { position: static; }
.plate.wide .text { margin: 0 auto; max-width: 41rem; padding-top: 1rem; }

.agenda, .projects { max-width: 82rem; margin: 0 auto; padding: clamp(5rem, 14vh, 10rem) clamp(16px, 4vw, 3.5rem) 0; }
.sec-head { text-align: center; margin: 0 auto 3rem; }
.sec-head h2 { margin: 0; }
.questions { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4.5rem clamp(1.5rem, 3vw, 3.5rem); }
.questions li { margin: 0; }
.questions .art { width: 100%; }
.fig-no { margin: 0.6rem 0 0.3rem; color: var(--chalk); font-size: 0.74rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.18em; }
.questions .q { margin: 0 0 0.4rem; font-style: italic; font-weight: 500; font-size: 1.13em; line-height: 1.28; }
.questions .a { margin: 0; text-align: left; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(2rem, 5vw, 5rem); max-width: 74rem; margin: 0 auto; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(2rem, 3.6vw, 3.8rem); max-width: 82rem; margin: 0 auto; }
.pair .art, .trio .art { width: 100%; }
.pair h3, .trio h3, .plate h3[id] { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 1rem; }
.pair h3 a, .trio h3 a, .plate h3[id] a { font-weight: 400; font-size: 0.9em; }
.pair p, .trio p { margin: 0; }

.colophon { max-width: 41rem; margin: 6rem auto 0; padding: 0.8rem 16px 5rem; border-top: 1px solid var(--rule); color: var(--ink-2); font-size: 0.9em; }
.colophon p { margin: 0; }

/* ---------- Narrower screens ---------- */
@media (max-width: 1080px) {
  .questions, .trio { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .plate { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
  .plate .fig { position: static; }
  .plate.flip .fig { order: 0; }
  .plate .text { padding-top: 0; max-width: 41rem; margin: 0 auto; }
  .pair, .trio { grid-template-columns: minmax(0, 1fr); gap: 4rem; }
  .bar .mark { display: none; }
  .bar { justify-content: center; padding: 0 12px; }
  .bar .links { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .bar .links::-webkit-scrollbar { display: none; }
  .art { --maxh: 64vh; }
}
@media (max-width: 600px) {
  .questions { grid-template-columns: minmax(0, 1fr); gap: 3.5rem; }
  .title-page .links { gap: 0.2rem 1.1rem; }
  .bar .links { gap: 0 0.8rem; font-size: 0.88rem; justify-content: flex-start; }
  .hero-art { height: clamp(320px, 100vw, 520px); }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar, .rail .n, .rail .t { transition: none !important; }
}
