/*
 * Chapter 5, pregnancy loss: the content note, and the chapter's three charts.
 *   .loss-note  content note with a skip link, under the chapter hero
 *   .lp         loss-path: lanes through the weeks of pregnancy (scrolly)
 *   .lc2        loss-cost: median claim per type, against smooth deliveries
 *   .lr         loss-refusal: refusal rate (arrows) or refused claims (lines)
 * Loss lanes and marks use the chapter ink (--cat-emph); births and context
 * use the ink wash. Tone: quiet. No loud fills, no alarm colour.
 */

/* ---- content note (17 Nov, round 2) -------------------------------------------
 * A dark panel in the chapter's own ink, so it stops the eye before the chapter starts: a small label, one sentence
 * in the display face, one line of reassurance, and one real button that skips the chapter. A rose glow from the
 * chapter colour in one corner; no alarm colour. Light and dark themes share it (the panel is dark in both). */
.loss-note {
  --ln-bg: #2a0a1c; --ln-fg: #fbeef2; --ln-rose: color-mix(in srgb, var(--cat-emph) 45%, #fff);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 22px 40px;
  box-sizing: border-box; max-width: 800px; margin: clamp(48px, 7vh, 72px) auto 0;
  padding: clamp(26px, 3vw, 36px) clamp(24px, 3.4vw, 40px);
  color: var(--ln-fg);
  background:
    radial-gradient(90% 150% at 100% 0%, color-mix(in srgb, var(--cat-emph) 46%, transparent) 0%, transparent 62%),
    var(--ln-bg);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(42, 10, 28, .18), 0 22px 60px rgba(42, 10, 28, .22);
}
.loss-note p { margin: 0; }
.ln-kicker {
  display: flex; align-items: center; gap: 8px; margin-bottom: 14px !important;
  font: 500 11.5px/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ln-rose);
}
.ln-kicker svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.ln-body { grid-column: 1 / -1; }   /* the sentence takes the panel's full width; the reassurance and the button share the row under it */
.ln-text { font: 400 clamp(22px, 2.5vw, 30px)/1.25 var(--font-display); letter-spacing: -.02em; text-wrap: balance; max-width: 22em; }
.ln-sub { max-width: 30ch; font: 400 15px/1.5 var(--font-sans); color: color-mix(in srgb, var(--ln-fg) 74%, transparent); }
.ln-skip {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px 13px 18px;
  color: var(--ln-bg); background: var(--ln-fg); text-decoration: none;
  border-radius: 10px; box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 6px 18px rgba(0, 0, 0, .22);
  transition: transform .18s var(--rv-ease, ease), background .18s;
}
.ln-skip span { display: grid; gap: 3px; }
.ln-skip b { font: 600 15px/1.2 var(--font-sans); }
.ln-skip small { font: 400 11.5px/1.3 var(--font-mono); letter-spacing: .02em; color: color-mix(in srgb, var(--ln-bg) 68%, transparent); }
.ln-skip .chev { width: 18px; height: 18px; flex: none; transition: transform .18s var(--rv-ease, ease); }
.ln-skip:hover, .ln-skip:focus-visible { background: #fff; transform: translateY(-1px); }
.ln-skip:hover .chev, .ln-skip:focus-visible .chev { transform: translateY(2px); }
.ln-skip:focus-visible { outline: 2px solid var(--ln-rose); outline-offset: 3px; }
@media (width < 760px) {
  .loss-note { grid-template-columns: minmax(0, 1fr); margin-inline: var(--fig-gutter, 16px); gap: 18px; }
  .ln-sub { max-width: none; }
  .ln-skip { justify-content: space-between; margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { .ln-skip, .ln-skip .chev { transition: none; } .ln-skip:hover { transform: none; } }
html[data-theme="dark"] .loss-note { box-shadow: 0 0 0 1px rgba(255, 255, 255, .09), 0 22px 60px rgba(0, 0, 0, .45); }   /* an edge against the dark page */

/* ---- loss-path ------------------------------------------------------------- */
.lp { display: flex; flex-direction: column; height: 100%; color: var(--ink); }
.lp-field { position: relative; flex: 1; min-height: 0; }
.lp:not(.in-scrolly) .lp-field { flex: none; height: 620px; margin-top: 14px; }
.lp-field svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; outline: none; }
.lp-field svg:focus-visible { outline: 2px solid var(--accent2, var(--cat-emph)); outline-offset: 4px; }

.lp-hud { flex: none; padding-bottom: 14px; }
.lp-num {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(36px, 4.2vw, 54px);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.lp[data-state="outcome"] .lp-val,
.lp[data-state="type"] .lp-val { color: var(--cat-emph); }
.lp-label {
  margin: 10px 0 3px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.lp-sub { margin: 0; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

.lp-grid { stroke: rgba(var(--ink-rgb), .07); stroke-width: 1px; }
.lp-tick { font-family: var(--font-mono); font-size: 11px; font-weight: 300; fill: var(--label-ink); }
.lp-bracket {
  stroke: var(--cat-emph);
  stroke-width: 3px;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity .35s ease, y1 .5s var(--rv-ease), y2 .5s var(--rv-ease);
}
.lp[data-state="type"] .lp-bracket { opacity: 1; }

.lp-lane { transition: fill .6s ease, opacity .45s ease; cursor: default; }
.lp-births { fill: rgba(var(--ink-rgb), .14); }
.lp-type { fill: var(--cat-emph); }
.lp-untyped { fill: var(--cat-ghost); }
.lp[data-state="all"] .lp-type,
.lp[data-state="all"] .lp-untyped { fill: rgba(var(--ink-rgb), .14); }
.lp[data-state="type"] .lp-type,
.lp[data-state="type"] .lp-untyped { opacity: .22; cursor: pointer; }
.lp[data-state="type"] .lp-lane.on { opacity: 1; }
.lp[data-state="zoom"] .lp-type, .lp[data-state="whole"] .lp-type { cursor: pointer; }
.lp-lane.hot { opacity: 1; filter: brightness(1.08); }

.lp-lab { transition: opacity .45s ease; }
.lp-leader { fill: none; stroke: rgba(var(--ink-rgb), .3); stroke-width: 1px; }
.lp-name { font-family: var(--font-sans); font-size: 13px; font-weight: 500; fill: var(--ink); }
.lp-lsub { font-family: var(--font-mono); font-size: 11.5px; font-weight: 300; fill: var(--label-ink); font-variant-numeric: tabular-nums; }
.lp-births-lab { font-family: var(--font-mono); font-size: 11.5px; fill: var(--label-ink); }

/* which labels each state shows */
.lp:not([data-state="outcome"]) .lp-lab.lp-lab-total { opacity: 0; }
.lp[data-state="all"] .lp-lab:not(.lp-lab-total),
.lp[data-state="outcome"] .lp-lab:not(.lp-lab-total) { opacity: 0; pointer-events: none; }
.lp[data-state="type"] .lp-lab { opacity: .35; }
.lp[data-state="type"] .lp-lab.on { opacity: 1; }
.lp[data-state="type"] .lp-lab.on .lp-name { font-weight: 650; }
.lp[data-state="type"] .lp-lab.on .lp-leader { stroke: var(--cat-emph); }

@media (width < 900px) {
  .lp.in-scrolly .lp-num { font-size: 36px; }
  .lp-label { font-size: 11.5px; margin-top: 8px; }
  .lp-name { font-size: 12px; }
  .lp-lsub { font-size: 11px; }
}

/* the illustration in each type's step card; the type cards are tall, so
   they get a full screen each and never touch the next card */
.sc-card .lp-art { max-width: 230px; margin: 0 0 12px; }
.sc-card .lp-art .vw-art-box { margin: 0; }
m-scrolly[chart="loss-path"] .sc-step.sc-sub { min-height: 96svh; }
@media (width < 900px) {
  .sc-card .lp-art { max-width: 150px; margin-bottom: 8px; }
  m-scrolly[chart="loss-path"] .sc-step.sc-sub { min-height: 110svh; }
}

/* ---- loss-cost ------------------------------------------------------------- */
.lc2 svg, .lr svg { display: block; width: 100%; height: auto; overflow: visible; }
.lc2-grid, .lr-grid { stroke: rgba(var(--ink-rgb), .08); stroke-width: 1px; }
.lc2-tick, .lr-tick { font-family: var(--font-mono); font-size: 11.5px; font-weight: 300; fill: var(--label-ink); }
.lc2-ref line, .lr-ref line { stroke: var(--ref-ink); stroke-width: 1px; stroke-dasharray: 3 4; }
.lc2-ref text, .lr-ref text { font-family: var(--font-mono); font-size: 11.5px; fill: var(--ref-ink); }
.lc2-name, .lr-name { font-family: var(--font-sans); font-size: 14px; font-weight: 500; fill: var(--ink); }
.lc2-stem { stroke: var(--cat-emph); stroke-width: 2px; opacity: .55; }
.lc2-dot { fill: var(--cat-emph); stroke: var(--bg); stroke-width: 2px; }
.lc2-val, .lr-val { font-family: var(--font-mono); font-size: 13px; font-weight: 500; fill: var(--ink); font-variant-numeric: tabular-nums; }
/* a halo in the card colour, so a value stays clear where a dashed line crosses it */
.lc2-val, .lc2-ref text, .lr-val, .lr-mult { paint-order: stroke; stroke: var(--fig-bg); stroke-width: 4px; stroke-linejoin: round; }
.lc2-row, .lr-row { transition: opacity .15s; }
.lc2-row.dim, .lr-row.dim { opacity: .4; }
.lc2-row.hot .lc2-stem { opacity: 1; }

/* ---- loss-refusal ---------------------------------------------------------- */
.lr-arrow { stroke: var(--cat-emph); stroke-width: 2.5px; }
.lr-headpath { fill: var(--cat-emph); }
.lr-all .lr-arrow { stroke: var(--ink); }
.lr-all .lr-name { font-weight: 650; }
.lr-mult { font-family: var(--font-mono); font-size: 12px; fill: var(--label-ink); transition: opacity .3s; }
.lr-mult.off { opacity: 0; }
.lr-row.key .lr-name, .lr-row.key .lr-val { fill: var(--cat-emph); }
.lr-row.key .lr-mult { fill: var(--cat-emph); }
.lr-seg { fill: var(--cat-emph); opacity: .35; }
.lr-seg.key { opacity: 1; }
.lr-ref { transition: opacity .3s; }
.lr-ref.off { opacity: 0; }
.lr-note { margin: 10px 0 0; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; color: var(--muted); }
.lr-views { margin-bottom: 4px; }

@media (width < 560px) {
  .lc2-name, .lr-name { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .lp-lane, .lp-lab, .lp-bracket, .lr-mult, .lr-ref { transition: none; }
}

/* phones: the step cards pass over the lower part of the stage, so the
   chart keeps to the upper part, and the cards drop the illustration */
@media (width < 900px) {
  .lp.in-scrolly .lp-field { flex: 0 0 auto; height: min(54svh, 100% - 96px); }
  m-scrolly[chart="loss-path"] .sc-card .lp-art { display: none; }
  m-scrolly[chart="loss-path"] .sc-step.sc-sub { min-height: 100svh; }
}
