/* ==========================================================================
   Diagrams inside Library items (tools/library_visuals.py) · 24 October 2026
   Risk taxonomy: capital view, taxonomy tree, subclass to model matrix, register inset, boundary call cards.
   Class colours (header text passes 4.5:1): Insurance #17797A, Market #9FB6BB, Counterparty #0E5E5A,
   Operational #1F4651, Strategic #DAA72C. The same colours in all three diagrams.
   ========================================================================== */
.rt-fig { margin: 22px 0 28px; }
/* the gated page is one centred column at every width (the breakout below centres on it) */
.lib-item.lib-item-gated { grid-template-columns: minmax(0, 1fr); }
.rt-lead { margin: 0 0 12px; font-size: 15.5px; line-height: 1.55; color: var(--ink-2); }
.rt-cap { margin-top: 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.lib-body .rt-statement { margin-top: 0; }
.lib-body .rt-statement strong { display: block; font-size: 21px; line-height: 1.3; letter-spacing: -0.01em; color: var(--ink); }

/* 1. capital view */
.rt-capwrap { display: flex; align-items: stretch; gap: 14px; }
.rt-bar { flex: 1 1 auto; display: flex; height: 56px; border-radius: 10px; overflow: hidden; background: var(--surface-2); min-width: 0; }
.rt-seg { display: flex; align-items: center; justify-content: center; background: var(--c); color: #F9FFF1; font-family: var(--font-data); font-weight: 700; font-size: 15px; font-variant-numeric: var(--tabular); box-shadow: inset -2px 0 0 var(--surface); min-width: 0; }
.rt-seg:last-child { box-shadow: none; }
.rt-seg-reserve, .rt-legend .rt-sw.is-reserve { background: repeating-linear-gradient(135deg, #17797A 0 6px, #116566 6px 12px); }
.rt-outside { flex: 0 0 200px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 8px 12px; border: 2px dashed #DAA72C; border-radius: 10px; font-size: 13px; line-height: 1.35; color: var(--ink); }
.rt-outside b { font-size: 14px; }
.rt-legend { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--ink); }
.rt-legend li { display: flex; align-items: flex-start; gap: 8px; max-width: 100%; }
.rt-legend b { font-weight: 700; }
.rt-sw { flex: none; width: 14px; height: 14px; margin-top: 3px; border-radius: 3px; background: var(--c); }
.rt-leg-d { display: block; font-size: 12.5px; color: var(--ink-2); }

/* 2. taxonomy: one column per class, subclasses either side of a spine */
.rt-wide { position: relative; left: 50%; transform: translateX(-50%); width: min(1180px, calc(100vw - 48px)); }
.rt-tx { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; align-items: start; }
.rt-col { min-width: 0; }
.rt-head { margin: 0; padding: 12px 10px; border-radius: 8px; background: var(--c); color: var(--t); text-align: center; font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.rt-subs { position: relative; list-style: none; margin: 0; padding: 16px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 18px; }
.rt-subs::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 14px; width: 2px; margin-left: -1px; background: var(--c); }
.rt-tile { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: 44px; padding: 6px 8px; border: 1px solid var(--c); border-radius: 6px; background: color-mix(in srgb, var(--c) 12%, #F9FFF1); font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--ink); }
/* no mid-word breaks: .lib-body sets overflow-wrap: anywhere on list items, so this needs the higher specificity */
.lib-body .rt-tile, .lib-body .rt-risk, .lib-body .rt-mrow, .lib-body .rt-head { overflow-wrap: normal; word-break: normal; hyphens: manual; }
.rt-tile.is-opt { border-style: dashed; }
.rt-tile::after { content: ""; position: absolute; top: 50%; width: 11px; height: 2px; background: var(--c); }
.rt-tile:nth-child(odd)::after { right: -10px; width: 9px; }
.rt-tile:nth-child(even)::after { left: -10px; width: 9px; }
.rt-chip { align-self: flex-start; font-family: var(--font-data); font-size: 11px; font-weight: 700; font-variant-numeric: var(--tabular); padding: 1px 6px; border-radius: 99px; background: var(--surface); border: 1px solid var(--c); color: var(--ink); }

/* 3. subclass to model: matrix, then the register inset */
.rt-mwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.rt-mtable { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; }
.rt-mtable th, .rt-mtable td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.rt-mtable thead th { font-size: 12.5px; font-weight: 700; color: var(--ink-2); vertical-align: bottom; }
.rt-mrow { overflow-wrap: break-word; word-break: normal; text-align: left; font-weight: 600; color: var(--ink); border-left: 4px solid var(--c); }
.rt-mtable thead .rt-mrow { border-left-color: transparent; }
.rt-mtable tr.rt-first th, .rt-mtable tr.rt-first td { border-top: 2px solid var(--border-strong); }
.rt-mc { text-align: center; width: 13%; }
.rt-mc:last-child { border-left: 1px dashed var(--border-strong); }
.rt-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--c); vertical-align: middle; }
.rt-dot.is-check { background: linear-gradient(90deg, var(--c) 50%, transparent 50%); box-shadow: inset 0 0 0 2px var(--c); }
.rt-dot.is-orsa { background: transparent; border: 2px dashed var(--c); }
.rt-mkey { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--ink-2); }
.rt-mkey li { display: inline-flex; align-items: center; gap: 6px; }
.rt-tree { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0 28px; align-items: center; }
.rt-tree-sub { position: relative; padding: 14px 16px; border-radius: 10px; background: var(--c); color: var(--t); display: flex; flex-direction: column; gap: 2px; }
.rt-tree-sub span { font-family: var(--font-data); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; opacity: .9; }
.rt-tree-sub b { font-size: 18px; }
.rt-tree-sub::after { content: ""; position: absolute; right: -28px; top: 50%; width: 14px; height: 2px; background: var(--c); }
.rt-risks { position: relative; list-style: none; margin: 0; padding: 0 0 0 14px; display: flex; flex-direction: column; gap: 6px; border-left: 2px solid var(--c); }
.rt-risk { position: relative; padding: 7px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; }
.rt-risk::before { content: ""; position: absolute; left: -16px; top: 50%; width: 14px; height: 2px; background: var(--c); }
.rt-risk span { font-size: 12.5px; color: var(--ink-2); }
.rt-risk.is-more { border-style: dashed; color: var(--ink-2); background: transparent; }

/* 4. boundary calls as cards */
.rt-calls { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rt-call { position: relative; padding: 18px 18px 18px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent-deep); border-radius: var(--radius-tile); display: flex; flex-direction: column; gap: 8px; }
.rt-call-n { font-family: var(--font-data); font-size: 26px; font-weight: 700; line-height: 1; color: var(--accent-deep); }
.lib-body .rt-call-h { margin: 0; font-size: 17px; line-height: 1.3; }
.rt-call p { margin: 0; font-size: 14.5px; line-height: 1.55; }

/* in detail: a closed accordion */
.rt-acc { margin: 28px 0 0; border: 1px solid var(--border); border-radius: var(--radius-tile); background: var(--surface); }
.rt-acc > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--tap); padding: 8px 18px; font-weight: 700; }
.rt-acc > summary::-webkit-details-marker { display: none; }
.rt-acc > summary::marker { content: ""; }
.rt-acc > summary::after { content: "+"; font-size: 22px; font-weight: 400; color: var(--accent-deep); }
.rt-acc[open] > summary::after { content: "\2212"; }
.rt-acc > summary:focus-visible { outline: 2px solid var(--accent-deep); outline-offset: 2px; }
.lib-body .rt-acc > summary h2 { margin: 0; }
.rt-acc-b { padding: 0 18px 18px; }
.rt-acc-b > :first-child { margin-top: 8px; }

/* above phone width two tile columns per class do not fit five classes across (a 1180px row leaves about 95px a tile):
   one tile column beside the spine, ticks from the spine */
@media (min-width: 768px) {
  .rt-subs { grid-template-columns: minmax(0, 1fr); gap: 6px; padding-left: 16px; }
  .rt-subs::before { left: 4px; margin-left: 0; }
  .rt-tile:nth-child(odd)::after, .rt-tile:nth-child(even)::after { left: -13px; right: auto; width: 12px; }
}
@media (max-width: 899px) {
  .rt-tx { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; }
}
@media (max-width: 767px) {
  .rt-capwrap { flex-direction: column; }
  .rt-outside { flex: none; }
  .rt-tx { grid-template-columns: minmax(0, 1fr); }
  .rt-subs { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 18px; padding-left: 0; }
  .rt-subs::before { left: 50%; margin-left: -1px; }
  .rt-tile:nth-child(odd)::after { left: auto; right: -10px; width: 9px; }
  .rt-tile:nth-child(even)::after { left: -10px; right: auto; width: 9px; }
  .rt-calls { grid-template-columns: minmax(0, 1fr); }
  .rt-tree { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rt-tree-sub::after { right: auto; left: 24px; top: auto; bottom: -14px; width: 2px; height: 14px; }
  .rt-risks { margin: 14px 0 0 24px; }
  .rt-mtable { font-size: 12.5px; }
  .rt-mtable thead .rt-mc span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; display: inline-block; }
  .rt-mc { width: 30px; padding: 5px 2px; }
}
/* the PDF (tools/library_pdf.py): no breakout, one tile column per class */
.rt-print .rt-wide { left: auto; transform: none; width: auto; }
