@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@200;300;400;500;600&display=swap");

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

.story-page {
  --story-bg: #071521;
  --story-text: #f4f8fb;
  --story-muted: #aab9c7;
  --story-blue: #8fc8ff;
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  background: var(--story-bg);
  overflow: hidden;
  overscroll-behavior: none;
  padding-top: 0 !important;
}

.story-page .quarto-title-block,
.story-page #title-block-header,
.story-page #quarto-header,
.story-page .nav-footer {
  display: none;
}

.story-page #quarto-content,
.story-page #quarto-document-content,
.story-page main.content,
.story-page .page-columns {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.story {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 75% 42%, rgba(54, 107, 146, 0.2), transparent 40%),
    linear-gradient(145deg, #091b2a, var(--story-bg) 55%, #08131d);
}

.story-loading,
.story-error {
  margin: 0;
  padding: 2rem clamp(1.25rem, 5vw, 5.5rem);
  color: var(--story-muted);
  font-size: 0.95rem;
}

.story-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.story-math-loader {
  display: none;
}

.story-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 38rem;
  overflow: hidden;
}

.story-stage::after {
  position: absolute;
  z-index: 2;
  inset: 0 auto 0 0;
  width: min(46rem, 46vw);
  content: "";
  pointer-events: none;
  background: radial-gradient(
    ellipse 105% 82% at 0% 0%,
    rgba(7, 21, 33, 0.88) 0%,
    rgba(7, 21, 33, 0.8) 40%,
    rgba(7, 21, 33, 0.5) 68%,
    transparent 100%
  );
}

#story-graphic {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.story-strip-labels,
.story-strip-label-set {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.story-strip-labels {
  z-index: 3;
}

.story-strip-label {
  position: absolute;
  display: flex;
  min-height: 1.5rem;
  align-items: baseline;
  justify-content: flex-end;
  color: var(--strip-colour);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.15;
  text-align: right;
  white-space: nowrap;
}

.story-strip-label mjx-container {
  margin: 0 !important;
}

.story-legend,
.story-controls,
.story-site-link {
  position: absolute;
  z-index: 3;
}

.story-brand {
  position: absolute;
  top: clamp(1rem, 2vw, 2rem);
  left: clamp(1.25rem, 4vw, 4.5rem);
  z-index: 7;
  margin: 0;
  color: var(--story-muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  pointer-events: none;
  text-shadow:
    0 0 6px rgba(7, 21, 33, 0.98),
    0 0 15px rgba(7, 21, 33, 0.95);
}

.story-brand::before {
  position: absolute;
  z-index: -1;
  inset: -0.45rem -0.8rem;
  border-radius: 999px;
  background: rgba(7, 21, 33, 0.76);
  filter: blur(10px);
  content: "";
}

.story-site-link {
  z-index: 6;
  right: clamp(1.25rem, 4vw, 4.5rem);
  bottom: clamp(1rem, 2vw, 1.75rem);
  color: var(--story-blue);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-decoration: none;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(7, 21, 33, 0.95);
}

.story-site-link:hover,
.story-site-link:focus-visible {
  color: var(--story-text);
}

.story-legend {
  top: clamp(1rem, 2vw, 2rem);
  right: clamp(1.25rem, 4vw, 4.5rem);
  max-width: 52vw;
  color: var(--story-muted);
  font-size: 0.76rem;
}

.story-legend-set {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem 1.1rem;
}

.story-legend-set[hidden] {
  display: none;
}

.story-legend-set > span {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
}

.story-legend i {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 4px;
  border-radius: 999px;
  background: var(--legend-colour, var(--story-blue));
}

.story-legend-label {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 1.35rem;
}

.story-legend-math {
  color: var(--story-text);
}

.story-controls {
  bottom: 1rem;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: max-content;
  padding: 0.45rem;
  border: 0;
  background: transparent;
  transform: translateX(-50%);
}

.story-controls button {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.38rem 0.68rem;
  border: 1px solid rgba(190, 216, 235, 0.16);
  border-radius: 999px;
  color: var(--story-text);
  background: rgba(255, 255, 255, 0.04);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1;
  cursor: pointer;
}

.story-controls .story-arrow {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  place-items: center;
}

.story-arrow svg {
  display: block;
  width: 1rem;
  height: 1rem;
}

.story-controls button:hover,
.story-controls button:focus-visible {
  border-color: rgba(143, 200, 255, 0.7);
  background: rgba(143, 200, 255, 0.12);
  outline: none;
}

.story-controls button:disabled {
  cursor: default;
  opacity: 0.34;
}

.story-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.25rem, 0.7vw, 0.6rem);
}

.story-progress button {
  width: clamp(0.5rem, 0.75vw, 0.7rem);
  min-width: 0;
  height: clamp(0.5rem, 0.75vw, 0.7rem);
  min-height: 0;
  padding: 0;
  border: 0;
  background: rgba(202, 220, 234, 0.28);
  transition: width 260ms ease, background-color 260ms ease;
}

.story-progress button[aria-current="step"] {
  width: clamp(0.5rem, 0.75vw, 0.7rem);
  background: var(--story-blue);
  box-shadow: 0 0 0 4px rgba(143, 200, 255, 0.2);
}

.story-counter {
  min-width: 3.2rem;
  margin: 0;
  color: var(--story-muted);
  font-size: 0.72rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.story-scenes {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.story-scene {
  box-sizing: border-box;
  position: absolute;
  inset: 0 auto 0 0;
  display: flex;
  height: 100%;
  width: min(32rem, 33vw);
  padding: clamp(6.5rem, 11vh, 7.5rem) 1.25rem 6.5rem clamp(1.25rem, 5vw, 5.5rem);
  flex-direction: column;
  justify-content: flex-start;
  opacity: 0;
  transition: opacity 360ms ease;
  pointer-events: none;
}

.story-scene.is-active {
  opacity: 1;
  pointer-events: auto;
}

.story-page .story-scene h1,
.story-page .story-scene h2 {
  max-width: 12ch;
  margin: 0 0 1rem;
  border: 0;
  color: #f4f8fb;
  font-size: clamp(2rem, 3.3vw, 4.1rem);
  font-weight: 250;
  line-height: 1;
  letter-spacing: -0.035em;
}

.story-page .story-scene h2 {
  font-size: clamp(1.9rem, 3vw, 3.65rem);
}

.story-scene > p:not(.story-kicker, .story-formula, .story-downloads) {
  max-width: 28rem;
  margin: 0;
  color: #d4dee7;
  font-size: clamp(0.95rem, 1.05vw, 1.08rem);
  line-height: 1.5;
}

.story-kicker {
  margin: 0 0 0.8rem;
  color: var(--story-blue);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.story-formula {
  width: fit-content;
  margin: 1.5rem 0 0;
  padding: 0.72rem 1rem;
  border: 1px solid rgba(143, 200, 255, 0.19);
  border-radius: 0.65rem;
  color: #f6fbff;
  background: rgba(143, 200, 255, 0.07);
  font-size: clamp(0.94rem, 1.28vw, 1.28rem);
  line-height: 1.5;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.story-formula.is-compact {
  font-size: clamp(0.82rem, 1.04vw, 1.05rem);
}

.story-formula mjx-container {
  margin: 0 !important;
}

.story-downloads {
  display: flex;
  gap: 0.65rem;
  margin: 1.3rem 0 0;
}

.story-downloads a {
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(143, 200, 255, 0.4);
  border-radius: 999px;
  color: var(--story-blue);
  font-size: 0.82rem;
  text-decoration: none;
}

@media (max-width: 760px) {
  .story-stage {
    height: 100%;
    min-height: 34rem;
  }

  .story-stage::after {
    display: none;
  }

  .story-brand,
  .story-legend {
    right: 1rem;
    left: 1rem;
    max-width: none;
    text-align: center;
  }

  .story-legend-set {
    justify-content: center;
  }

  .story-legend {
    top: 3.35rem;
  }

  .story-controls {
    bottom: 0.75rem;
    max-width: calc(100vw - 2rem);
  }

  .story-site-link {
    right: 1rem;
    bottom: 4.25rem;
  }

  .story-strip-label {
    font-size: 0.66rem;
  }

  .story-counter {
    display: none;
  }

  .story-scene {
    justify-content: flex-end;
    height: 100%;
    width: 100%;
    padding: 8rem 1.25rem 8.3rem;
    background: linear-gradient(0deg, rgba(7, 21, 33, 0.98) 4%, rgba(7, 21, 33, 0.8) 50%, transparent 82%);
  }

  .story-page .story-scene h1,
  .story-page .story-scene h2 {
    max-width: 15ch;
    font-size: clamp(2.1rem, 10vw, 3.4rem);
  }

  .story-scene > p:not(.story-kicker, .story-formula, .story-downloads) {
    font-size: 0.98rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-scene,
  .story-progress button {
    transition: none;
  }
}
