/* =====================================================================
   Clark legal page (templates/legal.html), "Instrument", NHS blue.
   The public chrome (top bar, footer, .pub base) comes from auth.css;
   this sheet lays out the contents sidebar and the reading column.
   Linked after auth.css and before design-system.css. Tokens only;
   square; flat. The legal text itself is verbatim (guarded by
   tests/unit/test_public_pages.py).
   ===================================================================== */

/* Wide: sunken contents column on the left (spanning the page), the
   heading and text in a 720px reading column on the right. Source order
   stays heading, contents, text. */
.legal {
    display: grid;
    flex: 1 0 auto;
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "toc head"
        "toc body";
}

.legal__head {
    grid-area: head;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 800px;
    padding: 56px 40px 8px;
}
.legal__title {
    font-size: 44px;
    line-height: 1.1;
    font-weight: 500;
    letter-spacing: -0.03em;
}
.last-updated {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.last-updated time { color: var(--text-primary); }

/* ----- Contents ----- */
.legal__toc {
    grid-area: toc;
    background: var(--surface-sunken);
    border-right: 1px solid var(--border);
}
.legal-toc {
    position: sticky;
    top: 0;
    padding: 32px 0;
}
.legal-toc__summary {
    display: block;
    padding: 0 16px 12px 18px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.4;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    list-style: none;
    cursor: default;
}
.legal-toc__summary::-webkit-details-marker { display: none; }
.legal-toc__nav {
    display: flex;
    flex-direction: column;
}
.pub .legal-toc__nav .c-nav { color: var(--text-primary); }
.pub .legal-toc__nav .c-nav:hover { text-decoration: none; }

/* ----- Reading column ----- */
.legal__body {
    grid-area: body;
    width: 100%;
    max-width: 800px;
    padding: 8px 40px 72px;
    font-size: 15px;
    line-height: 1.65;
}
.legal-part {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 720px;
    padding: 32px 0;
    border-bottom: 1px solid var(--border);
}
.legal-part:last-child { border-bottom: 0; }
.legal-h2 {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 500;
    letter-spacing: -0.01em;
    scroll-margin-top: 16px;
}
.legal-part h3 {
    margin-top: 12px;
    font-size: 16px;
    line-height: 1.35;
    font-weight: 600;
}
.legal-num {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 400;
    color: var(--accent-fg);
}
.pub .legal-part ul,
.pub .legal-part ol { padding-left: 22px; }
.legal-part li + li { margin-top: 6px; }
.legal-part strong { font-weight: 600; }
.legal-part em { color: var(--text-muted); }
.pub .legal-part .warning-box {
    max-width: none;
    padding: 14px 18px;
}
.pub .legal-part .warning-box p { color: var(--text-primary); }

/* ----- Narrow: contents collapse into a list above the text ----- */
@media (max-width: 900px) {
    .legal {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto 1fr;
        grid-template-areas:
            "head"
            "toc"
            "body";
    }
    .legal__head { padding: 40px 24px 20px; }
    .legal__toc {
        margin: 0 24px;
        border: 1px solid var(--border);
    }
    .legal-toc {
        position: static;
        padding: 0;
    }
    .legal-toc__summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        cursor: pointer;
    }
    .legal-toc__summary::after {
        content: "+";
        font-size: 16px;
        letter-spacing: 0;
    }
    .legal-toc[open] .legal-toc__summary::after { content: "\2212"; }
    .legal-toc[open] .legal-toc__nav {
        padding-bottom: 8px;
        border-top: 1px solid var(--border);
    }
    .legal__body { padding: 8px 24px 56px; }
}

@media (max-width: 600px) {
    .legal__head { padding: 32px 16px 16px; }
    .legal__title { font-size: 34px; }
    .legal__toc { margin: 0 16px; }
    .legal__body { padding: 8px 16px 48px; }
}
