/* ==========================================================================
   US–Pakistan Relations Index (/relations-index): a brass barometer dial on a
   deep-plum stage, the year strip beneath it, the contribution waterfall and
   the component lines. Builds on site.css tokens and trade.css (tr-*).
   Bands (diverging around "usual", 50):
     b0 #5A3F8C  b1 #9A82C2  b2 #D6CEC0  b3 #DDB45E  b4 #B07A1E
   Components: trade #6E42A6 · aid #B07A1E · congress #1A9E8F · arc #B5524A · issues #3D5A99
   ========================================================================== */

.ri-hero { padding-bottom: var(--s-3); }
.ri-hero h1 { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.02em; max-width: 18ch; }
.ri-hero .lede { max-width: 62ch; color: var(--on-ink); }

.ri-stage {
  --b0: #5A3F8C; --b1: #9A82C2; --b2: #D6CEC0; --b3: #DDB45E; --b4: #B07A1E;
  position: relative; overflow: hidden; padding: var(--s-3) 0 var(--s-5); color: #fff;
  background:
    radial-gradient(ellipse 70% 60% at 50% 18%, rgba(110, 66, 166, 0.45), transparent 70%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(201, 151, 58, 0.14), transparent 70%),
    linear-gradient(180deg, var(--ink) 0%, #1A1030 100%);
}
.ri-instrument { max-width: 820px; margin: 0 auto; }
.ri-dial-wrap { margin: 0; }
.ri-dial { display: block; width: 100%; max-width: 680px; margin: 0 auto; height: auto; overflow: visible; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); }
.ri-rim { fill: url(#ri-brass); }
.ri-face { stroke: rgba(138, 100, 32, 0.6); stroke-width: 1; }
.ri-band { fill: none; stroke-width: 24; }
.ri-b0 { --c: var(--b0); } .ri-b1 { --c: var(--b1); } .ri-b2 { --c: var(--b2); } .ri-b3 { --c: var(--b3); } .ri-b4 { --c: var(--b4); }
.ri-band.ri-b0 { stroke: var(--b0); } .ri-band.ri-b1 { stroke: var(--b1); } .ri-band.ri-b2 { stroke: var(--b2); } .ri-band.ri-b3 { stroke: var(--b3); } .ri-band.ri-b4 { stroke: var(--b4); }
.ri-ticks { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; opacity: 0.75; }
.ri-nums text { fill: var(--ink); font: 600 13px var(--font); text-anchor: middle; font-variant-numeric: tabular-nums; }
.ri-range { fill: none; stroke: #8A6420; stroke-width: 5; stroke-linecap: round; opacity: 0.9; }
.ri-cap { fill: var(--ink); font: 600 11px var(--font); letter-spacing: 0.32em; text-anchor: middle; opacity: 0.7; }
.ri-cap-sub { font: italic 400 13px var(--font-serif); letter-spacing: 0; opacity: 0.65; }
.ri-needle { transform-box: view-box; transform-origin: 260px 262px; transform: rotate(var(--a)); transition: transform 1.6s cubic-bezier(0.3, 1.35, 0.45, 1); }
.ri-needle path { fill: var(--ink); }
.ri-needle .ri-needle-hi { fill: #5A3689; }
.ri-needle[data-empty] { opacity: 0.25; }
.ri-instrument.is-armed .ri-needle { transform: rotate(-90deg); transition: none; }
.ri-hub { stroke: #6E4E17; stroke-width: 1; }
.ri-hub-dot { fill: #3B2A12; }
.ri-base { stroke: #8A6420; stroke-width: 1.5; }

.ri-read { display: grid; justify-items: center; gap: 0.2rem; margin-top: var(--s-2); text-align: center; }
.ri-year { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: #E8C877; }
.ri-num { font-family: var(--font-serif); font-size: clamp(3.6rem, 9vw, 5.6rem); font-weight: 500; line-height: 0.95; letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums; color: #fff; }
.ri-num.ri-none { font-size: clamp(2rem, 5vw, 2.8rem); }
.ri-of { font-size: 0.32em; letter-spacing: 0; color: var(--on-ink-muted); margin-left: 0.15em; }
.ri-band-l { font-family: var(--font-serif); font-style: italic; font-size: 1.3rem; color: var(--on-ink); }
.ri-basis { max-width: 46ch; font-size: 0.86rem; color: var(--on-ink-muted); }

.ri-strip-wrap { margin-top: var(--s-4); }
.ri-strip-h { margin: 0 0 0.6rem; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-ink); }
.ri-strip-h .tr-muted { color: var(--on-ink-muted); font-weight: 400; letter-spacing: 0.04em; text-transform: none; }
.ri-strip { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; margin: 0; padding: 0 0 1.5rem; list-style: none; }
.ri-cell { position: relative; min-width: 0; }
.ri-cell a, .ri-cell > .ri-cell-c { display: block; }
.ri-cell a { border-radius: 3px; outline-offset: 2px; }
.ri-cell-c { display: block; height: 40px; border-radius: 3px; background: var(--c, rgba(255, 255, 255, 0.08)); transition: transform 0.2s ease, box-shadow 0.2s ease; }
.ri-cell.is-none .ri-cell-c { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 7px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12); }
.ri-cell a:hover .ri-cell-c, .ri-cell a:focus-visible .ri-cell-c { transform: translateY(-3px); }
.ri-cell.is-sel .ri-cell-c { box-shadow: 0 0 0 2px #1A1030, 0 0 0 4px #E8C877; transform: translateY(-3px); }
.ri-cell-y { position: absolute; top: 46px; left: 0; font-size: 0.7rem; color: var(--on-ink-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ri-key { display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--on-ink); }
.ri-key > span { display: inline-flex; align-items: center; gap: 0.4rem; }
.ri-key-sw { width: 14px; height: 14px; border-radius: 2px; background: var(--c); }
.ri-key-sw.is-none { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 5px); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }

/* -------------------------------------------------------------- Waterfall */
.ri { --ri-trade: #6E42A6; --ri-aid: #B07A1E; --ri-congress: #1A9E8F; --ri-arc: #B5524A; --ri-issues: #3D5A99; }
.ri-sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 0.45rem; vertical-align: 0; background: var(--cc); }
.ri-c-trade { --cc: #6E42A6; } .ri-c-aid { --cc: #B07A1E; } .ri-c-congress { --cc: #1A9E8F; } .ri-c-arc { --cc: #B5524A; } .ri-c-issues { --cc: #3D5A99; }
.ri-wf { margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--ink); }
.ri-wf-row { display: grid; grid-template-columns: 12rem minmax(0, 1fr) 11rem; align-items: center; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.ri-wf-k { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.ri-wf-track { position: relative; height: 22px; background: linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(42, 27, 69, 0.35) calc(50% - 0.5px), rgba(42, 27, 69, 0.35) calc(50% + 0.5px), transparent calc(50% + 0.5px)), var(--mist); border-radius: 2px; }
.ri-wf-bar { position: absolute; top: 3px; bottom: 3px; left: var(--l); width: var(--w); border-radius: 2px; background: var(--ink); transition: left 0.6s ease, width 0.6s ease; }
.ri-wf-row.is-up .ri-wf-bar { background: #C99A3A; }
.ri-wf-row.is-down .ri-wf-bar { background: #7E5CB5; }
.ri-wf-row.is-start .ri-wf-bar { background: #CFC8DA; }
.ri-wf-row.is-end { border-bottom: 2px solid var(--ink); }
.ri-wf-row.is-end .ri-wf-k { font-family: var(--font-serif); font-size: 1.1rem; font-weight: 600; }
.ri-wf-v { font-variant-numeric: tabular-nums; font-size: 0.92rem; }
.ri-wf-v strong { font-size: 1.02rem; color: var(--ink); }
.ri-wf-why { color: var(--muted); font-size: 0.8rem; }

/* ------------------------------------------------------------- Components */
.ri-comps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.ri-comp { padding: var(--s-2) 0 0; border-top: 3px solid var(--cc); min-width: 0; }
.ri-comp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem; }
.ri-comp h3 { margin: 0; font-family: var(--font-serif); font-size: 1.22rem; font-weight: 560; }
.ri-comp h3 a { color: var(--ink); text-decoration: none; }
.ri-comp h3 a:hover { text-decoration: underline; }
.ri-comp-w { font-size: 0.76rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.ri-spark { display: block; width: 100%; height: 96px; margin: 0.6rem 0 0.4rem; }
.ri-spark .g { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ri-spark .comp { fill: none; stroke: var(--ink); stroke-width: 1.3; stroke-dasharray: 4 4; opacity: 0.45; vector-effect: non-scaling-stroke; }
.ri-spark .line { fill: none; stroke: var(--cc); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ri-spark .dot { fill: var(--cc); stroke: #fff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.ri-comp-read { margin: 0.2rem 0; font-size: 0.92rem; }
.ri-comp-status { margin: 0.6rem 0; padding: 0.6rem 0.75rem; font-size: 0.86rem; background: var(--mist); border-radius: 3px; color: var(--text); }
.ri-comp-meta { margin: 0.2rem 0 0; font-size: 0.78rem; color: var(--muted); }
.ri-legend { margin: var(--s-2) 0 0; font-size: 0.82rem; color: var(--muted); }
.ri-legend-comp { display: inline-block; width: 26px; border-top: 2px dashed rgba(42, 27, 69, 0.5); vertical-align: middle; margin-right: 0.3rem; }

/* ----------------------------------------------------------------- Method */
.ri-method { max-width: 78ch; }
.ri-method h3 { margin: var(--s-3) 0 0.4rem; font-family: var(--font-serif); font-size: 1.2rem; font-weight: 560; color: var(--ink); }
.ri-method p, .ri-method li { font-size: 0.98rem; line-height: 1.6; }
.ri-table td, .ri-table th { vertical-align: top; }
.ri-changes { padding-left: 1.1rem; }
.ri-changes time { font-weight: 600; margin-right: 0.4rem; }

@media (max-width: 720px) {
  .ri-wf-row { grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 0.8rem; }
  .ri-wf-track { grid-column: 1 / -1; grid-row: 2; }
  .ri-wf-why { display: block; }
  .ri-cell-c { height: 32px; }
  .ri-cell-y { top: 37px; font-size: 0.64rem; }
  .ri-stage { padding-top: var(--s-2); }
}
@media (prefers-reduced-motion: reduce) {
  .ri-needle, .ri-wf-bar, .ri-cell-c { transition: none; }
}
.ri-earlier { margin: 0.5rem 0 0; font-size: 0.8rem; color: var(--on-ink-muted); }
.ri-table-wrap { max-height: none; }
@media (max-width: 720px) {
  .ri-table-wrap { border: 0; overflow: visible; }
  .ri-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .ri-table, .ri-table tbody, .ri-table tr, .ri-table th, .ri-table td { display: block; width: auto; }
  .ri-table tr { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
  .ri-table th, .ri-table td { padding: 0.15rem 0; border: 0; text-align: left !important; }
  .ri-table th { font-weight: 700; font-size: 1.02rem; }
  .ri-table td.num::before { content: 'Weight: '; color: var(--muted); }
  .ri-table td:last-child::before { content: 'Years: '; color: var(--muted); }
}
