/* Reading shell layered on landing.css. Solid colours only — the landing body
   gradients are replaced by a flat surface here, so a long document stays calm.

   Structure, not decoration: the number in the margin and the numbered index are
   what make this read as a document. Nothing animates on scroll. */

body.legal-page {
    min-height: 100dvh;
    margin: 0;
    background: var(--lp-bg);
    color: var(--lp-text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.legal-main {
    padding: clamp(1.75rem, 4vw, 3.25rem) 0 clamp(3rem, 6vw, 5rem);
}

.legal-article {
    max-width: 1180px;
}

/* ---------- Hero: title, one sentence, two facts ---------- */

.legal-hero {
    max-width: 44rem;
    padding-bottom: clamp(1.5rem, 3vw, 2.25rem);
    border-bottom: 1px solid var(--lp-border);
    margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.legal-hero h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3.6vw, 2.9rem);
    line-height: 1.14;
    letter-spacing: -.02em;
    font-weight: 700;
    text-wrap: balance;
}

.legal-lead {
    margin: .9rem 0 0;
    color: var(--lp-muted);
    font-size: clamp(1rem, 1.4vw, 1.08rem);
    line-height: 1.6;
    text-wrap: pretty;
}

.legal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 2.25rem;
    margin: 1.35rem 0 0;
}

.legal-meta div {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.legal-meta-icon {
    display: inline-flex;
    align-items: center;
    color: color-mix(in srgb, var(--lp-primary) 22%, var(--lp-text));
}

.legal-meta-icon .lp-svg-icon {
    width: 1rem;
    height: 1rem;
}

.legal-meta dt {
    color: var(--lp-muted);
    font-size: .82rem;
}

.legal-meta dd {
    margin: 0;
    font-size: .9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- Layout: index rail + document column ---------- */

.legal-layout {
    display: grid;
    grid-template-columns: minmax(0, 248px) minmax(0, 1fr);
    gap: clamp(1.75rem, 4vw, 4rem);
    align-items: start;
}

/* ---------- Index (table of contents) ---------- */

.legal-toc {
    position: sticky;
    top: calc(var(--lp-nav-h) + 1.25rem);
    max-height: calc(100dvh - var(--lp-nav-h) - 2.5rem);
    overflow-y: auto;
    font-size: .86rem;
    scrollbar-width: thin;
}

.legal-toc-details > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    cursor: pointer;
    padding: 0 0 .7rem;
    margin-bottom: .35rem;
    border-bottom: 1px solid var(--lp-border);
    color: var(--lp-muted);
    font-size: .78rem;
    font-weight: 600;
    list-style: none;
}

.legal-toc-details > summary::-webkit-details-marker {
    display: none;
}

.legal-toc-count {
    padding: .05rem .45rem;
    border: 1px solid var(--lp-border);
    border-radius: 999px;
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.legal-toc ol {
    margin: 0;
    padding: 0;
    list-style: none;
}

.legal-toc a {
    display: grid;
    grid-template-columns: 1.1rem 1fr;
    gap: .55rem;
    align-items: start;
    padding: .44rem 0 .44rem .55rem;
    margin-left: -.55rem;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    color: var(--lp-muted);
    text-decoration: none;
    line-height: 1.4;
}

.legal-toc-icon {
    display: inline-flex;
    padding-top: .18rem;
    /* Lifted off the base accent so the glyph stays legible on the dark rail at 15px. */
    color: color-mix(in srgb, var(--lp-primary) 22%, var(--lp-text));
}

.legal-toc-icon .lp-svg-icon {
    width: 1rem;
    height: 1rem;
}

.legal-toc a:hover .legal-toc-icon,
.legal-toc a.is-active .legal-toc-icon {
    color: var(--lp-primary-text);
}

.legal-toc-label {
    display: block;
}

.legal-toc a:hover,
.legal-toc a:focus-visible {
    color: var(--lp-text);
    border-left-color: color-mix(in srgb, var(--lp-primary) 45%, transparent);
}

.legal-toc a.is-active {
    color: var(--lp-text);
    border-left-color: var(--lp-primary);
    background: color-mix(in srgb, var(--lp-primary) 8%, transparent);
    font-weight: 600;
}

.legal-toc-num {
    margin-right: .4rem;
    color: color-mix(in srgb, var(--lp-primary) 55%, var(--lp-muted));
    font-variant-numeric: tabular-nums;
    font-size: .78rem;
    font-weight: 600;
}

.legal-toc a.is-active .legal-toc-num {
    color: var(--lp-primary-text);
}

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

.legal-body {
    max-width: 66ch;
}

.legal-section {
    padding: clamp(1.15rem, 2.4vw, 1.6rem);
    margin-bottom: clamp(.9rem, 1.8vw, 1.2rem);
    border: 1px solid var(--lp-border);
    border-radius: var(--lp-radius);
    background: color-mix(in srgb, var(--lp-surface) 55%, transparent);
    scroll-margin-top: calc(var(--lp-nav-h) + 1.5rem);
}

/* The card is a surface, not a button: it must not lift on hover. */
.legal-section:last-of-type {
    margin-bottom: 0;
}

.legal-section h2 {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .85rem;
    /* A wrapped heading must keep the badge level with its first line, not centred
       against a two-line block. */
    align-items: start;
    margin: 0 0 1.1rem;
    font-size: clamp(1.15rem, 1.9vw, 1.4rem);
    line-height: 1.28;
    font-weight: 700;
    text-wrap: balance;
}

/* Icon + number sit in one solid block, so a section is recognisable at a glance
   instead of being an undifferentiated run of headings. */
.legal-section-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    /* Pulled up so the badge's optical centre matches the first line of the heading. */
    margin-top: -.35rem;
    border: 1px solid color-mix(in srgb, var(--lp-primary) 34%, var(--lp-border));
    border-radius: 10px;
    background: color-mix(in srgb, var(--lp-primary) 12%, transparent);
    color: var(--lp-primary-text);
}

.legal-section-badge .lp-svg-icon {
    width: 1.15rem;
    height: 1.15rem;
}

.legal-section-num {
    position: absolute;
    right: -.35rem;
    bottom: -.35rem;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 .2rem;
    border-radius: 999px;
    background: var(--lp-primary);
    color: var(--lp-on-primary, #fff);
    font-size: .72rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    line-height: 1.25rem;
    text-align: center;
}

.legal-section p {
    margin: 0 0 1rem;
    line-height: 1.78;
    color: color-mix(in srgb, var(--lp-text) 90%, var(--lp-muted));
    text-wrap: pretty;
}

.legal-section ul,
.legal-section dl {
    margin: 0 0 1.15rem;
    padding-left: 1.15rem;
}

.legal-section li {
    margin-bottom: .55rem;
    line-height: 1.72;
    color: color-mix(in srgb, var(--lp-text) 90%, var(--lp-muted));
}

.legal-section dt {
    margin-top: .9rem;
    font-weight: 600;
}

.legal-section dd {
    margin: .2rem 0 0;
    line-height: 1.72;
    color: color-mix(in srgb, var(--lp-text) 90%, var(--lp-muted));
}

.legal-placeholder {
    padding: 0 .2em;
    border-radius: 3px;
    background: color-mix(in srgb, var(--lp-warning) 26%, transparent);
    color: var(--lp-text);
    font-weight: 600;
}

.legal-disclaimer {
    margin-top: 2.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--lp-border);
    color: var(--lp-muted);
    font-size: .86rem;
    line-height: 1.6;
}

/* ---------- Mobile: the index collapses to a single row ---------- */

@media (max-width: 991.98px) {
    .legal-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Without open, the summary is the collapsed bar; the list only appears on tap, so
       eleven entries no longer push the article below the fold. */
    .legal-toc {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 1.5rem;
        border: 1px solid var(--lp-border);
        border-radius: var(--lp-radius);
        padding: 0 1rem;
        background: var(--lp-glass);
    }

    .legal-toc-details > summary {
        padding: .85rem 0;
        margin-bottom: 0;
        border-bottom: 0;
    }

    .legal-toc-details[open] > summary {
        border-bottom: 1px solid var(--lp-border);
        margin-bottom: .6rem;
    }

    .legal-toc-details[open] ol {
        padding-bottom: .75rem;
    }

    .legal-section h2 {
        grid-template-columns: 1.6rem 1fr;
        gap: .4rem;
    }
}

@media (max-width: 575.98px) {
    .legal-meta {
        gap: 0 1.5rem;
    }
}

/* ---------- Shared footer link groups ---------- */

/* One link group per layout, with its own label, instead of legal links trailed after
   a copyright line where nothing marks them as a group. */

/* Footer link groups are NOT styled here. Each one lives in the stylesheet its layout
   actually loads: landing.css for the public footer, main-theme.css for the app and auth
   shells. Declaring them in this file meant they never applied. */

@media (prefers-reduced-motion: reduce) {
    .legal-toc {
        scroll-behavior: auto;
    }
}
