/*
 * Legal pages: Terms and Conditions, Privacy Policy, About Us (home/docs/templates/docs/).
 * Loaded after dashboard.css (tokens, .dash, .dash-header) and guide.css (.guide-layout, .guide-toc: same sidebar as
 * the Rules page). Change markup and styles here; change the legal wording only when the owner asks.
 * The Terms use numbered clauses (.legal-clause + .legal-num) and (a)/(b) lists (.legal-alpha) so sections can be cited.
 */

/* Title block: document name, then "Last updated" */
.legal .dash-header {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--d-border);
    margin-bottom: 28px;
}

.legal .legal-updated {
    margin-top: 6px;
    font-size: 14px;
    color: var(--d-faint);
}

/* ---------- Document ---------- */

.legal-doc {
    max-width: 760px;
    font-size: 15.5px;
    line-height: 1.75;
    color: hsla(0, 0%, 100%, 0.78);
}

.legal .legal-doc p + p,
.legal .legal-doc p + ul,
.legal .legal-doc ul + p {
    margin-top: 14px;
}

.legal .legal-doc .legal-lead {
    margin-bottom: 32px;
    font-size: 17px;
    line-height: 1.7;
    color: hsla(0, 0%, 100%, 0.86);
}

.legal-section {
    scroll-margin-top: calc(var(--site-header-height, 60px) + 24px);   /* TOC jumps land below the fixed header */
}

.legal-section + .legal-section {
    margin-top: 30px;
    padding-top: 28px;
    border-top: 1px solid var(--d-border);
}

.legal-doc h2 {
    margin-bottom: 12px;
    font-size: 19px;
    letter-spacing: -0.005em;
}

/* Lists: real bullets in place of the hand-typed "- " markers */
.legal-doc .legal-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.legal-doc .legal-list > li {
    position: relative;
    padding-left: 22px;
}

.legal-doc .legal-list > li::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 0.72em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--d-faint);
}

.legal .legal-doc a {
    color: var(--d-accent);
    text-decoration: underline;
    text-decoration-color: var(--d-accent-line);
    text-underline-offset: 3px;
}

.legal .legal-doc a:hover {
    text-decoration-color: currentColor;
}

.legal-doc strong {
    font-weight: 600;
    color: #fff;
}

/* ---------- Numbered clauses (Terms): "6.5" in a narrow column, the text beside it ---------- */

.legal-doc .legal-clause {
    display: grid;
    grid-template-columns: 3em minmax(0, 1fr);
    column-gap: 10px;
}

.legal-doc .legal-clause > * {
    grid-column: 2;
}

.legal-doc .legal-clause > .legal-num {
    grid-column: 1;
    grid-row: 1;
}

.legal .legal-doc .legal-clause + .legal-clause {
    margin-top: 14px;
}

.legal .legal-doc .legal-clause > p + ol {
    margin-top: 10px;
}

.legal-doc .legal-num {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--d-faint);
}

/* (a), (b), (c) sub-lists inside a clause */
.legal-doc .legal-alpha {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: legal-alpha;
}

.legal-doc .legal-alpha > li {
    position: relative;
    padding-left: 2.1em;
    counter-increment: legal-alpha;
}

.legal-doc .legal-alpha > li::before {
    content: '(' counter(legal-alpha, lower-alpha) ')';
    position: absolute;
    left: 0;
    color: var(--d-faint);
}

/* The all-caps warranty disclaimer reads better a touch smaller */
.legal .legal-doc .legal-caps {
    font-size: 14px;
    letter-spacing: 0.01em;
}

/* ---------- Long contents list (Terms has 20 sections) ---------- */

.legal nav.guide-toc--compact {
    max-height: calc(100vh - 108px);   /* stays usable while sticky on short screens */
    overflow-y: auto;
}

.legal .guide-toc--compact a {
    gap: 8px;
    padding: 5px 10px;
    font-size: 13.5px;
}

.legal-toc-num {
    min-width: 1.4em;
    font-variant-numeric: tabular-nums;
    color: var(--d-faint);
}

/* guide.css hides the contents under 900px; a long legal page still needs it, so show it above the text in two columns */
@media (max-width: 900px) {
    .legal .guide-layout nav.guide-toc--compact {
        display: block;
        position: static;
        max-height: none;
        columns: 2;
        column-gap: 8px;
    }

    .legal .guide-toc--compact .guide-toc__title {
        column-span: all;
    }

    .legal .guide-toc--compact a {
        break-inside: avoid;
    }
}

/* Closing acknowledgement (end of the Terms) */
.legal .legal-doc .legal-ack {
    margin-top: 32px;
    padding: 16px 18px;
    border: 1px solid var(--d-border);
    border-left: 3px solid var(--d-accent);
    border-radius: var(--d-radius-sm);
    background: var(--d-bg-card);
    color: hsla(0, 0%, 100%, 0.86);
}

/* About Us has no table of contents: one column */
.legal-single .legal-doc {
    max-width: 760px;
}

@media (max-width: 600px) {
    .legal-doc {
        font-size: 15px;
    }

    .legal .legal-doc .legal-lead {
        font-size: 16px;
    }

    .legal-doc .legal-clause {
        grid-template-columns: 2.7em minmax(0, 1fr);
        column-gap: 6px;
    }
}
