/* Shared styles for #terms and #privacy pages */

/*
 * Both language versions of each document ship in the page; this picks the one that
 * matches <html lang>, which initLocale sets. English is the default so the page is
 * never blank if lang is missing or some third locale appears — the Dutch version is
 * the binding one, but showing the wrong language beats showing none.
 */
/* Scoped to the two things that ship both languages at once — the documents and the
 * per-release change summaries. This file is linked from <head> on every route, so an
 * unscoped [data-legal-lang] rule would hide any future element carrying that attribute
 * anywhere in the app, and force display:block on it in a Dutch UI. */
.legal-doc[data-legal-lang="nl"],
.legal-changes [data-legal-lang="nl"] {
    display: none;
}

:root[lang="nl"] .legal-doc[data-legal-lang="nl"],
:root[lang="nl"] .legal-changes [data-legal-lang="nl"] {
    display: block;
}

:root[lang="nl"] .legal-doc[data-legal-lang="en"],
:root[lang="nl"] .legal-changes [data-legal-lang="en"] {
    display: none;
}

/*
 * The reader's own override, set by the toggle in each document's header. The Dutch
 * text is the binding one, so someone on an English UI has to be able to open it —
 * being asked to accept a document the interface never shows is not a real choice.
 */
.legal-page[data-legal-show="nl"] .legal-doc[data-legal-lang="nl"],
.legal-page[data-legal-show="nl"] .legal-changes [data-legal-lang="nl"],
.legal-page[data-legal-show="en"] .legal-doc[data-legal-lang="en"],
.legal-page[data-legal-show="en"] .legal-changes [data-legal-lang="en"] {
    display: block;
}

.legal-page[data-legal-show="nl"] .legal-doc[data-legal-lang="en"],
.legal-page[data-legal-show="nl"] .legal-changes [data-legal-lang="en"],
.legal-page[data-legal-show="en"] .legal-doc[data-legal-lang="nl"],
.legal-page[data-legal-show="en"] .legal-changes [data-legal-lang="nl"] {
    display: none;
}

.legal-switch {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--color-primary, #1172b9);
    text-decoration: underline;
    cursor: pointer;
}

/* Asides that are about the document rather than part of it: the precedence note and
   the reason our address is not on the page. */
.legal-note {
    margin: 0.75rem 0 0;
    padding: 0.6rem 0.85rem;
    border-left: 3px solid var(--color-border);
    background: var(--color-gray-6);
    font-size: 0.9rem;
    color: var(--color-gray-2);
}

.legal-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    line-height: 1.7;
    color: var(--color-gray-1);
}

.legal-page__header {
    margin-bottom: 1.5rem;
}

.legal-page__title {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    line-height: 1.3;
}

.legal-page__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-gray-3);
}

.legal-page__back {
    color: var(--color-link);
    text-decoration: none;
}
.legal-page__back:hover {
    text-decoration: underline;
}

/* Table of contents */

.legal-toc {
    background: var(--color-gray-6);
    border: 1px solid var(--color-border);
    border-radius: var(--roundness-3);
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
}

.legal-toc__title {
    font-size: 1rem;
    margin: 0 0 0.5rem;
}

.legal-toc__list {
    margin: 0;
    padding-left: 1.25rem;
    columns: 1;
    column-gap: 2rem;
}

.legal-toc__list li {
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    break-inside: avoid;
}

.legal-toc__list a {
    color: var(--color-link);
    text-decoration: none;
}
.legal-toc__list a:hover {
    text-decoration: underline;
}

@media (min-width: 600px) {
    .legal-toc__list {
        columns: 2;
    }
}

/* Sections */

.legal-section {
    margin-bottom: 2rem;
    scroll-margin-top: calc(var(--topbar-h, 48px) + 1rem);
}

.legal-section h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
    border-bottom: 1px solid var(--color-gray-5);
    padding-bottom: 0.35rem;
}

.legal-section h3 {
    font-size: 1rem;
    margin: 1rem 0 0.4rem;
}

.legal-section p,
.legal-section ul,
.legal-section ol {
    margin: 0.5rem 0;
}

.legal-section ul,
.legal-section ol {
    padding-left: 1.5rem;
}

.legal-section li {
    margin-bottom: 0.25rem;
}

/* Legal bases table (privacy page) */

.legal-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

.legal-table th,
.legal-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    vertical-align: top;
}

.legal-table th {
    background: var(--color-gray-6);
    font-weight: 600;
}

.legal-table tr:nth-child(even) td {
    background: var(--color-gray-7);
}

/* Accept section */

.legal-accept {
    background: var(--color-gray-6);
    border: 2px solid var(--color-link);
    border-radius: var(--roundness-3);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.legal-accept h2 {
    border-bottom: none;
    padding-bottom: 0;
}

.legal-accept .btn--primary {
    margin-top: 0.75rem;
}

/* Print styles */

@media print {
    .legal-page {
        max-width: none;
        padding: 0;
        color: #000;
    }

    .legal-page__back,
    #topBar,
    #mainNav,
    .app-footer {
        display: none !important;
    }

    .legal-toc {
        background: #f8f8f8;
        border-color: #ccc;
    }

    .legal-section {
        break-inside: avoid;
    }

    .legal-section a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    .legal-section a[href^="#"]::after {
        content: none;
    }
}

/* Mobile adjustments */

@media (max-width: 767px) {
    .legal-page {
        padding: 1rem 0.75rem 2rem;
    }

    .legal-page__title {
        font-size: 1.4rem;
    }

    .legal-table {
        font-size: 0.8rem;
    }

    .legal-table th,
    .legal-table td {
        padding: 0.35rem 0.5rem;
    }
}
