/* ===================================================================
   Tax Optimiser - Terms of Service
   Styles are scoped under .to-terms so they don't collide with the
   site's global CSS. Source: Spec/tax-optimiser-terms.html.
   =================================================================== */

.to-terms {
    --ink:       #1a1614;
    --ink-soft:  #54504c;
    --ink-faint: #8a847e;
    --paper:     #fcfbf8;
    --line:      #e4ded6;
    --accent:    #2196f3;          /* Tax Optimiser primary blue */
    --accent-dk: #1976d2;
    --card:      #ffffff;

    box-sizing: border-box;
    background: var(--paper);
    color: var(--ink);
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 18px;
    line-height: 1.68;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.to-terms *, .to-terms *::before, .to-terms *::after { box-sizing: border-box; }
.to-terms ::selection { background: var(--accent); color: #fff; }

/* ---- Layout ---- */
.to-terms .to-wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 5rem) clamp(1.1rem, 4vw, 3rem) 5rem;
}
.to-terms .to-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: start;
}
@media (max-width: 860px) {
    .to-terms .to-grid { grid-template-columns: 1fr; gap: 2.25rem; }
}

/* ---- Masthead ---- */
.to-terms .to-head {
    border-bottom: 2px solid var(--ink);
    box-shadow: 0 2px 0 var(--accent);
    padding-bottom: 1.6rem;
    margin-bottom: clamp(2rem, 5vw, 3.4rem);
}
.to-terms .to-eyebrow {
    font-family: "Source Serif 4", serif;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 .7rem;
}
.to-terms .to-title {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-weight: 600;
    font-size: clamp(2.3rem, 6vw, 3.6rem);
    line-height: 1.04;
    letter-spacing: -0.015em;
    margin: 0 0 .85rem;
    color: var(--ink);
}
.to-terms .to-meta {
    font-size: .92rem;
    color: var(--ink-faint);
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .35rem 1.2rem;
}
.to-terms .to-meta strong { color: var(--ink-soft); font-weight: 600; }
.to-terms .to-meta-date { flex: 1 1 auto; }

/* ---- Print button ---- */
.to-terms .to-print {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent-dk);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 999px;
    padding: .45rem 1rem;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .1s ease;
}
.to-terms .to-print:hover {
    background: var(--accent);
    color: #fff;
}
.to-terms .to-print:active { transform: translateY(1px); }
.to-terms .to-print svg { width: 14px; height: 14px; }

/* ---- Contents sidebar ---- */
.to-terms .to-toc {
    position: sticky;
    top: 1.5rem;
    font-family: "Source Serif 4", serif;
}
@media (max-width: 860px) {
    .to-terms .to-toc {
        position: static;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 1.4rem 1.5rem;
    }
}
.to-terms .to-toc-label {
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 .9rem;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--line);
}
.to-terms .to-toc ol {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: toc;
}
.to-terms .to-toc li { margin: 0; }
.to-terms .to-toc a {
    counter-increment: toc;
    display: flex;
    gap: .6rem;
    padding: .32rem 0;
    font-size: .9rem;
    line-height: 1.35;
    color: var(--ink-soft);
    text-decoration: none;
    transition: color .15s ease;
}
.to-terms .to-toc a::before {
    content: counter(toc);
    flex: 0 0 1.5rem;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
    font-weight: 600;
}
.to-terms .to-toc a:hover { color: var(--accent-dk); }

/* ---- TOC active highlight (scrollspy) ---- */
.to-terms .to-toc a.is-active {
    color: var(--accent-dk);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
    padding-left: .6rem;
}
.to-terms .to-toc a.is-active::before { color: var(--accent-dk); }

/* ---- Body article ---- */
.to-terms .to-body { min-width: 0; }
.to-terms .to-intro {
    font-size: 1.06rem;
    color: var(--ink-soft);
    border-left: 3px solid var(--accent);
    padding: .2rem 0 .2rem 1.4rem;
    margin: 0 0 2.6rem;
}
.to-terms section { scroll-margin-top: 1.5rem; }
.to-terms section + section {
    margin-top: 2.7rem;
    padding-top: 2.6rem;
    border-top: 1px solid var(--line);
}
.to-terms h2 {
    font-family: "Plus Jakarta Sans", sans-serif;
    font-weight: 600;
    font-size: clamp(1.32rem, 2.6vw, 1.62rem);
    line-height: 1.22;
    letter-spacing: -0.01em;
    margin: 0 0 1.05rem;
    color: var(--ink);
    display: flex;
    gap: .7rem;
    align-items: baseline;
}
.to-terms h2 .to-cn {
    flex: 0 0 auto;
    font-size: .82em;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* ---- Anchorable h2 headings ---- */
.to-terms section h2 { cursor: pointer; }
@media (hover: hover) {
    .to-terms section h2::after {
        content: "#";
        color: var(--accent);
        font-weight: 500;
        opacity: 0;
        margin-left: .35rem;
        transition: opacity .15s ease;
    }
    .to-terms section h2:hover::after { opacity: .55; }
}

/* numbered sub-clauses */
.to-terms .to-clauses { margin: 0; padding: 0; list-style: none; }
.to-terms .to-clauses > li {
    display: grid;
    grid-template-columns: 3.1rem 1fr;
    gap: .25rem .15rem;
    margin: 0 0 .85rem;
}
.to-terms .to-clauses > li:last-child { margin-bottom: 0; }
.to-terms .to-cnum {
    font-weight: 600;
    color: var(--accent-dk);
    font-variant-numeric: tabular-nums;
}
.to-terms .to-clauses p { margin: 0; }
.to-terms .to-clauses .to-lead { font-weight: 600; color: var(--ink); }

/* bullet list nested under a clause */
.to-terms .to-list {
    grid-column: 2 / 3;
    margin: .5rem 0 .2rem;
    padding: 0 0 0 1.1rem;
}
.to-terms .to-list li { margin: 0 0 .42rem; padding-left: .25rem; }
.to-terms .to-list li::marker { color: var(--accent); }

.to-terms .to-defs { grid-column: 2 / 3; margin: .5rem 0 .2rem; padding-left: 1.1rem; }
.to-terms .to-defs li { margin: 0 0 .5rem; }
.to-terms .to-defs li::marker { color: var(--accent); }
.to-terms .to-defs strong { color: var(--ink); }

.to-terms p.to-plain { margin: .2rem 0 .55rem; }
.to-terms a.to-link {
    color: var(--accent-dk);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}
.to-terms a.to-link:hover { color: var(--accent); }

/* contact block */
.to-terms .to-contact {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.5rem 1.7rem;
    margin-top: 1rem;
}
.to-terms .to-contact p { margin: 0 0 .35rem; }
.to-terms .to-contact p:last-child { margin-bottom: 0; }
.to-terms .to-contact .to-org { font-weight: 600; color: var(--ink); }

/* footer note */
.to-terms .to-note {
    margin-top: 2.6rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--line);
    font-size: .88rem;
    font-style: italic;
    color: var(--ink-faint);
}

/* ---- Reading progress bar ---- */
.to-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent, #2196f3);
    transform: scaleX(0);
    transform-origin: left center;
    z-index: 9999;
    pointer-events: none;
    will-change: transform;
}

/* ---- Floating back-to-top button ---- */
.to-top-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent, #2196f3);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    box-shadow: 0 6px 20px rgba(33,150,243,.35);
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease, background .15s ease;
    z-index: 9998;
}
.to-top-fab.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.to-top-fab:hover { background: var(--accent-dk, #1976d2); }

/* ---- "Link copied" toast ---- */
.to-anchor-toast {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translate(-50%, 14px);
    background: #1a1614;
    color: #fff;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: .82rem;
    letter-spacing: .04em;
    padding: .6rem 1.1rem;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    z-index: 9999;
}
.to-anchor-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media print {
    .to-terms { background: #fff; font-size: 11pt; }
    .to-terms .to-toc { display: none; }
    .to-terms .to-grid { grid-template-columns: 1fr; }
    .to-terms section + section { border-top: none; }
    .to-terms .to-print,
    .to-progress,
    .to-top-fab,
    .to-anchor-toast { display: none !important; }
}
