/* ===================================================================
   The privacy policy (src/pages/privacy-policy.html). Shared building blocks are in style/pages.css (.prose for the text);
   only this page's own parts go here. style/terms.css has the same layout for the terms.

   layout ...... .legal > nav.legal-toc (contents, sticky beside the text; scripts/privacy-policy.js marks .is-current) + article.prose
   short ....... .legal-short (the four-line summary at the top)
   table ....... td > .cell-k (the column name, shown above each cell on a phone, where the table becomes cards)
   =================================================================== */

.legal-sec {
    padding-top: clamp(36px, 5vw, 64px);
}

.legal {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    align-items: start;
    gap: clamp(32px, 5vw, 72px);
    max-width: 1120px;
    margin-inline: auto;
}

/* ===== contents ===== */

.legal-toc {
    position: sticky;
    top: calc(var(--header-height) + 20px);
    max-height: calc(100vh - var(--header-height) - 40px);
    overflow-y: auto;
    padding: 18px 12px 14px;

    border: 1px solid var(--color-border-soft);
    border-radius: 18px;
    background: var(--color-bg);
    box-shadow: var(--shadow-sm);
}

:root[data-theme="dark"] .legal-toc {
    border-color: var(--color-border);
    background: var(--color-bg-soft);
}

.legal-toc-title {
    padding-inline: 10px;

    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-text-soft);
}

.legal-toc ol {
    display: grid;
    gap: 2px;
    margin-top: 10px;
    padding: 0;
    list-style: none;
    counter-reset: toc;
}

.legal-toc li {
    counter-increment: toc;
}

.legal-toc a {
    display: flex;
    gap: 6px;
    padding: 6px 10px;

    border-inline-start: 3px solid transparent;
    border-radius: 8px;

    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text-soft);

    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.legal-toc a::before {
    content: counter(toc) ".";
    flex: none;
    min-width: 1.5em;
    color: var(--color-text-quiet);
    font-variant-numeric: tabular-nums;
}

.legal-toc a:hover {
    background: var(--color-bg-soft);
    color: var(--color-text);
}

:root[data-theme="dark"] .legal-toc a:hover {
    background: var(--color-bg);
}

.legal-toc a.is-current {
    border-inline-start-color: var(--color-green);
    background: var(--color-green-soft);
    color: var(--color-text);
}

/* ===== the text ===== */

.legal .prose {
    max-width: 74ch;
    margin-inline: 0;
}

.legal-short {
    padding: 18px 22px 20px;

    border: 1px solid color-mix(in srgb, var(--color-green) 30%, var(--color-border-soft));
    border-radius: 18px;
    background: var(--color-green-soft);
}

.legal-short-title {
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--green-text);
}

.prose .legal-short ul {
    margin-top: 8px;
    padding-inline-start: 0;
    list-style: none;
}

.legal-short li {
    position: relative;
    padding-inline-start: 26px;
    color: var(--color-text);
    font-weight: 600;
}

.legal-short li::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: .3em;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23052e16' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 11px no-repeat,
        var(--color-green);
}

/* the column names inside cells are for phones only */
.prose .cell-k {
    display: none;
}

@media (max-width: 960px) {

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

    .legal-toc {
        position: static;
        max-height: none;
    }

    .legal-toc ol {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: 8px;
    }
}

@media (max-width: 640px) {

    .legal-toc ol {
        grid-template-columns: minmax(0, 1fr);
    }

    .legal-short {
        padding: 16px 16px 18px;
    }

    /* the table becomes one card per row, each cell with its column name */
    .prose table,
    .prose tbody,
    .prose tr,
    .prose td {
        display: block;
    }

    /* (hidden the screen-reader way: the column names stay with the cells; each card also shows them in .cell-k) */
    .prose thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .prose tr {
        padding: 14px 16px;
        border: 1px solid var(--color-border);
        border-radius: 14px;
    }

    .prose tr + tr {
        margin-top: 10px;
    }

    .prose td {
        padding: 0;
        border: 0;
    }

    .prose td + td {
        margin-top: 8px;
    }

    .prose .cell-k {
        display: block;
        font-size: 12px;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--color-text-quiet);
    }
}
