/* ============================================================
   Legal pages (Views/Legal, shell Views/Legal/_LegalLayout; legal.js): the head with the four documents as tabs, the contents
   beside the document (a bar under the header on phones), the document set for long reading, and print.
   The documents' own classes (legal-intro, legal-company) are kept as they are in Views/Legal.
   ============================================================ */

.lg-page {
    --lg-top: 75px; /* the sticky header's height */
}

/* ---------- head ---------- */
.lg-hero {
    padding: 44px 0 0;
    border-bottom: 1px solid var(--ds-line);
}

.lg-title {
    margin: 14px 0 10px !important;
}

.lg-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 22px;
    font-size: 14px;
    color: var(--ds-muted);
}

    .lg-meta i {
        margin-inline-end: 4px;
    }

.lg-print {
    padding: 4px 12px;
    border: 1px solid var(--ds-line);
    border-radius: var(--ds-r-pill);
    background: var(--ds-surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--ds-text);
}

    .lg-print:hover {
        border-color: var(--ds-red);
        color: var(--ds-red);
    }

/* the four documents; on narrow screens they scroll sideways inside their row */
.lg-tabs {
    display: flex;
    gap: 4px;
    margin-top: 28px;
    overflow-x: auto;
    scrollbar-width: none;
}

    .lg-tabs::-webkit-scrollbar {
        display: none;
    }

    .lg-tabs a {
        display: inline-flex;
        flex: none;
        align-items: center;
        gap: 9px;
        padding: 12px 16px 14px;
        border-bottom: 3px solid transparent;
        font-size: 14.5px;
        font-weight: 700;
        white-space: nowrap;
        color: var(--ds-muted);
        transition: color .15s ease, border-color .15s ease;
    }

        .lg-tabs a i {
            font-size: 14px;
        }

        .lg-tabs a:hover {
            color: var(--ds-ink);
        }

        .lg-tabs a.is-on {
            border-bottom-color: var(--ds-red);
            color: var(--ds-ink);
        }

            .lg-tabs a.is-on i {
                color: var(--ds-red);
            }

/* ---------- body ---------- */
.lg-body {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 64px;
    align-items: start;
    padding-top: 40px;
    padding-bottom: 88px;
}

/* the contents */
.lg-toc {
    position: sticky;
    top: calc(var(--lg-top) + 20px);
    padding: 16px 12px 12px;
    border-radius: var(--ds-r-md);
    background: var(--ds-surface);
    border: 1px solid var(--ds-line);
}

.lg-toc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0 8px;
    border: 0;
    background: none;
    text-align: start;
    cursor: default;
}

.lg-toc-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ds-muted);
}

.lg-toc-now,
.lg-toc-head > i {
    display: none;
}

.lg-progress {
    height: 3px;
    margin: 12px 8px 8px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--ds-line-soft);
}

    .lg-progress i {
        display: block;
        width: 0;
        height: 100%;
        background: var(--ds-red);
    }

.lg-toc-list {
    max-height: calc(100vh - var(--lg-top) - 120px);
    margin: 0 !important;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    counter-reset: lg-toc;
}

    .lg-toc-list a {
        display: flex;
        gap: 10px;
        padding: 7px 8px;
        border-radius: 9px;
        font-size: 13.5px;
        line-height: 1.6;
        color: var(--ds-text);
        counter-increment: lg-toc;
        transition: background .15s ease, color .15s ease;
    }

        .lg-toc-list a::before {
            content: counter(lg-toc, decimal-leading-zero);
            flex: none;
            padding-top: 1px;
            font-family: var(--ds-mono);
            font-size: 11.5px;
            color: var(--ds-muted);
        }

        .lg-toc-list a:hover {
            background: var(--ds-soft);
            color: var(--ds-ink);
        }

        .lg-toc-list a.is-on {
            background: var(--ds-tint);
            color: var(--ds-red);
            font-weight: 700;
        }

            .lg-toc-list a.is-on::before {
                color: var(--ds-red);
            }

/* ---------- the document ---------- */
.lg-doc {
    max-width: 74ch;
    font-size: 16.5px;
    line-height: 2;
    color: var(--ds-text);
    counter-reset: lg-sec;
}

html[lang="en"] .lg-doc {
    line-height: 1.85;
}

    .lg-doc p {
        margin: 0 0 14px !important;
    }

    .lg-doc a {
        color: var(--ds-red);
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    .lg-doc strong {
        color: var(--ds-ink);
    }

    .lg-doc .legal-intro {
        margin: 0 0 40px !important;
        padding: 18px 22px;
        border-radius: var(--ds-r-md);
        background: var(--ds-tint);
        border-inline-start: 4px solid var(--ds-red);
        font-size: 17.5px;
        color: var(--ds-ink);
    }

    .lg-doc section {
        margin-bottom: 38px;
        scroll-margin-top: calc(var(--lg-top) + 24px);
        counter-increment: lg-sec;
    }

    .lg-doc h2 {
        position: relative;
        display: flex;
        align-items: baseline;
        gap: 12px;
        margin: 0 0 12px !important;
        font-size: 21px;
        font-weight: 800;
        line-height: 1.6;
        color: var(--ds-ink);
    }

        .lg-doc h2::before {
            content: counter(lg-sec, decimal-leading-zero);
            flex: none;
            padding: 0 8px;
            border-radius: 6px;
            background: var(--ds-red-soft);
            font-family: var(--ds-mono);
            font-size: 13px;
            line-height: 1.9;
            color: var(--ds-red);
        }

/* a section's link (legal.js), shown on hover and focus */
.lg-anchor {
    flex: none;
    align-self: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    font-size: 13px;
    color: var(--ds-muted);
    opacity: 0;
    transition: opacity .15s ease, background .15s ease;
}

.lg-doc h2:hover .lg-anchor,
.lg-anchor:focus-visible {
    opacity: 1;
}

.lg-anchor:hover {
    background: var(--ds-soft);
    color: var(--ds-red);
}

    .lg-doc ul {
        margin: 0 0 14px !important;
        padding: 0;
        list-style: none;
    }

    .lg-doc li {
        position: relative;
        margin-bottom: 8px;
        padding-inline-start: 24px;
    }

        .lg-doc li::before {
            content: "";
            position: absolute;
            top: .85em;
            inset-inline-start: 4px;
            width: 7px;
            height: 7px;
            border-radius: 2px;
            background: var(--ds-red);
            transform: rotate(45deg);
        }

/* the company's facts (terms) */
.lg-doc .legal-company {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0 0;
}

    .lg-doc .legal-company > div {
        padding: 12px 16px;
        border-radius: 12px;
        background: var(--ds-soft);
        border: 1px solid var(--ds-line-soft);
    }

    .lg-doc .legal-company dt {
        font-size: 12.5px;
        font-weight: 700;
        line-height: 1.7;
        color: var(--ds-muted);
    }

    .lg-doc .legal-company dd {
        margin: 0;
        font-size: 15px;
        font-weight: 700;
        line-height: 1.7;
        color: var(--ds-ink);
        overflow-wrap: anywhere;
    }

/* ---------- after the document ---------- */
.lg-help {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 74ch;
    margin-top: 20px;
    padding: 16px 22px 16px 16px;
    border-radius: var(--ds-r-lg);
    background: var(--ds-surface);
    border: 1px solid var(--ds-line);
}

html[dir="rtl"] .lg-help {
    padding: 16px 16px 16px 22px;
}

    .lg-help img {
        flex: none;
        width: 76px;
        height: 76px;
    }

    .lg-help h2 {
        margin: 0 0 2px !important;
        font-size: 17px;
        font-weight: 800;
        color: var(--ds-ink);
    }

    .lg-help p {
        margin: 0 !important;
        font-size: 14px;
        color: var(--ds-muted);
    }

    .lg-help .ds-btn {
        flex: none;
        margin-inline-start: auto;
    }

.lg-toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    z-index: 60;
    padding: 9px 16px;
    border-radius: 12px;
    background: var(--ds-ink);
    font-size: 14px;
    font-weight: 600;
    color: var(--ds-surface);
    transform: translateX(-50%);
}

    .lg-toast[hidden] {
        display: none;
    }

/* ---------- tablets and phones: the contents become a bar under the header ---------- */
@media (max-width: 991px) {
    .lg-body {
        grid-template-columns: minmax(0, 1fr);
        gap: 24px;
        padding-top: 20px;
    }

    .lg-toc {
        top: var(--lg-top);
        z-index: 30;
        padding: 0;
        border-radius: 0 0 var(--ds-r-md) var(--ds-r-md);
        border-top: 0;
        background: var(--ds-header-bg);
        backdrop-filter: saturate(1.4) blur(14px);
        box-shadow: var(--ds-shadow-sm);
    }

    .lg-toc-head {
        min-height: 48px;
        padding: 0 16px;
        cursor: pointer;
    }

    .lg-toc-now {
        display: block;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        font-size: 14px;
        font-weight: 700;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: var(--ds-ink);
    }

    .lg-toc-head > i {
        display: block;
        font-size: 12px;
        color: var(--ds-muted);
        transition: transform .2s ease;
    }

    .lg-toc.is-open .lg-toc-head > i {
        transform: rotate(180deg);
    }

    .lg-progress {
        margin: 0;
        border-radius: 0;
    }

    .lg-toc-list {
        display: none;
        max-height: 60vh;
        padding: 8px;
    }

    .lg-toc.is-open .lg-toc-list {
        display: block;
    }

    .lg-doc section {
        scroll-margin-top: calc(var(--lg-top) + 64px);
    }
}

@media (max-width: 575px) {
    .lg-page {
        --lg-top: 67px;
    }

    .lg-hero {
        padding-top: 28px;
    }

    .lg-tabs {
        margin-top: 20px;
    }

        .lg-tabs a {
            padding: 10px 12px 12px;
            font-size: 13.5px;
        }

    .lg-doc {
        font-size: 16px;
    }

        .lg-doc .legal-intro {
            padding: 14px 16px;
            font-size: 16.5px;
        }

        .lg-doc h2 {
            font-size: 19px;
        }

        .lg-doc .legal-company {
            grid-template-columns: minmax(0, 1fr);
        }

    .lg-anchor {
        opacity: 1;
    }

    .lg-help {
        flex-wrap: wrap;
        padding: 16px !important;
    }

        .lg-help img {
            width: 60px;
            height: 60px;
        }

        .lg-help > div {
            flex: 1;
            min-width: 0;
        }

        .lg-help .ds-btn {
            width: 100%;
            justify-content: center;
        }
}

@media (prefers-reduced-motion: reduce) {
    .lg-tabs a,
    .lg-toc-list a,
    .lg-toc-head > i,
    .lg-anchor {
        transition: none;
    }
}

/* ---------- print: the document only ---------- */
@media print {
    .ds-header,
    .ds-footer,
    .lg-tabs,
    .lg-toc,
    .lg-help,
    .lg-print,
    .lg-anchor,
    .lg-toast,
    [data-lg-read] {
        display: none !important;
    }

    .lg-hero {
        padding: 0 0 12px;
        background: none !important;
    }

    .lg-body {
        display: block;
        padding: 16px 0 0;
    }

    .lg-doc {
        max-width: none;
        font-size: 12pt;
        line-height: 1.7;
        color: #000;
    }

        .lg-doc h2,
        .lg-doc strong,
        .lg-doc .legal-intro {
            color: #000;
        }

        .lg-doc .legal-intro {
            background: none;
        }

        .lg-doc h2 {
            break-after: avoid;
        }

        .lg-doc li,
        .lg-doc .legal-company > div {
            break-inside: avoid;
        }
}
