:root {
  --ink: #111111;
  --paper: #ffffff;
  --measure: 42rem;
  --font-body: Georgia, "Times New Roman", serif;
  --font-heading: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body,
button,
summary {
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background: var(--paper);
}

h1,
h2 {
  margin: 0 0 1.5rem;
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  text-wrap: balance;
}

h3 {
  margin: 0 0 1.5rem;
  font: inherit;
}

p {
  margin: 0 0 1.5rem;
  text-wrap: pretty;
}

strong,
em,
dt,
dd,
span,
a {
  font: inherit;
}

em {
  font-style: normal;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
}

button {
  min-height: 44px;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  transition: transform 120ms ease-out;
}

button:active {
  transform: scale(0.96);
}

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.5rem;
  background: var(--paper);
  transform: translateY(-150%);
  transition: transform 120ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

main {
  width: min(calc(100% - 3rem), var(--measure));
  margin: 0 auto;
  padding: 5rem 0 10rem;
}

.hero,
.contents,
.story-section,
.printer-section {
  margin: 0 0 5rem;
}

.contents ol {
  margin: 0;
  padding-left: 1.5rem;
}

.contents li + li {
  margin-top: 0.5rem;
}

.barter-lab,
.brrr-widget {
  margin: 3.5rem 0;
  padding: 1.5rem;
  border: 1px solid rgb(17 17 17 / 0.22);
  font-size: 16px;
}

.barter-lab button,
.brrr-widget button {
  font-size: 16px;
}

.lab-header,
.brrr-topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.lab-header h3,
.brrr-topbar p {
  margin-bottom: 0;
}

.lab-status,
.simulation-state {
  flex: 0 0 auto;
}

.trade-stage {
  display: grid;
  align-items: center;
  margin: 2.5rem 0;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2rem;
}

.person-card {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.person-card p {
  margin: 0;
}

.exchange {
  text-align: center;
}

.exchange-track {
  position: relative;
  height: 2.5rem;
}

.route-line {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  left: 0.5rem;
  height: 1px;
  background: currentColor;
}

.route-arrow {
  position: absolute;
  top: 50%;
  right: 0;
  width: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  transform: translateY(-50%);
}

.moving-good {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.25rem;
  background: var(--paper);
  transform: translateY(-50%) translateX(35%);
  transition-property: transform, opacity, filter;
  transition-duration: 300ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.moving-good svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.shared-token {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  opacity: 0;
  filter: blur(4px);
  transform: translate(-50%, -50%) scale(0.25);
  transition-property: transform, opacity, filter;
  transition-duration: 300ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.exchange-message {
  min-height: 3.5rem;
  margin: 1rem 0 0;
}

.trade-stage[data-stage="credit"] .moving-good {
  opacity: 0;
  filter: blur(4px);
  transform: translateY(-50%) translateX(170%) scale(0.25);
}

.trade-stage[data-stage="credit"] .shared-token {
  opacity: 1;
  filter: blur(0);
  transform: translate(-50%, -50%) scale(1);
}

.lab-controls {
  display: flex;
  gap: 1.5rem;
}

.scenario-button.is-active {
  text-decoration-thickness: 2px;
}

.button-index {
  margin-right: 0.25rem;
}

.margin-note,
.explanation-grid,
.wtf-card,
.sources,
.printer-explanation {
  margin-top: 3.5rem;
}

.sources summary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.sources summary::-webkit-details-marker {
  display: none;
}

.sources summary svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.5;
  transition: transform 140ms cubic-bezier(0.2, 0, 0, 1);
}

.sources[open] summary svg {
  transform: rotate(45deg);
}

.sources-body {
  margin-top: 1rem;
}

.brrr-machine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin: 2.5rem 0;
}

.brrr-word {
  margin: 0;
}

.brrr-word span {
  display: inline-block;
  transform-origin: left center;
}

.brrr-widget.is-running .brrr-word span {
  animation: brrr-shiver 90ms linear 4;
}

@keyframes brrr-shiver {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(0.025em); }
}

.brrr-button {
  position: relative;
  min-width: 6rem;
}

.brrr-button span {
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.brrr-button svg {
  width: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.button-idle {
  display: flex;
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
  transition-property: opacity, filter, transform;
  transition-duration: 300ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.button-done {
  position: absolute;
  inset: 0;
  display: flex;
  opacity: 0;
  filter: blur(4px);
  transform: scale(0.25);
  transition-property: opacity, filter, transform;
  transition-duration: 300ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.brrr-widget.is-complete .button-idle {
  opacity: 0;
  filter: blur(4px);
  transform: scale(0.25);
}

.brrr-widget.is-complete .button-done {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}

.balance-sheet-sim {
  display: grid;
  align-items: center;
  margin: 3rem 0;
  grid-template-columns: 1fr 8rem 1fr;
  gap: 2rem;
}

.balance-heading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.balance-heading p,
.balance-card dl,
.balance-card dd {
  margin: 0;
}

.institution-dot {
  display: none;
}

.balance-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.asset-swap {
  display: grid;
  gap: 2rem;
}

.swap-track {
  position: relative;
  display: flex;
  align-items: center;
}

.swap-track svg {
  width: 100%;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.swap-chip {
  position: absolute;
  z-index: 1;
  padding: 0 0.25rem;
  background: var(--paper);
  white-space: nowrap;
  transition-property: transform, opacity, filter;
  transition-duration: 420ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.bond-chip {
  right: 0;
}

.reserve-chip {
  left: 0;
  opacity: 0;
  filter: blur(4px);
  transform: scale(0.25);
}

.brrr-widget.is-complete .bond-chip {
  transform: translateX(-2rem);
}

.brrr-widget.is-complete .reserve-chip {
  opacity: 1;
  filter: blur(0);
  transform: translateX(2rem) scale(1);
}

.wallet-check {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
}

.wallet-check div {
  display: flex;
  gap: 1rem;
}

.wallet-check p {
  margin: 0;
}

@media (max-width: 680px) {
  main {
    width: min(calc(100% - 2.5rem), var(--measure));
    padding-top: 3rem;
  }

  .hero,
  .story-section,
  .printer-section {
    margin-bottom: 4rem;
  }

  .barter-lab,
  .brrr-widget {
    padding: 1rem;
  }

  .lab-header,
  .brrr-topbar,
  .wallet-check,
  .wallet-check div {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .trade-stage {
    grid-template-columns: 1fr 1fr;
  }

  .exchange {
    order: 3;
    grid-column: 1 / -1;
  }

  .bob-card {
    justify-self: end;
  }

  .lab-controls {
    align-items: flex-start;
    flex-direction: column;
    gap: 0;
  }

  .balance-sheet-sim {
    grid-template-columns: 1fr;
  }

  .asset-swap {
    width: 10rem;
    min-height: 6rem;
    margin: 1.5rem 0;
    justify-self: center;
    transform: rotate(90deg);
  }

  .swap-chip {
    transform: rotate(-90deg);
  }

  .brrr-widget.is-complete .bond-chip {
    transform: rotate(-90deg) translateY(-3.5rem);
  }

  .brrr-widget.is-complete .reserve-chip {
    transform: rotate(-90deg) translateY(3.5rem) scale(1);
  }
}

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

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
