:root {
  color-scheme: dark;
  --background: #0a0a0b;
  --surface: #111114;
  --gold: #d4af37;
  --light-gold: #f2d675;
  --deep-gold: #8a6d1f;
  --text: #ede6d0;
  font-family: system-ui, -apple-system, sans-serif;
}

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

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

main {
  --return-width: clamp(1.5rem, 8vw, 2.75rem);
  width: min(35rem, calc(100% - 2rem));
  margin-inline: auto;
  padding-block: clamp(1.5rem, 4vw, 2.5rem) 1.75rem;
}

h1 {
  margin: 0 var(--return-width) 0.9rem 0;
  color: var(--gold);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-align: center;
}

.diagram {
  --return-inset: 3rem;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--return-width);
}

.stage {
  grid-column: 1;
  padding: 1rem clamp(0.55rem, 2vw, 1rem) 0.85rem;
  border: 1.5px solid var(--gold);
  border-radius: 1.125rem;
  background: var(--surface);
  box-shadow: 0 0 18px rgb(212 175 55 / 9%);
  text-align: center;
}

.stage h2 {
  margin: 0 0 0.8rem;
  color: var(--gold);
  font-size: clamp(1.5rem, 5.8vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.loop {
  position: relative;
}

.loop svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.principles {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(min-content, 1fr));
  gap: 0.4rem 0.6rem;
  min-height: 7.25rem;
  margin: 0;
  padding: 0.95rem 8.5%;
  list-style: none;
  font-size: 0.9375rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.principles li:nth-child(3) {
  grid-area: 2 / 2;
  align-self: end;
}

.principles li:nth-child(4) {
  grid-area: 2 / 1;
  align-self: end;
}

.down-river {
  grid-column: 1;
  justify-self: center;
  width: 4.5rem;
  height: 2.65rem;
}

.return-river {
  position: absolute;
  inset: var(--return-inset) 0 auto auto;
  width: var(--return-width);
  height: calc(100% - 2 * var(--return-inset));
  overflow: visible;
}

.track, .flow, .direction {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.track, .direction {
  vector-effect: non-scaling-stroke;
}

.track {
  stroke: var(--deep-gold);
  stroke-width: 1.6;
}

.loop .track {
  stroke: var(--gold);
  stroke-width: 1;
  opacity: 0.56;
}

.stations {
  fill: var(--gold);
}

.direction {
  stroke: var(--gold);
  stroke-width: 1.15;
}

.flow {
  stroke: var(--light-gold);
  stroke-width: 2.25;
  stroke-dasharray: 21 79;
  filter: drop-shadow(0 0 2px rgb(242 214 117 / 36%));
  animation: flow 8s linear infinite;
}

.return-river .flow {
  stroke-width: 3;
  stroke-dasharray: 10 90;
  animation-delay: -2s;
}

.loop .flow {
  stroke-dasharray: 0.45 99.55;
  animation-duration: 15s;
}

.stage:nth-of-type(2) .flow {
  animation-delay: -5s;
}

.stage:nth-of-type(3) .flow {
  animation-delay: -10s;
}

@keyframes flow {
  to { stroke-dashoffset: -100; }
}

@media (prefers-reduced-motion: reduce) {
  .flow {
    display: none;
    animation: none;
  }
}
