/* Product chapters · the dark scroll scenes on the three product pages.
   One system, three themes: Evening (Best-shot, ember), Season (GerOS,
   periwinkle), Yard (Barilga ERP, periwinkle, unpinned). Shares the Dealy
   flowline's grammar — near-black field, drawn strokes, flow-clock packets,
   pixel formation — so the four products read as one family.
   Tokens are declared on the section; this file depends on nothing.         */

.chapter {
  --ch-black: #05080f;
  --ch-ink: #f2f6ff;
  --ch-ink-2: rgba(228, 236, 255, .72);
  /* .45 measured 3.96:1 on the chapter black — below the 4.5:1 AA floor, and
     it is used exclusively on 9.5-11px labels. .62 lands at ~5.7:1 and stays
     clearly subordinate to --ch-ink-2 (.72). */
  --ch-ink-3: rgba(228, 236, 255, .62);
  --ch-panel: rgba(13, 22, 40, .72);
  --ch-line: rgba(139, 147, 255, .18);
  --ch-accent: #8b93ff;
  --ch-accent-2: #b9befc;
  --ch-glow: rgba(139, 147, 255, .5);
  --ch-soft: rgba(139, 147, 255, .12);
  --ch-sans: "Inter", Arial, Helvetica, sans-serif;
  --ch-display: "Inter Tight", "Inter", Arial, Helvetica, sans-serif;
  --ch-mono: "IBM Plex Mono", monospace;

  position: relative;
  background: var(--ch-black);
  color: var(--ch-ink);
  isolation: isolate;
}
.chapter::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  background:
    radial-gradient(110% 70% at 16% 0%, var(--ch-soft), transparent 58%),
    radial-gradient(90% 70% at 84% 100%, var(--ch-soft), transparent 62%);
  content: "";
  pointer-events: none;
}

/* Evening runs warm: ember on a coal-black field. */
.chapter-evening {
  --ch-black: #0a0704;
  --ch-panel: rgba(38, 22, 10, .55);
  --ch-line: rgba(255, 138, 61, .2);
  --ch-accent: #ff8a3d;
  --ch-accent-2: #ffc79b;
  --ch-glow: rgba(255, 138, 61, .5);
  --ch-soft: rgba(255, 138, 61, .09);
}

.ch-intro { position: relative; z-index: 2; padding: clamp(72px, 8vw, 120px) 0 clamp(26px, 3vw, 44px); }
.ch-intro .pp-kicker { color: var(--ch-accent); }
/* .pp-display carries family/weight/tracking but no size; every other heading
   gets its size from an ancestor rule (.pp-hero h1, .pp-heading h2 …). Without
   one here the chapter title fell through to the UA default 24px — smaller
   than its own lead, at the peak moment of the page. */
.ch-intro h2 {
  max-width: 17ch;
  color: var(--ch-ink);
  font-family: var(--ch-display);
  font-size: clamp(40px, 4.4vw, 60px);
  letter-spacing: -.04em;
  line-height: .98;
}
.ch-lead { max-width: 52ch; margin: 14px 0 0; color: var(--ch-ink-2); font-size: clamp(15px, 1.4vw, 18px); line-height: 1.55; }

.ch-stage { position: relative; z-index: 2; padding-bottom: clamp(56px, 6vw, 96px); }

/* ── Evening: the ring ──────────────────────────────────────────────────── */
.ch-evening-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr); gap: clamp(28px, 4vw, 72px); align-items: center; }
.ch-ring-wrap { position: relative; max-width: min(74vh, 620px); margin-inline: auto; aspect-ratio: 1; width: 100%; }
.ch-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ch-ring .ch-ring-base { fill: none; stroke: rgba(228, 236, 255, .10); stroke-width: 2; }
.ch-ring .ch-ring-arc { fill: none; stroke: var(--ch-accent); stroke-width: 3; stroke-linecap: round; }
.ch-ring .ch-halo { fill: none; stroke: var(--ch-glow); stroke-width: 8; stroke-linecap: round; opacity: 0; }
.ch-ring .ch-pulse { fill: none; stroke: var(--ch-accent-2); stroke-width: 2.4; stroke-linecap: round; opacity: 0; }
.ch-ring .ch-st circle { fill: #140d07; stroke: rgba(228, 236, 255, .22); stroke-width: 1.4; transition: fill .45s ease, stroke .45s ease; }
.ch-ring .ch-st text { font: 600 11px var(--ch-mono); letter-spacing: .1em; fill: var(--ch-ink-3); text-transform: uppercase; transition: fill .45s ease; }
.ch-ring .ch-st.is-lit circle { fill: var(--ch-accent); stroke: rgba(255, 199, 155, .9); filter: drop-shadow(0 0 10px var(--ch-glow)); }
.ch-ring .ch-st.is-lit text { fill: var(--ch-accent-2); }
.ch-ring-center { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; text-align: center; pointer-events: none; }
.ch-ring-center .ch-center-label { color: var(--ch-ink-3); font: 500 10px/1 var(--ch-mono); letter-spacing: .16em; text-transform: uppercase; }
.ch-counter { color: var(--ch-accent); font-family: var(--ch-display); font-size: clamp(46px, 5vw, 72px); font-weight: 700; letter-spacing: -.04em; line-height: 1; text-shadow: 0 0 34px var(--ch-glow); }
.ch-ring-center .ch-center-sub { color: var(--ch-ink-2); font-size: 12px; }

.ch-beats { display: grid; gap: 14px; }
.ch-beat { padding: 18px 20px; border: 1px solid var(--ch-line); border-radius: 16px; background: var(--ch-panel); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); }
.ch-beat > span { color: var(--ch-accent); font: 600 10px/1 var(--ch-mono); letter-spacing: .14em; text-transform: uppercase; }
.ch-beat b { display: block; margin-top: 9px; color: var(--ch-ink); font-size: 15px; font-weight: 600; letter-spacing: -.02em; }
.ch-beat p { margin: 6px 0 0; color: var(--ch-ink-2); font-size: 12.5px; line-height: 1.5; }

/* ── Season: the year arc ───────────────────────────────────────────────── */
.ch-season-wrap { position: relative; max-width: 1080px; margin-inline: auto; }
.ch-season { display: block; width: 100%; height: auto; overflow: visible; }
.ch-season .ch-arc-base { fill: none; stroke: rgba(228, 236, 255, .10); stroke-width: 2; }
.ch-season .ch-arc { fill: none; stroke: var(--ch-accent); stroke-width: 3; stroke-linecap: round; }
.ch-season .ch-comet { fill: #fff; filter: drop-shadow(0 0 9px var(--ch-accent)); }
.ch-season .ch-month text { font: 600 11px var(--ch-mono); letter-spacing: .12em; fill: var(--ch-ink-3); transition: fill .4s ease; }
.ch-season .ch-month line { stroke: rgba(228, 236, 255, .18); stroke-width: 1.4; transition: stroke .4s ease; }
.ch-season .ch-month.is-lit text { fill: var(--ch-accent-2); }
.ch-season .ch-month.is-lit line { stroke: var(--ch-accent); }
.ch-season .ch-sat circle { fill: #0b1222; stroke: rgba(228, 236, 255, .2); stroke-width: 1.4; transition: fill .45s ease, stroke .45s ease; }
.ch-season .ch-sat text { font: 600 10.5px var(--ch-mono); letter-spacing: .1em; fill: var(--ch-ink-3); text-anchor: middle; transition: fill .45s ease; }
.ch-season .ch-sat.is-lit circle { fill: var(--ch-accent); stroke: #cdd1ff; filter: drop-shadow(0 0 10px var(--ch-glow)); }
.ch-season .ch-sat.is-lit text { fill: var(--ch-accent-2); }
.ch-season .ch-spoke { fill: none; stroke: rgba(139, 147, 255, .16); stroke-width: 1.2; }
.ch-season .ch-spoke-pulse { fill: none; stroke: var(--ch-accent-2); stroke-width: 2; stroke-linecap: round; opacity: 0; }
.ch-season .ch-demand { fill: none; stroke: var(--ch-accent); stroke-width: 2.4; stroke-linecap: round; opacity: .85; }
.ch-season .ch-demand-label { font: 600 10.5px var(--ch-mono); letter-spacing: .12em; fill: var(--ch-ink-3); }
.ch-ger {
  position: absolute;
  left: 50%;
  top: 61%;
  width: min(17%, 168px);
  transform: translate(-50%, -50%);
  /* The -alpha asset carries the stipple in its alpha channel with white ink,
     so it composites correctly on the dark field with no blend mode. The old
     grayscale+invert+screen approach could not work: mix-blend-mode resolves
     against the nearest stacking context, and .ch-stage (z-index: 2) has a
     transparent backdrop — screening onto transparent yields a black plate. */
  opacity: .62;
  pointer-events: none;
}
.ch-ger-label { position: absolute; left: 50%; top: 70.5%; transform: translateX(-50%); color: var(--ch-ink-3); font: 600 11px/1 var(--ch-mono); letter-spacing: .16em; }
.ch-chip { position: absolute; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--ch-line); border-radius: 999px; background: var(--ch-panel); color: var(--ch-accent-2); font: 600 11px/1 var(--ch-mono); letter-spacing: .12em; box-shadow: 0 0 30px -10px var(--ch-glow); }
.ch-chip--peak { left: 50%; top: 4%; transform: translateX(-50%); color: var(--ch-ink); font-size: 13px; }
.ch-chip--ready { right: 4%; bottom: 10%; }

/* ── Yard: stock against forecast ───────────────────────────────────────── */
.ch-yard-grid { position: relative; display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) minmax(140px, 190px); gap: clamp(20px, 3vw, 44px); align-items: center; }
.ch-tags { display: grid; gap: 12px; align-content: center; }
.ch-tag { justify-self: start; padding: 9px 15px; border: 1px solid var(--ch-line); border-radius: 999px; background: var(--ch-panel); color: var(--ch-ink-2); font: 500 11px/1 var(--ch-mono); letter-spacing: .08em; }
.ch-tags--out .ch-tag { color: var(--ch-accent-2); border-color: rgba(139, 147, 255, .32); }
.ch-chart { padding: clamp(18px, 2vw, 28px); border: 1px solid var(--ch-line); border-radius: 20px; background: rgba(8, 14, 26, .6); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04); }
.ch-chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 14px; }
.ch-chart-legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ch-ink-3); font: 500 11px/1 var(--ch-mono); letter-spacing: .1em; }
.ch-chart-legend i { width: 12px; height: 8px; border-radius: 2px; background: rgba(139, 147, 255, .45); }
.ch-chart-legend .ch-leg-line { height: 2px; border-radius: 2px; background: var(--ch-accent-2); }
.ch-chart-legend .ch-leg-buy { width: 8px; height: 8px; border-radius: 50%; background: #ffb45c; }
.ch-chart canvas { display: block; width: 100%; height: 280px; }
.ch-edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 1; }
.ch-edges path { fill: none; stroke-linecap: round; }
.ch-edges .ch-edge { stroke: rgba(139, 147, 255, .4); stroke-width: 1.4; }
.ch-edges .ch-edge-pulse { stroke: var(--ch-accent-2); stroke-width: 2.2; opacity: 0; }

/* Formation: same pixel-dissolve contract as the Dealy flowline. */
.ch-anim .ch-forming {
  -webkit-mask-image: radial-gradient(circle, #000 calc(var(--chd, 12) * 1px), transparent calc(var(--chd, 12) * 1px + .6px));
  -webkit-mask-size: 15px 15px;
  -webkit-mask-repeat: repeat;
  mask-image: radial-gradient(circle, #000 calc(var(--chd, 12) * 1px), transparent calc(var(--chd, 12) * 1px + .6px));
  mask-size: 15px 15px;
  mask-repeat: repeat;
}

/* Entry states. The chapter JS drives these; without it nothing hides. */
.ch-anim .ch-beat,
.ch-anim .ch-chip,
.ch-anim .ch-chart,
.ch-anim .ch-tag { opacity: 0; transform: translateY(16px); }

@media (max-width: 900px) {
  .ch-evening-grid { grid-template-columns: 1fr; }
  .ch-yard-grid { grid-template-columns: 1fr; }
  .ch-tags { display: flex; flex-wrap: wrap; }
  .ch-edges { display: none; }
}

@media (max-width: 760px) {
  .ch-chip--peak { top: 0; }
  .ch-chip--ready { position: static; justify-self: start; margin-top: 14px; }
  .ch-season-wrap { overflow-x: clip; }
}

@media (prefers-reduced-motion: reduce) {
  .ch-anim .ch-beat,
  .ch-anim .ch-chip,
  .ch-anim .ch-chart,
  .ch-anim .ch-tag { opacity: 1 !important; transform: none !important; }
  .ch-anim .ch-forming { -webkit-mask-image: none !important; mask-image: none !important; }
  .ch-ring .ch-halo, .ch-ring .ch-pulse,
  .ch-season .ch-spoke-pulse,
  .ch-edges .ch-edge-pulse { display: none; }
  .ch-ring .ch-ring-arc, .ch-season .ch-arc, .ch-season .ch-demand, .ch-edges .ch-edge { stroke-dashoffset: 0 !important; }
}

html.static-mode .ch-anim .ch-beat,
html.static-mode .ch-anim .ch-chip,
html.static-mode .ch-anim .ch-chart,
html.static-mode .ch-anim .ch-tag { opacity: 1 !important; transform: none !important; }
html.static-mode .ch-anim .ch-forming { -webkit-mask-image: none !important; mask-image: none !important; }
html.static-mode .ch-ring .ch-halo, html.static-mode .ch-ring .ch-pulse,
html.static-mode .ch-season .ch-spoke-pulse,
html.static-mode .ch-edges .ch-edge-pulse { display: none; }
html.static-mode .ch-ring .ch-ring-arc, html.static-mode .ch-season .ch-arc,
html.static-mode .ch-season .ch-demand, html.static-mode .ch-edges .ch-edge { stroke-dashoffset: 0 !important; }

/* Pinned stages fill the viewport so the pin engages cleanly. */
.ch-stage--pin { display: grid; min-height: 100svh; align-content: center; padding-bottom: 0; }
.ch-stage--pin > .container { width: 100%; }

/* A dark chapter running into the dark outcome card needs a deliberate band
   between them. The original 20px of white read as a rendering fault; killing
   the padding entirely just moved the problem, leaving the CTA card butted
   18px against the figure. A generous white band is the same rhythm the rest
   of the site uses between sections. */
.chapter + .pp-outcome { padding-top: clamp(64px, 7vw, 104px); }
