/* css/pages/bonds.css: the bond market (/bonds) and one bond (/bonds?b=0x..), owned by the bonds page agent.
   Built on css/base.css (DESIGN.md); colours only through the tokens in css/tokens.css. Mobile first:
   base rules for phones, then 640 / 900 / 1120. Prefixes: bx- the market, bd- one bond, tl- the timeline,
   act- the action panels, iss the issuer desk. */

/* ================================================================== views */
@keyframes bxIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bx-view.in { animation: bxIn .42s var(--ease) both; }

/* a fully redeemed series: neither good nor bad news any more */
.tag.settled { color: var(--muted); }
.stats .v.warn { color: var(--warn); }

/* ================================================================== the market: head */
.bx-aside { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; max-width: none; }
.page-head .bx-factory { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; max-width: none; font: 400 13.5px/1.5 var(--sans); color: var(--muted); }
.bx-factory:empty { display: none; }
@media (min-width: 900px) {
  .bx-aside { align-items: flex-end; }
  .page-head .bx-factory { justify-content: flex-end; max-width: 24em; }
}

/* ================================================================== the market: toolbar */
.bx-tools { gap: 12px 16px; }
.bx-filter { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.bx-filter::-webkit-scrollbar { display: none; }
.bx-filter button { display: inline-flex; align-items: baseline; gap: 6px; }
.bx-filter .n { font: 400 11.5px/1 var(--mono); color: var(--faint); }
.bx-filter .n:empty { display: none; }
.bx-filter button[aria-pressed="true"] .n { color: inherit; opacity: .7; }
.bx-sort { display: inline-flex; align-items: center; gap: 10px; margin: 0; }
.bx-sort .input select { padding-block: 7px; font-size: 13.5px; }
@media (min-width: 640px) { .bx-tools .search { width: 220px; } }

/* ================================================================== the market: ledger */
.bx-ledger td.c-bond { white-space: normal; min-width: 250px; max-width: 360px; }
.bx-ledger .who { align-items: flex-start; }
.bx-ledger .who .cc { margin-top: 1px; }
.bx-ledger .nm-wrap { min-width: 0; }
.bx-ledger .nm { overflow-wrap: anywhere; transition: color .15s; }
.bx-ledger .nm-s .mine { color: var(--orange-ink); }
.bx-ledger .bx-iss { font: 13px var(--mono); color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; }
.bx-ledger .bx-iss:hover { color: var(--orange-ink); }
.bx-ledger .bx-iss.lab { font: 500 14px var(--sans); color: var(--ink); }
.bx-ledger .c-iss .tag { margin-left: 10px; }
.bx-ledger .px .to { margin: 0 7px; color: var(--faint); font-family: var(--sans); }
.bx-ledger .px .apy { color: var(--orange-ink); }
.bx-ledger td.num .nm-s { font-family: var(--sans); }
.bx-ledger .cov-cell { display: inline-flex; align-items: baseline; gap: 8px; }
.bx-ledger .cov { font: 13.5px var(--mono); color: var(--ink-2); }
.bx-ledger .cov.short { color: var(--down); }
.bx-ledger tr.empty td { padding: 0; }
.bx-empty { padding: 32px 0 34px; }

/* phones and tablets: each series becomes a ruled card instead of a sideways table */
@media (max-width: 899px) {
  .ledger.bx-ledger { display: flex; flex-direction: column; min-width: 0; }
  .ledger.bx-ledger caption { order: 2; }
  .ledger.bx-ledger thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .ledger.bx-ledger tbody { display: block; order: 1; }
  .ledger.bx-ledger tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; padding: 18px 0 16px; border-bottom: 1px solid var(--rule-2); }
  .ledger.bx-ledger tbody tr:last-child { border-bottom: 0; }
  .ledger.bx-ledger tbody td { display: block; min-width: 0; max-width: none; padding: 0; border: 0; text-align: left; white-space: normal; }
  .ledger.bx-ledger tbody td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; font: 400 12px/1.3 var(--sans); color: var(--muted); }
  .ledger.bx-ledger td.c-bond { grid-column: 1 / -1; min-width: 0; }
  .ledger.bx-ledger td.num { font-size: 13.5px; }
  .ledger.bx-ledger td.num .nm-s { display: block; margin: 2px 0 0; }
  .ledger.bx-ledger .c-st { order: 1; } .ledger.bx-ledger .px { order: 2; }
  .ledger.bx-ledger .c-mat { order: 3; } .ledger.bx-ledger .c-sold { order: 4; }
  .ledger.bx-ledger .c-iss { order: 5; } .ledger.bx-ledger .c-col { order: 6; }
  .ledger.bx-ledger .cellbar { display: block; width: 100%; max-width: 150px; margin: 7px 0 0; }
  .ledger.bx-ledger .c-iss .tag { margin-left: 8px; }
  .ledger.bx-ledger tr.empty { display: block; max-width: none; padding: 0; } /* the row, not the .empty block inside it */
  .ledger.bx-ledger tr.empty td { display: block; }
  .ledger.bx-ledger tbody.sk-rows td { display: block; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .ledger.bx-ledger tbody tr { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 20px; }
}
@media (max-width: 639px) {
  .bx-filter { -webkit-mask-image: linear-gradient(90deg, black 82%, transparent); mask-image: linear-gradient(90deg, black 82%, transparent); }
}

/* ================================================================== the market: not deployed */
/* one calm banner: the page then leads with the world bond board */
.bx-soon { padding-top: 6px; }
.bx-banner .link { margin-left: auto; }
@media (min-width: 900px) { .bx-soon { padding-top: 10px; } }
.bx-three b { font-size: 20px; }
@media (min-width: 900px) { .bx-three b { font-size: 22px; } }

/* ================================================================== the world bond board (reference snapshot) */
/* an opaque surface that matches --panel, for the first column while the table scrolls under it */
#world { --wb-solid: var(--paper-2); }
[data-theme="light"] #world { --wb-solid: var(--paper); }
.wb-strip { margin-top: 2px; background: var(--panel); }
.wb-strip .cell { padding-top: 16px; padding-bottom: 15px; }
@media (min-width: 900px) { .wb-strip .cell, .wb-strip .cell:nth-child(odd) { padding-top: 20px; padding-bottom: 18px; } }
.wb-strip .k { margin-bottom: 8px; font-size: 13.5px; }
.wb-strip .v.sm { font-size: clamp(25px, 2.6vw, 34px); line-height: 1.1; }
.wb-strip .v .u { font-size: .48em; }
.wb-strip .s { margin-top: 7px; font-size: 13px; white-space: normal; }
.wb-strip .v .sk, .wb-strip .s .sk { height: .8em; }
@media (max-width: 639px) { .wb-strip .v.sm { font-size: 25px; } }
.wb-ref { margin-top: 22px; max-width: 54em; }
.wb-ref b { color: var(--ink); font-weight: 500; }

.wb-tools { margin-top: 18px; gap: 10px 14px; }
.wb-segs { max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.wb-segs::-webkit-scrollbar { display: none; }
.wb-segs .seg button { padding: 9px 12px; }
.wb-count { font-size: 13px; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
@media (min-width: 640px) { .wb-tools .search { width: 220px; } }
@media (max-width: 639px) {
  .wb-segs { padding-right: 24px; -webkit-mask-image: linear-gradient(90deg, black 86%, transparent); mask-image: linear-gradient(90deg, black 86%, transparent); }
  .wb-count { order: 3; }
}

.wb-wrap { margin-top: 4px; }
.ledger.wide.wb-table { min-width: 1010px; }
.wb-table td, .wb-table th { padding-inline: 9px; }
.wb-table td.num { white-space: nowrap; }
.wb-table th.wb-star .sort { color: var(--ink); }
.wb-table td.wb-ytm { font-weight: 500; color: var(--ink); }
.wb-table .nm { font-size: 16.5px; }
.wb-table .nm-s { font-size: 12px; }
.wb-table td.num .nm-s { font-family: var(--sans); }
.wb-table .who { gap: 10px; }
.wb-type { font-size: 13.5px; color: var(--ink-2); }
.wb-country .cc { margin-right: 9px; min-width: 28px; height: 22px; }
.wb-rating { font: 500 13px var(--mono); color: var(--ink-2); }
.wb-ccy { font: 13px var(--mono); color: var(--ink-2); }
.wb-table tbody tr:hover td { cursor: default; }
@media (min-width: 900px) { .wb-table > tbody > tr > td { padding-block: 9px; } }
/* the yield beside the name, only while the YTM column is out of the visible frame (bonds.js wbKeyInView) */
.wb-peek { display: none; }
.wb-wrap.key-off .wb-peek { display: inline-block; margin-left: auto; padding-left: 12px; font: 500 13px var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }
/* "est.": a data note right after what it qualifies; muted with a dotted underline, never a warning colour */
.wb-est { margin-left: 4px; font: 500 12px var(--sans); color: var(--muted); text-decoration: underline dotted 1px; text-underline-offset: 3px; cursor: help; }
.nm-s .wb-est, .stats .s .wb-est { margin-left: 6px; font-size: inherit; }
.wb-empty { margin-right: 10px; font: italic 400 18px/1.4 var(--serif); color: var(--ink-2); }
.wb-clear { padding: 0; border: 0; background: none; cursor: pointer; }
.wb-note { margin-top: 14px; max-width: 64em; }
/* a table wider than the screen: its caption stays in the visible frame and wraps there */
.wb-wrap > .ledger > caption { position: sticky; left: 0; max-width: calc(100vw - 2 * var(--gutter)); }
/* the issuer column stays while the table scrolls sideways, with a hairline beside it */
.wb-wrap > .ledger > thead > tr > th:first-child,
.wb-wrap > .ledger > tbody > tr > td.wb-first { position: sticky; left: 0; z-index: 1; padding-right: 14px; box-shadow: 1px 0 0 var(--rule-2); }
.wb-wrap > .ledger > thead > tr > th:first-child { z-index: 2; }
.wb-wrap > .ledger > tbody > tr > td.wb-first { background: var(--wb-solid); }
.wb-wrap > .ledger > tbody > tr:hover > td.wb-first { background: linear-gradient(var(--hover), var(--hover)), var(--wb-solid); }
.wb-wrap > .ledger > tbody > tr.empty > td { position: static; background: transparent; box-shadow: none; }
@media (min-width: 1120px) { .wb-wrap > .ledger > thead > tr > th:first-child, .wb-wrap > .ledger > tbody > tr > td.wb-first { box-shadow: none; } }
@media (max-width: 639px) {
  .wb-table td.wb-first .wb-nm { display: block; max-width: 132px; }
  .wb-table td.wb-first .nm, .wb-table td.wb-first .nm-s { white-space: normal; }
  .wb-table .nm { font-size: 15.5px; }
}

/* ================================================================== the market: how a bond lives */
.life { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); margin: 0; padding: 0 0 0 24px; list-style: none; border-left: 1px solid var(--ink); background: var(--panel); }
.life > li { position: relative; padding: 2px 0 30px; min-width: 0; }
.life > li:last-child { padding-bottom: 6px; }
.life > li::before { content: ""; position: absolute; left: -28px; top: 6px; width: 7px; height: 7px; background: var(--c, var(--ink-2)); box-shadow: 0 0 0 4px var(--paper); }
.life .sale { --c: var(--orange); }
.life .active { --c: var(--ink-2); }
.life .repaid { --c: var(--up); }
.life .grace { --c: var(--warn); }
.life .defaulted { --c: var(--down); }
.life .when { margin-bottom: 10px; font: italic 400 17px/1.3 var(--serif); color: var(--muted); }
.life h3 { margin: 10px 0 8px; font: 400 25px/1.12 var(--serif); letter-spacing: -.01em; }
.life p { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.life .life-who { margin-top: 14px; padding-top: 10px; border-top: 1px dotted var(--rule); font-size: 13.5px; color: var(--muted); }
@media (min-width: 1120px) {
  .life { grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 0; border-left: 0; border-top: 1px solid var(--ink); }
  .life > li, .life > li:last-child { padding: 30px 22px 30px 0; border-right: 1px solid var(--rule); }
  .life > li + li { padding-left: 22px; }
  .life > li:last-child { border-right: 0; }
  .life > li::before { left: 0; top: -4px; box-shadow: none; }
  .life > li + li::before { left: 22px; }
}
.bx-risk { margin-top: 32px; max-width: 46em; }

/* ================================================================== one bond: head */
.bd-head { padding-bottom: 34px; }
@media (min-width: 900px) { .bd-head { padding-bottom: 40px; } }
.bd-title { min-width: 0; }
.bd-back { display: inline-block; margin-bottom: 22px; text-decoration: none; }
.bd-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 16px; }
.bd-id .cc { height: 26px; padding: 0 8px; font-size: 12px; color: var(--ink); border-color: var(--field-edge); }
.bd-unver { color: var(--muted); }
.bd-head h1 { overflow-wrap: anywhere; max-width: 18em; }
.bd-head .bd-sk-h1 { margin: 6px 0 0; font-size: 46px; line-height: 1; }
.bd-head .bd-sk-h1 .sk { min-width: min(100%, 9em); }
.bd-memo { margin-top: 22px; max-width: 40em; padding: 2px 0 2px 16px; border-left: 2px solid var(--orange); }
.bd-memo .label { display: block; margin-bottom: 4px; font-size: 12.5px; }
.page-head .bd-memo p { margin: 0; font: italic 400 19px/1.5 var(--serif); color: var(--ink-2); overflow-wrap: anywhere; }
.bd-meta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0; margin: 26px 0 0; font-size: 14px; border-top: 1px solid var(--ink); }
.bd-meta > div { display: contents; }
.bd-meta dt, .bd-meta dd { padding: 9px 0; border-bottom: 1px solid var(--rule-2); }
.bd-meta dt { padding-right: 18px; color: var(--muted); }
.bd-meta dd { margin: 0; color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.bd-meta .link.sm { color: var(--ink-2); font-family: var(--mono); font-size: 13px; font-weight: 400; }
.bd-meta .link.sm:hover { color: var(--orange-ink); }
.bd-meta .link.sm.lab { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); }
.bd-lab { display: block; margin-bottom: 3px; font: 500 14px var(--sans); color: var(--ink); }
@media (min-width: 900px) { .bd-meta { width: 320px; margin-top: 0; } }
.bd-missing p { max-width: 34em; }
.bd-missing .actions { margin-top: 28px; }
.bd-missing h1 { max-width: none; }

/* the band under the head */
.stats .v .bd-n { font: inherit; }
.meter { display: block; position: relative; height: 3px; margin: 2px 0 10px; overflow: hidden; background: var(--rule-2); }
.meter > i { position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); background: var(--orange); transition: width .6s var(--ease); }
.bd-source { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.bd-source .tag { margin-right: 4px; }
.bd-source .link.sm { font-size: 13px; }

/* ================================================================== one bond: layout */
.bd-body { padding-top: 32px; }
@media (min-width: 900px) { .bd-body { padding-top: 44px; } }
.bd-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; grid-template-areas: "tl" "act" "terms"; }
.bd-grid > * { min-width: 0; }
.bd-tl { grid-area: tl; }
.bd-act { grid-area: act; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.bd-terms { grid-area: terms; }
@media (min-width: 900px) {
  .bd-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 32px 40px; grid-template-areas: "tl tl" "terms act"; align-items: start; }
}
@media (min-width: 1120px) { .bd-grid { grid-template-columns: minmax(0, 1fr) 380px; } }

/* the term sheet */
.bd-kv > div { grid-template-columns: minmax(120px, 42%) minmax(0, 1fr); }
.bd-kv .addr { font-size: 12.5px; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; }
.bd-kv .addr:hover { color: var(--orange-ink); }
.bd-copy { margin-left: 2px; padding: 2px 7px; border: 1px solid var(--rule); border-radius: var(--radius); background: none; font: 500 12px var(--sans); color: var(--muted); vertical-align: 1px; }
.bd-copy:hover { border-color: var(--ink); color: var(--ink); }

/* ================================================================== one bond: timeline */
.bd-tl-b { padding-top: 22px; padding-bottom: 20px; }
.tl { display: none; position: relative; padding: 30px 0 0; }
@media (min-width: 640px) { .tl { display: block; } }
.tl-bar { position: relative; display: flex; height: 34px; border: 1px solid var(--rule); background: var(--paper-2); }
.tl-seg { position: relative; flex: none; width: calc(var(--w) * 1%); min-width: 0; display: flex; align-items: center; padding: 0 10px; border-left: 1px solid var(--rule); overflow: hidden; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.tl-seg:first-child { border-left: 0; }
.tl-seg::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--fill, 0%); background: var(--orange-soft); box-shadow: inset 0 -2px 0 var(--orange); transform-origin: left; animation: tlGrow .9s var(--ease) both; }
.tl-seg > span { position: relative; overflow: hidden; text-overflow: ellipsis; }
.tl-seg.is-past, .tl-seg.is-cur { color: var(--ink); }
.tl-seg.lab-end { justify-content: flex-end; } /* keeps the label clear of the "now" line early in a phase */
.tl-seg.k-post { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--rule-2) 6px 7px); }
@keyframes tlGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.tl-now { position: absolute; z-index: 1; top: -30px; bottom: -7px; left: var(--at); width: 0; border-left: 2px solid var(--orange); }
.tl-now::after { content: ""; position: absolute; left: -5px; bottom: -4px; width: 8px; height: 8px; background: var(--orange); }
.tl-now b { position: absolute; top: 0; left: 7px; font: 500 12.5px/1.2 var(--sans); color: var(--orange-ink); white-space: nowrap; }
.tl-now.end b { left: auto; right: 9px; }
.tl-marks { position: relative; height: 48px; margin: 12px 0 0; padding: 0; list-style: none; }
.tl-marks li { position: absolute; top: 0; left: var(--at); padding: 0 0 0 8px; border-left: 1px solid var(--rule); font-size: 12.5px; line-height: 1.35; color: var(--muted); white-space: nowrap; }
.tl-marks li b { display: block; font-weight: 500; color: var(--ink-2); }
.tl-marks li time { font: 12px var(--mono); }
.tl-marks li.is-past { border-left-color: var(--ink-2); }
.tl-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--rule-2); font: 400 17px/1.5 var(--serif); color: var(--ink-2); max-width: 44em; }

/* phones: a vertical rail */
.tl-v { display: grid; grid-template-columns: minmax(0, 1fr); margin: 0; padding: 0; list-style: none; }
@media (min-width: 640px) { .tl-v { display: none; } }
.tl-v li { display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 14px; }
.tl-v .d { padding-top: 1px; font: 12px/1.4 var(--mono); color: var(--muted); text-align: right; }
.tl-v .t { position: relative; min-width: 0; padding: 0 0 0 16px; border-left: 1px solid var(--rule); }
.tl-v .v-mark .t { padding-bottom: 8px; }
.tl-v .v-mark .t::before { content: ""; position: absolute; left: -4px; top: 5px; width: 7px; height: 7px; background: var(--paper); border: 1px solid var(--ink-2); }
.tl-v .v-mark.is-past .t::before { background: var(--ink-2); }
.tl-v .v-mark b { display: block; font-size: 14px; font-weight: 500; color: var(--ink); }
.tl-v .v-mark .sub { display: block; font-size: 12.5px; }
.tl-v .v-seg .t { padding: 4px 0 14px 16px; font-size: 13px; color: var(--muted); }
.tl-v .v-seg.is-past .t { border-left-color: var(--ink-2); }
.tl-v .v-seg.is-cur .t { border-left: 2px solid var(--orange); padding-left: 15px; }
.tl-v .v-post .t { border-left-style: dashed; padding-bottom: 4px; }
.tl-v .v-now .d { color: var(--orange-ink); }
.tl-v .v-now .t { padding: 2px 0 12px 15px; border-left: 2px solid var(--orange); }
.tl-v .v-now .t::before { content: ""; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px; background: var(--orange); }
.tl-v .v-now b { font-size: 14px; font-weight: 500; color: var(--orange-ink); }

/* ================================================================== one bond: action panels */
.act .panel-b { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.act .panel-h h2 em { font-style: italic; }
.act-text { font-size: 14.5px; line-height: 1.55; color: var(--ink-2); }
.act-q { border-top: 1px solid var(--rule-2); }
.act-q > div { grid-template-columns: minmax(0, 1fr) auto; padding: 8px 0; font-size: 14px; }
.act-q dd.accent { color: var(--orange-ink); }
.act-err { font-size: 14px; line-height: 1.45; color: var(--down); }
.act .steps { padding-top: 4px; border-top: 1px solid var(--rule-2); }
.act .note { margin: 0; }
.act-red { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding-top: 16px; border-top: 1px solid var(--rule); }
.act .field-k .sub { font-family: var(--mono); font-size: 12px; }
/* collateral a token refused to send: claimed from the position panel */
.act-claim .act-h { font: 400 21px/1.2 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.act-claim .act-h em { font-style: italic; color: var(--orange-ink); }
.act-claim .input input { font-size: 13.5px; }
.bd-banner { display: grid; gap: 8px; }
.bd-you { color: var(--muted); }

/* the issuer desk: one ruled block per power */
.iss { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 18px; border-top: 1px solid var(--rule); }
.iss:first-child { padding-top: 2px; border-top: 0; }
.iss h3 { font: 400 21px/1.2 var(--serif); letter-spacing: -.01em; color: var(--ink); }
