/* Demo Day stage: one screen, driven by the presenter. Tokens come from home.css. */

/* How much slower than its written timings every animation runs. Each
   transition below multiplies by it, and demo.js reads it for its timers. */
:root {
  --pace: 1.4;
}

html,
body.demo-page {
  height: 100%;
  overflow: hidden;
}

body.demo-page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* The walkthrough grows to 1280px wide and no wider. On a bigger screen
     the side padding takes the rest, so the header, the stage and the
     footer all line up on the same edges. */
  --demo-inline: max(var(--home-gutter), calc((100% - 1280px) / 2));
}

.demo-bar {
  display: grid;
  /* The track takes whatever the logo leaves, and centres itself in it. */
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 32px;
  height: 88px;
  padding: 0 var(--demo-inline);
  border-bottom: 1px solid var(--home-rule-soft);
}

.demo-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  color: var(--home-ink);
  font-size: 25px;
  font-weight: 640;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.demo-brand img {
  width: 44px;
  height: 44px;
}

.demo-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  height: 68px;
  padding: 0 var(--demo-inline);
  border-top: 1px solid var(--home-rule-soft);
}

/* The link keeps the left end; the key hint and the pager sit together at
   the right. */
.demo-links {
  display: flex;
  gap: 24px;
  margin-right: auto;
}

.demo-links a {
  color: var(--home-ink-muted);
  font-size: 14px;
  text-decoration: none;
  transition: color 160ms ease;
}

.demo-links a:focus-visible {
  outline: 2px solid var(--home-carmine);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .demo-links a:hover {
    color: var(--home-ink);
  }
}

.demo-keys {
  margin: 0;
  color: var(--home-ink-muted);
  font-size: 14px;
}

/* Back, where we are, and Next, on every screen. */
.demo-pager {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-pager button {
  min-width: 88px;
  height: 44px;
  padding: 0 16px;
  border: 1.5px solid var(--home-ink);
  border-radius: 9px;
  background: none;
  color: var(--home-ink);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 160ms ease, background-color 160ms ease;
}

.demo-count {
  min-width: 3.4em;
  color: var(--home-ink-muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .demo-pager button[data-step="-1"]:not(:disabled):hover {
    background: var(--home-paper-muted);
  }

  .demo-pager button[data-step="1"]:hover {
    background: color-mix(in srgb, var(--home-carmine) 88%, var(--home-ink));
  }
}

.demo-pager button[data-step="1"] {
  border-color: var(--home-carmine);
  background: var(--home-carmine);
  color: var(--home-white);
}

.demo-pager button:disabled {
  opacity: 0.3;
  cursor: default;
}

.demo-pager button:focus-visible {
  outline: 2px solid var(--home-carmine);
  outline-offset: 4px;
}

@media (max-width: 900px), (pointer: coarse) {
  .demo-keys {
    display: none;
  }
}

.demo-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(16px, 3vh, 36px);
  min-height: 0;
  padding: clamp(20px, 4vh, 44px) var(--demo-inline) clamp(12px, 2vh, 24px);
}

/* On a big screen the stage stops growing taller too, at the height the
   1280px diagram and its words need, and sits in the middle of the space
   between the header and the footer. */
@media (min-width: 901px) {
  .demo-stage {
    align-self: center;
    height: 100%;
    max-height: 760px;
  }
}

/* The words the presenter speaks over. */

.demo-copy {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: clamp(32px, 6vw, 110px);
  align-items: start;
  transition:
    opacity calc(480ms * var(--pace)) var(--home-ease),
    transform calc(480ms * var(--pace)) var(--home-ease);
}

.demo-copy.is-leaving {
  opacity: 0;
  transform: translateY(14px);
  transition-duration: calc(180ms * var(--pace));
  transition-timing-function: cubic-bezier(0.3, 0, 1, 1);
}

.demo-headline {
  margin: 0;
  font-size: clamp(38px, 4.4vw, 60px);
  font-variation-settings: "wdth" 94, "opsz" 64;
  font-weight: 560;
  letter-spacing: -0.038em;
  line-height: 1;
  /* Room for two lines always, so the diagram below never moves. */
  min-height: 2em;
  text-wrap: balance;
}

.demo-headline em {
  color: var(--home-carmine);
  font-style: normal;
}

.demo-fact {
  max-width: 30em;
  margin: 0.35em 0 0;
  color: var(--home-ink-body);
  font-size: clamp(18px, 1.45vw, 21px);
  line-height: 1.45;
  text-wrap: pretty;
}

/* The diagram. Its layout never changes; only what is lit does. */

.demo-diagram {
  width: 100%;
  height: 100%;
  min-height: 0;
  font-family: var(--home-font);
}

.columns text {
  fill: var(--home-ink-muted);
  font-family: var(--home-mono);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-anchor: middle;
  text-transform: uppercase;
}

/* Corners are softened a little everywhere. */

.node rect {
  rx: 9px;
  fill: var(--home-paper-raised);
  stroke: var(--home-rule);
  stroke-width: 1;
  transition: stroke calc(400ms * var(--pace)) var(--home-ease), stroke-width calc(400ms * var(--pace)) var(--home-ease);
}

.node.outside rect {
  fill: none;
  stroke-dasharray: 5 5;
}

.node.dark rect {
  fill: var(--home-card);
  stroke: var(--home-card);
}

.node text {
  text-anchor: middle;
}

.node text.start {
  text-anchor: start;
}

.node .name {
  fill: var(--home-ink);
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.015em;
}

.node .value {
  fill: var(--home-ink-muted);
  /* Sized so the longest status line keeps 14px clear of its box's sides. */
  font-size: 15px;
  transition: opacity calc(300ms * var(--pace)) var(--home-ease);
}

/* Nothing in a box moves. Its name stays at the top. Under it is one
   content area with one centred spot, which the status line and the coins
   take turns in: the line fades out while the box holds coins. */
.node.has-coins .value {
  opacity: 0;
}

/* The one exception: the pool's line stays above its small fee coin, and
   the two are centred on that spot together. */
.node.has-coins.keeps-line .value {
  opacity: 1;
  transform: translateY(-15px);
}

/* The small line under Morpho's name: the products it stands for. */
.node .kinds {
  fill: var(--home-ink-muted);
  font-family: var(--home-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.node.dark .name {
  fill: var(--home-white);
}

.node.dark .value {
  fill: var(--home-card-muted);
}

.node.is-lit rect {
  stroke: var(--home-carmine);
  stroke-width: 2.5;
}

.node.dark.is-lit rect {
  stroke: var(--home-carmine);
}

.is-swapping {
  opacity: 0;
}

.edges path {
  fill: none;
  stroke: #b9b5b1;
  stroke-width: 1.5;
  transition:
    stroke calc(400ms * var(--pace)) var(--home-ease),
    stroke-width calc(400ms * var(--pace)) var(--home-ease),
    opacity calc(700ms * var(--pace)) var(--home-ease);
}

.edges path.is-live {
  stroke: var(--home-carmine);
  stroke-width: 2.5;
}

.edge-labels text {
  fill: var(--home-ink);
  font-size: 17px;
  font-weight: 600;
  text-anchor: middle;
  transition: opacity calc(300ms * var(--pace)) var(--home-ease);
}

.edge-labels text.start {
  text-anchor: start;
}

.edge-labels text.end {
  text-anchor: end;
}

.edges path.is-gold {
  stroke: var(--home-ink);
}

.head {
  fill: var(--home-carmine);
}

/* cbBTC's own lines are ink, and so are their heads. */
.head.is-ink {
  fill: var(--home-ink);
}

/* The platform outline. */

.platform path {
  /* A faint wash of the brand red, so the platform reads as BitRepo's. */
  fill: color-mix(in srgb, var(--home-carmine) 4%, var(--home-paper-muted));
  stroke: color-mix(in srgb, var(--home-carmine) 30%, var(--home-rule));
  stroke-width: 1;
}

.platform text {
  fill: var(--home-ink);
  font-size: 20px;
  font-weight: 620;
}

/* The swap venue appears only for the Yield scene. */

#e-swap {
  fill: none;
}

#n-swap,
#e-swap {
  opacity: 0;
  transition: opacity calc(400ms * var(--pace)) var(--home-ease);
}

body[data-scene="5"] #n-swap,
body[data-scene="5"] #e-swap {
  opacity: 1;
}

body[data-scene="5"] #e-swap {
  stroke: var(--home-carmine);
  stroke-width: 2.5;
}

/* Unnamed vaults for other assets: they rise from behind the cbBTC vault. */

.more-vaults rect {
  rx: 7px;
  /* The nearer card. A step darker than the box in front, and darker
     than the platform tint behind it, so it reads as its own card. */
  fill: #e4dfd8;
  stroke: var(--home-rule);
  transition: transform calc(700ms * var(--pace)) var(--home-ease);
}

/* The card at the back: a step darker again. */
.more-vaults rect:first-child {
  fill: #d6d0c8;
}

body:not([data-scene="0"]) .more-vaults rect:first-child {
  transform: translateY(-22px);
}

body:not([data-scene="0"]) .more-vaults rect:last-child {
  transform: translateY(-11px);
  transition-delay: calc(90ms * var(--pace));
}

/* The tokens. cbBTC is gold and still once it is posted; USDC makes the trip. */

.cbbtc,
.yield,
.mini,
.owed,
.usdc {
  transition: transform calc(650ms * var(--pace)) var(--home-ease), opacity calc(300ms * var(--pace)) var(--home-ease);
}

.yield,
.mini,
.owed,
.usdc {
  opacity: 0;
}

.yield.is-out,
.mini.is-out,
.owed.is-out,
.usdc.is-out {
  opacity: 1;
}

/* A shadow: the coin's outline and a ghost of its mark, left where a
   borrowed coin used to sit. */
.owed circle {
  fill: var(--home-paper);
  stroke: #9a9692;
  stroke-dasharray: 3 4;
  stroke-width: 1.5;
}

.owed image {
  opacity: 0.16;
}

.cbbtc circle,
.yield circle,
.mini circle,
.usdc circle {
  fill: var(--home-paper);
}

/* The end borrowers: one pill for each business. The coin lands on its
   left end; its right side names the business and the receivable the loan
   is drawn against. */

.biz .ico,
.biz .pair,
.biz .split,
.biz text {
  transition:
    fill calc(400ms * var(--pace)) var(--home-ease),
    stroke calc(400ms * var(--pace)) var(--home-ease);
}

/* Dashed until a loan lands. */
.biz .pair {
  rx: 10px;
  fill: var(--home-paper-raised);
  stroke: #b9b5b1;
  stroke-dasharray: 4 4;
}

.biz .split {
  stroke: #b9b5b1;
  stroke-dasharray: 4 4;
}

.biz .ico {
  fill: none;
  stroke: #9a9692;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.biz .who {
  fill: var(--home-ink);
  font-size: 14.5px;
  font-weight: 600;
}

.biz .recv {
  fill: var(--home-ink-muted);
  font-family: var(--home-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Funded: the pill closes around the loan and its receivable. */
.biz:not([data-state="pending"]) .pair,
.biz:not([data-state="pending"]) .split {
  stroke: #9a9692;
  stroke-dasharray: none;
}

/* The receivable pays out, which is what repays the loan. */
.biz[data-state="paid"] .recv,
.biz[data-state="repaid"] .recv {
  fill: var(--home-carmine);
}

/* Loan to value: the one number the Bitcoin's safety hangs on. */

.ltv {
  opacity: 0;
  transition: opacity calc(400ms * var(--pace)) var(--home-ease);
}

.ltv.is-shown {
  opacity: 1;
}

.ltv-caption {
  fill: var(--home-ink-muted);
  font-size: 15px;
}

.ltv-number {
  fill: var(--home-ink);
  font-size: 44px;
  font-variation-settings: "wdth" 94, "opsz" 48;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.ltv-track,
.ltv-fill {
  rx: 4px;
}

.ltv-track {
  fill: var(--home-paper-muted);
  stroke: var(--home-rule-soft);
}

.ltv-fill {
  fill: var(--home-ink);
  transform-box: fill-box;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform calc(900ms * var(--pace)) var(--home-ease);
}

.ltv-tick {
  stroke: var(--home-ink);
  stroke-width: 1.5;
}

.ltv-label {
  fill: var(--home-ink-muted);
  font-size: 13px;
  text-anchor: middle;
}

/* The title holds the diagram back until the story starts. */

/* The title card fills the stage. When the story starts, "Bitcoin" and
   "real businesses" leave the sentence and travel to the two ends of the
   diagram, where the cbBTC LPs and the end borrowers appear. The rest of
   the card fades where it stands. Then BitRepo is drawn between them. */

.demo-stage {
  position: relative;
}

.demo-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 var(--demo-inline) 6vh;
  pointer-events: none;
  /* Waits for the diagram to clear before it comes in. */
  transition: opacity calc(450ms * var(--pace)) var(--home-ease) calc(180ms * var(--pace));
}

body[data-title="off"] .demo-title {
  opacity: 0;
  transition-duration: 0.01ms;
  transition-delay: 0s;
}

.demo-title .rest {
  transition: opacity calc(350ms * var(--pace)) var(--home-ease);
}

body[data-title="fly"] .demo-title .rest {
  opacity: 0;
}

.demo-title-line {
  margin: 0;
  font-size: clamp(56px, 8.6vw, 116px);
  font-variation-settings: "wdth" 108, "opsz" 72;
  font-weight: 560;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.demo-title .fly {
  display: inline-block;
}

/* The two outer column titles start out lying over "Bitcoin" and "real
   businesses" in the headline, at headline size, and travel home from
   there. Nothing is swapped at the end: where they stop is where they
   live. So the diagram must let them be drawn outside its own box. */
.demo-diagram {
  overflow: visible;
}

#col-lp,
#col-biz {
  transform-box: fill-box;
  transform-origin: center;
}

body[data-title="show"] #col-lp,
body[data-title="show"] #col-biz {
  opacity: 0;
}

#col-lp .late {
  transition: fill-opacity calc(500ms * var(--pace)) var(--home-ease) calc(120ms * var(--pace));
}

body:not([data-title="off"]) #col-lp .late {
  fill-opacity: 0;
  transition: none;
}

.demo-title-line em {
  color: var(--home-carmine);
  font-style: normal;
}

.demo-title-sub {
  max-width: 34em;
  margin: 4.5vh 0 0;
  color: var(--home-ink-body);
  font-size: clamp(18px, 1.7vw, 24px);
  line-height: 1.4;
}

body[data-scene="0"] .demo-copy {
  opacity: 0;
  transition-duration: calc(160ms * var(--pace));
}

.demo-diagram {
  transition: opacity calc(200ms * var(--pace)) var(--home-ease);
}

/* Going back to the title, the whole diagram clears at once, before the
   title comes in. */
body[data-title="show"] .demo-diagram {
  opacity: 0;
  transition: opacity calc(160ms * var(--pace)) cubic-bezier(0.3, 0, 1, 1);
}

.demo-diagram [data-intro]:not(path):not(.cbbtc) {
  transition:
    opacity calc(500ms * var(--pace)) var(--home-ease),
    transform calc(650ms * var(--pace)) var(--home-ease);
}

body[data-stage="0"] [data-intro],
body[data-stage="1"] [data-intro="b"],
body[data-stage="1"] [data-intro="c"],
body[data-stage="2"] [data-intro="c"] {
  opacity: 0;
}

body[data-stage="0"] [data-intro]:not(path):not(.cbbtc),
body[data-stage="1"] [data-intro="b"]:not(path),
body[data-stage="1"] [data-intro="c"]:not(path),
body[data-stage="2"] [data-intro="c"]:not(path) {
  transform: translateY(18px);
}

/* The platform is drawn, not faded, so its group shows at once. */
.demo-diagram .platform[data-intro] {
  transition-duration: calc(150ms * var(--pace));
}

/* BitRepo's three boxes arrive left to right. */
.demo-diagram #n-vault[data-intro],
.demo-diagram .more-vaults[data-intro] {
  transition-delay: calc(220ms * var(--pace));
}

.demo-diagram #n-pool[data-intro] {
  transition-delay: calc(320ms * var(--pace));
}

.demo-diagram #n-facility[data-intro] {
  transition-delay: calc(420ms * var(--pace));
}

.demo-fact.is-url {
  color: var(--home-ink);
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: underline 3px var(--home-carmine);
  text-underline-offset: 0.18em;
}

/* The line under the address is the paragraph's. The link adds none. */
.demo-fact.is-url a {
  text-decoration: none;
}

/* The lifecycle track in the header: numbered stops joined by a line.
   Stops already passed are ink, the current one is carmine. */

.demo-steps {
  display: flex;
  align-items: center;
  justify-self: center;
}

.demo-steps button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border: 0;
  background: none;
  color: var(--home-ink-muted);
  font: inherit;
  font-size: 17px;
  white-space: nowrap;
  /* One weight for every stop. A bolder current stop is wider, and the
     extra pixel nudges the whole track. */
  font-weight: 540;
  cursor: pointer;
  transition: color calc(300ms * var(--pace)) var(--home-ease);
}

.demo-steps button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1.5px solid #b9b5b1;
  border-radius: 50%;
  color: var(--home-ink-muted);
  font-size: 13px;
  font-weight: 620;
  transition:
    background-color calc(300ms * var(--pace)) var(--home-ease),
    border-color calc(300ms * var(--pace)) var(--home-ease),
    color calc(300ms * var(--pace)) var(--home-ease),
    box-shadow calc(300ms * var(--pace)) var(--home-ease);
}

/* The line to the next stop. */
.demo-steps button:not(:last-child)::after {
  content: "";
  width: clamp(12px, 2vw, 40px);
  margin: 0 12px 0 2px;
  border-top: 1.5px solid #b9b5b1;
  transition: border-color calc(300ms * var(--pace)) var(--home-ease);
}

.demo-steps button:has(~ button[aria-current]),
body[data-scene="7"] .demo-steps button {
  color: var(--home-ink);
}

.demo-steps button:has(~ button[aria-current]) span,
body[data-scene="7"] .demo-steps button span {
  border-color: var(--home-ink);
  background: var(--home-ink);
  color: var(--home-white);
}

.demo-steps button:has(~ button[aria-current])::after,
body[data-scene="7"] .demo-steps button::after {
  border-top-color: var(--home-ink);
}

.demo-steps button[aria-current="step"] {
  color: var(--home-ink);
}

.demo-steps button[aria-current="step"] span {
  border-color: var(--home-carmine);
  background: var(--home-carmine);
  box-shadow: 0 0 0 5px rgba(200, 16, 30, 0.14);
  color: var(--home-white);
}

.demo-steps button:focus-visible {
  outline: 2px solid var(--home-carmine);
  outline-offset: 4px;
}

@media (hover: hover) and (pointer: fine) {
  .demo-steps button:hover {
    color: var(--home-ink);
  }
}

@media (max-width: 900px) {
  html,
  body.demo-page {
    height: auto;
    overflow: auto;
  }

  /* The page scrolls, and Back and Next stay in reach at the bottom. */
  body.demo-page {
    min-height: 100dvh;
  }

  .demo-foot {
    position: sticky;
    bottom: 0;
    background: var(--home-paper);
  }

  /* While the title card is up there is nothing to scroll to, and the card
     needs the stage to be what is left of the screen, to sit centred in. */
  body.demo-page:not([data-title="off"]) {
    height: 100dvh;
    overflow: hidden;
  }

  /* Sized to the shorter of the screen's two sides, so the card clears the
     header on a phone held either way. */
  .demo-title-line {
    font-size: clamp(36px, min(13vw, 14dvh), 77px);
    text-wrap: balance;
  }

  .demo-copy {
    grid-template-columns: 1fr;
    row-gap: 16px;
  }

  .demo-headline {
    min-height: 0;
  }

  /* Its height comes from its shape, which demo.js gives. */
  .demo-diagram {
    height: auto;
    aspect-ratio: 1 / var(--diagram-ratio);
  }

  .demo-bar {
    grid-template-columns: 1fr;
    height: auto;
    padding-block: 12px;
    gap: 8px;
  }

  .demo-steps {
    overflow-x: auto;
  }

  .demo-steps button {
    font-size: 15px;
  }
}

/* A phone: 640px wide or narrower, the same width demo.js asks about when
   it draws the diagram for a narrow screen. Everything around the diagram
   is made small, so the diagram gets as much of the screen as it can. */
@media (max-width: 640px) {
  /* The height of everything around the diagram, each written once. The
     page is laid out from these, and so is the diagram's own height. */
  body.demo-page {
    --bar-height: 44px;
    --foot-height: 52px;
    --stage-top: 12px;
    --stage-bottom: 6px;
    --stage-gap: 8px;
    --headline-size: clamp(22px, 6.4vw, 28px);
    /* Sized to the screen, so the longest fact takes two lines on any
       phone. */
    --fact-size: clamp(11px, 3.5vw, 14px);
    --copy-gap: 4px;
    /* Two lines of headline and two of fact. */
    --copy-height: calc(2.1 * var(--headline-size) + var(--copy-gap) + 2.8 * var(--fact-size));
  }

  /* The mark and the track share one row. The link keeps its label. */
  .demo-bar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 14px;
    height: var(--bar-height);
    padding-block: 0;
  }

  .demo-brand span {
    display: none;
  }

  .demo-brand img {
    width: 28px;
    height: 28px;
  }

  /* Only the stop the story is at shows its name, beside its number. The
     lines between the stops take up the slack. */
  .demo-steps {
    justify-self: stretch;
    overflow: visible;
  }

  .demo-steps button {
    gap: 0;
    padding: 9px 0;
    font-size: 0;
  }

  .demo-steps button:not(:last-child) {
    flex: 1;
  }

  .demo-steps button[aria-current="step"] {
    gap: 6px;
    font-size: 13px;
  }

  .demo-steps button:not(:last-child)::after {
    flex: 1;
    width: auto;
    min-width: 4px;
    margin: 0 5px;
  }

  .demo-stage {
    gap: var(--stage-gap);
    padding-block: var(--stage-top) var(--stage-bottom);
  }

  /* The words keep one height on every slide, so the diagram below never
     moves or changes size. */
  .demo-copy {
    height: var(--copy-height);
    row-gap: var(--copy-gap);
  }

  .demo-headline {
    min-height: 2.1em;
    font-size: var(--headline-size);
    line-height: 1.05;
  }

  .demo-fact {
    min-height: calc(2.8 * var(--fact-size));
    margin: 0;
    font-size: var(--fact-size);
    line-height: 1.4;
  }

  /* The closing address stays inside the room the facts have. */
  .demo-fact.is-url {
    font-size: 22px;
    line-height: 30px;
  }

  /* The diagram runs closer to the screen's edges than the words do. */
  .demo-diagram {
    width: calc(100% + 28px);
    margin-inline: -14px;
  }

  .demo-foot {
    gap: 12px;
    height: var(--foot-height);
  }

  .demo-links a {
    white-space: nowrap;
  }

  .demo-pager {
    gap: 6px;
  }

  .demo-pager button {
    min-width: 64px;
    padding: 0 10px;
  }

  .demo-count {
    font-size: 13px;
  }
}

/* The narrowest phones: smaller numbers, so the track still fits. */
@media (max-width: 350px) {
  .demo-steps button span {
    width: 22px;
    height: 22px;
  }

  .demo-steps button:not(:last-child)::after {
    margin: 0 3px;
  }
}

/* On a phone tall enough for it, a whole slide fits the screen and nothing
   scrolls. The diagram is as tall as it is at full width, or as tall as
   the screen leaves room for, whichever is less, and the words and the
   diagram sit together in the middle of the space between the header and
   the footer. A shorter screen keeps the diagram at full width and
   scrolls.

   The diagram's height is a length worked out here, from the screen and
   the heights above. It is not a percentage of its row: some iPhone
   browsers take such a percentage of the whole stage, which pushed the
   diagram's foot under the footer. */
@media (max-width: 640px) and (min-height: 520px) {
  html,
  body.demo-page {
    height: 100dvh;
    overflow: hidden;
  }

  .demo-stage {
    grid-template-rows: auto auto;
    align-content: center;
  }

  .demo-diagram {
    height: min(
      calc((100vw - 2 * var(--home-gutter) + 28px) * var(--diagram-ratio)),
      calc(
        100dvh - var(--bar-height) - var(--foot-height) - var(--stage-top) - var(--stage-bottom) -
          var(--stage-gap) - var(--copy-height)
      )
    );
    aspect-ratio: auto;
  }
}

/* A short phone: the words give the diagram more of the screen. */
@media (max-width: 640px) and (max-height: 600px) {
  body.demo-page {
    --foot-height: 48px;
    --stage-top: 8px;
    --stage-bottom: 4px;
    --stage-gap: 6px;
    --headline-size: clamp(20px, 5.6vw, 22px);
    --fact-size: clamp(11px, 3.4vw, 12px);
    --copy-gap: 2px;
  }
}

/* The phone diagram has no room for the three inner column titles or the
   line under Morpho's name, and draws loan to value small, under Morpho. */
.demo-diagram[data-layout="tall"] .columns [data-intro="b"],
.demo-diagram[data-layout="tall"] .node .kinds {
  display: none;
}

.demo-diagram[data-layout="tall"] .ltv-number {
  font-size: 24px;
}

.demo-diagram[data-layout="tall"] .ltv-label {
  font-size: 11px;
}

@media (prefers-reduced-motion: reduce) {
  .demo-copy,
  .node rect,
  .node .value,
  .edges path,
  .edge-labels text,
  .ltv,
  .ltv-fill,
  .cbbtc,
  .yield,
  .mini,
  .owed,
  .usdc,
  .node .value,
  .platform path,
  .demo-title,
  .demo-diagram [data-intro],
  #n-swap,
  #e-swap,
  .more-vaults rect,
  .biz *,
  .demo-diagram,
  .demo-pager button {
    transition-duration: 0.01ms;
    transition-delay: 0s;
  }
}
