/*
 * Common CMS pages — Terms, Privacy, Advisor Terms, ... (frontend/pages/document.blade.php).
 * Everything is scoped to .cms-hero / .cms-doc / .cms-toc. Colours follow site.css
 * (--brand #684287, .bg-lavender #f3ecfa) and the /jobs palette; dark mode at the bottom.
 */
.cms-hero,
.cms-doc {
    --cms-brand: var(--brand, #684287);
    --cms-brand-hover: #553172;
    --cms-ink: #1f1330;
    --cms-text: #3d3548;
    --cms-muted: #5f5670;
    --cms-surface: #fff;
    --cms-tint: #f8f3fd;
    --cms-tint-2: #f1e7fb;
    --cms-border: #ece3f6;
    --cms-hero-bottom: #f0e5fc;
}

/* ---------- Heading band ---------- */
/*
 * Background: the "Dreamy Crystal Ball" banner (images/cms/document-header-banner.webp, 3:1).
 * Its waves cover the band; on desktop ::before repeats it at the band's height on the
 * right so the crystal ball and tarot cards always show whole, fading in from the left.
 */
.cms-hero {
    position: relative;
    background: var(--cms-hero-bottom) var(--cms-hero-art) left center / cover no-repeat;
    border-bottom: 1px solid var(--cms-border);
    padding: 1.5rem 0 1.75rem;
    overflow: hidden;
}

.cms-hero__inner { position: relative; z-index: 1; }

.cms-hero__crumbs { font-size: .9rem; margin-bottom: .75rem; }
.cms-hero__crumbs a { color: var(--cms-brand); }
.cms-hero__crumbs a:hover { color: var(--cms-brand-hover); text-decoration: underline; }
.cms-hero__crumbs .breadcrumb-item.active { color: var(--cms-muted); }

.cms-hero__title {
    color: var(--cms-ink);
    font-size: clamp(1.75rem, 3.6vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
    margin: 0 0 .6rem;
    overflow-wrap: break-word;
}

.cms-hero__updated { color: var(--cms-ink); font-weight: 600; margin: 0 0 .4rem; }
.cms-hero__lead { color: var(--cms-text); margin: 0; line-height: 1.6; }
.cms-hero__lead a { color: var(--cms-brand); text-decoration: underline; }

@media (min-width: 992px) {
    .cms-hero__inner {
        min-height: 190px;
        /* Keeps the text clear of the crystal ball (the right ~38% of the art layer). */
        padding-right: calc(340px + var(--bs-gutter-x, 1.5rem) * .5);
    }

    .cms-hero::before {
        content: "";
        position: absolute;
        right: 0;
        bottom: 0;
        height: 100%;
        max-height: 300px;
        aspect-ratio: 3;
        background: var(--cms-hero-art) center / 100% 100% no-repeat;
        -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 40%);
        mask-image: linear-gradient(90deg, transparent 0%, #000 40%);
        pointer-events: none;
    }
}

/* ---------- Card layout ---------- */
.cms-doc {
    display: grid;
    gap: 1.5rem;
    margin-top: 1.75rem;
    color: var(--cms-text);
}

.cms-doc__card,
.cms-toc {
    background: var(--cms-surface);
    border: 1px solid var(--cms-border);
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(91, 45, 142, .05);
    min-width: 0;
}

.cms-doc__card { padding: clamp(1.25rem, 3.5vw, 2.5rem); }

@media (min-width: 992px) {
    .cms-doc--toc {
        grid-template-columns: 260px minmax(0, 1fr);
        align-items: start;
    }

    .cms-doc__aside {
        position: sticky;
        top: 1.5rem;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 14px;
    }
}

/* ---------- On this page ---------- */
.cms-toc { padding: .5rem 1rem; }

.cms-toc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 44px;
    color: var(--cms-ink);
    font-size: 1.1rem;
    font-weight: 700;
    list-style: none;
    cursor: pointer;
    border-radius: 8px;
}

.cms-toc__summary::-webkit-details-marker { display: none; }
.cms-toc__chevron { color: var(--cms-brand); transition: transform .2s ease; }
.cms-toc__details[open] .cms-toc__chevron { transform: rotate(180deg); }

.cms-toc__list { list-style: none; margin: .25rem 0 .5rem; padding: 0; }

.cms-toc__link {
    display: flex;
    gap: .6rem;
    padding: .5rem .75rem;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    color: var(--cms-text);
    font-size: .95rem;
    line-height: 1.35;
}

.cms-toc__link:hover { background: var(--cms-tint); color: var(--cms-brand); }

.cms-toc__link[aria-current] {
    background: var(--cms-tint-2);
    border-left-color: var(--cms-brand);
    color: var(--cms-brand);
    font-weight: 600;
}

.cms-toc__num { flex: 0 0 1.6rem; font-variant-numeric: tabular-nums; }

.cms-toc__summary:focus-visible,
.cms-toc__link:focus-visible {
    outline: 2px solid var(--cms-brand);
    outline-offset: 2px;
}

@media (min-width: 992px) {
    .cms-toc { padding: 1.25rem 1rem; }
    .cms-toc__summary { cursor: default; min-height: 0; margin: 0 0 .5rem .75rem; }
    .cms-toc__chevron { display: none; }
}

/* ---------- Article ---------- */
.cms-doc__body {
    font-size: 1.02rem;
    line-height: 1.7;
    overflow-wrap: break-word;
}

.cms-doc__body > :first-child { margin-top: 0; }
.cms-doc__body > :last-child { margin-bottom: 0; }
.cms-doc__body p { margin: 0 0 1rem; }
.cms-doc__body strong,
.cms-doc__body b { color: var(--cms-ink); font-weight: 600; }

.cms-doc__body h2,
.cms-doc__body h3,
.cms-doc__body h4,
.cms-doc__body h5,
.cms-doc__body h6 {
    color: var(--cms-ink);
    font-weight: 700;
    line-height: 1.25;
    scroll-margin-top: 1.25rem;
}

.cms-doc__body h2 {
    font-size: clamp(1.35rem, 2.4vw, 1.75rem);
    margin: 2.25rem 0 1.25rem;
    padding-top: 2.25rem;
    border-top: 1px solid var(--cms-border);
}

.cms-doc__body h2:first-child { border-top: 0; padding-top: 0; }
.cms-doc__body h3 { font-size: 1.2rem; margin: 1.75rem 0 .75rem; }
.cms-doc__body h4 { font-size: 1.08rem; margin: 1.5rem 0 .6rem; }
.cms-doc__body h5,
.cms-doc__body h6 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

/* "1." in a section heading shown as a lavender circle (the "." stays for screen readers). */
.cms-doc__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    margin-right: .85rem;
    border-radius: 50%;
    background: var(--cms-tint-2);
    color: var(--cms-brand);
    font-size: 1.2rem;
    vertical-align: middle;
    position: relative;
    top: -.1rem;
}

/* "1.1" clauses: hanging number; what follows a clause lines up with its text. */
.cms-doc__clause { position: relative; padding-left: 2.75rem; }

.cms-doc__clause-num {
    position: absolute;
    left: 0;
    top: 0;
    color: var(--cms-muted);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.cms-doc__in-clause { margin-left: 2.75rem; }

/* Lists: a soft lavender panel; nested lists stay plain. */
.cms-doc__body > ul,
.cms-doc__body > ol {
    background: var(--cms-tint);
    border: 1px solid var(--cms-border);
    border-radius: 12px;
    margin: 0 0 1.25rem;
    padding: 1rem 1.25rem 1rem 2.6rem;
}

.cms-doc__body li { margin: .3rem 0; }
.cms-doc__body li::marker { color: var(--cms-brand); }
.cms-doc__body li > p { margin: 0; }
.cms-doc__body li ul,
.cms-doc__body li ol { margin: .3rem 0; padding-left: 1.25rem; }

.cms-doc__body a {
    color: var(--cms-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cms-doc__body a:hover { color: var(--cms-brand-hover); text-decoration-thickness: 2px; }

.cms-doc__body a:focus-visible {
    outline: 2px solid var(--cms-brand);
    outline-offset: 2px;
    border-radius: 2px;
}

.cms-doc__body blockquote {
    margin: 0 0 1.25rem;
    padding: .75rem 1rem;
    border-left: 4px solid #d9c6ee;
    background: var(--cms-tint);
    border-radius: 0 8px 8px 0;
}

.cms-doc__body hr { margin: 2rem 0; border-color: var(--cms-border); opacity: 1; }
.cms-doc__body img { max-width: 100%; height: auto; border-radius: 8px; }
.cms-doc__body figure { margin: 0 0 1.25rem; }
.cms-doc__body figcaption { color: var(--cms-muted); font-size: .9rem; margin-top: .4rem; }
.cms-doc__body address { font-style: normal; }
.cms-doc__body pre { overflow-x: auto; background: var(--cms-tint); padding: 1rem; border-radius: 8px; }
.cms-doc__body code { color: var(--cms-ink); }

/* Legacy "color" block (About): a highlighted line between sections. */
.cms-doc__callout {
    background: linear-gradient(135deg, var(--cms-tint), var(--cms-tint-2));
    border: 1px solid var(--cms-border);
    border-radius: 12px;
    margin: 0 0 1.5rem;
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.cms-doc__body .cms-doc__callout > :last-child { margin-bottom: 0; }

.cms-doc__body .cms-doc__callout h2,
.cms-doc__body .cms-doc__callout h3 {
    border-top: 0;
    padding-top: 0;
    margin: 0 0 .5rem;
    color: var(--cms-brand);
    font-size: 1.2rem;
}

/* Legacy alignment classes and screenshots (Refer & Earn Cash). */
.cms-doc__align-center { text-align: center; }
.cms-doc__align-left { text-align: left; }
.cms-doc__align-right { text-align: right; }

.cms-doc__body figure img {
    max-height: 560px;
    width: auto;
    border: 1px solid var(--cms-border);
}

.cms-doc__body figure.cms-doc__align-center img,
.cms-doc__align-center figure img { display: block; margin: 0 auto; }

.cms-doc__table { overflow-x: auto; margin: 0 0 1.25rem; }
.cms-doc__table table { width: 100%; border-collapse: collapse; }

.cms-doc__body th,
.cms-doc__body td {
    border: 1px solid var(--cms-border);
    padding: .5rem .75rem;
    text-align: left;
    vertical-align: top;
}

.cms-doc__body th { background: var(--cms-tint); color: var(--cms-ink); }

@media (max-width: 991.98px) {
    /* Room for the mobile app banner (sticky at the top when shown). */
    .cms-doc__body h2,
    .cms-doc__body h3 { scroll-margin-top: 5rem; }
}

@media (max-width: 575.98px) {
    .cms-doc__clause { padding-left: 2.4rem; }
    .cms-doc__in-clause { margin-left: 0; }
    .cms-doc__body > ul,
    .cms-doc__body > ol { padding: .85rem 1rem .85rem 2.1rem; }
    .cms-doc__num { width: 2.2rem; height: 2.2rem; font-size: 1.05rem; margin-right: .6rem; }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.cms-doc--toc) { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
    .cms-toc__chevron { transition: none; }
}

@media print {
    .cms-hero { background: none; border: 0; padding: 0 0 1rem; }
    .cms-hero::before,
    .cms-doc__aside { display: none !important; }
    .cms-hero__inner { padding-right: 0; min-height: 0; }
    .cms-doc { display: block; margin-top: 0; }
    .cms-doc__card { border: 0; box-shadow: none; padding: 0; }
    .cms-doc__body h2 { break-after: avoid; }
}

/* ---------- Dark mode (site-dark.css tokens) ---------- */
[data-bs-theme="dark"] .cms-hero,
[data-bs-theme="dark"] .cms-doc {
    --cms-brand: #c9a7e8;
    --cms-brand-hover: #dcc4f1;
    --cms-ink: #f1ecf6;
    --cms-text: #d3cadb;
    --cms-muted: #b0a6ba;
    --cms-surface: var(--lpc-surface, #211a29);
    --cms-tint: #261d30;
    --cms-tint-2: #3a2c4a;
    --cms-border: var(--lpc-border, #3a3045);
    --cms-hero-bottom: #261d30;
}

/* The banner is light: darken the waves layer and dim the crystal ball layer. */
[data-bs-theme="dark"] .cms-hero {
    background-image: linear-gradient(rgba(21, 17, 26, .86), rgba(21, 17, 26, .86)), var(--cms-hero-art);
}

[data-bs-theme="dark"] .cms-hero::before { opacity: .5; }
[data-bs-theme="dark"] .cms-doc__body blockquote { border-left-color: #5a4670; }
