/* /default-rates chart module — design direction C, "The Broadsheet".
   Everything inside the [data-dr-chart] slot: head (eyebrow, headline,
   subhead, dek, key numbers), plot, tooltip, key line, readout row, bracket
   caption. The page shell (the white card) is css/default-rates.css.
   Motion here is the small stuff (headline sequence, head FLIP, key-number
   cells, tooltip, ring, guide); the plot's tweens run on the module's own
   clock. Vertical rhythm is 8px: 16 / 8 / 16 / 24 / 16 / 24 down the head. */

/* --drc-surface is the colour of the surface the chart sits on; the module
   resolves it from the nearest painted ancestor at build time (the white
   figure card) and uses it for hollow markers, the note halo and the tooltip. */
.drc {
  position: relative;
  --drc-surface: #fff;
  --drc-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --drc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}
.drc--static { pointer-events: none; }

/* ---------- Head: the industry as headline, a serif subhead, a sans dek, the key numbers ---------- */
.drc-head { padding-top: 4px; }
/* FLIP: the module eases the block's height when the headline or the key numbers change shape,
   and slides everything under the h1 from its old place on the same curve */
.drc-head.is-flip { overflow: hidden; transition: height 220ms var(--drc-ease); }
.drc-head__body { transition: transform 220ms var(--drc-ease); will-change: transform; }
.drc-eyebrow { display: block; margin-bottom: 16px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.drc-h1 {
  position: relative; font-family: var(--ink-serif); font-weight: 400; margin: 0;
  line-height: 1.04; letter-spacing: -0.01em;
  text-wrap: balance; overflow-wrap: anywhere;
}
.drc-h1--xl { font-size: 44px; }
.drc-h1--lg { font-size: 34px; line-height: 1.08; }
.drc-h1--md { font-size: 28px; line-height: 1.12; }
.drc[data-narrow="1"] .drc-h1--xl { font-size: 34px; }
.drc[data-narrow="1"] .drc-h1--lg { font-size: 28px; }
.drc[data-narrow="1"] .drc-h1--md { font-size: 24px; }
.drc-h1__t { display: block; }
/* Sequenced, not overlapped: the ghost leaves over 90ms (3px up, at the incoming size), the new text rises from 90ms over 200ms */
.drc-h1__t.is-enter { animation: drc-rise 200ms var(--drc-ease) 90ms both; }
.drc-h1__ghost { position: absolute; left: 0; top: 0; right: 0; pointer-events: none; animation: drc-ghost-out 90ms var(--drc-ease) forwards; }
.drc-sub { font-family: var(--ink-serif); font-style: italic; font-size: 22px; line-height: 1.25; margin: 8px 0 0; }
.drc-sub[hidden] { display: none; }
.drc[data-narrow="1"] .drc-sub { font-size: 19px; }
.drc-dek { font-family: var(--ink-sans); font-size: 14px; line-height: 1.5; color: var(--ink-fg-muted); margin: 16px 0 0; max-width: 60ch; text-wrap: pretty; }

/* Key numbers: serif lining figures (tabular, so a counting number holds
   still), sans labels, cells divided by hairlines. Every cell carries a left
   divider; the row is shifted left under a clipping box so the first cell of
   each wrapped row loses its divider off the edge. The row is held at
   opacity 0 only until the card's own entrance has settled (never behind the
   plot's draw-in wait) and fades in as the numbers start counting. On a
   switch, cells that stay slide (FLIP), new ones rise in, leaving ones fade
   out in place. */
.drc-stats { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--ink-hairline); overflow: hidden; transition: opacity 300ms var(--drc-ease); }
.drc-stats[hidden] { display: none; }
.drc-stats.is-pending { opacity: 0; transition: none; }
.drc-stats__row { position: relative; display: flex; flex-wrap: wrap; gap: 16px 0; margin-left: -25px; }
.drc-stat { min-width: 0; padding-left: 24px; margin-right: 24px; border-left: 1px solid var(--ink-hairline); transition: transform 220ms var(--drc-ease), opacity 120ms var(--drc-ease); }
.drc-stat:last-child { margin-right: 0; }
.drc-stat.is-new { animation: drc-rise 220ms var(--drc-ease) 40ms both; }
.drc-stat.is-leaving { position: absolute; pointer-events: none; }
.drc-stat.is-out { opacity: 0; }
.drc-stat__n { display: block; font-family: var(--ink-serif); font-variant-numeric: lining-nums tabular-nums; font-size: 26px; line-height: 1.1; letter-spacing: -0.01em; color: var(--ink-carbon); white-space: nowrap; }
.drc-stat__dagger { font-family: var(--ink-sans); font-size: 12px; color: var(--ink-fg-muted); line-height: 0; margin-left: 2px; }
.drc-stat__l { display: block; font-family: var(--ink-sans); font-size: 12px; line-height: 1.4; color: var(--ink-fg-muted); margin-top: 4px; white-space: nowrap; }
.drc-stat__lt { white-space: nowrap; }
.drc-stat__l small { font-size: 12px; color: var(--ink-fg-muted); white-space: nowrap; }
.drc-stat__l small::before { content: " · "; }
.drc[data-narrow="1"] .drc-stats { margin-top: 24px; padding-top: 16px; }
.drc[data-narrow="1"] .drc-stats__row { margin-left: -17px; gap: 16px 0; }
.drc[data-narrow="1"] .drc-stat { padding-left: 16px; margin-right: 16px; }
.drc[data-narrow="1"] .drc-stat__n { font-size: 22px; }
.drc[data-narrow="1"] .drc-stat__l small { display: block; }
.drc[data-narrow="1"] .drc-stat__l small::before { content: none; }
/* Container < 400px: three equal columns, 20px figures, short labels with the
   fiscal span on its own line, so the row never wraps 2 + 1 or breaks a phrase. */
.drc[data-key="1"] .drc-stats__row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.drc[data-key="1"] .drc-stat { margin-right: 0; padding-right: 8px; }
.drc[data-key="1"] .drc-stat__n { font-size: 20px; }
.drc[data-key="1"] .drc-stat__l { white-space: normal; }

/* ---------- Plot ---------- */
.drc-plot { position: relative; margin-top: 24px; }
.drc-svg { display: block; width: 100%; max-width: 100%; height: auto; font-family: var(--ink-sans); overflow: visible; }
.drc-svg:focus { outline: none; }
.drc-svg .drc-serif { font-family: var(--ink-serif); font-variant-numeric: lining-nums; }
.drc-svg .drc-italic { font-family: var(--ink-serif); font-style: italic; font-variant-numeric: lining-nums; }
/* The pointer is hit-tested by the module (nearest point of either series);
   these circles are the keyboard targets only. */
.drc-hit { fill: transparent; pointer-events: none; outline: none; }
.drc-measure { position: absolute; left: 0; top: 0; overflow: visible; visibility: hidden; pointer-events: none; font-family: var(--ink-sans); }
.drc-measure .drc-serif { font-family: var(--ink-serif); font-variant-numeric: lining-nums; }
.drc-measure .drc-italic { font-family: var(--ink-serif); font-style: italic; font-variant-numeric: lining-nums; }
/* Program-only: the all-7(a) line alone is the subject and reads in carbon;
   the hand-off to the reference grey eases when an industry is picked. */
.drc-svg [data-g="ref"] path, .drc-svg [data-g="ref"] circle { transition: stroke 450ms var(--drc-ease), fill 450ms var(--drc-ease); }
.drc-svg [data-g="ref"].is-solo path, .drc-svg [data-g="ref"].is-solo circle { stroke: var(--ink-carbon); }
.drc-svg [data-g="ref"].is-solo circle[data-k="solid"] { fill: var(--ink-carbon); }
/* The pre-COVID note dims while the tooltip sits on it (bracket years), so the card can stay by its point */
.drc-svg [data-g="bracket"] { transition: opacity 140ms var(--drc-ease); }
.drc-svg [data-g="bracket"].is-dim { opacity: 0.25; }
/* Hover: the warm ring (with its carbon edge) scales in; the one guide line slides to the hovered year */
.drc-ring { transform-box: fill-box; transform-origin: center; animation: drc-ring-in 150ms var(--drc-ease-out) both; }
.drc-guide { animation: drc-fade-in 140ms var(--drc-ease) both; transition: transform 160ms var(--drc-ease-out); }

/* ---------- Tooltip (viewport >= 640): a three-line card pinned near the point ---------- */
.drc-tip {
  position: absolute; z-index: 2; pointer-events: none; box-sizing: border-box;
  background: var(--drc-surface); border: 1px solid var(--ink-carbon);
  padding: 6px 10px 7px; white-space: nowrap;
  font-family: var(--ink-sans); font-size: 12px; line-height: 1.4; color: var(--ink-fg-muted);
  box-shadow: 0 1px 0 rgba(27,26,25,0.08), 0 6px 18px rgba(27,26,25,0.08);
  animation: drc-tip-in 140ms var(--drc-ease) both;
  transition: left 160ms var(--drc-ease-out), top 160ms var(--drc-ease-out);
}
.drc-tip[hidden] { display: none; }
.drc-tip.is-snap { transition: none; }
.drc-tip__k { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.drc-tip__v { display: block; font-family: var(--ink-serif); font-variant-numeric: lining-nums; font-size: 17px; line-height: 1.25; color: var(--ink-carbon); margin: 1px 0 1px; }
.drc-tip__dagger { font-family: var(--ink-sans); font-size: 11px; color: var(--ink-fg-muted); margin-left: 2px; }
.drc-tip__c { display: block; }
.drc-tip::after { /* caret */
  content: ""; position: absolute; left: var(--cx, 50%); bottom: -5px; width: 8px; height: 8px;
  background: var(--drc-surface); border-right: 1px solid var(--ink-carbon); border-bottom: 1px solid var(--ink-carbon);
  transform: translateX(-50%) rotate(45deg);
}
.drc-tip.is-below::after { bottom: auto; top: -5px; transform: translateX(-50%) rotate(225deg); }
.drc-tip.is-right::after { left: -5px; bottom: auto; top: var(--cy, 50%); transform: translateY(-50%) rotate(135deg); }  /* card right of its point: caret on the left edge */
.drc-tip.is-left::after { left: auto; right: -5px; bottom: auto; top: var(--cy, 50%); transform: translateY(-50%) rotate(315deg); }
.drc-tip.is-loose::after { display: none; } /* moved off the point: the ring marks it instead */
.drc[data-tip="row"] .drc-tip { display: none !important; }

/* ---------- Key line: the series (container < 400px only) and the marker glyphs that carry meaning ---------- */
.drc-key {
  display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 8px;
  font-family: var(--ink-sans); font-size: 12px; line-height: 1.4; color: var(--ink-fg-muted);
  transition: opacity 300ms var(--drc-ease);
}
.drc-key[hidden] { display: none; }
.drc-key.is-pending { opacity: 0; transition: none; }
.drc-key.is-enter { animation: drc-rise 200ms var(--drc-ease) 90ms both; }
.drc-key__item { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.drc-key__swatch { flex: none; overflow: visible; }
.drc-key__item--series:first-child .drc-key__name { color: var(--ink-carbon); }

/* ---------- Readout row (viewport < 640): persistent, by fiscal year ---------- */
.drc-readout {
  margin-top: 8px; padding: 10px 0 2px; border-top: 1px solid var(--ink-hairline);
  font-family: var(--ink-sans); font-size: 13px; line-height: 1.45; color: var(--ink-carbon);
  transition: opacity 300ms var(--drc-ease);
}
.drc[data-tip="card"] .drc-readout { display: none; }
.drc-readout.is-pending { opacity: 0; transition: none; }
.drc-readout.is-enter { animation: drc-rise 200ms var(--drc-ease) 90ms both; }
.drc-readout__row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; }
.drc-readout__fy, .drc-readout__v { font-family: var(--ink-serif); font-variant-numeric: lining-nums; font-size: 17px; }
.drc-readout__sep { color: var(--ink-fg-quiet); }
.drc-readout__ref { margin-left: auto; color: var(--ink-fg-muted); font-size: 12px; }
.drc-readout__dagger { font-size: 11px; color: var(--ink-fg-muted); margin-left: 2px; }
.drc-readout__c { display: block; font-size: 12px; color: var(--ink-fg-muted); margin-top: 1px; }

/* ---------- Pre-COVID note as a caption line (when no in-plot placement is clear) ---------- */
.drc-bracket-cap { font-family: var(--ink-serif); font-style: italic; font-variant-numeric: lining-nums; font-size: 13px; line-height: 1.4; margin: 8px 0 0; color: var(--ink-carbon); }
.drc-bracket-cap[hidden] { display: none; }
.drc-bracket-cap.is-enter { animation: drc-rise 200ms var(--drc-ease) 90ms both; }
.drc-bracket-cap__icon { display: inline-block; vertical-align: -1px; margin-right: 6px; color: var(--ink-fg-muted); }

/* ---------- Live region ---------- */
.drc-vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Keyframes ---------- */
@keyframes drc-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes drc-ghost-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-3px); } }
@keyframes drc-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes drc-tip-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes drc-ring-in { from { opacity: 0; transform: scale(0.55); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .drc-h1__t.is-enter, .drc-h1__ghost, .drc-ring, .drc-guide, .drc-tip, .drc-stat.is-new, .drc-key.is-enter, .drc-readout.is-enter, .drc-bracket-cap.is-enter { animation: none; }
  .drc-h1__ghost { display: none; }
  .drc-tip, .drc-guide, .drc-svg [data-g="ref"] path, .drc-svg [data-g="ref"] circle, .drc-svg [data-g="bracket"], .drc-stats, .drc-stat, .drc-head.is-flip, .drc-head__body, .drc-key, .drc-readout { transition: none; }
  .drc-stats.is-pending, .drc-key.is-pending, .drc-readout.is-pending { opacity: 1; }
}

/* ---------- Print: no hover-only information, no colour dependence ---------- */
@media print {
  .drc-tip, .drc-ring, .drc-guide, .drc-hit { display: none !important; }
  .drc-readout { display: none !important; }
  .drc-svg [data-g], .drc-stats, .drc-key, .drc-stat, .drc-end, .drc-bracket { opacity: 1 !important; transition: none !important; } /* a held or in-flight draw-in prints at rest */
}
