/* ==========================================================================
   OpenPerps · ENGINE — reading surface (docs + roadmap prose)
   Same instrument, quieter: no 3D behind the text, one column of measured
   type, and every table built to be scanned rather than admired.
   ========================================================================== */

.doc-hero { padding-block: 118px 44px; border-bottom: 1px solid var(--line); position: relative; z-index: 1; }
.doc-hero h1 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; letter-spacing: -0.02em; line-height: 0.86;
  font-size: clamp(42px, 7vw, 108px); margin-top: 18px; }
.doc-hero .sub { margin-top: 20px; font-size: clamp(16.5px, 1.25vw, 20px); line-height: 1.6; color: var(--text-2); max-width: 64ch; }
.doc-hero .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }

.doc { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: clamp(28px, 4vw, 72px); align-items: start;
  padding-block: clamp(36px, 5vw, 64px) clamp(60px, 9vh, 120px); position: relative; z-index: 1; }

/* contents rail */
.toc { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; display: grid; gap: 2px; padding-right: 6px; }
.toc h2 { font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.toc a { display: block; padding: 7px 10px 7px 13px; border-left: 2px solid var(--line); color: var(--text-2);
  text-decoration: none; font-size: 13.5px; line-height: 1.35; border-radius: 0 var(--r-sm) var(--r-sm) 0; transition: all 0.22s; }
.toc a:hover { color: var(--text); background: var(--surf); }
.toc a.on { color: var(--text); border-left-color: var(--short); background: var(--surf-2); }
.toc .k { font-family: var(--f-data); font-size: 10.5px; color: var(--text-3); margin-right: 7px; }

.doc-body { max-width: 86ch; }
.doc-body section { padding-top: 14px; margin-bottom: clamp(44px, 6vw, 80px); scroll-margin-top: 84px; }
.doc-body h2 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; letter-spacing: -0.015em; line-height: 0.9;
  font-size: clamp(30px, 3.8vw, 58px); padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.doc-body h2 .k { font-family: var(--f-data); font-size: 12px; letter-spacing: 0.1em; color: var(--text-3); display: block; margin-bottom: 10px; }
.doc-body h3 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: clamp(19px, 1.8vw, 27px);
  line-height: 0.98; margin: 32px 0 12px; }
.doc-body h4 { font-family: var(--f-data); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--long-2); margin: 26px 0 10px; }
.doc-body p { color: var(--text-2); line-height: 1.68; margin-bottom: 14px; }
.doc-body p strong, .doc-body li strong { color: var(--text); font-weight: 500; }
.doc-body a { color: var(--long-2); }
.doc-body ul, .doc-body ol { color: var(--text-2); line-height: 1.68; padding-left: 22px; margin-bottom: 16px; }
.doc-body li { margin-bottom: 8px; }
.doc-body li::marker { color: var(--text-3); }
.doc-body code { font-family: var(--f-data); font-size: 0.86em; background: var(--surf-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; color: var(--text); overflow-wrap: anywhere; }
.doc-body hr { border: 0; border-top: 1px solid var(--line); margin: 30px 0; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; margin: 16px 0 20px; font-size: 14.5px; display: block; overflow-x: auto; }
.tbl thead th { font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3);
  text-align: left; padding: 10px 14px; background: var(--surf-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); color: var(--text-2); line-height: 1.5; vertical-align: top; }
.tbl tbody tr:hover td { background: var(--surf); }
.tbl td:first-child { color: var(--text); }
.tbl td.m, .tbl th.m { font-family: var(--f-data); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .ln { color: var(--long-2); } .tbl .sh { color: var(--short); } .tbl .pd { color: var(--pending); }

/* callouts */
.note { border: 1px solid var(--line); border-left: 3px solid var(--long); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surf); padding: 16px 18px; margin: 20px 0; }
.note p:last-child { margin-bottom: 0; }
.note .h { font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--long-2); margin-bottom: 8px; }
.note--warn { border-left-color: var(--pending); }
.note--warn .h { color: var(--pending); }
.note--stop { border-left-color: var(--short); background: color-mix(in srgb, var(--short) 7%, var(--surf)); }
.note--stop .h { color: var(--short-2); }

/* checklist */
.chk-list { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.chk-list li { background: var(--surf); padding: 14px 16px 14px 44px; position: relative; color: var(--text-2); line-height: 1.55; margin: 0; }
.chk-list li::before { content: ""; position: absolute; left: 16px; top: 17px; width: 14px; height: 14px; border-radius: 4px;
  border: 1.5px solid var(--line-2); }
.chk-list li::after { content: ""; position: absolute; left: 20px; top: 20px; width: 5px; height: 8px;
  border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3); transform: rotate(42deg); opacity: 0.45; }

/* glossary */
.gloss { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 16px 0; }
.gloss > div { background: var(--surf); padding: 14px 16px; display: grid; grid-template-columns: 190px minmax(0,1fr); gap: 18px; }
.gloss dt { font-family: var(--f-data); font-size: 12.5px; color: var(--text); }
.gloss dd { margin: 0; color: var(--text-2); line-height: 1.55; font-size: 14.5px; }

@media (max-width: 940px) {
  .doc { grid-template-columns: minmax(0,1fr); }
  .toc { position: static; max-height: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); }
  .toc h2 { flex: 1 1 100%; margin: 0 0 4px; }
  .toc a { border-left: 0; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; font-size: 13px; }
  .toc a.on { border-color: var(--short); }
  .gloss > div { grid-template-columns: minmax(0,1fr); gap: 6px; }
}

/* ---------- docs landing cards ---------- */
.doc-cards { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: clamp(12px, 1.4vw, 18px); margin-bottom: clamp(32px, 4vw, 56px); }
.doc-card { display: grid; gap: 9px; align-content: start; padding: clamp(18px, 2vw, 26px); border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surf); text-decoration: none; transition: border-color 0.25s, transform 0.25s var(--ease); }
.doc-card:hover { border-color: var(--line-2); transform: translateY(-3px); }
.doc-card .n { font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--long-2); }
.doc-card h3 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: clamp(19px, 1.8vw, 26px); line-height: 0.97; }
.doc-card p { color: var(--text-2); font-size: 14.5px; line-height: 1.55; margin: 0; }
@media (max-width: 900px) { .doc-cards { grid-template-columns: minmax(0,1fr); } }

/* ---------- expandable advanced sections ---------- */
.adv { border: 1px solid var(--line); border-radius: var(--r); background: var(--surf); margin-bottom: 10px; overflow: hidden; }
.adv > summary { cursor: pointer; list-style: none; padding: 16px 18px; display: flex; align-items: center; gap: 12px;
  font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: clamp(17px, 1.5vw, 22px); color: var(--text); }
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::after { content: "+"; margin-left: auto; font-family: var(--f-data); font-size: 18px; color: var(--text-3); }
.adv[open] > summary::after { content: "−"; }
.adv > summary:hover { background: var(--surf-2); }
.adv > summary:focus-visible { outline: 2px solid var(--short); outline-offset: -2px; }
.adv-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.adv-body > *:first-child { margin-top: 16px; }

/* ---------- FAQ ---------- */
.faq { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.faq details { background: var(--surf); }
.faq summary { cursor: pointer; list-style: none; padding: 15px 18px; font-weight: 500; color: var(--text); display: flex; gap: 12px; align-items: baseline; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; margin-left: auto; font-family: var(--f-data); color: var(--text-3); }
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { background: var(--surf-2); }
.faq summary:focus-visible { outline: 2px solid var(--short); outline-offset: -2px; }
.faq .a { padding: 0 18px 16px; color: var(--text-2); line-height: 1.65; }
.faq .a p { margin-bottom: 10px; }
.faq .a p:last-child { margin-bottom: 0; }

/* ==========================================================================
   Docs shell — grouped sidebar, article column, on-this-page rail
   ========================================================================== */
.dx { display: grid; grid-template-columns: 268px minmax(0, 1fr) 210px; gap: clamp(24px, 3vw, 56px);
  align-items: start; padding-block: 92px clamp(60px, 9vh, 120px); position: relative; z-index: 1; }

/* sidebar */
.dx-nav { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; padding-right: 10px; }
.dx-nav::-webkit-scrollbar { width: 6px; }
.dx-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.dx-grp { margin-bottom: 22px; }
.dx-grp > h3 { font-family: var(--f-data); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 8px; padding-left: 13px; }
.dx-nav a { display: block; padding: 9px 12px; border-left: 2px solid var(--line); color: var(--text-2);
  text-decoration: none; font-size: 14px; line-height: 1.4; border-radius: 0 8px 8px 0; transition: all 0.2s; }
.dx-nav a:hover { color: var(--text); background: var(--surf); }
.dx-nav a[aria-current="page"] { color: var(--text); border-left-color: var(--short); background: var(--surf-2); font-weight: 500; }

/* article */
.dx-art { max-width: 78ch; min-width: 0; }
.dx-crumb { font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.dx-crumb a { color: var(--text-3); text-decoration: none; }
.dx-crumb a:hover { color: var(--text-2); }
.dx-art h1 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; letter-spacing: -0.02em;
  line-height: 0.88; font-size: clamp(34px, 4.6vw, 68px); margin: 14px 0 0; }
.dx-art .intro { font-size: clamp(16.5px, 1.25vw, 19.5px); line-height: 1.6; color: var(--text-2); margin-top: 18px;
  padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.dx-art h2 { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; letter-spacing: -0.012em;
  font-size: clamp(22px, 2.3vw, 34px); line-height: 0.96; margin: 44px 0 14px; scroll-margin-top: 90px; }
.dx-art h3 { font-family: var(--f-data); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--long-2); margin: 28px 0 10px; }
.dx-art p { color: var(--text-2); line-height: 1.72; margin-bottom: 15px; }
.dx-art strong { color: var(--text); font-weight: 500; }
.dx-art a { color: var(--long-2); }
.dx-art ul, .dx-art ol { color: var(--text-2); line-height: 1.72; padding-left: 22px; margin-bottom: 16px; }
.dx-art li { margin-bottom: 9px; }
.dx-art li::marker { color: var(--text-3); }
.dx-art code { font-family: var(--f-data); font-size: 0.85em; background: var(--surf-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; color: var(--text); overflow-wrap: anywhere; }
.dx-art hr { border: 0; border-top: 1px solid var(--line); margin: 34px 0; }

/* key/value panel used for worked numbers */
.kvp { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden; margin: 18px 0 20px; }
.kvp > div { background: var(--surf); padding: 12px 15px; display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.kvp dt { color: var(--text-2); font-size: 14.5px; }
.kvp dd { margin: 0; font-family: var(--f-data); font-size: 14.5px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.kvp dd.ln { color: var(--long-2); } .kvp dd.sh { color: var(--short); } .kvp dd.pd { color: var(--pending); }
.kvp > div.tot { background: color-mix(in srgb, var(--confirmed) 32%, var(--surf)); }

/* on this page */
.dx-otp { position: sticky; top: 84px; display: grid; gap: 3px; align-content: start; }
.dx-otp h4 { font-family: var(--f-data); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 7px; }
.dx-otp a { color: var(--text-3); text-decoration: none; font-size: 13px; line-height: 1.4; padding: 7px 0 7px 11px;
  border-left: 2px solid var(--line); transition: all 0.2s; }
.dx-otp a:hover { color: var(--text-2); }
.dx-otp a.on { color: var(--text); border-left-color: var(--short); }

/* prev / next */
.dx-feet { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 52px;
  padding-top: 26px; border-top: 1px solid var(--line); }
.dx-feet a { display: grid; gap: 5px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--r);
  text-decoration: none; background: var(--surf); transition: border-color 0.25s, transform 0.25s var(--ease); }
.dx-feet a:hover { border-color: var(--line-2); transform: translateY(-2px); }
.dx-feet a span { font-family: var(--f-data); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.dx-feet a b { font-family: var(--f-display); font-weight: 900; text-transform: uppercase; font-size: 19px; color: var(--text); line-height: 0.98; }
.dx-feet .nx { text-align: right; }
.dx-feet .ph { border-style: dashed; opacity: 0.3; pointer-events: none; }
.dx-updated { margin-top: 26px; font-family: var(--f-data); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3); }

/* mobile: nav collapses to a disclosure */
.dx-toggle { display: none; }
@media (max-width: 1180px) { .dx { grid-template-columns: 250px minmax(0, 1fr); } .dx-otp { display: none; } }
@media (max-width: 900px) {
  .dx { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 84px; }
  .dx-nav { position: static; max-height: none; padding: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
  .dx-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 16px; background: var(--surf);
    border: 0; color: var(--text); font: inherit; font-family: var(--f-display); font-weight: 900; text-transform: uppercase;
    font-size: 17px; cursor: pointer; }
  .dx-toggle::after { content: "+"; margin-left: auto; font-family: var(--f-data); color: var(--text-3); }
  .dx-nav.open .dx-toggle::after { content: "−"; }
  .dx-nav-in { display: none; padding: 6px 14px 16px; border-top: 1px solid var(--line); }
  .dx-nav.open .dx-nav-in { display: block; }
  .dx-feet { grid-template-columns: minmax(0,1fr); }
}
