/* Resources hub, commodity pages and explainers. Loaded after guide.css, which holds the tokens, nav, footer and consent banner.
   rx- shared, rh- hub, cp- commodity page, ex- explainer. */
:root {
  --ink-inverse-muted: #A9BACB;   /* muted text on surface-inverse */
  --inverse-accent-text: #2FD1BE; /* teal text on surface-inverse */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink-inverse-muted: #4A5B6C; --inverse-accent-text: #0B7A6E; }
}

/* Shared */
h3 { margin: 0; }
.section-head { max-width: 680px; margin-bottom: var(--space-6); }
.section-head p { margin-top: var(--space-3); }
.h2 { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }
.body-l { font-size: 18px; line-height: 28px; }
.rx-accent { color: var(--accent-text); }
.rx-on-inv-accent { color: var(--inverse-accent-text); }
.rx-sec + .rx-sec { border-top: 1px solid var(--border); }
.talk a { display: inline-block; padding-block: 11px; }

.rx-band { padding-block: var(--space-6) var(--space-8); }
.rx-band h1 { margin-top: var(--space-3); font-size: 36px; line-height: 42px; font-weight: 600; letter-spacing: -0.02em; }
@media (min-width: 720px) { .rx-band h1 { font-size: 48px; line-height: 52px; } }
.rx-lede { margin-top: var(--space-4); font-size: 18px; line-height: 28px; color: var(--ink-inverse-muted); max-width: 60ch; }
.rx-hero { margin-top: var(--space-6); }
.rx-hero-split { display: grid; gap: var(--space-7); align-items: center; }
@media (min-width: 960px) { .rx-hero-split { grid-template-columns: 7fr 5fr; } }

.inverse .rx-crumbs { color: var(--ink-inverse-muted); }
.inverse .rx-crumbs a { color: var(--ink-inverse); }
.ex-top .rx-crumbs { color: var(--ink-muted); }
.ex-top .rx-crumbs a { color: var(--ink); }

/* Element tile (atomic number, symbol) */
.rx-el { display: inline-grid; grid-template-rows: auto 1fr; width: 64px; height: 64px; padding: 6px 8px; border: 2px solid currentColor; border-radius: var(--radius-md); flex: none; }
.rx-el .z { font-size: 12px; line-height: 14px; }
.rx-el .sym { font-size: 26px; line-height: 30px; font-weight: 600; align-self: end; }
.rx-el-lg { width: 112px; height: 112px; padding: 10px 12px; grid-template-rows: auto 1fr auto; }
.rx-el-lg .z { font-size: 14px; line-height: 18px; }
.rx-el-lg .sym { font-size: 44px; line-height: 48px; align-self: center; }
.rx-el-lg .w { font-size: 12px; line-height: 14px; color: var(--ink-inverse-muted); }

/* Chain preview (line plus ring nodes, solid teal end nodes) */
.rx-chain { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.rx-st { position: relative; display: grid; justify-items: center; text-align: center; gap: var(--space-1); padding-inline: 2px; }
.rx-st::before { content: ""; position: absolute; top: 12px; left: 50%; width: 100%; height: 4px; margin-top: -2px; background: var(--ink); }
.rx-st:last-child::before { display: none; }
.rx-node { position: relative; width: 24px; height: 24px; border-radius: var(--radius-full); border: 4px solid var(--ink); background: var(--surface-100); margin-bottom: var(--space-2); }
.rx-st.is-end .rx-node { background: var(--accent); border-color: var(--accent); }
.rx-st b { font-weight: 600; font-size: 14px; line-height: 20px; }
.rx-st span:not(.rx-node) { font-size: 14px; line-height: 20px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.inverse .rx-st::before { background: var(--ink-inverse); }
.inverse .rx-st span:not(.rx-node) { color: var(--ink-inverse-muted); }
.inverse .rx-node { border-color: var(--ink-inverse); background: var(--surface-inverse); }
.inverse .rx-st.is-end .rx-node { background: var(--accent-on-inverse); border-color: var(--accent-on-inverse); }
.rx-chain-mini { margin-block: var(--space-4) var(--space-5); }
.rx-chain-mini .rx-st b, .rx-chain-mini .rx-st span:not(.rx-node) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rx-chain-mini .rx-node { margin-bottom: 0; }
@media (max-width: 719px) {
  .rx-chain:not(.rx-chain-mini) { grid-template-columns: 1fr; gap: var(--space-3); }
  .rx-chain:not(.rx-chain-mini) .rx-st { grid-template-columns: 24px 1fr auto; justify-items: start; text-align: left; column-gap: var(--space-3); align-items: center; }
  .rx-chain:not(.rx-chain-mini) .rx-st::before { top: 12px; left: 12px; width: 4px; height: calc(100% + var(--space-3)); margin: 0 0 0 -2px; }
  .rx-chain:not(.rx-chain-mini) .rx-node { margin: 0; }
}

/* Featured card on the hub band */
.rx-feat { border: 1px solid color-mix(in srgb, var(--ink-inverse) 28%, transparent); border-radius: var(--radius-lg); padding: var(--space-5); }
.rx-feat p:not(.label-mono) { margin-top: var(--space-2); color: var(--ink-inverse-muted); }
.rx-feat-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: var(--space-3); font-weight: 600; border-bottom: 2px solid var(--inverse-accent-text); }

.rx-sources { margin: 0; padding-left: var(--space-5); display: grid; gap: 0; font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.rx-sources a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; display: inline-block; padding-block: 11px; }
.rx-sources li { line-height: 22px; }

/* Hub: commodity tiles */
.rh-tiles { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.rh-tile { display: flex; gap: var(--space-4); align-items: flex-start; padding: var(--space-5); background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.rh-tile:hover { border-color: var(--border-strong); }
.rh-tile .rx-el { color: var(--accent-text); }
.rh-tile-body { display: grid; gap: var(--space-1); }
.rh-tile-name { font-size: 22px; line-height: 30px; font-weight: 600; }
.rh-tile:hover .rh-tile-name { text-decoration: underline; text-underline-offset: 4px; }
.rh-tile-line { color: var(--ink-muted); }
.rh-tile-meta { margin-top: var(--space-2); color: var(--ink-muted); }

.rh-group { margin: var(--space-8) 0 var(--space-4); font-size: 14px; line-height: 22px; font-weight: 600; color: var(--ink-muted); letter-spacing: 0.06em; text-transform: uppercase; }
.rh-group:first-of-type { margin-top: 0; }
.ex-src { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 18px; }

/* Hub: filters and cards */
.rh-filters { display: grid; gap: var(--space-3); margin-bottom: var(--space-5); }
.rh-filters[hidden] { display: none; }
.rh-frow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.rh-flabel { width: 96px; color: var(--ink-muted); }
.rh-chip { min-height: 44px; padding: 0 var(--space-4); border: 2px solid var(--border-strong); border-radius: var(--radius-full); background: transparent; color: var(--ink); font: 600 14px/20px var(--font-sans); cursor: pointer; }
.rh-chip:hover { border-color: var(--ink); }
.rh-select { min-height: 44px; min-width: 220px; padding: 0 var(--space-4); border: 2px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-200); color: var(--ink); font: 600 14px/20px var(--font-sans); }
.rh-select:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.rh-chip[aria-pressed="true"] { background: var(--action); border-color: var(--action); color: var(--on-action); }
.rh-chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.rh-count { margin-bottom: var(--space-4); color: var(--ink-muted); font-size: 14px; line-height: 22px; }
.rh-count:empty { display: none; }
.rh-cards { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.rh-card { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); position: relative; }
.rh-card[hidden] { display: none; }
.rh-card:hover { border-color: var(--border-strong); }
.rh-meta { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--ink-muted); }
.rh-type { color: var(--accent-text); }
.rh-card h3 { font-size: 20px; line-height: 28px; font-weight: 600; }
.rh-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.rh-card h3 a:focus-visible { outline: none; }
.rh-card:has(h3 a:focus-visible) { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.rh-card:hover h3 a { text-decoration: underline; text-underline-offset: 3px; }
.rh-sum { color: var(--ink-muted); }
.rh-tags { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.rh-tags li { font-size: 12px; line-height: 16px; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-full); }
.rh-date { font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.rh-empty { padding: var(--space-5); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--ink-muted); }

/* Commodity page */
.cp-hero { display: grid; gap: var(--space-5); align-items: start; }
.cp-hero .rx-el-lg { color: var(--inverse-accent-text); }
.cp-hero .rx-el-lg .w { color: var(--ink-inverse-muted); }
@media (min-width: 960px) { .cp-hero { grid-template-columns: auto 1fr auto; gap: var(--space-6); } }
.cp-hero h1 { margin-top: var(--space-2); }
.cp-checked { display: grid; gap: var(--space-2); font-size: 14px; line-height: 22px; color: var(--ink-inverse-muted); padding: var(--space-4); border: 1px solid color-mix(in srgb, var(--ink-inverse) 28%, transparent); border-radius: var(--radius-lg); max-width: 320px; }
.cp-checked b { color: var(--ink-inverse); font-weight: 600; }
.cp-stats { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.cp-stat { display: grid; gap: var(--space-2); align-content: start; padding: var(--space-5); background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.cp-v { font-size: 36px; line-height: 42px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.cp-stat p { color: var(--ink-muted); }
.cp-stat .cp-src { font-size: 14px; line-height: 22px; }
.cp-src a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.cp-exp { display: grid; gap: var(--space-6); padding: var(--space-6); background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.cp-exp-h { margin-top: var(--space-2); font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }
.cp-exp .muted { margin-top: var(--space-3); max-width: 62ch; }
.cp-exp .rx-node { background: var(--surface-200); }
.cp-exp .rx-st.is-end .rx-node { background: var(--accent); }
.cp-acts { margin-top: var(--space-5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-5); }
.rx-tl { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cp-two { display: grid; gap: var(--space-7); }
@media (min-width: 960px) { .cp-two { grid-template-columns: 1fr 1fr; gap: var(--space-8); } }
.cp-log { list-style: none; margin: 0; padding: 0; display: grid; }
.cp-log li { display: grid; grid-template-columns: 96px 1fr; gap: var(--space-4); padding-block: var(--space-4); border-top: 1px solid var(--border); }
.cp-log time { font-weight: 600; }
.cp-log p { margin-top: var(--space-1); color: var(--ink-muted); }
.cp-pill { display: inline-block; font-size: 12px; line-height: 16px; padding: 2px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-full); }
.cp-pill.is-done { border-color: var(--accent-text); color: var(--accent-text); }
.cp-rels { list-style: none; margin: 0; padding: 0; display: grid; }
.cp-rel { display: grid; gap: var(--space-1); padding-block: var(--space-4); border-top: 1px solid var(--border); }
.cp-rel a { font-size: 18px; line-height: 28px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; justify-self: start; padding-block: 8px; }
.cp-rel p { color: var(--ink-muted); }

/* Explainer */
.ex-top { padding-block: var(--space-6) var(--space-8); }
.ex-hero { margin-top: var(--space-5); max-width: 820px; }
.ex-hero h1 { margin-top: var(--space-3); font-size: 40px; line-height: 44px; font-weight: 600; letter-spacing: -0.02em; }
.ex-hero h1 span { display: block; }
.ex-hero h1 span:last-child { color: var(--accent-text); }
@media (min-width: 720px) { .ex-hero h1 { font-size: 64px; line-height: 68px; } }
.ex-lede { margin-top: var(--space-5); font-size: 18px; line-height: 28px; color: var(--ink-muted); max-width: 62ch; }
.ex-byline { margin-top: var(--space-4); font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.ex-byline a { color: var(--accent-text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; display: inline-block; padding-block: 11px; }
.ex-sec { border-top: 1px solid var(--border); }
.ex-head { display: grid; gap: var(--space-3); max-width: 760px; margin-bottom: var(--space-7); }
.ex-head h2 { font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }
.ex-head p:not(.label-mono) { color: var(--ink-muted); }

.ex-chain { --gap: 8px; display: grid; grid-template-columns: 72px repeat(7, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; }
.ex-axis { position: relative; grid-row: 1; grid-column: 1; }
.ex-ttl { position: absolute; left: 0; top: 0; width: 68px; color: var(--ink-muted); }
.ex-axis ol { list-style: none; margin: 0; padding: 0; position: absolute; left: 0; right: 8px; bottom: 80px; height: 180px; }
.ex-axis li { position: absolute; right: 0; bottom: var(--p); transform: translateY(50%); font-size: 12px; line-height: 16px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ex-stage { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: 12px 8px 16px; border: 1px solid transparent; border-radius: var(--radius-lg); background: transparent; color: var(--ink); font: inherit; cursor: pointer; min-width: 0; }
.ex-stage:hover { background: var(--surface-200); border-color: var(--border); }
.ex-stage[aria-selected="true"] { background: var(--surface-200); border-color: var(--border-strong); }
.ex-stage::before { content: ""; position: absolute; top: 32px; left: 50%; width: calc(100% + var(--gap)); height: 4px; margin-top: -2px; background: var(--ink); z-index: 0; }
.ex-stage:last-child::before { display: none; }
.ex-node { position: relative; z-index: 1; width: 40px; height: 40px; border-radius: var(--radius-full); border: 4px solid var(--ink); background: var(--surface-100); flex: none; }
.ex-stage.is-end .ex-node { background: var(--accent); border-color: var(--accent); }
.ex-stage[aria-selected="true"] .ex-node { outline: 2px solid var(--accent); outline-offset: 4px; }
.ex-num { color: var(--accent-text); font-variant-numeric: tabular-nums; }
.ex-name { display: block; font-size: 17px; line-height: 22px; font-weight: 600; }
.ex-out { display: block; font-size: 14px; line-height: 20px; color: var(--ink-muted); min-height: 40px; }
.ex-meter { position: relative; display: block; width: 100%; height: 180px; margin-top: auto; border-bottom: 1px solid var(--border-strong);
  background: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px calc(100% / var(--dec, 4))); }
.ex-bar { position: absolute; left: 50%; width: 16px; margin-left: -8px; border-radius: var(--radius-full); background: var(--accent); bottom: calc(var(--lo) * 100%); height: max(8px, calc((var(--hi) - var(--lo)) * 100%)); }
.ex-val { display: block; font-size: 14px; line-height: 20px; font-weight: 600; font-variant-numeric: tabular-nums; height: 56px; }
.ex-val small { display: block; font-weight: 400; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.ex-note { margin-top: var(--space-4); color: var(--ink-muted); font-size: 14px; line-height: 22px; max-width: 80ch; }

.ex-panel { margin-top: var(--space-6); background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: var(--space-6) var(--space-7); }
.ex-panel:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ex-panel h3 { margin-top: var(--space-2); font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.01em; }
.ex-plede { margin-top: var(--space-4); font-size: 18px; line-height: 28px; }
.ex-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--space-3) var(--space-5); align-content: start; }
.ex-facts dt { color: var(--ink-muted); font-size: 14px; line-height: 26px; }
.ex-facts dd { margin: 0; min-width: 0; }
.ex-record { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); background: var(--surface-100); }
.ex-record .label-mono { margin-bottom: var(--space-1); }
.ex-pager { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: var(--space-5); }
.ex-pager .btn:disabled { opacity: .45; cursor: default; }

.ex-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.ex-stat, .ex-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); background: var(--surface-200); display: grid; gap: var(--space-2); align-content: start; }
.ex-big { font-size: 36px; line-height: 42px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ex-stat p { color: var(--ink-muted); font-size: 14px; line-height: 22px; }
.ex-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.ex-card { gap: var(--space-3); }
.ex-card h3 { font-size: 22px; line-height: 30px; font-weight: 600; }
.ex-card p:not(.label-mono) { color: var(--ink-muted); }
.ex-breaks { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.ex-breaks li { border-top: 4px solid var(--ink); padding-top: var(--space-4); display: grid; gap: var(--space-2); align-content: start; }
.ex-breaks b { font-weight: 600; font-size: 18px; line-height: 28px; }
.ex-breaks span { color: var(--ink-muted); }
.ex-close { margin-top: var(--space-6); font-size: 18px; line-height: 28px; max-width: 68ch; }
.ex-share { display: grid; gap: var(--space-6); align-items: center; }
@media (min-width: 960px) { .ex-share { grid-template-columns: 1fr 1fr; gap: var(--space-8); } }
.ex-video { margin: 0; display: grid; gap: var(--space-3); }
.ex-video video { display: block; width: 100%; height: auto; background: var(--surface-200); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.ex-video figcaption { max-width: 760px; font-size: 14px; line-height: 22px; color: var(--ink-muted); }
.ex-share img { display: block; width: 100%; max-width: 440px; height: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }

@media (max-width: 959px) {
  .ex-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ex-cards, .ex-breaks { grid-template-columns: 1fr; }
  .ex-panel { grid-template-columns: 1fr; }
}
@media (max-width: 719px) {
  .rx-band, .ex-top { padding-block: var(--space-4) var(--space-7); }
  .rx-el-lg { width: 88px; height: 88px; }
  .rx-el-lg .sym { font-size: 34px; line-height: 38px; }
  .cp-exp { padding: var(--space-5) var(--space-4); }
  .cp-log li { grid-template-columns: 1fr; gap: var(--space-1); }
  .rh-flabel { width: 100%; }
  .ex-head { margin-bottom: var(--space-6); }
  .ex-chain { grid-template-columns: 1fr; }
  .ex-axis { grid-row: auto; grid-column: auto; display: grid; gap: var(--space-1); padding: 0 12px 0 68px; }
  .ex-ttl { position: static; width: auto; }
  .ex-axis ol { position: relative; left: auto; right: auto; bottom: auto; height: 16px; width: auto; }
  .ex-axis li { right: auto; bottom: auto; left: var(--p); transform: translateX(-50%); }
  .ex-axis li:first-child { transform: none; }
  .ex-axis li:last-child { transform: translateX(-100%); }
  .ex-axis li.ex-minor { visibility: hidden; }
  .ex-stage { display: grid; grid-template-columns: 40px 1fr; grid-template-areas: "node txt" ". meter"; column-gap: var(--space-4); row-gap: var(--space-2); text-align: left; align-items: start; padding: 12px; }
  .ex-stage::before { top: 32px; left: 32px; width: 4px; height: calc(100% + var(--gap)); margin-top: 0; margin-left: -2px; }
  .ex-node { grid-area: node; }
  .ex-txt { grid-area: txt; }
  .ex-out { min-height: 0; }
  .ex-mw { grid-area: meter; display: grid; gap: var(--space-1); }
  .ex-meter { height: 16px; border-bottom: 0; background: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px calc(100% / var(--dec, 4))); }
  .ex-meter::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 1px; background: var(--border); }
  .ex-bar { left: calc(var(--lo) * 100%); bottom: auto; top: 4px; height: 8px; margin-left: 0; width: max(8px, calc((var(--hi) - var(--lo)) * 100%)); }
  .ex-val { height: auto; }
  .ex-val small { display: inline; margin-left: var(--space-1); }
  .ex-panel { padding: var(--space-5) var(--space-4); }
  .ex-facts { grid-template-columns: 1fr; gap: var(--space-1); }
  .ex-facts dd { margin-bottom: var(--space-3); }
  .ex-stats { grid-template-columns: 1fr; }
}
@media (min-width: 720px) { .ex-txt, .ex-mw { display: contents; } }
