/* ============================================
   Quill — Legal pages (Privacy, Terms, CCPA)
   Shared styles for interactive legal documents
   ============================================ */

/* Restore normal document flow: styles.css pins html/body to 100%/hidden for
   the fixed-viewport homepage; legal pages need the window itself to scroll
   so scroll-spy, the progress bar, and back-to-top track window.scrollY. */
html, body { height: auto; overflow: auto; }

html { scroll-behavior: smooth; }

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--lavender-bright), var(--sky-bright));
    z-index: 20;
    opacity: 0.8;
}

.legal-main {
    flex: 1;
    display: block;
    padding: 0 48px 96px;
}

.legal-layout {
    max-width: 1060px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 230px minmax(0, 720px);
    gap: 64px;
    justify-content: center;
    align-items: start;
    opacity: 0;
    animation: fade-up 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.3s forwards;
}

/* ---- Table of contents ---- */

.legal-toc {
    position: sticky;
    top: 28px;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(169, 155, 235, 0.2) transparent;
    padding-right: 4px;
}

.legal-toc summary {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    list-style: none;
    cursor: default;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.legal-toc summary::-webkit-details-marker { display: none; }

@media (min-width: 1081px) {
    /* Sidebar TOC is always open on desktop; the summary is a label, not a toggle */
    .legal-toc summary { pointer-events: none; }
}

.legal-toc summary .toc-chevron { display: none; }

.legal-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.legal-toc a {
    display: block;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 300;
    line-height: 1.45;
    color: rgba(255, 255, 255, 0.38);
    text-decoration: none;
    padding: 4px 0 4px 14px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    transition: color 0.25s ease, border-color 0.25s ease;
}

.legal-toc a:hover { color: rgba(255, 255, 255, 0.7); }

.legal-toc a.active {
    color: var(--lavender-bright);
    border-left-color: var(--lavender-bright);
}

/* ---- Content column ---- */

.legal-content { min-width: 0; }

.legal-content h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.01em;
    margin-bottom: 24px;
    line-height: 1.15;
}

.page-intro {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--lavender-bright);
    margin-bottom: 40px;
}

.doc-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.doc-switch a {
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.doc-switch a:hover {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.22);
}

.doc-switch a[aria-current="page"] {
    color: var(--lavender-bright);
    border-color: rgba(169, 155, 235, 0.45);
}

.doc-meta {
    font-family: var(--font-body);
    font-size: 0.84rem;
    font-weight: 300;
    color: var(--text-muted);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 10px;
}

.doc-meta a {
    color: var(--lavender-bright);
    text-decoration: none;
    transition: color 0.3s ease;
}

.doc-meta a:hover { color: #C4BAFF; }

.meta-divider { opacity: 0.4; }

.divider {
    height: 1px;
    background: linear-gradient(to right, rgba(169, 155, 235, 0.2), rgba(139, 184, 240, 0.1), transparent);
    margin-bottom: 56px;
}

.legal-section {
    margin-bottom: 52px;
    scroll-margin-top: 28px;
}

.legal-content h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: -0.005em;
    margin-bottom: 16px;
}

.legal-content h3 {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.78);
    margin: 28px 0 12px;
    scroll-margin-top: 28px;
}

.hlink {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: rgba(169, 155, 235, 0.55);
    text-decoration: none;
    margin-left: 10px;
    opacity: 0;
    transition: opacity 0.25s ease, color 0.25s ease;
}

.legal-content h2:hover .hlink,
.hlink:focus-visible { opacity: 1; }

.hlink:hover { color: #C4BAFF; }

.legal-content p {
    font-family: var(--font-body);
    font-size: 0.96rem;
    font-weight: 300;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 20px;
}

.legal-content p strong,
.legal-content li strong {
    color: rgba(255, 255, 255, 0.78);
    font-weight: 500;
}

.legal-content p.caps { letter-spacing: 0.01em; }

.legal-content p.clause { padding-left: 22px; }

.legal-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legal-content ul li {
    font-family: var(--font-body);
    font-size: 0.96rem;
    font-weight: 300;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.55);
    padding-left: 20px;
    position: relative;
}

.legal-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 11px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--lavender-bright), var(--sky-bright));
    opacity: 0.7;
}

.legal-content a.inline-link {
    color: var(--lavender-bright);
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: color 0.3s ease;
}

.legal-content a.inline-link:hover { color: #C4BAFF; }

.legal-content a.xref {
    color: rgba(169, 155, 235, 0.85);
    text-decoration: none;
    border-bottom: 1px dotted rgba(169, 155, 235, 0.4);
    transition: color 0.3s ease, border-color 0.3s ease;
}

.legal-content a.xref:hover {
    color: #C4BAFF;
    border-bottom-color: rgba(196, 186, 255, 0.7);
}

/* ---- Tables ---- */

.table-wrap {
    overflow-x: auto;
    margin: 4px 0 24px;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}

.legal-table th {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    padding: 0 20px 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: bottom;
}

.legal-table td {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 300;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.4);
    padding: 14px 20px 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    vertical-align: top;
}

.legal-table td:first-child {
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
}

.legal-table tr:last-child td { border-bottom: none; }

/* ---- Back to top ---- */

.back-top {
    position: fixed;
    right: 28px;
    bottom: 28px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(169, 155, 235, 0.3);
    background: rgba(21, 24, 34, 0.82);
    backdrop-filter: blur(8px);
    color: var(--lavender-bright);
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease, border-color 0.3s ease, color 0.3s ease;
    z-index: 15;
}

.back-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-top:hover {
    border-color: rgba(169, 155, 235, 0.6);
    color: #C4BAFF;
}

.nav-logo-link {
    display: inline-block;
    text-decoration: none;
}

/* ---- Responsive ---- */

@media (max-width: 1080px) {
    .legal-layout {
        grid-template-columns: minmax(0, 720px);
        gap: 0;
    }

    .legal-toc {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 40px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 12px;
        padding: 16px 20px;
        background: rgba(21, 24, 34, 0.5);
    }

    .legal-toc summary {
        cursor: pointer;
        margin-bottom: 0;
        justify-content: space-between;
    }

    .legal-toc summary .toc-chevron {
        display: inline-block;
        transition: transform 0.25s ease;
        font-size: 0.65rem;
    }

    .legal-toc details[open] summary { margin-bottom: 14px; }

    .legal-toc details[open] summary .toc-chevron { transform: rotate(180deg); }

    .legal-toc a { border-left: none; padding-left: 0; }
    .legal-toc a.active { border-left: none; }
}

@media (max-width: 768px) {
    .legal-main { padding: 0 24px 64px; }
    .back-top { right: 18px; bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .legal-layout { opacity: 1; animation: none; }
}

/* ---- Print ---- */

@media print {
    html, body { overflow: visible; background: #fff; }

    #ink-canvas, .glow, .grain, .scroll-progress, .back-top,
    .legal-toc, .doc-switch, header, .footer-legal { display: none !important; }

    .page { min-height: auto; }

    .legal-main { padding: 0; }

    .legal-layout {
        display: block;
        max-width: none;
        opacity: 1;
        animation: none;
    }

    .legal-content h1,
    .legal-content h2,
    .legal-content h3,
    .legal-content p,
    .legal-content li,
    .legal-table td,
    .legal-table th,
    .page-intro,
    .doc-meta,
    footer p {
        color: #000 !important;
    }

    .legal-content a,
    .doc-meta a {
        color: #000 !important;
        text-decoration: underline;
        border-bottom: none;
    }

    .hlink { display: none; }

    .legal-content ul li::before { background: #000; }

    .legal-table th,
    .legal-table td { border-bottom: 1px solid #ccc; }

    .divider { background: #ccc; }

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