/*
 * Legal pages (/tos, /privacy).
 * Base look comes from /articles/styles.css (top bar, breadcrumbs, hero,
 * prose, footer); this file adds what long legal text needs on top of it.
 */

/* Muted text that still reaches 4.5:1 on white (--text-muted is 3.7:1) */
.legal, footer { --legal-muted: #6b6761; }

/* Browser surfaces */
::selection { background: #F2E8DB; color: #0C3044; }
:focus-visible { outline: 2px solid #0C3044; outline-offset: 3px; border-radius: 4px; }
html { scroll-padding-top: 96px; }

/* Hero */
.hero-content .legal-lead {
    margin-top: 16px;
    max-width: 640px;
    font-size: 18px;
    line-height: 1.7;
    color: var(--text-dark);
    text-wrap: pretty;
}
.hero h1 { text-wrap: balance; }
/* Line the title up with the breadcrumbs and contents, not a centred column */
.legal-hero .hero-content { max-width: none; margin: 0; }

/* Layout: contents beside the text on wide screens, above it on narrow ones */
.legal {
    background: var(--background-light);
    padding: 56px 0 96px;
}
.legal-layout {
    display: grid;
    gap: 32px;
}
@media (min-width: 900px) {
    .legal-layout {
        grid-template-columns: 208px minmax(0, 1fr);
        gap: 56px;
        align-items: start;
    }
}

/* Contents */
.legal-toc {
    font-size: 14px;
    line-height: 1.45;
    background: var(--background-muted);
    border-radius: 12px;
    padding: 4px 16px;
}
.legal-toc summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: #0C3044;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.legal-toc summary::-webkit-details-marker { display: none; }
.legal-toc summary::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.2s ease;
}
.legal-toc[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.legal-toc ol {
    list-style: none;
    padding: 0 0 12px;
    margin: 0;
}
.legal-toc a {
    display: block;
    padding: 6px 10px;
    margin: 0 -10px;
    border-radius: 6px;
    color: var(--legal-muted);
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.legal-toc a:hover { color: var(--text-dark); background: rgba(0, 0, 0, 0.04); }
.legal-toc a[aria-current="true"] { color: #0C3044; font-weight: 500; background: #F2E8DB; }

@media (min-width: 900px) {
    .legal-toc {
        position: sticky;
        top: 96px;
        max-height: calc(100vh - 128px);
        overflow-y: auto;
        background: none;
        /* Room for the highlight, which reaches 10px past the text and
           would otherwise be clipped by the scroll box. */
        padding: 0 10px;
        margin: 0 -10px;
        border-radius: 0;
        scrollbar-width: thin;
        scrollbar-color: var(--border-light) transparent;
    }
    .legal-toc summary {
        cursor: default;
        pointer-events: none;
        padding: 0 0 12px;
        color: var(--legal-muted);
        font-family: 'Work Sans', sans-serif;
        font-weight: 500;
        font-size: 13px;
        letter-spacing: 0.02em;
    }
    .legal-toc summary::after { display: none; }
}

/* Text */
.legal .prose { max-width: 680px; margin: 0; }
.legal .prose h2 {
    font-size: 24px;
    color: #0C3044;
    margin: 56px 0 16px;
    line-height: 1.35;
    text-wrap: balance;
}
.legal .prose h2:first-child { margin-top: 0; }
.legal .prose h3 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 32px 0 12px;
    line-height: 1.4;
}
.legal .prose p { margin-bottom: 20px; text-wrap: pretty; }
.legal .prose ul {
    margin: 0 0 24px;
    padding-left: 1.3em;
}
.legal .prose li {
    margin-bottom: 12px;
    padding-left: 4px;
    line-height: 1.75;
}
.legal .prose li::marker { color: var(--text-muted); }
.legal .prose li:last-child { margin-bottom: 0; }

/* All-caps clauses stay legible: slightly smaller, a touch of tracking */
.legal .prose .legal-caps {
    font-size: 15px;
    letter-spacing: 0.015em;
    line-height: 1.85;
}

/* Pointer to the plain-language version */
.legal-aside {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    margin: 0 0 48px;
    padding: 20px 24px;
    background: var(--accent-yellow);
    border-radius: var(--radius);
}
.legal .prose .legal-aside p { margin: 0; flex: 1 1 280px; line-height: 1.55; }
.legal .prose .legal-aside a.btn {
    background: var(--text-dark);
    color: var(--background-light);
    text-decoration: none;
    white-space: nowrap;
}
.legal .prose .legal-aside a.btn:hover { background: #2a2825; }

/* Footer links (Cookie settings is added next to Privacy by consent.js) */
footer .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 20px;
    margin-top: 12px;
}
footer { color: var(--legal-muted); }
footer a {
    color: var(--legal-muted);
    text-decoration: underline;
    text-decoration-color: var(--border-light);
    text-underline-offset: 3px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
footer a:hover { color: var(--text-dark); text-decoration-color: currentColor; }

@media (max-width: 768px) {
    .legal { padding: 32px 0 64px; }
    .legal .prose h2 { font-size: 21px; margin-top: 44px; }
    .hero-content .legal-lead { font-size: 16px; }
    /* Article titles shrink to 20px for long headlines; these are short
       and must stay larger than the section headings. */
    .legal-hero h1 { font-size: 28px; line-height: 1.25; }
    .legal .prose .legal-caps { font-size: 14px; }
    .legal-aside { padding: 18px 16px; }
}

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