/* CorrConnect developer docs (Ticket 1456). Builds on ea.css tokens: Open Water,
   dark first, daylight on request. Read mode: the page is for reading and copying. */

:root {
  --header-h: 60px;
  --nav-w: 264px;
  --toc-w: 216px;
  --measure: 46rem;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --tint-accent: color-mix(in srgb, var(--accent) 14%, transparent);
  --tint-lime: color-mix(in srgb, var(--lime) 16%, transparent);
  --tint-danger: color-mix(in srgb, var(--danger) 16%, transparent);
  --tint-iris: color-mix(in srgb, var(--iris) 16%, transparent);
  --code-line: rgba(255, 255, 255, 0.08);
  --code-muted: #8F9AA6;
  --tk-kw: #9DB4FF;
  --tk-str: #C4EB7A;
  --tk-num: #F2C17D;
  --tk-key: #5FE0EA;
  --tk-var: #F2C17D;
  --tk-com: #8F9AA6;
  --shadow-pop: 0 18px 48px -12px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  --ok-text: var(--ok);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --ok-text: #046B45; --shadow-pop: 0 18px 48px -14px rgba(11, 12, 14, 0.28), 0 2px 6px rgba(11, 12, 14, 0.08); }
}
:root[data-theme="light"] { --ok-text: #046B45; --shadow-pop: 0 18px 48px -14px rgba(11, 12, 14, 0.28), 0 2px 6px rgba(11, 12, 14, 0.08); }

::selection { background: color-mix(in srgb, var(--accent) 34%, transparent); color: var(--text); }
html { scroll-padding-top: calc(var(--header-h) + 20px); scrollbar-color: var(--stroke-strong) transparent; }
body.docs { font-size: 16px; line-height: 1.65; caret-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
kbd { font-family: var(--mono); font-size: 12px; padding: 1px 6px; border: 1px solid var(--stroke-strong); border-radius: 6px; color: var(--text3); }

/* Header ------------------------------------------------------------- */
.docs-header { position: sticky; top: 0; z-index: 30; height: var(--header-h);
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--stroke); }
.docs-bar { height: 100%; display: flex; align-items: center; gap: 14px; padding: 0 var(--gutter); max-width: 1600px; margin: 0 auto; }
.docs-bar .brand { font-size: 17px; gap: 9px; flex: none; }
.docs-bar .brand img { width: 28px; height: 28px; border-radius: 7px; }
.docs-home { text-decoration: none; color: var(--text2); font-weight: 600; font-size: 15px; padding-left: 14px; border-left: 1px solid var(--stroke-strong); line-height: 1; }
.docs-home:hover { color: var(--text); }
.search-trigger { margin-left: 18px; flex: 0 1 300px; display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px 0 12px;
  font: inherit; font-size: 14px; color: var(--text3); background: var(--surface); border: 1px solid var(--stroke-strong); border-radius: 10px; cursor: pointer; }
.search-trigger:hover { color: var(--text2); border-color: var(--text3); }
.search-trigger svg { width: 18px; height: 18px; flex: none; }
.search-trigger span { flex: 1; text-align: left; }
.bar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ea-chip { font-size: 12px; font-weight: 650; letter-spacing: 0.02em; color: var(--accent-text); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.docs-bar .pill { display: inline-flex; align-items: center; min-height: 38px; padding: 0 16px; border-radius: 999px; background: var(--btn-bg); color: var(--btn-ink); font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.docs-bar .pill:hover { opacity: 0.88; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text2); cursor: pointer; flex: none; }
.icon-button:hover { color: var(--text); background: var(--surface); }
.icon-button svg { width: 20px; height: 20px; }
.nav-toggle { display: none; }
[hidden] { display: none !important; }

/* Shell -------------------------------------------------------------- */
.docs-shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); max-width: 1600px; margin: 0 auto; }
.docs-nav { position: sticky; top: var(--header-h); align-self: start; height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain; padding: 28px 16px 48px var(--gutter); border-right: 1px solid var(--stroke); font-size: 14.5px; }
.docs-nav ul { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 1px; }
.nav-section { margin: 0 0 6px; padding-left: 10px; font-size: 13px; font-weight: 650; color: var(--text); letter-spacing: -0.005em; }
.docs-nav a { display: flex; align-items: center; min-height: 34px; padding: 4px 10px; border-radius: 8px; color: var(--text2); text-decoration: none; line-height: 1.35; }
.docs-nav a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.docs-nav a[aria-current="page"] { color: var(--accent-text); background: var(--tint-accent); font-weight: 600; }

.docs-main { display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-w); gap: 48px; padding: 44px clamp(20px, 4vw, 56px) 96px; min-width: 0; }
.layout-reference .docs-main { grid-template-columns: minmax(0, 1fr); }
.docs-article { min-width: 0; max-width: var(--measure); }
.layout-reference .docs-article { max-width: 1180px; }

/* Article type ------------------------------------------------------- */
.crumb { margin: 0 0 10px; font-size: 14px; color: var(--text3); font-weight: 550; }
.docs-article h1 { font-size: clamp(32px, 4.4vw, 46px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 14px; text-wrap: balance; }
.docs-article .lede { font-size: clamp(17px, 1.6vw, 19px); line-height: 1.55; color: var(--text2); max-width: 40em; margin: 0 0 8px; text-wrap: pretty; }
.docs-article h2 { position: relative; font-size: clamp(22px, 2.3vw, 27px); line-height: 1.2; letter-spacing: -0.02em; margin: 52px 0 14px; padding-top: 26px; border-top: 1px solid var(--stroke); text-wrap: balance; }
.docs-article h3 { position: relative; font-size: 18px; line-height: 1.35; letter-spacing: -0.01em; margin: 34px 0 10px; }
.docs-article p, .docs-article li { color: var(--text2); text-wrap: pretty; overflow-wrap: break-word; }
.docs-article p { margin: 0 0 16px; }
.docs-article strong { color: var(--text); font-weight: 650; }
.docs-article a { color: var(--accent-text); text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.docs-article a:hover { text-decoration-color: var(--accent); }
.docs-article ul, .docs-article ol { padding-left: 1.3em; margin: 0 0 18px; }
.docs-article li { margin: 6px 0; padding-left: 2px; }
.docs-article li::marker { color: var(--text3); }
.docs-article ol > li::marker { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--accent-text); }
.docs-article :not(pre) > code { font-family: var(--mono); font-size: 0.86em; color: var(--text); background: var(--surface); border: 1px solid var(--stroke);
  padding: 1px 5px; border-radius: 6px; overflow-wrap: break-word; }
.docs-article a code { color: inherit; }
.anchor { position: absolute; left: -28px; bottom: 2px; width: 22px; height: 22px; display: grid; place-items: center; color: var(--text3); opacity: 0; border-radius: 6px; }
.docs-article h2 .anchor { bottom: auto; top: 30px; }
.anchor svg { width: 16px; height: 16px; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent-text); }

.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { position: relative; padding-left: 30px; }
.checklist li::before { content: ""; position: absolute; left: 2px; top: 5px; width: 16px; height: 16px; border: 1.5px solid var(--stroke-strong); border-radius: 5px; }

/* Callouts: tint and hairline, no side bars */
.callout { margin: 22px 0; padding: 16px 18px 2px; border-radius: 14px; border: 1px solid var(--stroke); background: var(--surface); }
.callout p { color: var(--text2); }
.callout-title { margin: 0 0 6px !important; font-weight: 650; color: var(--text) !important; display: flex; align-items: center; gap: 10px; }
.callout-soon { background: color-mix(in srgb, var(--iris) 9%, var(--surface)); border-color: color-mix(in srgb, var(--iris) 34%, transparent); }
.callout-soon .callout-title::before { content: "Coming soon"; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; color: var(--iris);
  border: 1px solid color-mix(in srgb, var(--iris) 50%, transparent); border-radius: 999px; padding: 1px 8px; }
.callout-caution { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 34%, transparent); }
.callout-note { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }

/* Tables ------------------------------------------------------------- */
.table-scroll { overflow-x: auto; margin: 16px 0 26px; border: 1px solid var(--stroke); border-radius: 12px; }
.docs-article table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.5; }
.docs-article th, .docs-article td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--stroke); }
.docs-article tr:last-child td { border-bottom: 0; }
.docs-article th { font-size: 13px; font-weight: 650; color: var(--text); background: color-mix(in srgb, var(--text) 3%, transparent); white-space: nowrap; }
.docs-article td { color: var(--text2); overflow-wrap: break-word; }
.type { white-space: nowrap; }
.docs-article td:first-child { color: var(--text); }
.docs-article td code { font-size: 0.84em; }
table.fields td:first-child, table.errors td:first-child { white-space: nowrap; overflow-wrap: normal; }
table.errors td:nth-child(3) { min-width: 15em; }
.req { font-size: 11px; font-weight: 650; color: var(--danger); margin-left: 4px; letter-spacing: 0.02em; }

/* Code --------------------------------------------------------------- */
figure.code { margin: 18px 0 22px; background: var(--code-bg); border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; color: var(--code-text); }
figure.code figcaption { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 8px 0 16px;
  font-size: 12.5px; font-weight: 600; color: var(--code-muted); border-bottom: 1px solid var(--code-line); letter-spacing: 0.01em; }
figure.code pre { margin: 0; padding: 16px 18px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.65; tab-size: 2;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
figure.code pre:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 0 0 12px 12px; }
figure.code code { font-family: inherit; color: inherit; white-space: pre; }
figure.code ::selection { background: rgba(95, 224, 234, 0.3); color: #fff; }
.tk-kw { color: var(--tk-kw); }
.tk-str { color: var(--tk-str); }
.tk-num { color: var(--tk-num); }
.tk-key { color: var(--tk-key); }
.tk-var { color: var(--tk-var); }
.tk-flag { color: var(--tk-kw); }
.tk-com { color: var(--tk-com); font-style: italic; }

.copy { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--code-muted); background: transparent; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.copy:hover { color: #fff; border-color: var(--code-line); background: rgba(255, 255, 255, 0.04); }
.copy[data-copied] { color: var(--tk-str); }
.copy svg { width: 15px; height: 15px; }

.code-group { margin: 18px 0 22px; }
.code-group > figure.code { margin: 0 0 12px; }
.js .code-group { background: var(--code-bg); border: 1px solid var(--stroke); border-radius: 14px; overflow: hidden; }
.js .code-group > figure.code { margin: 0; border: 0; border-radius: 0; }
.js .code-group > figure.code[hidden] { display: none; }
.js .code-group > figure.code figcaption { display: none; }
.tabbar { display: flex; align-items: stretch; gap: 2px; padding: 0 6px 0 8px; border-bottom: 1px solid var(--code-line); min-height: 42px; }
.tablist { display: flex; align-items: stretch; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tablist::-webkit-scrollbar { display: none; }
.tabbar [role="tab"] { position: relative; flex: none; font: inherit; font-size: 13px; font-weight: 600; color: var(--code-muted); background: none; border: 0;
  padding: 0 11px; min-height: 42px; cursor: pointer; }
.tabbar [role="tab"]:hover { color: #E6ECF1; }
.tabbar [role="tab"][aria-selected="true"] { color: #fff; }
.tabbar [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; border-radius: 2px; background: var(--gradient); }
.tabbar [role="tab"]:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 8px; }
.tabbar .file { margin-left: auto; align-self: center; font-family: var(--mono); font-size: 12px; color: var(--code-muted); padding-left: 12px; white-space: nowrap; }
.tabbar .copy { align-self: center; margin-left: 6px; flex: none; }

/* Reference ---------------------------------------------------------- */
.endpoint { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 14px !important; }
.endpoint code { font-family: var(--mono); font-size: 15px !important; color: var(--text) !important; background: none !important; border: 0 !important; padding: 0 !important; overflow-wrap: break-word; }
.method { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; flex: none; }
.method-get { color: var(--accent-text); background: var(--tint-accent); }
.method-post { color: var(--lime); background: var(--tint-lime); }
.method-delete { color: var(--danger); background: var(--tint-danger); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 8px; font-size: 14.5px; }
.facts div { display: contents; }
.facts dt { color: var(--text3); font-weight: 600; }
.facts dd { margin: 0; color: var(--text2); }
.ctype { font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text3); margin-left: 6px; }
.status { font-family: var(--mono); font-size: 12.5px; font-weight: 650; color: var(--danger); font-variant-numeric: tabular-nums; }
.status-ok { color: var(--ok-text); margin-left: 6px; }
.op { padding-top: 6px; }
.op + .op { margin-top: 40px; }
.op h3 { font-size: 15.5px; margin: 26px 0 8px; }
.op-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 40px; }
.op-samples { min-width: 0; }
.op-samples figure.code, .op-samples .code-group { margin-top: 0; }
table.ops-index td:nth-child(2) { white-space: nowrap; }
@media (min-width: 1240px) {
  .op-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 0.92fr); }
  .op-samples { position: sticky; top: calc(var(--header-h) + 20px); align-self: start; max-height: calc(100vh - var(--header-h) - 40px); overflow: auto; padding-top: 4px; scrollbar-width: thin; }
}

/* TOC ---------------------------------------------------------------- */
.docs-toc { position: sticky; top: calc(var(--header-h) + 44px); align-self: start; max-height: calc(100vh - var(--header-h) - 60px); overflow-y: auto; font-size: 13.5px; }
.toc-title { margin: 0 0 10px; font-weight: 650; color: var(--text); font-size: 13px; }
.docs-toc ul { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--stroke); display: grid; gap: 2px; }
.docs-toc a { display: block; padding: 4px 0; color: var(--text3); text-decoration: none; line-height: 1.4; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a[aria-current="true"] { color: var(--accent-text); font-weight: 600; }

/* Pager -------------------------------------------------------------- */
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--stroke); }
.pager a { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid var(--stroke-strong); border-radius: 14px; text-decoration: none; color: var(--text) !important; font-weight: 650; }
.pager a:hover { border-color: var(--accent); }
.pager span { font-size: 13px; font-weight: 550; color: var(--text3); }
.pager-next { grid-column: 2; text-align: right; }

/* Footer ------------------------------------------------------------- */
.docs-footer .wrap { max-width: 1600px; }

/* Search ------------------------------------------------------------- */
.search-dialog { width: min(640px, calc(100% - 32px)); max-height: min(560px, calc(100dvh - 120px)); margin: 10vh auto auto; padding: 0;
  border: 0; border-radius: 16px; background: var(--raised); color: var(--text); box-shadow: var(--shadow-pop); overflow: hidden; }
.search-dialog[open] { display: flex; flex-direction: column; }
.search-dialog::backdrop { background: color-mix(in srgb, var(--canvas) 62%, transparent); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.search-form { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--stroke); margin: 0; }
.search-form svg { width: 20px; height: 20px; color: var(--text3); flex: none; }
.search-form input { flex: 1; min-width: 0; height: 56px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; outline: none; }
.search-form input::placeholder { color: var(--text3); }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-close { font: inherit; font-size: 12px; color: var(--text3); background: none; border: 1px solid var(--stroke-strong); border-radius: 6px; padding: 2px 7px; cursor: pointer; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results a { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--text); }
.search-results [aria-selected="true"] a { background: var(--tint-accent); }
.search-results .r-title { font-weight: 620; }
.search-results .r-meta { font-size: 13px; color: var(--text3); }
.search-results .r-snip { font-size: 13.5px; color: var(--text2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-results mark { background: none; color: var(--accent-text); font-weight: 650; }
.search-status { margin: 0; padding: 10px 18px 14px; font-size: 13px; color: var(--text3); }
.search-status:empty { display: none; }

/* Responsive --------------------------------------------------------- */
@media (max-width: 1200px) {
  .docs-main { grid-template-columns: minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 960px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--stroke); padding: 20px var(--gutter) 8px; }
  .js .docs-nav { position: fixed; inset: var(--header-h) 0 0 0; z-index: 25; height: auto; background: var(--canvas); padding: 20px var(--gutter) 64px; border: 0;
    transform: translateX(-100%); visibility: hidden; transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 220ms; }
  .js.nav-open .docs-nav { transform: none; visibility: visible; transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1); }
  .js .nav-toggle { display: inline-grid; }
  .docs-main { padding: 28px var(--gutter) 72px; }
  .anchor { display: none; }
}
@media (max-width: 720px) {
  .search-trigger { flex: none; margin-left: auto; width: 44px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .bar-end { margin-left: 0; gap: 2px; }
  .ea-chip, .docs-home { display: none; }
  .docs-bar { gap: 6px; }
  .docs-bar .pill { padding: 0 12px; min-height: 36px; font-size: 13px; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager-next { grid-column: 1; }
  figure.code pre { font-size: 12.5px; padding: 14px; }
}
@media (max-width: 400px) {
  .docs-bar .pill { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .js .docs-nav, .js.nav-open .docs-nav { transition: none; }
}
@media print {
  .docs-header, .docs-nav, .docs-toc, .pager, .copy, .tabbar { display: none !important; }
  .docs-shell, .docs-main { display: block; }
  .js .code-group > figure.code[hidden] { display: block; }
}

/* Diagram: three swim lanes, drawn from tokens so it follows the theme */
.diagram { margin: 20px 0 26px; }
.diagram-scroll { overflow-x: auto; border: 1px solid var(--stroke); border-radius: 14px; background: var(--surface); padding: 12px 8px; }
svg.flow { display: block; width: 100%; min-width: 580px; height: auto; font-family: inherit; }
.flow-lane-box { fill: var(--canvas-2); stroke: var(--stroke-strong); stroke-width: 1; }
.flow-lane { fill: var(--text); font-size: 13.5px; font-weight: 650; stroke: none; }
.flow-life { stroke: var(--lane); stroke-width: 1.5; stroke-dasharray: 2 6; }
.flow-arrow { stroke: var(--accent); stroke-width: 1.6; }
.flow-head { fill: var(--accent); stroke: none; }
.flow-label { fill: var(--text2); font-size: 12.5px; stroke: none; }
.flow-dot { fill: var(--canvas); stroke: var(--accent); stroke-width: 1.5; }
.flow-num { fill: var(--accent-text); font-size: 11.5px; font-weight: 700; stroke: none; font-variant-numeric: tabular-nums; }
