/* App documentation pages (/docs). A formal method document: Plex Sans
   for structure, Plex Serif for running text, the Studio palette of the
   login/updates pages. Scoped under .docs-body so mainUI.css's generic
   selectors don't leak in. */

.docs-body {
    --ink: #14171c;
    --ink-2: #3a4049;
    --muted: #5b6169;
    --paper: #ffffff;
    --canvas: #f5f6f7;
    --line: #e3e5e8;
    --line-soft: #eef0f2;
    --accent: #1c7a4d;
    --accent-ink: #145c3a;
    --accent-tint: #e6f3ec;
    --note-bg: #eef2f6;
    --note-line: #c9d3de;
    --sans: 'IBM Plex Sans', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
    --serif: 'IBM Plex Serif', Georgia, 'Times New Roman', serif;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--sans);
}

.docs-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 48px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 96px 24px 72px;
}

/* ---- side contents ---- */
.docs-side { position: relative; }
.docs-toc-box {
    position: sticky; top: 84px;
    max-height: calc(100vh - 104px); overflow-y: auto;
    padding-right: 6px;
}
.docs-toc-box > summary {
    font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
    color: var(--muted); list-style: none; cursor: default; margin-bottom: 10px;
}
.docs-toc-box > summary::-webkit-details-marker { display: none; }
.docs-filter { display: block; margin: 0 0 12px; }
.docs-filter input {
    width: 100%; font: 14px var(--sans); color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px; background: var(--paper);
    padding: 7px 10px;
}
.docs-filter input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.docs-toc ol { list-style: none; margin: 0; padding: 0; }
.docs-toc > ol > li { margin: 1px 0; }
.docs-toc a {
    display: flex; gap: 8px; padding: 4px 8px; border-radius: 5px;
    color: var(--ink-2); font-size: 14px; line-height: 1.35; text-decoration: none;
    border-left: 2px solid transparent;
}
.docs-toc a:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.docs-toc a .n { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.2em; }
.docs-toc ol ol a { font-size: 13px; padding-left: 8px; color: var(--muted); }
.docs-toc ol ol { margin: 1px 0 6px 2.2em; display: none; }
.docs-toc li.is-open > ol, .docs-toc.is-filtering ol ol { display: block; }
.docs-toc a.is-current { background: var(--accent-tint); color: var(--accent-ink); border-left-color: var(--accent); font-weight: 500; }
.docs-toc li[hidden] { display: none !important; }
.docs-nomatch { font-size: 13px; color: var(--muted); margin: 6px 8px; }

/* ---- document ---- */
.docs-main { max-width: 780px; min-width: 0; }
.docs-head { padding-bottom: 22px; margin-bottom: 8px; border-bottom: 2px solid var(--ink); }
.docs-eyebrow, .docs-main p.docs-eyebrow { font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.docs-head h1 { font-size: 34px; font-weight: 700; letter-spacing: -.015em; margin: 0 0 10px; text-wrap: balance; }
.docs-lede, .docs-main p.docs-lede { font-family: var(--serif); font-size: 18px; line-height: 1.55; color: var(--ink-2); margin: 0 0 18px; max-width: 40em; }
.docs-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 24px; margin: 0; }
.docs-meta dt { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.docs-meta dd { font-size: 14px; margin: 2px 0 0; }

.docs-main section { counter-reset: sub; padding-top: 18px; scroll-margin-top: 80px; }
.docs-main h2 {
    font-size: 23px; font-weight: 600; margin: 26px 0 10px; padding-top: 18px;
    border-top: 1px solid var(--line); text-wrap: balance; scroll-margin-top: 80px;
}
.docs-main section:first-of-type h2 { border-top: 0; padding-top: 0; }
.docs-main h2::before { content: attr(data-num) "  "; color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 10px; }
.docs-main h3 { font-size: 16.5px; font-weight: 600; margin: 22px 0 6px; scroll-margin-top: 80px; }
.docs-main h3::before { content: attr(data-num); color: var(--muted); font-weight: 500; margin-right: 10px; font-variant-numeric: tabular-nums; }
.docs-main p, .docs-main li { font-family: var(--serif); font-size: 16.5px; line-height: 1.7; color: var(--ink); }
.docs-main p { margin: 0 0 12px; max-width: 42em; }
.docs-main ul, .docs-main ol { padding-left: 1.3em; margin: 0 0 14px; }
.docs-main li { margin: 4px 0; }
.docs-main strong { font-family: var(--sans); font-weight: 600; font-size: .94em; }
.docs-main a { color: var(--accent-ink); }

/* equations: the expression, with its source to the right */
.docs-eq {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
    margin: 12px 0 16px; padding: 4px 0 4px 16px;
    border-left: 2px solid var(--line);
    overflow-x: auto; overflow-y: hidden;
}
.docs-eq mjx-container[display="true"] { margin: .35em 0 !important; flex: 1 1 auto; text-align: left !important; }
.docs-eq-ref { flex: 0 0 auto; font-size: 12px; color: var(--muted); white-space: nowrap; margin-left: auto; }

/* assumptions */
.docs-assume {
    margin: 14px 0 18px; padding: 12px 16px 2px;
    background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 8px;
    scroll-margin-top: 80px;
}
.docs-assume:target { box-shadow: 0 0 0 2px var(--accent); }
.docs-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 4px; }
.docs-assume p { font-size: 15.5px; }
.docs-assume-list { list-style: none; padding-left: 0 !important; }
.docs-assume-list li { display: grid; grid-template-columns: 3.2em 1fr; gap: 6px; font-size: 15.5px; }
.docs-assume-list a { font-family: var(--sans); font-weight: 600; font-size: 14px; }

/* tables */
.docs-table-wrap { overflow-x: auto; margin: 12px 0 18px; }
.docs-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--paper); }
.docs-table th, .docs-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.docs-table thead th { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border-bottom: 1.5px solid var(--ink); }

/* references */
.docs-refs { padding-left: 2em !important; }
.docs-refs li { font-size: 15px; line-height: 1.6; }
.docs-refs li::marker { font-family: var(--sans); color: var(--muted); content: "[" counter(list-item) "]  "; }

/* ---- /docs home ---- */
.docs-home { max-width: 720px; margin: 0 auto; padding: 110px 24px 80px; }
.docs-home h1 { font-size: 32px; font-weight: 700; margin: 0 0 10px; }
.docs-apps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; }
.docs-apps a { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; }
.docs-apps a:hover { border-color: var(--accent); text-decoration: none; }
.docs-apps span { color: var(--muted); font-size: 14px; }

/* ---- phones and tablets: contents collapse above the document ---- */
@media (max-width: 900px) {
    .docs-shell { grid-template-columns: 1fr; gap: 16px; padding: 84px 16px 56px; }
    .docs-toc-box { position: static; max-height: none; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
    .docs-toc-box > summary { cursor: pointer; margin: 0; font-size: 12px; }
    .docs-toc-box[open] > summary { margin-bottom: 10px; }
    .docs-head h1 { font-size: 28px; }
    .docs-main p, .docs-main li { font-size: 16px; }
}

@media print {
    .docs-side, #calcNavbar, .footer { display: none !important; }
    .docs-shell { display: block; padding: 0; }
    .docs-body { background: #fff; }
}
