/* ==========================================================================
   NPX Wiki — npxexchange.wiki
   A documentation-style reference system for NPX Exchange Ltd.
   Palette: paper blue-gray, white panels, deep blue, slate, pale borders.
   Type: IBM Plex Sans (text) / IBM Plex Mono (labels, metadata, tables).
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f5f8fc;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --ink: #22344b;
  --slate: #4a5a70;
  --muted: #5c6c82;
  --blue: #1f3f78;
  --blue-dark: #17325f;
  --blue-soft: #eaf1fa;
  --blue-soft-2: #eef4fb;
  --border: #dce6f2;
  --border-strong: #c4d4e7;
  --rule: 4px;
  --font-sans: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", Consolas, "Courier New", monospace;
  --sidebar-w: 264px;
  --shadow: 0 1px 2px rgba(31, 63, 120, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--blue);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--blue-dark);
  text-decoration-thickness: 2px;
}

a:focus-visible,
summary:focus-visible {
  outline: 3px solid #6f97d6;
  outline-offset: 2px;
}

.mono {
  font-family: var(--font-mono);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--blue);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
  color: #fff;
}

/* ---------- Fixed sidebar ---------- */
.wiki-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.brand {
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-link {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-link:hover {
  color: var(--ink);
}

.brand-mark {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 3px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  display: block;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  margin-top: 3px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.5;
}

/* Mobile disclosure wrapper: summary hidden on desktop */
.nav-disclosure > summary {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0 8px;
}

.nav-group {
  padding: 0 24px;
  margin-bottom: 24px;
}

.nav-label {
  margin: 0 0 7px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #5c6c82;
}

.sidebar-nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar-nav li + li {
  margin-top: 1px;
}

.sidebar-nav a {
  display: block;
  margin-left: -11px;
  padding: 7px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  color: var(--slate);
  font-size: 14.5px;
  line-height: 1.4;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--bg);
  color: var(--blue);
}

.sidebar-nav a[aria-current="page"] {
  border-left-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.sidebar-foot {
  padding: 18px 24px 26px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
}

.sidebar-foot a {
  color: var(--blue);
}

/* ---------- Content shell ---------- */
.wiki-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin-left: var(--sidebar-w);
}

.breadcrumb-bar {
  padding: 11px 40px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.breadcrumb-bar ol {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.breadcrumb-bar li {
  display: flex;
  gap: 4px;
  align-items: center;
}

.breadcrumb-bar li + li::before {
  content: "/";
  color: #6b7b90;
}

.breadcrumb-bar a {
  color: var(--slate);
  text-decoration: none;
}

.breadcrumb-bar a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.breadcrumb-bar [aria-current="page"] {
  color: var(--blue);
  font-weight: 500;
}

.page {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 34px 40px 56px;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 34px;
  align-items: start;
}

/* ---------- Article panel ---------- */
.article-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 48px 52px 56px;
}

.article-kicker {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--blue);
}

.article-kicker span {
  color: #5f7088;
  font-weight: 400;
}

.article-panel h1 {
  margin: 0 0 16px;
  color: #162c4e;
  font-size: clamp(2rem, 3.6vw, 2.85rem);
  font-weight: 700;
  line-height: 1.13;
  letter-spacing: -0.022em;
}

.lede {
  margin: 0 0 22px;
  color: #3c4e65;
  font-size: 1.17rem;
  line-height: 1.6;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.article-meta span {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
}

.article-meta strong {
  font-weight: 500;
  color: var(--slate);
}

.article-meta .status {
  color: #2c6b4f;
}

.article-body {
  margin-top: 30px;
}

.article-body p,
.article-body li {
  color: #35465c;
}

.article-body p {
  margin: 0 0 1.15em;
}

.article-body h2 {
  margin: 2.1em 0 0.65em;
  padding-top: 1.1em;
  border-top: 1px solid var(--border);
  color: #17305a;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.012em;
}

.article-body h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.article-body h3 {
  margin: 1.7em 0 0.5em;
  color: #1d3557;
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.35;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.2em;
  padding-left: 1.4em;
}

.article-body li {
  margin-bottom: 0.5em;
}

.article-body li::marker {
  color: #7790b3;
}

.article-body strong {
  color: #1f3554;
  font-weight: 600;
}

.article-body a {
  font-weight: 500;
}

.article-body abbr {
  text-decoration: underline dotted;
  cursor: help;
}

/* Figures */
.article-figure {
  margin: 26px 0;
  background: var(--panel-soft);
  border: 1px solid var(--border);
}

.article-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.article-figure figcaption {
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* Definition / info boxes */
.defbox {
  margin: 24px 0;
  padding: 18px 22px;
  background: var(--blue-soft-2);
  border-left: var(--rule) solid var(--blue);
}

.defbox--plain {
  background: var(--panel-soft);
  border-left-color: #8ba3c4;
}

.defbox--caution {
  background: #fbf6ec;
  border-left-color: #a8781f;
}

.defbox-label {
  display: block;
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
}

.defbox--caution .defbox-label {
  color: #7d5a16;
}

.defbox p:last-child,
.defbox ul:last-child {
  margin-bottom: 0;
}

.defbox p {
  margin-bottom: 0.7em;
  font-size: 0.96rem;
}

.defbox ul {
  margin: 0.4em 0 0;
  padding-left: 1.2em;
  font-size: 0.96rem;
}

/* Fact grid used inside boxes and above tables */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--panel);
}

.fact-grid > div {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.fact-grid > div:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.fact-grid dt {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.fact-grid dd {
  margin: 0;
  font-size: 0.94rem;
  color: #2c3f58;
}

/* Tables */
.table-scroll {
  margin: 24px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  background: var(--panel);
}

.data-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}

.data-table caption {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.data-table th:last-child,
.data-table td:last-child {
  border-right: 0;
}

.data-table thead th {
  background: var(--blue-soft);
  color: #17305a;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.data-table tbody th {
  color: #22344b;
  font-weight: 600;
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:nth-child(even) td {
  background: #fafcff;
}

/* Pull-out list of article cards on the index */
.directory {
  margin: 24px 0;
  border: 1px solid var(--border);
}

.directory-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.directory-item:last-child {
  border-bottom: 0;
}

.directory-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #5f7088;
  padding-top: 3px;
}

.directory-item h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
}

.directory-item h3 a {
  text-decoration: none;
}

.directory-item h3 a:hover {
  text-decoration: underline;
}

.directory-item p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--slate);
  line-height: 1.55;
}

.directory-tag {
  margin-top: 2px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* Inline code-like label */
.tag {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--panel-soft);
  font-family: var(--font-mono);
  font-size: 0.82em;
  color: var(--blue);
}

/* Read-next pager */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 40px 0 0;
  border: 1px solid var(--border);
  background: var(--border);
}

.pager a {
  display: block;
  padding: 16px 18px;
  background: var(--panel);
  text-decoration: none;
}

.pager a:hover {
  background: var(--blue-soft-2);
}

.pager .pager-label {
  display: block;
  margin-bottom: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.pager .pager-title {
  color: var(--blue);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

.pager a:last-child {
  text-align: right;
}

/* ---------- Right-hand table of contents ---------- */
.toc {
  position: sticky;
  top: 20px;
  font-size: 13px;
}

.toc-disclosure > summary {
  display: none;
}

.toc-panel {
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 18px;
}

.toc-title {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5c6c82;
}

.toc-panel ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-panel li {
  margin-bottom: 7px;
  line-height: 1.4;
}

.toc-panel a {
  color: var(--slate);
  text-decoration: none;
}

.toc-panel a:hover {
  color: var(--blue);
  text-decoration: underline;
}

.toc-note {
  margin: 18px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Footer and NPX network block ---------- */
.site-footer {
  margin-top: 14px;
  background: var(--panel);
  border-top: var(--rule) solid var(--blue);
}

.network-block {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.6fr);
  gap: 30px 48px;
  max-width: 1380px;
  margin: 0 auto;
  padding: 32px 40px 34px;
}

.network-kicker {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--blue);
}

.network-block h2 {
  margin: 0 0 8px;
  color: #162c4e;
  font-size: 1.28rem;
  line-height: 1.3;
}

.network-block p {
  margin: 0;
  color: var(--slate);
  font-size: 0.92rem;
  line-height: 1.6;
}

.network-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--border);
  border: 1px solid var(--border);
  align-self: start;
}

.network-list li {
  background: var(--panel-soft);
  padding: 11px 14px;
}

.network-list a {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
}

.network-list a:hover {
  text-decoration: underline;
}

.network-list span {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
}

.footer-legal {
  max-width: 1380px;
  margin: 0 auto;
  padding: 18px 40px 30px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

.footer-legal p {
  margin: 0 0 6px;
}

.footer-legal p:last-child {
  margin-bottom: 0;
}

.footer-legal strong {
  color: var(--slate);
  font-weight: 600;
}

/* ---------- Glossary ---------- */
.glossary {
  margin: 22px 0 8px;
}

.glossary-term {
  padding: 18px 0;
  border-top: 1px solid var(--border);
}

.glossary-term:first-child {
  border-top: 0;
  padding-top: 0;
}

.glossary-term dt {
  margin: 0 0 4px;
  color: #17305a;
  font-size: 1.08rem;
  font-weight: 600;
}

.glossary-term dt span {
  display: inline-block;
  margin-right: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #5f7088;
  vertical-align: 2px;
}

.glossary-term dd {
  margin: 0;
  color: #35465c;
  font-size: 0.96rem;
}

.glossary-term dd a {
  white-space: nowrap;
}

.az-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 18px 0 8px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.az-nav a {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-family: var(--font-mono);
  font-size: 11px;
  text-decoration: none;
}

.az-nav a:hover {
  background: var(--blue-soft);
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 26px;
  }

  .article-panel {
    padding: 40px 40px 46px;
  }

  .page {
    padding: 28px 30px 48px;
  }

  .breadcrumb-bar {
    padding-inline: 30px;
  }

  .network-block,
  .footer-legal {
    padding-inline: 30px;
  }
}

@media (max-width: 1020px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    position: static;
    order: -1;
    margin-bottom: 2px;
  }

  .toc-disclosure {
    border: 1px solid var(--border);
    background: var(--panel);
  }

  .toc-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 16px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--blue);
    list-style: none;
  }

  .toc-disclosure > summary::-webkit-details-marker {
    display: none;
  }

  .toc-disclosure > summary::after {
    content: "+";
    font-size: 17px;
    line-height: 1;
    color: var(--slate);
  }

  .toc-disclosure[open] > summary::after {
    content: "\2212";
  }

  .toc-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 14px 16px 16px;
  }

  .toc-note {
    display: none;
  }
}

@media (max-width: 960px) {
  .wiki-sidebar {
    position: static;
    width: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0;
  }

  .brand {
    padding: 16px 22px;
    border-bottom: 0;
  }

  .brand-mark {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-sub {
    display: inline;
    margin-left: 8px;
    font-size: 10px;
  }

  .nav-disclosure {
    border-top: 1px solid var(--border);
  }

  .nav-disclosure > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 22px;
    cursor: pointer;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--blue);
  }

  .nav-disclosure > summary::-webkit-details-marker {
    display: none;
  }

  .nav-disclosure > summary::after {
    content: "\2261";
    font-size: 18px;
    line-height: 1;
  }

  .nav-disclosure[open] > summary::after {
    content: "\00d7";
  }

  .sidebar-nav {
    padding: 8px 22px 18px;
    border-top: 1px solid var(--border);
    background: var(--panel-soft);
  }

  .nav-group {
    padding: 0;
    margin-bottom: 18px;
  }

  .sidebar-foot {
    display: none;
  }

  .wiki-content {
    margin-left: 0;
  }

  .breadcrumb-bar {
    padding: 10px 22px;
  }

  .page {
    padding: 22px 20px 40px;
  }

  .network-block {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 26px 22px 28px;
  }

  .footer-legal {
    padding: 16px 22px 26px;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 15.5px;
  }

  .article-panel {
    padding: 28px 22px 34px;
    border: 0;
    box-shadow: none;
  }

  .page {
    padding: 16px 14px 34px;
  }

  .article-panel h1 {
    font-size: 1.9rem;
  }

  .lede {
    font-size: 1.05rem;
  }

  .article-meta {
    gap: 5px 14px;
    font-size: 10.5px;
  }

  .article-body h2 {
    font-size: 1.32rem;
  }

  .fact-grid {
    grid-template-columns: 1fr;
  }

  .fact-grid > div:nth-child(odd) {
    border-right: 0;
  }

  .directory-item {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding: 15px 14px;
  }

  .directory-tag {
    display: none;
  }

  .network-list {
    grid-template-columns: 1fr;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager a:last-child {
    text-align: left;
    border-top: 1px solid var(--border);
  }

  .breadcrumb-bar {
    font-size: 10.5px;
    padding: 9px 16px;
  }

  .article-figure figcaption {
    font-size: 10.5px;
  }

  .data-table {
    min-width: 520px;
    font-size: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
