/* Fonts are served by the site (Latin subset from Google Fonts, SIL OFL 1.1,
   licences in fonts/). Geist and Geist Mono are variable fonts. */
@font-face {
  font-family: "Geist";
  src: url("fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("fonts/instrument-serif-italic.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f5f5f5;
  --paper-2: #ebecef;
  --rule: #d9dbe1;
  --ink: #2d3142;
  --muted: #4f5d75;
  --accent: #eb6c36;
  --accent-tint: #fbd9c8;
  /* Focus rings: tangerine deep enough for 3:1 on paper (WCAG 1.4.11), ember on the slab. */
  --focus: #c9561f;
  --ember: #ff9a6b;
  --slab: #2d3142;
  --key: #3b4054;
  --key-hover: #464c62;
  --on-slab: #f5f5f5;
  --on-slab-2: #bcc2d1;
  --gutter: clamp(16px, 4vw, 48px);
  /* Space follows the content: a change of topic gets a full pause, a
     section that continues the one before it a shorter one. Both grow with
     the screen's width and height, so a short laptop screen keeps less dead
     space than a tall monitor. */
  --space-topic: clamp(48px, 3vw + 4vh, 96px);
  --space-related: clamp(32px, 2vw + 2vh, 56px);
  --space-head: clamp(16px, 1vw + 1.5vh, 32px);
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
  scrollbar-color: var(--muted) var(--paper-2);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  caret-color: var(--accent);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--accent-tint);
  color: var(--ink);
}

img,
video,
canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.22em;
}

a:hover {
  text-decoration-thickness: 2.5px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.console :focus-visible {
  outline-color: var(--ember);
}

h1,
h2,
h3 {
  text-wrap: balance;
}

h2 {
  margin: 0 0 0.45em;
  font: 400 clamp(2.25rem, 1.4rem + 2.8vw, 3.75rem) / 1 var(--serif);
  letter-spacing: -0.015em;
}

.sprite {
  position: absolute;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
}

.skip:focus {
  top: 8px;
}

/* Top bar */

.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px var(--gutter);
  font-size: 0.9375rem;
}

.bar-name {
  font-weight: 600;
  text-decoration: none;
}

.bar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
}

.bar nav a {
  text-decoration: none;
  color: var(--muted);
}

.bar nav a:hover {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.bar-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.out {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Hero */

.hero {
  display: grid;
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px var(--gutter) 20px;
}

h1 {
  margin: 0 0 0.3em;
  font: 400 clamp(3.25rem, 1.8rem + 4.2vw, 5.25rem) / 0.92 var(--serif);
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 12px;
  max-width: 36ch;
  font-size: clamp(1.125rem, 1rem + 0.45vw, 1.3125rem);
  line-height: 1.5;
}

.byline {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.875rem;
}

.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
  margin: 0 0 24px;
  padding: 12px 0;
  border-block: 1px solid var(--rule);
}

.specs div {
  display: flex;
  flex-direction: column-reverse;
}

.specs dt {
  color: var(--muted);
  font-size: 0.8125rem;
}

.specs dd {
  margin: 0;
  font: 500 1.25rem/1.3 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.clip {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 16px;
  align-items: end;
  margin: 0;
}

.clip video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--ink);
}

.clip figcaption {
  text-wrap: pretty;
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 28ch;
}

.clip strong {
  color: var(--ink);
  font-weight: 600;
}

/* Remote: the drawn room plus the phone pad */

.remote {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.room {
  position: relative;
}

.room canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgb(45 49 66 / 0.08), 0 8px 24px -12px rgb(45 49 66 / 0.25);
}

.room-tag {
  position: absolute;
  left: 12px;
  top: 12px;
  margin: 0;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: rgb(245 245 245 / 0.92);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.room-tag span {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--paper);
  font: 500 0.6875rem/1.5 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Beside the room's buttons, so it never covers the furniture. */
.room-score {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.4;
}

.room-score span {
  color: var(--ink);
  font: 500 0.8125rem var(--mono);
  font-variant-numeric: tabular-nums;
}

.room-caption {
  position: absolute;
  left: 50%;
  bottom: 14px;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 6px);
  transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1), transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.room-caption.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.room-loading {
  position: absolute;
  inset: auto 12px 12px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgb(245 245 245 / 0.92);
  color: var(--muted);
  font-size: 0.875rem;
}

.room-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font: 500 0.8125rem/1.2 var(--sans);
  cursor: pointer;
  transition: border-color 120ms ease-out, background-color 120ms ease-out;
}

.chip:hover {
  border-color: var(--muted);
}

.chip:disabled,
.key:disabled,
.link:disabled {
  opacity: 0.45;
  cursor: progress;
}

.console {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--slab);
  color: var(--on-slab);
}

.pad {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  grid-auto-rows: 88px;
  gap: 8px;
}

.key {
  display: grid;
  grid-template-rows: 30px 1fr auto;
  justify-items: center;
  align-items: center;
  padding: 9px 4px 8px;
  border: 0;
  border-radius: 11px;
  background: var(--key);
  color: var(--on-slab);
  font: 500 0.8125rem/1.15 var(--sans);
  text-align: center;
  cursor: pointer;
  transition: background-color 120ms ease-out, transform 80ms ease-out, box-shadow 120ms ease-out;
}

.key svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: #dfe2ea;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 120ms ease-out;
}

.key:hover {
  background: var(--key-hover);
}

.key:active {
  transform: translateY(1px);
}

/* .is-on: the CLEAN key, whose label already says Start or Stop cleaning. */
.key[aria-pressed="true"],
.key.is-on {
  background: var(--key-hover);
  box-shadow: inset 0 0 0 1.5px var(--ember);
}

.key[aria-pressed="true"] svg,
.key.is-on svg {
  stroke: var(--accent);
}

.key[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.key[aria-disabled="true"]:active {
  transform: none;
}

.key-cmd {
  margin-top: 3px;
  color: var(--on-slab-2);
  font: 400 0.625rem/1 var(--mono);
  letter-spacing: 0.04em;
}

.key.key-empty {
  border: 1px dashed rgb(245 245 245 / 0.08);
  background: transparent;
  cursor: default;
}

.readout {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  padding: 4px 4px 2px 6px;
}

.status {
  margin: 0;
  min-height: 2.9em;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.meters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px 12px;
  margin: 0;
}

.meters dt {
  color: var(--on-slab-2);
  font-size: 0.6875rem;
}

.meters dd {
  margin: 0;
  font: 500 0.8125rem/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.meters .is-near {
  color: #ff9a6b;
}

.log {
  flex: 1;
  margin: 0;
  padding: 8px 0 0;
  list-style: none;
  border-top: 1px solid rgb(245 245 245 / 0.12);
  font: 400 0.75rem/1.55 var(--mono);
  min-height: 4.6em;
}

.log li {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.log li:not(:first-child) {
  opacity: 0.55;
}

.log-event,
.log-serial {
  color: var(--on-slab-2);
}

.log-serial::before {
  content: "serial  ";
  color: #ff9a6b;
}

.readout-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--on-slab-2);
  font-size: 0.75rem;
}

.link {
  padding: 6px 10px;
  font: 500 0.75rem/1 var(--sans);
  cursor: pointer;
  border: 1px solid rgb(245 245 245 / 0.2);
  border-radius: 8px;
  background: transparent;
  color: var(--on-slab);
}

.link.is-off {
  border-color: var(--accent);
  color: #ff9a6b;
}

.foot-buttons {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

#bench-name {
  white-space: nowrap;
}

.link:hover {
  border-color: rgb(245 245 245 / 0.45);
}

/* Switches: a slot as dark as the robot's body, and a knob that slides
   across and lights up as the green start button on its lid. */

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--ink);
  font: 500 0.8125rem/1.2 var(--sans);
  cursor: pointer;
}

.switch input {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: #23262f;
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.45);
  appearance: none;
  cursor: pointer;
}

.switch input::before,
.switch input::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform-origin: left center;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), opacity 160ms ease-out;
}

.switch input::before {
  background: #b9bec8;
  box-shadow: inset 0 -2px 0 #868d9c;
}

.switch input::after {
  background: #46e07a;
  box-shadow: inset 0 -2px 0 #2fae5a;
  opacity: 0;
}

.switch input:checked {
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.45), inset 0 0 0 1.5px var(--ember);
}

.switch input:checked::before,
.switch input:checked::after {
  transform: translateX(16px);
  transform-origin: right center;
}

.switch input:checked::after {
  opacity: 1;
}

/* Pressed, the knob squashes toward its travel. */
.switch input:active::before,
.switch input:active::after {
  transform: scaleX(1.2);
}

.switch input:checked:active::before,
.switch input:checked:active::after {
  transform: translateX(16px) scaleX(1.2);
}

.switch:hover input:not(:checked):not(:disabled) {
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.45), inset 0 0 0 1.5px var(--muted);
}

.switch input:disabled {
  opacity: 0.45;
  cursor: progress;
}

.switch-dark {
  color: var(--on-slab);
}

.switch-dark input {
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.45), inset 0 0 0 1.5px rgb(245 245 245 / 0.22);
}

.switch-dark:hover input:not(:checked):not(:disabled) {
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.45), inset 0 0 0 1.5px rgb(245 245 245 / 0.5);
}

.switch-small {
  min-height: 28px;
  font-size: 0.75rem;
}

.sim-note {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.sim-note p {
  max-width: 52ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (min-width: 1080px) {
  .hero {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: clamp(28px, 3.5vw, 56px);
    padding-top: 24px;
  }

  .sim-note p {
    margin-left: calc(41.67% + 16px);
  }

}

@media (max-width: 640px) {
  .clip {
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 12px;
  }

  .console {
    grid-template-columns: minmax(0, 1fr);
  }

  .pad {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 84px;
  }

  .room-tag {
    left: 8px;
    top: 8px;
    font-size: 0.6875rem;
  }

  .room-caption {
    bottom: 8px;
    font-size: 0.75rem;
  }

  /* Phone: the clip sits beside the three numbers. */
  .proof {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }

  .proof .specs {
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .proof .clip {
    display: block;
    order: -1;
  }

  .proof .clip figcaption {
    margin-top: 8px;
    font-size: 0.8125rem;
  }

  .readout-foot {
    flex-wrap: wrap;
  }
}

/* Sections */

.film,
.footage,
.build,
.story,
.results,
.how,
.thesis {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-topic) var(--gutter) 0;
}

/* The real-robot clips continue the project video. */
.footage {
  padding-top: var(--space-related);
}

.section-head {
  max-width: 62ch;
  margin-bottom: var(--space-head);
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 1.0625rem;
}

figure {
  margin: 0;
}

figcaption {
  color: var(--muted);
  font-size: 0.9375rem;
}

.film video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: 0 1px 2px rgb(45 49 66 / 0.08), 0 16px 40px -20px rgb(45 49 66 / 0.35);
}

/* The project video is the page's only clip with sound; the button above it says so and turns it on. */
.film-sound {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 11px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ember);
  color: var(--paper);
  font: 500 0.875rem/1 var(--sans);
  cursor: pointer;
  transition: background-color 120ms ease-out;
}

.film-sound:hover {
  background: var(--key-hover);
}

.film-sound:active {
  transform: translateY(1px);
}

.film-sound svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ember);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.film-sound-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.875rem;
}

.film figcaption {
  margin-top: 10px;
  font-size: 0.8125rem;
}

.footage-grid {
  display: grid;
  gap: 24px;
}

.footage video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  background: var(--ink);
}

.footage figcaption {
  margin-top: 10px;
  max-width: 44ch;
}

@media (min-width: 720px) {
  .footage-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Build stages: widths follow each photo's aspect ratio so a row shares one height. */

.stages {
  --gap: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 28px var(--gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage {
  flex: 1 1 100%;
}

.stage img {
  width: 100%;
  border-radius: 10px;
  background: var(--paper-2);
}

.stage p {
  margin: 10px 0 0;
  max-width: 44ch;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.tool {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

@media (min-width: 760px) {
  .stage {
    flex: 0 0 calc((100% - 2 * var(--gap)) * var(--ar) / var(--row));
  }
}

.finished {
  display: grid;
  gap: 20px;
  margin-top: var(--space-related);
  align-items: end;
}

.finished img {
  border-radius: 12px;
}

.finished figcaption {
  color: var(--ink);
  font: 400 clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem) / 1.15 var(--serif);
  max-width: 22ch;
}

@media (min-width: 900px) {
  .finished {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 40px;
  }
}

/* Story */

.story h2 {
  max-width: 20ch;
}

.story-body {
  max-width: 64ch;
  font-size: 1.0625rem;
}

.story-body p {
  margin: 0 0 1em;
}

.diagram img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 12px;
}

.story .diagram {
  margin-top: 16px;
  max-width: 900px;
}

.diagram figcaption {
  margin-top: 10px;
}

/* Results */

.results-grid {
  display: grid;
  gap: 40px;
}

@media (min-width: 900px) {
  .results-grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 56px;
  }
}

.sheet,
.gains {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.sheet th,
.sheet td {
  padding: 13px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.sheet tr:first-child th,
.sheet tr:first-child td {
  border-top: 1px solid var(--ink);
}

.sheet th {
  width: 38%;
  padding-right: 16px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9375rem;
}

.sheet b {
  font-weight: 600;
}

.limits h3 {
  margin: 0 0 12px;
  font: 600 1.125rem/1.3 var(--sans);
}

.limits ul {
  margin: 0;
  padding-left: 1.1em;
}

.limits li {
  margin-bottom: 0.7em;
}

.limits li::marker {
  color: var(--accent);
}

/* Engineers */

.how-grid {
  display: grid;
  gap: 40px;
  max-width: 1000px;
}

.gains-wrap {
  margin-top: 40px;
  /* At 320 px the five columns are a few pixels too wide; scroll the table, not the page. */
  overflow-x: auto;
}

.gains {
  max-width: 760px;
}

.gains caption {
  margin-bottom: 10px;
  text-align: left;
  font-weight: 600;
}

.gains th,
.gains td {
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.gains thead th {
  border-bottom-color: var(--ink);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.875rem;
}

.gains td:nth-child(n + 3) {
  font-family: var(--mono);
  font-size: 0.9375rem;
}

.gains tbody th {
  font-weight: 500;
}

.links {
  display: grid;
  gap: 8px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.links a {
  margin-right: 10px;
  color: var(--ink);
  font: 500 0.9375rem var(--mono);
}

/* Thesis */

.thesis > p {
  max-width: 64ch;
}

.thesis-title {
  margin: 0 0 12px;
  font: italic 400 clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem) / 1.15 var(--serif);
}

.thesis-title cite {
  font-style: inherit;
}

.thesis-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}

.button {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 20px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms ease-out;
}

.button span {
  color: var(--on-slab-2);
  font-size: 0.8125rem;
}

.button:hover {
  background: #3b4054;
}

/* Ask the thesis */

.ask {
  max-width: 76ch;
  margin-top: clamp(48px, 6vw, 72px);
  padding-top: clamp(32px, 4vw, 48px);
  border-top: 1px solid var(--rule);
}

.ask h3 {
  margin: 0 0 8px;
  font: 400 clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem) / 1.1 var(--serif);
  letter-spacing: -0.01em;
}

.ask-note {
  max-width: 64ch;
  margin: 0 0 24px;
  color: var(--muted);
}

.ask-form label {
  display: block;
  margin-bottom: 8px;
  font: 500 0.8125rem var(--mono);
  color: var(--muted);
}

.ask-row {
  display: flex;
  gap: 8px;
}

.ask-row input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  transition: border-color 120ms ease-out;
}

.ask-row input::placeholder {
  color: var(--muted);
}

.ask-row input:hover,
.ask-row input:focus {
  border-color: var(--muted);
}

.ask-row button {
  padding: 14px 22px;
  border: 0;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font: 500 1rem var(--sans);
  cursor: pointer;
  transition: background-color 120ms ease-out;
}

.ask-row button:hover {
  background: #3b4054;
}

.ask-try {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.ask-try span {
  margin-right: 4px;
  color: var(--muted);
  font: 500 0.8125rem var(--mono);
}

.ask-try button {
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 400 0.875rem var(--sans);
  cursor: pointer;
  transition:
    border-color 120ms ease-out,
    background-color 120ms ease-out;
}

.ask-try button:hover {
  border-color: var(--muted);
  background: var(--paper-2);
}

.ask-status {
  min-height: 1.6em;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

.ask-results {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.ask-results > li {
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}

.ask-results > li:first-child {
  border-top: 1px solid var(--rule);
}

.ask-where {
  margin: 0 0 8px;
  font: 500 0.8125rem/1.4 var(--mono);
  color: var(--muted);
}

/* Passages keep the thesis's own structure: headings, lists, tables. */
.ask-heading {
  margin: 0 0 6px;
  font: 600 1rem/1.35 var(--sans);
}

.ask-text {
  margin: 0 0 10px;
}

.ask-label {
  margin: 14px 0 4px;
  font-size: 0.9375rem;
}

.ask-list {
  margin: 0 0 10px;
  padding-left: 1.3em;
}

.ask-list li {
  margin: 0 0 6px;
}

.ask-list li::marker {
  color: var(--muted);
}

.ask-list .ask-list {
  margin: 6px 0 0;
}

.ask-list .ask-text {
  margin: 0 0 6px;
}

.ask-results strong {
  font-weight: 600;
}

.ask-results sub {
  font-size: 0.75em;
  line-height: 0;
}

/* Wide tables scroll inside the result, never the page. */
.ask-table {
  margin: 4px 0 12px;
  overflow-x: auto;
}

.ask-table table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.ask-table caption {
  margin-bottom: 6px;
  color: var(--muted);
  font: 500 0.8125rem/1.4 var(--mono);
  text-align: left;
}

.ask-table th,
.ask-table td {
  padding: 7px 14px 7px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.ask-table th {
  border-bottom-color: var(--ink);
  color: var(--muted);
  font-weight: 500;
}

.ask-results > li > a {
  font: 500 0.875rem var(--mono);
  text-underline-offset: 3px;
}

@media (max-width: 480px) {
  .ask-row {
    flex-direction: column;
  }
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
  max-width: 1240px;
  margin: var(--space-topic) auto 0;
  padding: 24px var(--gutter) 40px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}

.foot p {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.foot ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Back to top: a slab-coloured button, shown once the hero has scrolled away. */

.to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 5;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--slab);
  color: var(--on-slab);
  box-shadow: 0 6px 18px -8px rgb(45 49 66 / 0.6);
  opacity: 0;
  transform: translateY(8px);
  visibility: hidden;
  transition:
    opacity 180ms ease-out,
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0s linear 220ms;
}

.to-top.is-shown {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}

.to-top:hover {
  background: var(--key-hover);
}

.to-top svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Viewer for diagrams and photos */

.zoom {
  position: relative;
  display: block;
  cursor: zoom-in;
}

.zoom::after {
  content: "Enlarge";
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 9px;
  border-radius: 7px;
  background: rgb(45 49 66 / 0.82);
  color: var(--paper);
  font: 500 0.75rem/1.3 var(--sans);
  opacity: 0;
  transition: opacity 120ms ease-out;
}

.zoom:hover::after,
.zoom:focus-visible::after {
  opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
  .zoom::after {
    opacity: 1;
  }
}

.viewer {
  width: min(96vw, 1400px);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 64px -16px rgb(45 49 66 / 0.5);
}

/* The bar keeps its height for any caption length; the picture scrolls below it. */
.viewer[open] {
  display: flex;
  flex-direction: column;
}

.viewer::backdrop {
  background: rgb(45 49 66 / 0.72);
}

.viewer-bar {
  display: flex;
  flex: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

/* The whole caption, on as many lines as it needs. */
.viewer-caption {
  margin: 0;
  max-width: 90ch;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.viewer-close {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: var(--ink);
  color: var(--paper);
  font: 500 0.875rem/1 var(--sans);
  cursor: pointer;
}

.viewer-close svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.viewer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.viewer-body img {
  margin: 0 auto;
  max-height: calc(94vh - 160px);
  border-radius: 8px;
}

.viewer.is-diagram .viewer-body img {
  width: 100%;
  min-width: 860px;
  max-height: none;
}
