/* Shared styles for legal pages (privacy policy, terms and conditions).
   Loaded after styles.css, which provides the site header and footer. */

:root {
    --bg: #FAFAF7;
    --surface: #F2F7EC;
    --text: #1F1F1F;
    --muted: #6B6B6B;
    --border: #DDE3D5;
    --link: #3F5A24;
    --accent: #FF9800;
    --brand-green: #4B662C;
    --focus: #1F6FEB;
    --header-bg: #FFFFFF;
    --header-border: #CCCCCC;
    --table-head: #EEF3E7;
    --header-offset: 120px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141614;
        --surface: #1D221B;
        --text: #ECECE8;
        --muted: #A9ADA4;
        --border: #313830;
        --link: #B5D69A;
        --brand-green: #9CC27A;
        --focus: #7AB8FF;
        --header-bg: #1A1D19;
        --header-border: #313830;
        --table-head: #232A21;
    }
}

body.legal-page {
    background-color: var(--bg);
    color: var(--text);
}

/* styles.css sets Arial on every element, so set the reading font on each one */
.legal-layout * {
    font-family: "Onest", Arial, sans-serif;
}

/* Header from styles.css, adapted to the theme */
.legal-page header {
    background-color: var(--header-bg);
    border-bottom-color: var(--header-border);
}

/* The policy title is the page's h1, so the logo name is a span here */
.legal-page .logo-name {
    font-size: 36px;
    font-weight: bold;
    line-height: 1.2;
}

@media (max-width: 768px) {
    .legal-page .logo-name {
        font-size: 24px;
    }
}

.legal-page .menu-toggle {
    color: var(--text);
    background: none;
    border: none;
    font-family: inherit;
}

@media (max-width: 900px) {
    .legal-page .nav-buttons {
        background: var(--header-bg);
        border-color: var(--header-border);
    }

    .legal-page {
        --header-offset: 96px;
    }
}

@media (prefers-color-scheme: dark) {
    .legal-page .app-green {
        color: var(--brand-green);
    }

    /* logo.svg has a white background; round it into an app-icon tile */
    .legal-page .logo img {
        border-radius: 12px;
    }

    .legal-page .nav-btn {
        color: var(--text);
        border-color: var(--brand-green);
    }

    .legal-page .nav-btn:hover {
        background-color: var(--surface);
        color: var(--text);
    }
}

/* Layout */
.legal-layout {
    max-width: 1080px;
    margin: 0 auto;
    padding: 40px 16px 64px;
}

.legal-content {
    max-width: 720px;
    margin: 0 auto;
    min-width: 0;
    font-size: 17px;
    line-height: 1.65;
}

@media (min-width: 900px) {
    .legal-layout {
        display: grid;
        grid-template-columns: 240px minmax(0, 720px);
        gap: 56px;
        justify-content: center;
        padding: 56px 32px 80px;
    }

    .legal-content {
        margin: 0;
    }
}

/* Title block */
.legal-title {
    font-family: "Onest", Arial, sans-serif;
    font-size: clamp(32px, 6vw, 44px);
    line-height: 1.2;
    font-weight: 700;
    color: var(--text);
}

.legal-updated {
    margin-top: 12px;
    color: var(--muted);
    font-size: 15px;
}

.legal-related {
    margin-top: 8px;
    font-size: 15px;
}

.legal-intro {
    margin-top: 24px;
}

/* Sections */
.legal-content section {
    margin-top: 56px;
}

.legal-content h2,
.legal-content h3 {
    font-family: "Onest", Arial, sans-serif;
    color: var(--text);
    scroll-margin-top: var(--header-offset);
}

.legal-content h2 {
    font-size: 26px;
    line-height: 1.3;
    font-weight: 700;
    margin-bottom: 16px;
}

.legal-content h3 {
    font-size: 19px;
    line-height: 1.4;
    font-weight: 700;
    margin: 28px 0 8px;
}

.legal-content p + p,
.legal-content p + ul,
.legal-content ul + p,
.legal-content .table-wrap + p,
.legal-content p + .table-wrap {
    margin-top: 16px;
}

.legal-content ul {
    padding-left: 24px;
}

.legal-content li + li {
    margin-top: 10px;
}

.legal-content li::marker {
    color: var(--accent);
}

.legal-content strong {
    font-weight: 700;
}

.legal-content a {
    color: var(--link);
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}

.legal-content a:hover {
    text-decoration-thickness: 2px;
}

/* "The short version" card */
.legal-content .summary-card {
    margin-top: 32px;
    padding: 24px 24px 24px 28px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 12px;
}

.summary-card h2 {
    font-size: 20px;
    margin-bottom: 12px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.legal-content table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.5;
}

.legal-content th,
.legal-content td {
    text-align: left;
    vertical-align: top;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.legal-content th + th,
.legal-content td + td {
    border-left: 1px solid var(--border);
}

.legal-content thead th {
    background-color: var(--table-head);
    font-weight: 700;
}

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

.contact-block {
    font-style: normal;
}

/* Table of contents: a collapsible menu on mobile, a sticky sidebar on desktop */
.toc {
    margin-bottom: 32px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background-color: var(--surface);
}

.toc summary {
    cursor: pointer;
    padding: 14px 18px;
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    list-style-position: inside;
}

.toc ol {
    list-style: none;
    padding: 0 10px 12px;
}

.toc a {
    display: block;
    padding: 8px 10px 8px 12px;
    border-left: 3px solid transparent;
    border-radius: 4px;
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    line-height: 1.4;
}

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

.toc a[aria-current="true"] {
    color: var(--text);
    font-weight: 700;
    border-left-color: var(--accent);
}

@media (min-width: 900px) {
    .toc {
        position: sticky;
        top: calc(var(--header-offset) - 8px);
        align-self: start;
        max-height: calc(100vh - var(--header-offset) - 16px);
        overflow-y: auto;
        margin-bottom: 0;
        border: none;
        background: none;
    }

    .toc summary {
        pointer-events: none;
        list-style: none;
        padding: 0 0 12px 12px;
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted);
    }

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

    .toc ol {
        padding: 0;
    }
}

/* End-of-page links */
.legal-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px 24px;
    margin-top: 64px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 15px;
}

/* Focus states */
.legal-page a:focus-visible,
.legal-page summary:focus-visible,
.legal-page button:focus-visible,
.legal-page .table-wrap:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

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

/* Print: just the policy, black on white */
@media print {
    body.legal-page {
        background: #FFFFFF;
        color: #000000;
    }

    .legal-page header,
    .legal-page .toc,
    .legal-page .info,
    .legal-page .back-to-top {
        display: none;
    }

    .legal-layout {
        display: block;
        padding: 0;
    }

    .legal-content {
        max-width: none;
        font-size: 11pt;
    }

    .legal-content *,
    .legal-content a {
        color: #000000;
        background: none;
    }

    .legal-content .summary-card,
    .legal-content thead th {
        background: none;
    }

    .legal-content .summary-card,
    .table-wrap {
        border-color: #999999;
    }

    .legal-content li::marker {
        color: #000000;
    }

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

    .legal-content section {
        margin-top: 24px;
        break-inside: auto;
    }

    .legal-content h2,
    .legal-content h3 {
        break-after: avoid;
    }
}

/* styles.css pulls the footer up 80px on mobile for anchor scrolling on the
   homepage, which would overlap the end of the policy here */
@media (max-width: 768px) {
    .legal-page .info {
        margin-top: 0;
    }
}
