:root {
  color-scheme: dark;
  --background: #070a13;
  --field: #080f1b;
  --rule: #25304a;
  --paper: #f8fbff;
  --accent: #5af4ea;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
body, h1, p { margin: 0; }

.demo {
  width: min(100% - clamp(1rem, 5vw, 5rem), 79rem);
  margin-inline: auto;
  padding-block: clamp(1rem, 4vw, 3rem);
}

.demo-top {
  display: flex;
  align-items: center;
  gap: .85rem;
  margin-bottom: clamp(.75rem, 2vw, 1.25rem);
}

.demo-top h1 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-weight: 640;
  line-height: 1.1;
  letter-spacing: -.055em;
}

.demo-back, .feed-retry {
  display: grid;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: .55rem;
  color: var(--paper);
  background: var(--background);
}

.demo-back:hover, .feed-retry:hover { border-color: var(--accent); }
.demo-back:focus-visible, .feed-retry:focus-visible, #chart-cursor:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.demo-back span {
  position: relative;
  display: block;
  width: 1rem;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.demo-back span::before {
  position: absolute;
  top: -3px;
  left: 0;
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: rotate(45deg);
  content: "";
}

.demo-chart {
  position: relative;
  height: clamp(20rem, calc(100vh - 8rem), 42rem);
  height: clamp(20rem, calc(100dvh - 8rem), 42rem);
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: .65rem;
  background: var(--field);
}

.demo-chart canvas { position: absolute; display: block; inset: 0; width: 100%; height: 100%; }
.demo-chart[data-state="retrying"] #heatmap { opacity: .64; }
#chart-cursor { cursor: crosshair; }
#chart-cursor:focus-visible { outline-offset: -2px; }

.feed-connection {
  position: absolute;
  top: .7rem;
  left: .7rem;
}

.feed-wait {
  display: none;
  width: 1rem;
  height: 1rem;
  margin: .3rem;
  border: 2px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 100%;
}

.feed-connection[data-state="connecting"] .feed-wait { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .feed-wait { animation: feed-wait 1.1s linear infinite; }
  @keyframes feed-wait { to { transform: rotate(1turn); } }
}

.feed-retry { cursor: pointer; }
.feed-retry[hidden] { display: none; }

.feed-retry span {
  position: relative;
  display: block;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}

.feed-retry span::after {
  position: absolute;
  top: -3px;
  right: -3px;
  border: 4px solid transparent;
  border-left-color: currentColor;
  transform: rotate(40deg);
  content: "";
}

.demo-cursor-value {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 1;
  max-width: calc(100% - .5rem);
  padding: .4rem .55rem;
  border: 1px solid var(--rule);
  border-radius: .4rem;
  background: var(--background);
  color: var(--paper);
  font-size: .8rem;
  font-weight: 520;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  pointer-events: none;
}

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

@media (max-width: 30rem) {
  .demo-chart {
    height: clamp(19rem, calc(100vh - 5.6rem), 34rem);
    height: clamp(19rem, calc(100dvh - 5.6rem), 34rem);
  }
  .demo-top { gap: .65rem; }
}
