/* satoshi.science — the observatory. See DESIGN.md. */

/* ============================================================ fonts */
/* Subset, self-hosted OFL fonts. Newsreader has its weight pinned to 360
   and keeps the optical-size axis, so large headlines use the display cut. */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 360;
  font-display: swap;
  src: url("/static/fonts/newsreader.woff2") format("woff2");
}

@font-face {
  font-family: "Newsreader";
  font-style: italic;
  font-weight: 360;
  font-display: swap;
  src: url("/static/fonts/newsreader-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Schibsted Grotesk";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("/static/fonts/schibsted-grotesk.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono.woff2") format("woff2");
}

/* ============================================================ tokens */
:root {
  --night: #0b0a08;
  --night-2: #13110e;
  --night-3: #1c1915;
  --line: rgba(242, 234, 221, 0.1);
  --line-strong: rgba(242, 234, 221, 0.24);
  --ink: #f2eadd;
  --ink-2: #bdb4a6;
  --muted: #968d80;
  --accent: #f7931a;
  --accent-hot: #ffc27a;
  --positive-text: #8fd1a8;
  --bottom: #f08a76;
  --gain-tint: #15261c;
  --loss-tint: #2c1611;
  /* Chart aliases: the chart classes below read these. */
  --bg: var(--night-2);
  --surface: var(--night-3);
  --border: var(--line);
  --ath: var(--ink);
  --halving: var(--accent);

  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(20px, 4vw, 56px);
  --nav-h: 64px;
  --content: 1320px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  overflow-x: clip;
  color: var(--ink);
  background: var(--night);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent);
  color: var(--night);
}

a {
  color: inherit;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.view-hidden {
  display: none !important;
}

.accent {
  color: var(--accent);
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 16px;
  background: var(--accent);
  color: var(--night);
  font-weight: 600;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

.noscript {
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 24px var(--gutter);
  background: var(--night-3);
}

/* ============================================================ the world */
/* The orbit canvas is fixed behind the hero and the chapters. The quotes
   and the method sections have solid backgrounds and cover it. */
.world {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.world canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.world::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 60% 45%, transparent 45%, rgba(5, 4, 3, 0.7) 100%);
}

.world.is-paused {
  visibility: hidden;
}

/* ============================================================ navigation */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  width: 100%;
  height: var(--nav-h);
  padding: 0 var(--gutter);
}

/* The wash sits on a pseudo-element, not on the bar. A backdrop-filter makes
   its element the containing block of fixed descendants. */
.site-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 10, 8, 0.72);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  opacity: 0;
  transition: opacity 0.4s linear;
}

.site-nav.is-stuck::before {
  opacity: 1;
}

.wordmark {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.site-links {
  display: flex;
  gap: clamp(16px, 2.4vw, 32px);
  margin-left: auto;
}

.site-links a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 120ms ease;
}

.site-links a:hover,
.site-links a.is-current {
  color: var(--ink);
}

.site-links a.is-current::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 1px;
  background: var(--accent);
}

.nav-live {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 0 0 clamp(16px, 2vw, 24px);
  border-left: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
}

.nav-live-label {
  color: var(--muted);
}

.live-dot {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  animation: live-pulse 2.4s var(--ease-out) infinite;
}

@keyframes live-pulse {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(3.2); opacity: 0; }
}

/* ============================================================ type */
.display {
  margin: 0;
  font-family: var(--serif);
  font-weight: 360;
  font-optical-sizing: auto;
  letter-spacing: -0.02em;
  line-height: 1.02;
  text-wrap: balance;
}

.display em {
  color: var(--accent-hot);
  font-style: italic;
}

.kicker {
  margin: 0 0 24px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

.lead {
  max-width: 34rem;
  margin: 28px 0 0;
  color: var(--ink-2);
  font-size: clamp(1.0625rem, 1.3vw, 1.25rem);
  line-height: 1.6;
}

.section-title {
  font-size: clamp(1.75rem, 2.8vw, 2.75rem);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.button-primary {
  background: var(--accent);
  color: var(--night);
}

.button-primary:hover {
  background: var(--accent-hot);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 6px;
  cursor: pointer;
  transition: text-decoration-color 120ms ease;
}

.text-link:hover {
  text-decoration-color: var(--accent);
}

.text-link span {
  transition: transform 0.4s var(--ease-out);
}

.text-link:hover span {
  transform: translate3d(3px, 0, 0);
}

/* ============================================================ hero */
/* The chapter scrims reach past the screen edge. Clip them here: on a phone,
   any overflow widens the layout viewport, and the fixed navigation bar
   then takes that wider width (the price went off the right edge). */
main {
  position: relative;
  z-index: 1;
  overflow-x: clip;
}

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  min-height: 100svh;
  padding: calc(var(--nav-h) + clamp(32px, 8vh, 96px)) var(--gutter) clamp(24px, 4vh, 40px);
}

/* Holds the copy off the orbit. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(60% 70% at 16% 40%, rgba(11, 10, 8, 0.86), rgba(11, 10, 8, 0.5) 55%, transparent 85%);
}

.hero-copy {
  max-width: min(52rem, 56vw);
}

.hero-window {
  display: none;
}

.hero-title {
  font-size: clamp(2.75rem, 6.2vw, 6rem);
  line-height: 0.98;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  margin-top: 36px;
}

.readouts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 64rem;
  border-top: 1px solid var(--line-strong);
}

.readout {
  min-width: 0;
  padding: 16px 20px 0 0;
}

.readout + .readout {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.readout-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.readout-value {
  display: block;
  font-family: var(--mono);
  font-size: clamp(1.25rem, 2.2vw, 2rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.readout-live .readout-value {
  color: var(--accent-hot);
}

.readout-detail {
  display: block;
  margin-top: 6px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* ============================================================ the story */
.chapter {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 118svh;
  padding: calc(var(--nav-h) + 48px) var(--gutter) 96px;
}

.chapter-copy {
  position: relative;
  max-width: 35rem;
}

/* A scrim that holds the copy off the orbit. Its edges never show. */
.chapter-copy::before {
  content: "";
  position: absolute;
  inset: -22% -45% -22% -60%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(closest-side, rgba(11, 10, 8, 0.9), rgba(11, 10, 8, 0.62) 55%, rgba(11, 10, 8, 0));
}

.chapter-index {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 0 0 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

.chapter-index span {
  color: var(--accent);
}

.chapter-title {
  font-size: clamp(2.25rem, 4.4vw, 4.25rem);
}

.chapter-text {
  max-width: 32rem;
  margin: 24px 0 0;
  color: var(--ink-2);
  font-size: clamp(1rem, 1.15vw, 1.125rem);
}

.chapter-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 32px;
  margin: 32px 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--line-strong);
}

.chapter-stats div {
  min-width: 0;
}

.chapter-stats dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chapter-stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(1.375rem, 2vw, 1.875rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chapter-stats dd.stat-note {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  white-space: normal;
}

.pace {
  margin: 8px 0 24px;
}

.pace-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.pace-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.pace-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr 4.5rem;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
}

.pace-bar {
  height: 6px;
  background: var(--line);
}

.pace-bar i {
  display: block;
  height: 100%;
  background: var(--line-strong);
}

.pace-list li.is-current {
  color: var(--ink);
}

.pace-list li.is-current .pace-bar i {
  background: var(--accent);
}

.pace-list b {
  font-weight: 500;
  text-align: right;
}

.chapter-finale .chapter-title {
  max-width: 14ch;
}

/* ============================================================ reveals */
/* Content is visible by default. Only the js class hides it before the
   reveal, and story.js reveals everything that is already above the view. */
.js [data-rv] {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
}

.js [data-rv="fade"] {
  transform: none;
}

.js [data-rv].rv-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s var(--ease-out), transform 1s var(--ease-out);
  transition-delay: var(--rv-delay, 0ms);
}

.word-mask {
  display: inline-block;
  overflow: hidden;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
  vertical-align: top;
}

.word {
  display: inline-block;
  transform: translate3d(0, 112%, 0);
  transition: transform 0.95s var(--ease-out);
  transition-delay: var(--word-delay, 0ms);
}

.rv-in .word {
  transform: none;
}

/* ============================================================ charts page */
/* /charts is a tool, not a story. The navigation bar and one row of tabs
   sit at the top, and the chart fills the rest of the screen. */
.charts-page {
  --gutter: clamp(12px, 1.6vw, 32px);
  --nav-h: 52px;
}

.charts-page .site-nav {
  position: relative;
}

.charts-page .nav-live {
  margin-block: 0;
}

.charts-main {
  padding: 0 var(--gutter) 24px;
}

.method,
.site-foot {
  max-width: var(--content);
  margin-left: auto;
  margin-right: auto;
}

.view-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.view-group {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.view-group + .view-group {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.view-group-label {
  margin: 0 8px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Below this width, the group labels would push the tabs to a second row.
   The lines between the groups keep the groups, and screen readers keep
   the labels. */
@media (max-width: 1679px) {
  .view-group-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

.view-tab {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}

.view-tab:hover {
  background: var(--night-2);
  color: var(--ink);
}

.view-tab.is-active {
  border-bottom-color: var(--accent);
  background: var(--night-3);
  color: var(--ink);
}

@media (max-width: 1400px) {
  .view-nav {
    column-gap: 12px;
  }

  .view-group + .view-group {
    padding-left: 12px;
  }

  .view-tab {
    padding: 6px 8px;
  }
}

.explorer-panel {
  min-width: 0;
  margin-top: 8px;
}

.data-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.data-status p {
  margin: 0;
}

#retry-data {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  background: var(--night-2);
  color: var(--ink);
  font: 0.875rem var(--mono);
  cursor: pointer;
}

#retry-data:hover {
  background: var(--night-3);
}

#retry-data:disabled {
  color: var(--muted);
  cursor: wait;
}

.chart-section {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--night-2);
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 12px 16px 0;
}

.legend {
  min-width: 0;
  font-family: var(--mono);
}

#timeline-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
}

.legend h2 {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.legend ul,
.progress-legend ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend li,
.progress-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.75rem;
}

.legend-swatch {
  display: inline-block;
  flex-shrink: 0;
  width: 24px;
  height: 4px;
}

.legend-swatch.bitcoin { background: var(--accent); }
.legend-swatch.ath { background: var(--ath); }
.legend-swatch.bottom { background: var(--bottom); }
.legend-swatch.halving { background: var(--halving); }

.legend-swatch.drawdown {
  height: 2px;
  border: 1.5px solid var(--ath);
  background: transparent;
}

.halving-scale {
  width: 240px;
  max-width: 100%;
}

.halving-gradient-label {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.halving-gradient-bar {
  height: 6px;
  margin-top: 6px;
  background: linear-gradient(to right,
    hsl(0, 85%, 55%),
    hsl(45, 90%, 50%),
    hsl(90, 80%, 45%),
    hsl(135, 75%, 42%),
    hsl(180, 80%, 45%),
    hsl(225, 75%, 55%),
    hsl(270, 70%, 55%));
}

.halving-gradient-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px 16px;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.control-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.control select,
.control input {
  accent-color: var(--accent);
}

.control select {
  min-height: 44px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--night-3);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.toggle-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.toggle-control input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.chart-stage {
  position: relative;
  padding: 12px 16px 16px;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 18px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.footnote {
  max-width: 60rem;
  margin: 16px 0 0;
  color: var(--ink-2);
  font-size: 0.875rem;
}

/* Tooltip */
.chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 140px;
  max-width: 240px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  background: #1c1915;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 4px, 0);
  transition: opacity 120ms ease, transform 120ms ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
  transform: none;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tooltip-key {
  color: #b3aa9c;
}

/* Scroll regions */
.progress-scroll-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.drawdowns-table-scroll,
.progress-chart-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line-strong) transparent;
}

.progress-chart-scroll:focus-visible,
.drawdowns-table-scroll:focus-visible {
  outline: 2px solid var(--accent-hot);
  outline-offset: 2px;
}

/* The title, the summary, and the legend share one row above the chart. */
#halving-progress-view,
#mean-reversion-view,
#wma200-view,
#market-structure-view,
#halving-clock-view,
#cvdd-view,
#monthly-returns-view,
#returns-view,
#yearly-returns-view {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.chart-stage > div > .progress-scroll-hint,
.chart-stage > div > .progress-chart-scroll,
.chart-stage > div > p[id$="-empty"] {
  flex: 0 0 100%;
  margin-bottom: 0;
}

.progress-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
}

.progress-header h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.375rem;
  font-weight: 360;
  letter-spacing: -0.01em;
}

.progress-header p {
  margin: 0;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.progress-legend {
  font-family: var(--mono);
}

.legend-swatch.progress-band {
  height: 12px;
  background: var(--accent);
  opacity: 0.22;
}

.legend-swatch.estimated-halving {
  height: 0;
  border-top: 1px dashed var(--muted);
}

/* ============================================================ chart size */
/* Each chart is as large as the screen allows. It fills the width, but its
   height stays in the screen: app.js sets --chart-h (the free height below
   the top of the chart) and --ar (the viewBox aspect ratio). The pointer
   code needs the box to keep the viewBox ratio, so the limit is a width. */
:root {
  --chart-h: calc(100svh - 190px);
}

.chart-fit {
  display: block;
  width: 100%;
  max-width: calc(var(--chart-h) * var(--ar, 2));
  height: auto;
  margin: 0 auto;
}

/* On a narrow screen, the wide charts keep a minimum width and scroll. */
#timeline-chart,
#cycles-chart,
#halving-progress-chart,
#mean-reversion-chart,
#wma200-chart,
#market-structure-chart {
  min-width: 1000px;
}

#spiral-chart { --ar: 1; }
#halving-progress-chart,
#wma200-chart { --ar: 1.875; }
#mean-reversion-chart { --ar: 1.579; }
#market-structure-chart { --ar: 1.818; }
#cvdd-chart { --ar: 2.222; min-width: 960px; }
#halving-clock-chart { --ar: 2; min-width: 960px; }
#returns-chart { --ar: 1; min-width: 760px; }

/* ============================================================ spiral */
/* On a wide screen, the Spiral keys sit to the right of the square chart. */
@media (min-width: 1001px) {
  #spiral-view {
    display: grid;
    grid-template-columns: minmax(0, var(--chart-h)) auto;
    align-items: center;
    justify-content: center;
  }

  #spiral-view > .progress-scroll-hint {
    grid-column: 1 / -1;
  }

  #spiral-view .spiral-caption {
    width: 16rem;
    padding: 0 0 0 24px;
  }
}

#spiral-chart.compact-labels .axis-label,
#spiral-chart.compact-labels .price-label,
#spiral-chart.compact-labels .live-label {
  display: none;
}

.spiral-caption {
  padding: 0 0 16px;
  font: 0.75rem/1.6 var(--mono);
}

.spiral-caption h2 {
  margin: 16px 0 4px;
  font: inherit;
  font-weight: 500;
}

.spiral-live-label {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
}

.spiral-axis-key {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0;
}

.spiral-axis-key dt {
  color: var(--muted);
}

.spiral-axis-key dd {
  margin: 0;
}

.spiral-price-key {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ============================================================ chart SVGs */
.grid-line,
.tl-grid-line,
.cy-grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.grid-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.price-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.marker {
  opacity: 1;
  cursor: pointer;
}

#spiral-chart .marker {
  animation: marker-fade 0.55s ease backwards;
}

.ath-marker { fill: var(--ath); }
.bottom-marker { fill: var(--bottom); }
.halving-marker { fill: var(--halving); }

.bottom-marker.provisional {
  fill: var(--bg);
  stroke: var(--bottom);
  stroke-width: 2.5;
}

.drawdown-marker {
  fill: var(--bg);
  stroke: var(--ath);
  stroke-width: 2;
}

.current-marker {
  fill: var(--accent-hot);
  stroke: var(--bg);
  stroke-width: 3;
}

.hit-path,
.tl-hit-path,
.cy-hit-path {
  fill: none;
  stroke: rgba(0, 0, 0, 0.001);
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
}

.hit-path { stroke-width: 24; }
.tl-hit-path,
.cy-hit-path { stroke-width: 20; }

.axis-label,
.price-label,
.live-label,
.tl-halving-label,
.tl-axis-label,
.tl-price-label,
.cy-axis-label,
.cy-price-label,
.hp-axis-label,
.hp-halving-label,
.hp-halving-date,
.hp-progress-label,
.mr-quantile-label,
.mr-current-label,
.ms-event-label,
.ms-value-label,
.ar-axis-title,
.ar-cell-text {
  font-family: var(--mono);
}

.axis-label {
  fill: var(--muted);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.price-label {
  fill: var(--muted);
  font-size: 14px;
  stroke: var(--bg);
  stroke-width: 3px;
  paint-order: stroke;
}

.live-label {
  fill: var(--ink);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Timeline */
.tl-halving-line {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 6, 4;
  opacity: 0.55;
}

.tl-halving-label,
.tl-axis-label,
.tl-price-label,
.cy-axis-label,
.cy-price-label {
  fill: var(--muted);
  font-size: 15px;
  letter-spacing: 0.04em;
}

.tl-segment {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Cycles */
.cy-zero-line {
  stroke: var(--ink-2);
  stroke-width: 1;
}

.cy-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Halving progress */
.hp-progress-band {
  fill: var(--accent);
  opacity: 0.16;
}

.hp-band-end {
  stroke: var(--accent);
  stroke-width: 1;
}

.hp-halving-line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.hp-estimated-line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 6, 4;
}

.hp-price-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.hp-axis-label,
.hp-halving-label,
.hp-halving-date {
  fill: var(--muted);
  font-size: 15px;
}

.hp-progress-label {
  fill: var(--ink);
  font-size: 20px;
  font-weight: 500;
}

/* Mean reversion and 200WMA */
.mr-zone {
  fill: none;
  stroke: none;
}

.mr-zone-0,
.legend-swatch.mr-cheap {
  fill: #2bb673;
  background: #2bb673;
  opacity: 0.3;
}

.mr-zone-1 {
  fill: #2bb673;
  opacity: 0.14;
}

.mr-zone-3 {
  fill: #e0614a;
  opacity: 0.14;
}

.mr-zone-4,
.legend-swatch.mr-expensive {
  fill: #e0614a;
  background: #e0614a;
  opacity: 0.3;
}

.legend-swatch.mr-cheap,
.legend-swatch.mr-expensive {
  height: 12px;
}

.legend-swatch.mr-index,
.legend-swatch.wma-line {
  height: 2px;
  background: var(--ink);
}

.mr-price-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}

.mr-index-path,
.wma-path {
  fill: none;
  stroke: var(--ink);
  stroke-linejoin: round;
}

.mr-index-path { stroke-width: 1.25; }
.wma-path { stroke-width: 2; }

.cvdd-path {
  fill: none;
  stroke: var(--positive-text);
  stroke-width: 2;
  stroke-dasharray: 6 3;
}

.cvdd-dot { fill: var(--positive-text); }

.legend-swatch.cvdd-line {
  height: 0;
  border-top: 2px dashed var(--positive-text);
  background: none;
}

.wma-below-band {
  fill: #2bb673;
  opacity: 0.2;
}

.mr-quantile-label {
  fill: var(--muted);
  font-size: 15px;
}

.mr-current-label {
  fill: var(--ink);
  font-size: 18px;
  font-weight: 500;
  stroke: var(--bg);
  stroke-width: 5px;
  paint-order: stroke;
}

.mr-cursor {
  stroke: var(--ink-2);
  stroke-width: 1;
  stroke-dasharray: 4, 4;
  pointer-events: none;
}

.mr-hit-area {
  fill: transparent;
  pointer-events: all;
}

/* Market structure: the lines use the gain and loss text colors. */
.ms-dma-path,
.ms-sth-path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 0.5, 4;
}

.ms-dma-path { stroke: var(--bottom); }
.ms-sth-path { stroke: var(--positive-text); }

.legend-swatch.ms-dma,
.legend-swatch.ms-sth {
  height: 0;
  border-top: 3px dotted var(--bottom);
  background: none;
}

.legend-swatch.ms-sth {
  border-top-color: var(--positive-text);
}

.ms-ath,
.legend-swatch.ms-ath-dot {
  fill: var(--ink);
  background: var(--ink);
}

.legend-swatch.ms-ath-dot {
  width: 6px;
  height: 6px;
  margin: 0 9px;
  border-radius: 50%;
}

.ms-event-line {
  stroke: var(--line-strong);
  stroke-width: 1;
}

.ms-event-line.is-estimate {
  stroke-dasharray: 6, 4;
}

.ms-event-label,
.ms-value-label {
  font-size: 15px;
}

.ms-event-label {
  fill: var(--muted);
}

.ms-value-label {
  font-weight: 500;
  stroke: var(--bg);
  stroke-width: 4px;
  paint-order: stroke;
}

.ms-dma-label { fill: var(--bottom); }
.ms-sth-label { fill: var(--positive-text); }

/* Annualized return grid */
.ar-cell-rect {
  stroke: var(--bg);
  stroke-width: 1;
}

.ar-cell:hover .ar-cell-rect {
  stroke: var(--ink);
  stroke-width: 2;
}

.ar-cell-text {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  fill: #111111;
  pointer-events: none;
}

.ar-cell-text.is-light {
  fill: #ffffff;
}

.ar-frame {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1;
  pointer-events: none;
}

.ar-axis-title {
  fill: var(--muted);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#returns-chart .hp-axis-label {
  font-size: 16px;
}

.legend-swatch.ar-swatch {
  width: 16px;
  height: 12px;
}

/* The same hues as returnColor() in app.js, at the middle of each range. */
.legend-swatch.ar-loss { background: hsl(345, 72%, 50%); }
.legend-swatch.ar-25 { background: hsl(45, 72%, 50%); }
.legend-swatch.ar-50 { background: hsl(95, 72%, 50%); }
.legend-swatch.ar-75 { background: hsl(145, 72%, 50%); }
.legend-swatch.ar-100 { background: hsl(195, 72%, 50%); }
.legend-swatch.ar-over { background: hsl(220, 72%, 50%); }

/* ============================================================ tables */
#yearly-returns-view {
  max-width: 760px;
  margin: 0 auto;
}

#lows-view {
  max-width: 600px;
  margin: 0 auto;
}

.lows-title,
.drawdowns-title {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 1.75rem;
  font-weight: 360;
  letter-spacing: -0.01em;
}

.yearly-returns-table,
.lows-table,
.drawdowns-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.yearly-returns-table {
  min-width: 520px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.lows-table {
  min-width: 500px;
  font-size: 0.85rem;
}

.drawdowns-table {
  min-width: 940px;
  font-size: 0.85rem;
}

.yearly-returns-table th,
.yearly-returns-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.yearly-returns-table thead th,
.lows-table th,
.drawdowns-table thead th {
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.yearly-returns-table th:first-child {
  text-align: left;
}

.yearly-returns-table tbody th,
.yearly-returns-table td:last-child {
  font-weight: 500;
}

.yearly-gain {
  color: var(--positive-text);
  background: #15261c;
}

.yearly-loss {
  color: var(--bottom);
  background: #2c1611;
}

.yearly-flat {
  color: var(--muted);
  background: var(--night-3);
}

.lows-table th,
.lows-table td {
  padding: 10px 12px;
  text-align: left;
}

.lows-table td {
  border-bottom: 1px solid var(--line);
}

.lows-table td:nth-child(2) {
  font-weight: 500;
}

.lows-table th:nth-child(2),
.lows-table th:nth-child(3),
.lows-table td:nth-child(2),
.lows-table td:nth-child(3) {
  text-align: right;
}

.low-up { color: var(--positive-text); }
.low-down { color: var(--bottom); }
.low-flat { color: var(--muted); }

.drawdowns-table th,
.drawdowns-table td {
  padding: 16px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.drawdowns-table thead th {
  padding-top: 8px;
}

.drawdowns-table tbody th {
  font-weight: 600;
}

.drawdown-date,
.drawdown-halving-offset {
  display: block;
}

.drawdown-halving-offset {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.drawdowns-table tbody td:nth-child(6),
.drawdowns-table tbody td:last-child {
  font-weight: 600;
}

.drawdowns-table tr > :nth-child(3),
.drawdowns-table tr > :nth-child(5),
.drawdowns-table tr > :nth-child(6),
.drawdowns-table tr > :nth-child(7) {
  text-align: right;
}

.lows-table tbody tr:hover,
.drawdowns-table tbody tr:hover {
  background: var(--night-3);
}

/* ============================================================ market quotes */
.market-quotes {
  position: relative;
  z-index: 2;
  padding: 48px var(--gutter);
  border-top: 1px solid var(--line);
  background: var(--night);
}

.market-quotes-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: var(--content);
  gap: 32px 48px;
  margin: 0 auto;
}

.market-quotes figure {
  margin: 0;
  padding-left: 16px;
  border-left: 1px solid var(--line-strong);
}

.market-quotes blockquote {
  max-width: 34ch;
  margin: 0 0 12px;
  font: italic 360 clamp(1.25rem, 2.1vw, 1.75rem)/1.3 var(--serif);
}

.market-quotes figcaption {
  color: var(--ink-2);
  font-size: 0.875rem;
}

/* ============================================================ method */
.method {
  position: relative;
  z-index: 2;
  padding: 88px var(--gutter) 72px;
  max-width: none;
  border-top: 1px solid var(--line);
  background: var(--night);
}

.method > * {
  max-width: var(--content);
  margin-left: auto;
  margin-right: auto;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px 48px;
  margin-top: 32px;
}

.method h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.method p {
  max-width: 60ch;
  margin: 0;
  color: var(--ink-2);
  font-size: 0.9375rem;
}

.site-foot {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 32px;
  max-width: none;
  padding: 32px var(--gutter) 48px;
  border-top: 1px solid var(--line);
  background: var(--night);
}

.site-foot p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

@keyframes marker-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================ responsive */
@media (max-width: 1000px) {
  .method-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  :root {
    --nav-h: 56px;
  }

  .market-quotes-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .site-links a[data-nav="cycles"],
  .site-links a[data-nav="method"],
  .nav-live-label {
    display: none;
  }


  .site-links {
    gap: 16px;
  }

  .nav-live {
    padding-left: 14px;
  }

  .wordmark {
    font-size: 1rem;
  }

  .hero {
    gap: 32px;
    padding-top: calc(var(--nav-h) + 28px);
  }

  .readouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readout,
  .readout + .readout {
    padding: 14px 12px 14px 0;
    border-left: 0;
  }

  .readout:nth-child(even) {
    padding-left: 14px;
    border-left: 1px solid var(--line);
  }

  .readout:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }


  .chapter-stats {
    gap: 20px 20px;
  }

  .pace-list li {
    grid-template-columns: 5.5rem 1fr 4rem;
  }

  .chart-toolbar {
    padding: 12px 12px 0;
  }

  .chart-stage {
    padding: 12px;
  }

  /* On a phone, the twelve tabs use one row that scrolls sideways. The fade
     at the right edge shows that more tabs follow. */
  .view-nav {
    flex-wrap: nowrap;
    margin: 0 calc(-1 * var(--gutter));
    padding: 4px 64px 4px var(--gutter);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }

  .charts-page .site-links a[href="/#method"] {
    display: none;
  }

  .chart-tooltip {
    max-width: 190px;
  }
}

/* The stacked story: on a phone or a portrait tablet, the orbit holds the
   top of the screen and the copy sits below it. story.js uses the same query. */
@media (max-width: 760px), (max-aspect-ratio: 9/10) {
  .hero-copy {
    max-width: 40rem;
  }

  .hero-window {
    display: block;
    height: clamp(220px, 36svh, 380px);
  }

  .hero::before {
    background: linear-gradient(rgba(11, 10, 8, 0.88), rgba(11, 10, 8, 0.55) 52%, rgba(11, 10, 8, 0.15) 70%, rgba(11, 10, 8, 0.85));
  }

  .chapter {
    align-items: flex-end;
    min-height: 130svh;
    padding-bottom: 64px;
  }

  .chapter-copy::before {
    inset: -40% -30% -20% -30%;
    background: linear-gradient(rgba(11, 10, 8, 0), rgba(11, 10, 8, 0.86) 30%, rgba(11, 10, 8, 0.94));
  }
}

/* The price links to the charts, so the last link can go on small phones. */
@media (max-width: 480px) {
  .site-links {
    display: none;
  }

  .nav-live {
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .js [data-rv] {
    opacity: 1;
    transform: none;
  }

  .word {
    transform: none;
  }

  .price-path {
    stroke-dasharray: none !important;
    stroke-dashoffset: 0 !important;
  }
}

/* ============================================================ halving clock */
.hc-minor-line {
  stroke: var(--line);
  stroke-width: 1;
  opacity: 0.45;
}
.hc-path {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.25;
  opacity: 0.55;
}
.hc-dot {
  stroke: var(--night-2);
  stroke-width: 1.25;
  cursor: pointer;
}
.hc-dot:hover { stroke: var(--ink); stroke-width: 2; }
.hc-dot-live { stroke: var(--ink); stroke-width: 2; }
.hc-scale-bar { stroke: var(--line-strong); }

/* ============================================================ monthly returns */
.monthly-returns-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 6px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  white-space: nowrap;
}
.monthly-returns-table th {
  color: var(--muted);
  font-weight: 500;
  text-align: center;
}
.monthly-returns-table thead th.is-current {
  color: var(--ink);
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 6px;
}
.monthly-returns-table tbody th {
  padding-right: 8px;
  color: var(--ink);
  text-align: left;
}
.monthly-returns-table td { padding: 0; }
.monthly-returns-table .mr-year { padding-left: 12px; }
.mr-chip {
  display: block;
  padding: 9px 6px;
  border-radius: 5px;
  color: #0b0a08;
  font-weight: 600;
  text-align: center;
}
.mr-chip-gain { background: #5ccf8b; }
.mr-chip-loss { background: #f2736d; }
.mr-chip-live { outline: 2px dashed var(--ink); outline-offset: -2px; }
