/* barj capital · home story: a sticky canvas stage, the steps scroll over it.
   The language of the Monitor (monitor/monitor.css): hairlines, square corners, Geist Mono for figures,
   colour only on the data. Reduced motion: .is-static, every step its own still figure. */

.story {
  --gold: #C9A87A; --sig: #9cc5a1; --warn: #e0a458; --line: rgba(244, 239, 230, 0.16); --line-soft: rgba(244, 239, 230, 0.08);
  --panel: rgba(14, 20, 36, 0.92);  /* no backdrop blur: it would be recomputed at every frame of the canvas */
  position: relative;
  font-variant-numeric: lining-nums tabular-nums;
}

/* ------------------------------------------------------------ hero cue */
.hero-cue {
  display: inline-block;
  margin-top: 2.25rem;
  font-size: var(--fs-small);
  color: var(--text-2);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.hero-cue [data-k] { font-family: var(--mono); }
.hero-cue:hover { color: var(--text); border-bottom-color: var(--text); }

/* ------------------------------------------------------------ stage */
.story-stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  contain: strict;
}
.story-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.story-hud {
  position: absolute;
  top: 76px;
  left: var(--gutter);
  right: var(--gutter);
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 1rem;
  pointer-events: none;
}
.story-count {
  font-family: var(--mono);
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
}
.story-count-label {
  grid-column: 1 / -1;
  margin-top: 0.4rem;
  font-size: var(--fs-meta);
  color: var(--text-2);
  max-width: 34ch;
}
.story-sizes {
  grid-row: 1;
  grid-column: 2;
  justify-self: end;
  align-self: end;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.story-sizes.is-on { opacity: 1; }
.story-size { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 10px; }
.story-size i { display: block; width: 100%; background: rgba(244, 239, 230, 0.18); }
.story-size b { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--text-3); }
.story-size span { display: none; font-family: var(--mono); font-size: 10px; color: var(--text-3); white-space: nowrap; }
.story-size.is-cur i { background: var(--gold); }
.story-size.is-cur b, .story-size.is-cur span { color: var(--text); }

.story-tip {
  position: absolute;
  z-index: 3;
  max-width: 260px;
  padding: 0.45rem 0.6rem;
  background: #0E1424;
  border: 1px solid var(--line);
  font-size: var(--fs-meta);
  line-height: 1.45;
  color: var(--text);
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.story-tip .m { font-family: var(--mono); color: var(--text-3); }

/* ------------------------------------------------------------ steps */
.story-steps { position: relative; z-index: 2; margin-top: -100vh; margin-top: -100svh; pointer-events: none; }
.story-step {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  /* on a phone the card rests under the plot, then scrolls over it */
  padding: 60vh var(--gutter) 6vh;
  padding: 60svh var(--gutter) 6svh;
}
.story-step--tall { min-height: 220vh; min-height: 220svh; }
.story-step--tall .story-card { position: sticky; top: 60svh; }
.story-card {
  pointer-events: auto;
  width: 100%;
  max-width: 30rem;
  padding: 1.1rem 1.2rem 1.2rem;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--text-2);
}
.story-card h2 { font-size: var(--fs-lead); line-height: 1.3; color: var(--text); margin: 0 0 0.6rem; }
.story-card p { margin: 0 0 0.6rem; }
.story-card p:last-child { margin-bottom: 0; }
.story-card b { color: var(--text); font-weight: 500; }
.story-card span[data-k]:not([data-k="endWhy"]), .story-card b[data-k] { font-family: var(--mono); font-size: 0.95em; }
.story-card h2 [data-k] { font-size: 1em; }
.story-kicker { font-size: var(--fs-meta); color: var(--accent); margin-bottom: 0.45rem !important; }
.story-note { font-size: var(--fs-meta); color: var(--text-3); }
.story-math { margin: 0.4rem 0 0.7rem !important; color: var(--text); font-size: 1.05rem; overflow-x: auto; }
.story-math math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", serif; }

.story-pick { display: flex; flex-wrap: wrap; border: 1px solid var(--line); margin: 0.2rem 0 0.7rem; width: fit-content; max-width: 100%; }
.story-pick button { border: 0; border-left: 1px solid var(--line-soft); background: none; padding: 0.38rem 0.5rem; cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--text-3); transition: color .2s, background .2s; }
.story-pick button:first-child { border-left: 0; }
.story-pick button:hover { color: var(--text); }
.story-pick button[aria-pressed="true"] { color: var(--text); background: rgba(244, 239, 230, 0.07); box-shadow: inset 0 -1px 0 var(--gold); }
.sharecard-btn { margin-top: 0.8rem; }
.story-survivors { list-style: none; margin: 0.4rem 0 0.6rem; padding: 0; font-size: var(--fs-meta); max-height: 38svh; overflow-y: auto; }
.story-survivors li { display: grid; grid-template-columns: 0.6rem 1fr auto; gap: 0.5rem; align-items: baseline; padding: 0.28rem 0; border-top: 1px solid var(--line-soft); }
.story-survivors li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sig); transform: translateY(-1px); }
.story-survivors li.is-robust::before { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.story-survivors .sr { font-family: var(--mono); color: var(--text); }
.story-survivors a:hover { color: var(--text); }

/* ------------------------------------------------------------ after the story */
.story-next { padding-top: clamp(3rem, 8vh, 5rem); }
.story-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); border-top: 1px solid var(--rule); }
.story-tool { display: block; padding: 1.1rem 1.2rem 1.2rem 0; border-bottom: 1px solid var(--rule); }
.story-tool h3 { font-size: var(--fs-body); margin: 0 0 0.3rem; transition: color .2s var(--ease); }
.story-tool p { margin: 0; font-size: var(--fs-small); color: var(--text-3); line-height: 1.5; }
.story-tool:hover h3 { color: var(--accent); }
.story-tool[hidden] { display: none; }
.story-source { margin: 1.25rem 0 0; font-size: var(--fs-meta); color: var(--text-3); }
.story-source a { border-bottom: 1px solid var(--rule); }
.story-source a:hover { color: var(--text); }
.story-source [data-k] { font-family: var(--mono); }

/* ------------------------------------------------------------ phones: the scene keeps the top of the screen
   The scene holds the top 60% and sits above the text: each card rises in the window below it and slides
   under the scene as it is read, so no card ever covers a point. */
@media (max-width: 899.98px) {
  .story { --scene: 60svh; }
  .story-stage {
    z-index: 3;
    height: 60vh;
    height: var(--scene);
    background: var(--bg);
    overflow: visible;
    contain: layout style;
    box-shadow: 0 1px 0 var(--line-soft);
  }
  /* the text fades out as it reaches the scene */
  .story-stage::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 2rem; background: linear-gradient(var(--bg), rgba(10, 15, 28, 0)); pointer-events: none; }
  .story-steps { margin-top: -60vh; margin-top: calc(-1 * var(--scene)); }
  .story-step { padding-top: calc(60vh + 1.25rem); padding-top: calc(var(--scene) + 1.25rem); }
  .story-step--tall .story-card { top: calc(var(--scene) + 1.25rem); }
  .story-survivors { max-height: none; overflow: visible; }
  .story-hud { top: 72px; }
  .story-count { font-size: 2rem; }
}

/* ------------------------------------------------------------ wide screens: text on the left, plot on the right */
@media (min-width: 900px) {
  .story-hud { left: 44%; right: 48px; top: 88px; }
  .story-step { align-items: center; padding: 0 0 0 max(var(--gutter), calc((100vw - var(--col-wide)) / 2 + var(--gutter))); }
  .story-card { max-width: min(26rem, 36vw); }
  .story-step--tall .story-card { top: 30svh; }
  .story-size { width: 34px; }
  .story-size span { display: block; }
  .story-survivors { max-height: 40vh; }
  .story-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------ reduced motion: still figures, one per step */
.story.is-static .story-stage { display: none; }
.story.is-static .story-steps { margin-top: 0; pointer-events: auto; }
.story.is-static .story-step, .story.is-static .story-step--tall { min-height: 0; padding: 0 var(--gutter); margin: 0 auto 2.5rem; max-width: var(--col-wide); display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.story.is-static .story-card, .story.is-static .story-step--tall .story-card { position: static; max-width: none; background: none; border: 0; padding: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.story-fig { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; border: 1px solid var(--line-soft); }
.story.is-static .story-sizes--card { opacity: 1; display: flex; justify-content: flex-start; margin-top: 0.8rem; }
@media (min-width: 900px) {
  .story.is-static .story-step { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 2.5rem; }
  .story.is-static .story-fig { aspect-ratio: 16 / 10; }
}
