/* ==========================================================================
   Legal pages (Privacy Policy, Terms of Service, Data Requests)
   Builds on style.css: same tokens, navbar and footer.
   ========================================================================== */

:root {
    color-scheme: dark;
    --nav-height: 73px;
    --legal-max: 1180px;
    --prose-max: 760px;
    --text-body: #CBD5E1;
    --text-muted: #94A3B8;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.14);
    --card: rgba(255, 255, 255, 0.025);
    --card-hover: rgba(255, 255, 255, 0.045);
    --accent-soft: rgba(99, 102, 241, 0.12);
    --accent-text: #A5B4FC;
    --ok: #34D399;
    --ok-soft: rgba(52, 211, 153, 0.12);
    --warn: #FBBF24;
    --warn-soft: rgba(251, 191, 36, 0.10);
}

/* only on the legal pages: the home page scrolls with Lenis, which native smooth scrolling would fight */
html:has(body.legal) { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html:has(body.legal) { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

body.legal { background: var(--bg-dark); }

/* Skip link ------------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 2000;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--accent-primary);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}
.skip-link:focus { top: 12px; }

:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 3px;
    border-radius: 6px;
}

/* Reading progress ------------------------------------------------------ */
.read-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: 0 50%;
    transform: scaleX(0);
    background: var(--accent-gradient);
    z-index: 1100;
}

/* Navbar additions (menu button + mobile drawer) ------------------------ */
.nav-links a[aria-current="page"] { color: var(--text-primary); }

.nav-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.nav-toggle svg { width: 22px; height: 22px; }
.nav-toggle .icon-close { display: none; }
.nav-open .nav-toggle .icon-open { display: none; }
.nav-open .nav-toggle .icon-close { display: block; }

@media (max-width: 992px) {
    .nav-toggle { display: inline-flex; }
    .nav-container > .btn { display: none; }
    .navbar .nav-links {
        display: flex;
        /* the navbar's backdrop-filter makes it the containing block, so 100% is exactly its height */
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 4px;
        padding: 12px 16px 20px;
        background: var(--bg-dark);
        box-shadow: 0 24px 40px rgba(0, 0, 0, 0.5);
        border-bottom: 1px solid var(--glass-border);
        transform: translateY(-8px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
    }
    .nav-open .navbar .nav-links {
        opacity: 1;
        transform: none;
        visibility: visible;
    }
    .navbar .nav-links a {
        display: block;
        padding: 12px 14px;
        border-radius: 10px;
        font-size: 1rem;
    }
    .navbar .nav-links a:hover,
    .navbar .nav-links a[aria-current="page"] { background: rgba(255, 255, 255, 0.05); }
}

/* Hero ------------------------------------------------------------------ */
.legal-hero {
    position: relative;
    padding: calc(var(--nav-height) + 64px) 0 48px;
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}
.legal-hero::before {
    content: "";
    position: absolute;
    inset: -40% -10% auto;
    height: 520px;
    background: radial-gradient(ellipse at 30% 40%, rgba(99, 102, 241, 0.18) 0%, rgba(5, 5, 10, 0) 65%);
    pointer-events: none;
}
.legal-hero .container { position: relative; max-width: var(--legal-max); }

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb li + li::before { content: "/"; margin-right: 8px; opacity: 0.5; }

.legal-hero h1 {
    font-size: clamp(2.1rem, 5vw, 3.4rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
}
.legal-hero .lead {
    max-width: 720px;
    color: var(--text-body);
    font-size: 1.08rem;
    line-height: 1.7;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 100px;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.82rem;
    color: var(--text-body);
}
.pill strong { color: var(--text-primary); font-weight: 600; }
.pill svg { width: 15px; height: 15px; color: var(--accent-text); flex-shrink: 0; }

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}
.btn-sm { padding: 9px 18px; font-size: 0.88rem; }

/* Layout ---------------------------------------------------------------- */
.legal-layout {
    max-width: var(--legal-max);
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 64px;
    padding-top: 48px;
    padding-bottom: 96px;
}

/* Table of contents ----------------------------------------------------- */
.toc { position: relative; }
.toc-box {
    position: sticky;
    top: calc(var(--nav-height) + 24px);
    max-height: calc(100vh - var(--nav-height) - 48px);
    overflow-y: auto;
    scrollbar-width: thin;
}
.toc-box summary {
    list-style: none;
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 14px;
    cursor: default;
}
.toc-box summary::-webkit-details-marker { display: none; }
.toc-box ol { list-style: none; border-left: 1px solid var(--line); }
.toc-box a {
    display: block;
    margin-left: -1px;
    padding: 6px 0 6px 16px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    line-height: 1.45;
    transition: color 0.2s, border-color 0.2s;
}
.toc-box a:hover { color: var(--text-primary); }
.toc-box a.is-active {
    color: var(--text-primary);
    border-left-color: var(--accent-primary);
}
.toc-box .toc-sub a { padding-left: 30px; font-size: 0.83rem; }

/* Prose ----------------------------------------------------------------- */
.prose {
    max-width: var(--prose-max);
    color: var(--text-body);
    font-size: 1rem;
    line-height: 1.75;
    min-width: 0;
}
.prose section { padding-top: 8px; }
.prose section + section { margin-top: 48px; }
.prose h2, .prose h3 { scroll-margin-top: calc(var(--nav-height) + 20px); }
.prose h2 {
    position: relative;
    font-size: 1.55rem;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 18px;
    letter-spacing: -0.01em;
}
.prose h2 .num {
    display: inline-block;
    min-width: 2.1em;
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
}
.prose h3 {
    font-size: 1.12rem;
    color: #E2E8F0;
    margin: 30px 0 10px;
}
.prose h4 {
    font-size: 0.98rem;
    color: #E2E8F0;
    margin: 22px 0 8px;
}
.prose p { margin-bottom: 14px; }
.prose ul, .prose ol { margin: 0 0 18px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--accent-text); }
.prose strong { color: var(--text-primary); font-weight: 600; }
/* text links only: buttons inside the text (request cards) keep the site's own button look */
.prose a:not(.btn) {
    color: var(--accent-text);
    text-decoration: underline;
    text-decoration-color: rgba(165, 180, 252, 0.35);
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}
.prose a:not(.btn):hover { text-decoration-color: currentColor; }
.prose code {
    font-size: 0.88em;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
}

/* Heading anchor link */
.anchor {
    margin-left: 8px;
    opacity: 0;
    color: var(--text-muted);
    text-decoration: none !important;
    font-weight: 400;
    transition: opacity 0.2s;
}
.prose h2:hover .anchor, .prose h3:hover .anchor, .anchor:focus { opacity: 1; }

/* Cards and callouts ---------------------------------------------------- */
.callout {
    display: flex;
    gap: 14px;
    padding: 18px 20px;
    margin: 20px 0;
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.28);
    background: var(--accent-soft);
}
.callout svg { width: 20px; height: 20px; flex-shrink: 0; margin-top: 3px; color: var(--accent-text); }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.ok { border-color: rgba(52, 211, 153, 0.3); background: var(--ok-soft); }
.callout.ok svg { color: var(--ok); }
.callout.warn { border-color: rgba(251, 191, 36, 0.3); background: var(--warn-soft); }
.callout.warn svg { color: var(--warn); }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 20px 0 8px;
}
.summary-card {
    padding: 18px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--card);
    transition: background 0.2s, border-color 0.2s;
}
.summary-card:hover { background: var(--card-hover); border-color: var(--line-strong); }
.summary-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 1rem;
}
.summary-card h3 svg { width: 18px; height: 18px; color: var(--accent-text); flex-shrink: 0; }
.summary-card p { margin: 0; font-size: 0.92rem; color: var(--text-muted); line-height: 1.6; }

.app-card {
    margin: 24px 0;
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-strong);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(255, 255, 255, 0.015) 100%);
}
.app-card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}
.app-badge {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--accent-gradient);
    flex-shrink: 0;
}
.app-badge svg { width: 26px; height: 26px; color: #fff; }
.app-card-head h3 { margin: 0; font-size: 1.15rem; }
.app-card-head p { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted); }
.app-card dl {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px 18px;
    font-size: 0.92rem;
}
.app-card dt { color: var(--text-muted); }
.app-card dd { color: var(--text-body); overflow-wrap: anywhere; }

/* Tables ---------------------------------------------------------------- */
.table-wrap {
    margin: 18px 0 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrap table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 0.9rem;
    line-height: 1.55;
}
.table-wrap th, .table-wrap td {
    padding: 12px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}
.table-wrap th {
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.035);
    white-space: nowrap;
}
.table-wrap tr:last-child td { border-bottom: none; }
.table-wrap td:first-child { color: var(--text-primary); font-weight: 500; }

.tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}
.tag.local { background: var(--ok-soft); color: var(--ok); }
.tag.server { background: var(--accent-soft); color: var(--accent-text); }
.tag.optin { background: var(--warn-soft); color: var(--warn); }

/* Accordions (region-specific rights) ----------------------------------- */
.accordion { margin: 18px 0; display: grid; gap: 10px; }
.accordion details {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--card);
    overflow: hidden;
}
.accordion details[open] { border-color: var(--line-strong); }
.accordion summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--text-primary);
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::after {
    content: "";
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-top: -4px;
}
.accordion details[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
.accordion .acc-body { padding: 0 20px 18px; }
.accordion .acc-body > :last-child { margin-bottom: 0; }

/* Contact block --------------------------------------------------------- */
.contact-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}
.contact-card > div {
    padding: 18px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: var(--card);
}
.contact-card .label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

/* Request cards (data request page) ------------------------------------- */
.request-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 22px 0;
}
.request-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: var(--card);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.request-card:hover { border-color: var(--line-strong); background: var(--card-hover); transform: translateY(-2px); }
.request-card .icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-text);
    margin-bottom: 14px;
}
.request-card .icon svg { width: 22px; height: 22px; }
.request-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.request-card p { font-size: 0.92rem; color: var(--text-muted); flex: 1; }
.request-card .btn { align-self: flex-start; margin-top: 8px; text-decoration: none; }

.steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.steps li {
    counter-increment: step;
    position: relative;
    padding-left: 46px;
    margin-bottom: 16px;
}
.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    background: var(--accent-gradient);
}

/* Back to top ----------------------------------------------------------- */
.to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(15, 15, 25, 0.85);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
    z-index: 900;
}
.to-top.show { opacity: 1; visibility: visible; transform: none; }
.to-top svg { width: 20px; height: 20px; }

/* Footer additions ------------------------------------------------------ */
.footer-brand .footer-note { max-width: 320px; line-height: 1.6; }
.footer-bottom {
    max-width: 1280px;
    margin: 40px auto 0;
    padding: 24px 24px 0;
    border-top: 1px solid var(--glass-border);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Responsive ------------------------------------------------------------ */
@media (max-width: 992px) {
    .legal-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 28px;
        padding-top: 28px;
    }
    .toc-box {
        position: static;
        max-height: none;
        border: 1px solid var(--line);
        border-radius: var(--radius-md);
        background: var(--card);
        padding: 4px 16px;
    }
    .toc-box summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 0;
        margin: 0;
        cursor: pointer;
    }
    .toc-box summary::after {
        content: "";
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        margin-top: -4px;
        transition: transform 0.2s;
    }
    .toc-box[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
    .toc-box ol { margin-bottom: 12px; }
    .prose { max-width: none; }
    .footer-links { gap: 40px; flex-wrap: wrap; }
}

@media (max-width: 640px) {
    :root { --nav-height: 65px; }
    .navbar { padding: 16px 0; }
    .container { padding: 0 16px; }
    .legal-hero { padding: calc(var(--nav-height) + 40px) 0 36px; }
    .legal-hero .lead { font-size: 1rem; }
    .summary-grid, .contact-card, .request-grid { grid-template-columns: minmax(0, 1fr); }
    .prose h2 { font-size: 1.32rem; }
    .prose section + section { margin-top: 40px; }
    .app-card { padding: 18px; }
    .app-card dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .app-card dd { margin-bottom: 10px; }
    .callout { padding: 16px; }
    .footer-container { flex-direction: column; }
    .footer-bottom { padding: 24px 16px 0; }
}

/* Print ----------------------------------------------------------------- */
@media print {
    :root { color-scheme: light; }
    body.legal { background: #fff; color: #000; }
    .navbar, .toc, .to-top, .read-progress, .mouse-glow, .hero-actions, footer, .skip-link, .anchor { display: none !important; }
    .legal-hero { padding: 0 0 16px; border: none; }
    .legal-hero::before { display: none; }
    .legal-layout { display: block; padding: 0; }
    .prose, .prose strong, .prose h2, .prose h3, .prose h4, .legal-hero h1, .legal-hero .lead, .pill, .pill strong { color: #000 !important; }
    .prose a:not(.btn) { color: #000; text-decoration: underline; }
    .callout, .summary-card, .app-card, .accordion details, .contact-card > div, .table-wrap { border-color: #bbb; background: none; }
    .accordion details > .acc-body { display: block !important; }
    .table-wrap { overflow: visible; }
    .table-wrap th { background: #eee; color: #000; }
    .table-wrap td { color: #000 !important; }
}
