/* rex-extensions: the printer-cli light table, reused. Each slide sets a simulated Rex window on a grey mat, with
   the install command and an agent prompt beside it. Every colour is a neutral grey (r = g = b), black or white;
   alpha is used only for shadows, hairlines and tints, so no hue ever appears, inside the terminal too. */

/* Playfair Display for titles and Old Standard TT for text, as on printer-cli's site (SIL OFL, see fonts/). */
@font-face {
  font-family: "Playfair Display";
  src: url("fonts/PlayfairDisplay-Variable.ttf") format("truetype");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "Old Standard TT";
  src: url("fonts/OldStandard-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Old Standard TT";
  src: url("fonts/OldStandard-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --mat: #d6d6d6;
  --mat-glow: #e6e6e6;
  --ink: #0a0a0a;
  --text: #262626;
  --muted: #474747;
  --hairline: #0a0a0a29;
  --control: #5c5c5c;
  --tint: #0a0a0a12;
  --term: #0a0a0a;
  --term-text: #e0e0e0;
  --term-dim: #949494;
  --term-line: #2e2e2e;
  --term-raise: #1c1c1c;
  --card: #ffffff;
  --card-text: #1a1a1a;
  --card-muted: #4d4d4d;
  --dot: #666666;
  --focus: #0a0a0a;
  --shadow: 0 1px 1px #00000026, 0 8px 16px -6px #00000040, 0 28px 56px -18px #00000066;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --serif: "Old Standard TT", Georgia, serif;
  --display: "Playfair Display", Georgia, serif;
  --gutter: clamp(16px, 3vw, 40px);
  color-scheme: light dark;
  accent-color: #0a0a0a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --mat: #262626;
    --mat-glow: #303030;
    --ink: #f2f2f2;
    --text: #e0e0e0;
    --muted: #b3b3b3;
    --hairline: #ffffff2e;
    --control: #8c8c8c;
    --tint: #ffffff14;
    --card: #171717;
    --card-text: #ededed;
    --card-muted: #b3b3b3;
    --dot: #8c8c8c;
    --focus: #f2f2f2;
    --shadow: 0 1px 1px #00000066, 0 8px 16px -6px #00000080, 0 28px 56px -18px #000000b3;
    accent-color: #f2f2f2;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background-color: var(--mat);
  /* The light table: a soft glow from under the mat, brightest behind the window. */
  background-image: radial-gradient(110% 85% at 32% 45%, var(--mat-glow), var(--mat) 72%);
  color: var(--text);
  font: 400 17px/1.5 var(--serif);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:visited { color: var(--ink); }
a:hover { text-decoration-thickness: 2px; }

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

::selection { background-color: var(--ink); color: var(--mat); }
.cmd ::selection, .win ::selection, pre.code ::selection { background-color: var(--term-text); color: var(--term); }

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

.shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

/* --- header ------------------------------------------------------------------------------------ */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--gutter) 6px;
}

/* No logo: a text wordmark in the display serif stands where printer-cli's logo stood. */
.brandline { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand {
  color: var(--ink);
  font: 700 28px/1.1 var(--display);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:visited { color: var(--ink); }
.tagline { margin: 0; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.top-controls { display: flex; align-items: center; gap: 14px; }

.cta {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background-color: var(--ink);
  color: var(--mat);
  font: 700 13px/1 var(--serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.cta:visited { color: var(--mat); }
.cta:hover { background-color: transparent; color: var(--ink); }

.counter {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.06em;
}
.counter #current { color: var(--ink); font-weight: 700; }

.ctl {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--control);
  border-radius: 6px;
  background-color: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.ctl:hover { background-color: var(--tint); }
.ctl:active { transform: translateY(1px); }
.icon { width: 20px; height: 20px; display: block; }

#autoplay[aria-pressed="true"] .icon-play,
#autoplay[aria-pressed="false"] .icon-pause { display: none; }

/* --- the slide ----------------------------------------------------------------------------------- */

.stage { position: relative; min-height: 0; display: grid; }

.noscript { margin: auto; padding: var(--gutter); max-width: 36em; text-align: center; }

.slide {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr);
  gap: clamp(24px, 4vw, 64px);
  min-height: 0;
  padding: 6px var(--gutter) 12px;
}

.mat { position: relative; min-width: 0; min-height: 0; }

/* The rig: the window, as large as fits at 16:10, and under it the steps of the simulation. */
.rig {
  position: absolute;
  inset: 2% 1%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
}
.frame { position: relative; min-height: 0; container-type: size; }

/* --- the simulated Rex window. Sizes are in em of a font scaled to the window's width, so the whole window
   scales as one picture; --w is that width. ------------------------------------------------------------ */

.win {
  --w: min(100cqw, 160cqh);
  position: absolute;
  inset: 0;
  margin: auto;
  width: var(--w);
  height: calc(var(--w) / 1.6);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 10px;
  background-color: var(--term);
  color: var(--term-text);
  box-shadow: var(--shadow);
  font: 400 calc(var(--w) / 68) / 1.45 var(--mono);
}
.win-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 0.9em;
  border-bottom: 1px solid var(--term-line);
  color: var(--term-dim);
}
.win-bar i { width: 0.8em; height: 0.8em; border-radius: 50%; background-color: #3d3d3d; }
.win-bar b { position: absolute; left: 0; right: 0; text-align: center; font-weight: 400; pointer-events: none; }
.win-body { display: grid; grid-template-columns: 19% minmax(0, 1fr); min-height: 0; }

.side {
  padding: 0.8em 0.6em;
  border-right: 1px solid var(--term-line);
  background-color: #111111;
  overflow: hidden;
}
.sess { padding: 0 0.4em 0.3em; color: var(--term-dim); font-weight: 700; white-space: nowrap; }
.tab { padding: 0.15em 0.4em; border-radius: 0.3em; color: var(--term-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.cur { background-color: #2b2b2b; color: #ffffff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.panes { flex: 1 1 0; display: flex; min-height: 0; }
.pane {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  padding: 0.7em 0.9em;
  transition: flex-grow 0.5s cubic-bezier(0.2, 0.7, 0.2, 1), flex-basis 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.pane + .pane { border-left: 1px solid var(--term-line); }
/* A pane that opens during the simulation grows from nothing. */
.pane.grow { flex: 0 0 0; padding-inline: 0; border-left-width: 0; }
.pane.grow.on { padding-inline: 0.9em; border-left-width: 1px; }
.pane.agent.on { flex: 1 1 0; }
.pane.gh.on { flex: 0 0 43%; }
.plabel { margin-bottom: 0.4em; color: var(--term-dim); }

.tx { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.ps, .dim { color: var(--term-dim); }
.hi { color: #ffffff; font-weight: 700; }
.cur-blk { display: inline-block; width: 0.6em; background-color: var(--term-text); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.frozen .cur-blk { animation: none; } /* paused means nothing moves, the cursor included */

/* The github panel, drawn with rows rather than one block of text so its right-hand columns line up. */
.gh { white-space: nowrap; }
.gh-head { display: flex; justify-content: space-between; font-weight: 700; color: #ffffff; }
.gh-head span { color: var(--term-dim); font-weight: 400; }
.gh-labels { color: var(--term-dim); overflow: hidden; text-overflow: ellipsis; }
.rule { height: 0; margin: 0.45em 0; border-top: 1px solid var(--term-line); }
.switch { display: grid; grid-template-columns: 1fr 1fr; text-align: center; }
.switch span { padding: 0.1em 0; color: var(--term-dim); }
.switch span.cur { background-color: var(--term-text); color: var(--term); font-weight: 700; }
.item { padding: 0.3em 0 0.3em 0.9em; border-left: 0.25em solid transparent; }
.item.cur { border-left-color: var(--term-text); background-color: var(--term-raise); }
.item .t { color: #ffffff; overflow: hidden; text-overflow: ellipsis; }
.item .m { display: flex; gap: 0.6em; color: var(--term-dim); }
.item .m .grow-x { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.btns { display: flex; gap: 0.6em; margin-top: 0.25em; }
.btn { padding: 0 0.5em; border: 1px solid #5c5c5c; border-radius: 0.25em; color: var(--term-text); }
.btn.on { background-color: var(--term-text); color: var(--term); }
.hints { position: absolute; left: 0.9em; right: 0.9em; bottom: 0.6em; color: var(--term-dim); overflow: hidden; text-overflow: ellipsis; }

/* The mcc strip, along the bottom of the tab: it rises from nothing when the key is pressed. */
.strip {
  flex: 0 0 0;
  overflow: hidden;
  border-top: 0 solid var(--term-line);
  transition: flex-basis 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.strip.on { flex-basis: 47%; border-top-width: 1px; }
.strip .tx { padding: 0.5em 0.9em; white-space: pre; overflow: hidden; }

.box-term { color: var(--term-dim); }

/* A key being pressed: shown over the window for as long as the simulation holds it. */
.keys {
  position: absolute;
  left: 50%;
  bottom: 9%;
  z-index: 3;
  display: flex;
  gap: 0.4em;
  translate: -50% 0;
  animation: press 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.keys kbd {
  min-width: 2.2em;
  padding: 0.35em 0.6em;
  border: 1px solid #ffffff59;
  border-bottom-width: 3px;
  border-radius: 0.4em;
  background-color: #f2f2f2;
  color: #0a0a0a;
  font: 700 1.5em/1 var(--mono);
  text-align: center;
  box-shadow: 0 0.4em 1.2em #00000080;
}
@keyframes press { from { opacity: 0; scale: 0.9; } }

/* Rex restarting: the window goes dark for a moment. */
.blank {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background-color: var(--term);
  color: var(--term-dim);
  animation: fade 0.3s both;
}

/* The steps of the simulation, like the captions under a proof: the one playing is in ink. */
.steps {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  color: var(--muted);
  font-size: 14px;
}
.steps li { counter-increment: step; padding-top: 6px; border-top: 2px solid transparent; transition: color 0.2s ease, border-color 0.2s ease; }
.steps li::before { content: counter(step) "  "; font-weight: 700; }
.steps li.on { color: var(--ink); }
.steps li.cur { border-top-color: var(--ink); font-weight: 700; }
.steps kbd { font: inherit; }

/* --- the text panel --------------------------------------------------------------------------------- */

.panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 4px 2px;
}
.panel-inner { margin-block: auto; display: flex; flex-direction: column; gap: 14px; max-width: 34em; }

.group {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.title {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(30px, 3.3vw, 48px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.blurb { margin: 0 0 4px; font-size: 18px; line-height: 1.45; }

.box { border-radius: 6px; }
.box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 0 16px;
}
.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.copy {
  min-width: 72px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid;
  border-radius: 4px;
  background-color: transparent;
  color: inherit;
  font: 700 12px/1 var(--serif);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

.cmd {
  background-color: var(--term);
  color: var(--term-text);
  box-shadow: var(--shadow);
  --focus: #ffffff;
}
.cmd .label { color: var(--term-dim); }
.cmd .copy { border-color: #ffffff73; }
.cmd .copy:hover { background-color: #ffffff1f; }
.cmd pre {
  margin: 0;
  padding: 8px 16px 14px;
  font: 14px/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cmd .line { display: block; padding-left: 2ch; text-indent: -2ch; }
.cmd .ps { user-select: none; }

.ask {
  background-color: var(--card);
  color: var(--card-text);
  border: 1px solid var(--hairline);
}
.ask .label { color: var(--card-muted); }
.ask .copy { border-color: var(--control); }
.ask .copy:hover { background-color: var(--tint); }
.ask p { margin: 0; padding: 6px 16px 14px; font-size: 17px; line-height: 1.45; }

.slide .rig, .slide .panel-inner > * { animation: settle 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.slide .panel-inner > *:nth-child(2) { animation-delay: 0.05s; }
.slide .panel-inner > *:nth-child(3) { animation-delay: 0.1s; }
.slide .panel-inner > *:nth-child(4) { animation-delay: 0.15s; }
.slide .panel-inner > *:nth-child(5) { animation-delay: 0.2s; }
@keyframes settle { from { opacity: 0; translate: 0 8px; } }
@keyframes fade { from { opacity: 0; } }

/* --- progress, ticks, footer ------------------------------------------------------------------------ */

.bar { padding: 0 var(--gutter); }

.progress { height: 2px; background-color: var(--hairline); overflow: hidden; }
.progress span {
  display: block;
  height: 100%;
  background-color: var(--ink);
  transform: scaleX(0);
  transform-origin: left center;
}

.nav-row { display: flex; align-items: center; gap: 8px; padding: 6px 0 2px; }

.dots {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: safe center;
  overflow-x: auto;
  scrollbar-width: none;
}
.dots::-webkit-scrollbar { display: none; }
.dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 36px;
  padding: 0;
  border: 0;
  background-color: transparent;
  cursor: pointer;
}
.dot::before {
  content: "";
  width: 3px;
  height: 12px;
  background-color: var(--dot);
  transition: height 0.2s ease, background-color 0.2s ease;
}
.dot:hover::before { background-color: var(--ink); }
.dot[aria-current="true"]::before { height: 24px; width: 4px; background-color: var(--ink); }
.dots :focus-visible { outline-offset: -2px; }

.foot {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 16px;
  padding: 2px var(--gutter) 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}
.foot p { margin: 0; }
.credits { margin-left: auto; }
.foot > a, .credits summary { display: flex; align-items: center; min-width: 24px; min-height: 24px; }
.credits summary { justify-content: flex-end; }
.credits summary {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: pointer;
  list-style: none;
}
.credits summary::-webkit-details-marker { display: none; }
.credits summary:hover { text-decoration-thickness: 2px; }
.credits-panel {
  position: absolute;
  z-index: 2;
  right: var(--gutter);
  bottom: 100%;
  width: min(34em, 100% - 2 * var(--gutter));
  max-height: calc(100vh - 100% - 8px);
  max-height: calc(100dvh - 100% - 8px);
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid var(--control);
  border-radius: 6px;
  background-color: var(--card);
  color: var(--card-text);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.45;
}
.credits-panel p + p { margin-top: 8px; }
.credits-panel:focus-visible { outline-offset: -4px; }

/* --- companion pages: the same paper and type, as a page that scrolls ------------------------------- */

html.doc, html.doc body { height: auto; overflow: visible; }
html.doc body { min-height: 100vh; display: flex; flex-direction: column; }
.doc-main { flex: 1; width: 100%; max-width: 46em; margin: 0 auto; padding: 18px var(--gutter) 48px; }
.doc-main h1 { margin: 6px 0 4px; color: var(--ink); font: 600 clamp(34px, 4vw, 52px)/1.05 var(--display); letter-spacing: -0.01em; }
.doc-main h2 { margin: 40px 0 8px; padding-top: 14px; border-top: 1px solid var(--hairline); color: var(--ink); font: 600 26px/1.15 var(--display); }
.doc-main h3 { margin: 24px 0 6px; color: var(--ink); font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; }
.doc-main p, .doc-main li { font-size: 17px; line-height: 1.55; }
.doc-main ul, .doc-main ol { padding-left: 1.3em; }
.doc-main li + li { margin-top: 6px; }
.doc-main .lede { margin-top: 0; color: var(--muted); font-size: 18px; }
.doc-main .meta { color: var(--muted); font-size: 15px; }
.doc-main code { font: 0.86em var(--mono); padding: 0.05em 0.3em; border-radius: 3px; background-color: var(--tint); }
.doc-main pre.code {
  overflow-x: auto;
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: var(--term);
  color: var(--term-text);
  box-shadow: var(--shadow);
  font: 14px/1.6 var(--mono);
}
.doc-main pre.code code { padding: 0; background: none; font: inherit; }
.doc-main table { width: 100%; margin: 12px 0; border-collapse: collapse; font-size: 15.5px; }
.doc-main th, .doc-main td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--hairline); text-align: left; vertical-align: top; }
.doc-main th { color: var(--muted); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; }
.table-wrap { overflow-x: auto; }
.doc .foot { padding-top: 12px; border-top: 1px solid var(--hairline); }

/* --- narrow screens: the window above, the text below; only the text panel may scroll -------------- */

@media (max-width: 767px) {
  .slide {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(200px, 46%) minmax(0, 1fr);
    gap: 10px;
  }
  .rig { inset: 0; gap: 8px; }
  .steps { font-size: 12px; gap: 2px 14px; }
  .panel-inner { margin-block: 0; gap: 10px; }
  .title { font-size: 26px; }
  .blurb { font-size: 16px; }
  .ask p { font-size: 16px; }
  .cmd pre { font-size: 13px; }
  .brand { font-size: 22px; }
  .tagline, .cta-wide { display: none; }
  .top-controls { gap: 10px; }
  .foot { font-size: 11.5px; padding-block: 0 4px; gap: 0 8px; }
  .ctl { width: 44px; height: 44px; }
  .copy { min-height: 44px; }
  .dot { height: 44px; }
  .foot > a, .credits summary { min-width: 44px; min-height: 44px; }
}
@media (max-width: 1100px) { .tagline { display: none; } }
/* A phone: the header keeps the wordmark, the install link and Autoplay; the counter gives way (the ticks say it). */
@media (max-width: 520px) {
  .brand { font-size: 19px; }
  .counter { display: none; }
  .cta { min-height: 44px; padding: 0 10px; font-size: 11px; letter-spacing: 0.04em; }
}

@media (any-pointer: coarse) {
  .ctl { width: 44px; height: 44px; }
  .copy { min-height: 44px; }
  .dot { height: 44px; }
  .foot > a, .credits summary { min-width: 44px; min-height: 44px; }
  .foot { padding-block: 0 4px; }
}

@media (max-height: 500px) {
  .top { padding-block: 4px 2px; }
  .brand { font-size: 20px; }
  .nav-row { padding-block: 2px 0; }
  .foot { padding-block: 0 4px; }
  .foot > a, .credits summary { min-width: 32px; min-height: 32px; }
  .slide { padding-block: 4px 6px; }
  .steps { display: none; }
  .panel-inner { gap: 8px; }
  .title { font-size: 22px; }
  .blurb { font-size: 15px; }
}

@media (max-width: 767px) and (max-height: 500px) {
  .slide {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    grid-template-rows: minmax(0, 1fr);
    gap: 12px;
  }
  .box-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
