/* ==========================================================================
   Legal documents — privacy policy, terms & conditions.
   Two columns: a sticky contents list on the left, the numbered document on
   the right. Loaded by page.php only for the pages in kxp_legal_slugs().
   Depends on prose.css for the typography inside .kxp-legal__body.
   ========================================================================== */

.kxp-legal {
    display: grid;
    gap: clamp(2rem, 4vw, 4.5rem);
    /* The measure is what matters here; the document column is capped rather
       than stretched across a 1520px shell. */
    max-width: 1180px;
}

@media (min-width: 1024px) {
    .kxp-legal { grid-template-columns: 17rem minmax(0, 1fr); }
}

/* ── Contents ───────────────────────────────────────────────────────────── */
.kxp-legal__aside { min-width: 0; }

.kxp-legal__disclosure {
    background: var(--kxp-grey-50);
    border: 1px solid var(--kxp-grey-100);
    clip-path: polygon(
        var(--kxp-chamfer) 0, 100% 0, 100% calc(100% - var(--kxp-chamfer)),
        calc(100% - var(--kxp-chamfer)) 100%, 0 100%, 0 var(--kxp-chamfer)
    );
}

.kxp-legal__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    font-family: var(--kxp-font-display);
    font-size: var(--kxp-step--1);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--kxp-black);
}
.kxp-legal__summary::-webkit-details-marker { display: none; }

/* A chevron drawn from two borders — no icon font, no extra request. */
.kxp-legal__summary-cue {
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--kxp-accent);
    border-bottom: 2px solid var(--kxp-accent);
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.3s var(--kxp-ease);
}
.kxp-legal__disclosure[open] .kxp-legal__summary-cue { transform: translateY(2px) rotate(-135deg); }

.kxp-legal__toc { padding: 0 1.25rem 1.25rem; }
.kxp-legal__toc-title { display: none; }

.kxp-legal__toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--kxp-grey-100);
}
.kxp-legal__toc-list li + li { border-top: 1px solid var(--kxp-grey-100); }

.kxp-legal__toc-list a {
    display: grid;
    grid-template-columns: 1.6rem 1fr;
    gap: 0.35rem;
    align-items: baseline;
    padding: 0.7rem 0;
    font-size: var(--kxp-step--1);
    line-height: 1.4;
    color: var(--kxp-grey-700);
    transition: color 0.25s var(--kxp-ease);
}
.kxp-legal__toc-list a:hover { color: var(--kxp-black); }
.kxp-legal__toc-num { color: var(--kxp-grey-500); font-variant-numeric: tabular-nums; }
.kxp-legal__toc-list a:hover .kxp-legal__toc-num { color: var(--kxp-accent); }

.kxp-legal__toc-list a.is-current { color: var(--kxp-black); font-weight: 600; }
.kxp-legal__toc-list a.is-current .kxp-legal__toc-num { color: var(--kxp-accent); }

@media (min-width: 1024px) {
    /* On desktop the list is not a disclosure at all — it is always open and
       follows the reader down the page. */
    .kxp-legal__disclosure {
        position: sticky;
        top: calc(var(--kxp-hdr-h, 113px) + 1.5rem);
        max-height: calc(100vh - var(--kxp-hdr-h, 113px) - 3rem);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
    /* A long document overflows the list — fade the last row so it reads as
       "there is more", not as a list that simply stops. The class is set by the
       template's script only when it actually overflows, so a short document
       (the privacy policy) keeps a hard, unfaded edge. */
    .kxp-legal__disclosure.is-scrollable {
        -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent 100%);
        mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent 100%);
    }
    .kxp-legal__summary { display: none; }
    .kxp-legal__toc { padding: 1.25rem; }
    .kxp-legal__toc-title {
        display: block;
        margin: 0 0 0.75rem;
        font-family: var(--kxp-font-display);
        font-size: var(--kxp-step--1);
        font-weight: 700;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        color: var(--kxp-grey-500);
    }
}

/* ── Document ───────────────────────────────────────────────────────────── */
.kxp-legal__body { max-width: 72ch; }

.kxp-legal__intro {
    padding-bottom: clamp(1.5rem, 3vw, 2.25rem);
    border-bottom: 1px solid var(--kxp-grey-100);
    font-size: var(--kxp-step-0);
    color: var(--kxp-grey-700);
}
.kxp-legal__intro > * + * { margin-top: 1.2em; }
/* The opening sentence carries the document; give it a little more weight. */
.kxp-legal__intro > p:first-child {
    font-size: var(--kxp-step-1);
    line-height: 1.55;
    color: var(--kxp-black);
    letter-spacing: -0.01em;
}

.kxp-legal__sec {
    /* Anchor jumps have to clear the fixed header. */
    scroll-margin-top: calc(var(--kxp-hdr-h, 113px) + 1.5rem);
    padding-top: clamp(2.25rem, 5vw, 3.5rem);
}

.kxp-legal__h {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.85rem;
    /* Start, not centre: on a heading that wraps to two lines a centred badge
       floats down beside the second line. */
    align-items: start;
    margin: 0 0 1.25rem;
    font-size: var(--kxp-step-1);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--kxp-black);
}

.kxp-legal__num {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    background: var(--kxp-accent);
    color: var(--kxp-white);
    font-size: var(--kxp-step--1);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    /* The badge is taller than one line of the heading — nudge it back up so it
       sits optically centred on the first line. */
    margin-top: -3px;
    clip-path: polygon(6px 0, 100% 0, 100% calc(100% - 6px), calc(100% - 6px) 100%, 0 100%, 0 6px);
}

/* prose.css spaces every heading from above; inside a section the badge row is
   already the top of the block. */
.kxp-legal__body .kxp-legal__h { margin-top: 0; }
.kxp-legal__sec > :first-child { margin-top: 0; }

.kxp-legal__sec h3 {
    margin-top: 2em;
    font-size: var(--kxp-step-0);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--kxp-black);
}

/* Numbered clauses read as a contract, not as a blog list. */
.kxp-legal__sec ol {
    counter-reset: kxp-clause;
    list-style: none;
    padding-left: 0;
}
.kxp-legal__sec ol > li {
    counter-increment: kxp-clause;
    position: relative;
    padding-left: 2.6rem;
}
.kxp-legal__sec ol > li::before {
    content: counter(kxp-clause) ".";
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--kxp-accent);
}
.kxp-legal__sec ol > li + li { margin-top: 0.9em; }
/* Bullets nested inside a clause keep their indent under the clause text. */
.kxp-legal__sec ol ul { margin-top: 0.6em; padding-left: 1.1em; }
.kxp-legal__sec ol ul > li { padding-left: 0; }

/* ── The company block that closes the privacy policy ───────────────────── */
.kxp-legal__entity {
    margin-top: 1.5rem;
    padding: clamp(1.25rem, 3vw, 1.75rem);
    background: var(--kxp-black);
    color: var(--kxp-white);
    clip-path: polygon(
        var(--kxp-chamfer) 0, 100% 0, 100% calc(100% - var(--kxp-chamfer)),
        calc(100% - var(--kxp-chamfer)) 100%, 0 100%, 0 var(--kxp-chamfer)
    );
}
.kxp-legal__entity-name {
    margin: 0 0 0.9rem;
    font-family: var(--kxp-font-display);
    font-size: var(--kxp-step-1);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--kxp-white);
}
.kxp-legal__entity dl {
    display: grid;
    gap: 0.5rem 1.5rem;
    margin: 0;
    font-size: var(--kxp-step--1);
}
@media (min-width: 520px) { .kxp-legal__entity dl { grid-template-columns: 9rem 1fr; } }
.kxp-legal__entity dt {
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--kxp-grey-500);
}
.kxp-legal__entity dd { margin: 0; color: var(--kxp-white); }
.kxp-legal__entity a { color: var(--kxp-white); border-bottom: 1px solid rgba(255, 255, 255, 0.35); }
.kxp-legal__entity a:hover { color: #ff3b30; border-bottom-color: #ff3b30; }

/* ── Callout: the one or two lines that must not be skimmed past ────────── */
.kxp-legal__note {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    background: var(--kxp-grey-50);
    border-left: 3px solid var(--kxp-accent);
    font-size: var(--kxp-step--1);
    line-height: 1.7;
    color: var(--kxp-black);
}
.kxp-legal__note strong { display: block; margin-bottom: 0.2rem; }

/* ── Effective date ─────────────────────────────────────────────────────── */
.kxp-legal__effective {
    margin-top: clamp(2.5rem, 5vw, 3.5rem);
    padding-top: 1.5rem;
    border-top: 1px solid var(--kxp-grey-100);
    font-size: var(--kxp-step--1);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--kxp-grey-500);
}
