/* Compro-Terms page styles (v1.2.0) for /terms. Loaded only by page-terms.php. */

/* main.css sets .legal-page { overflow: hidden }, which stops the sticky table of contents.
   overflow: clip clips the same way without creating a scroll container. */
.legal-page.compro-terms { overflow: clip; }

.compro-terms {
    --ct-header: var(--header-height, 78px);
    --ct-ink: var(--page-text, #11161d);
    --ct-muted: var(--page-muted, #67717d);
    --ct-line: rgba(17, 22, 29, 0.10);
    --ct-navy: var(--island-bg, #0e141e);
    --ct-accent: var(--blue, #1478ff);
    --ct-accent-dark: var(--blue-dark, #0064e8);
    --ct-card: var(--bg, #ffffff);
    --ct-soft: rgba(20, 120, 255, 0.07);
    --ct-radius: 18px;
    --ct-width: min(var(--max, 1240px), 100% - 48px);
    color: var(--ct-ink);
}

@media (max-width: 980px) {
    .compro-terms { --ct-width: min(var(--max, 1240px), 100% - 32px); }
}

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

.compro-terms [id] { scroll-margin-top: calc(var(--ct-header) + 24px); }

.compro-terms .screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Hero comes from main.css (.legal-page-hero, same as Privacy Policy); only the version pills are added here. */
.compro-terms .ct-meta { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 0 !important; }
.compro-terms .ct-meta span {
    padding: 6px 14px; border-radius: 999px; font-size: 0.88rem; font-weight: 600; line-height: 1.3;
    background: rgba(255, 255, 255, 0.10); border: 1px solid rgba(255, 255, 255, 0.18); color: var(--island-text, #f4f6f9);
}

/* Two-column layout */
.compro-terms .ct-layout {
    width: var(--ct-width);
    margin: 0 auto;
    padding: 44px 0 96px;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}

/* Table of contents */
.compro-terms .ct-toc { position: sticky; top: calc(var(--ct-header) + 20px); }
.compro-terms .ct-toc-panel {
    background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius);
    box-shadow: 0 10px 30px rgba(16, 30, 58, 0.06);
}
.compro-terms .ct-toc-summary {
    list-style: none; cursor: pointer; padding: 16px 20px; font-weight: 700; font-size: 0.82rem;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--ct-muted);
}
.compro-terms .ct-toc-summary::-webkit-details-marker { display: none; }
.compro-terms .ct-toc-scroll {
    max-height: calc(100vh - var(--ct-header) - 110px);
    overflow-y: auto; overscroll-behavior: contain;
    padding: 0 10px 14px; scrollbar-width: thin;
}
.compro-terms .ct-toc-list { list-style: none; margin: 0; padding: 0; }
.compro-terms .ct-toc-depth-2 { padding-left: 12px; margin: 2px 0 6px; border-left: 1px solid var(--ct-line); margin-left: 12px; }
.compro-terms .ct-toc-depth-3 { padding-left: 10px; margin: 2px 0 6px; border-left: 1px solid var(--ct-line); margin-left: 10px; }
.compro-terms .ct-toc-item { margin: 0; padding: 0; }
.compro-terms .ct-toc-row { display: flex; align-items: flex-start; gap: 4px; }
.compro-terms .ct-toc-row a {
    flex: 1; display: block; padding: 6px 10px; border-radius: 10px; text-decoration: none;
    color: var(--ct-ink); font-size: 0.92rem; line-height: 1.35;
}
.compro-terms .ct-toc-depth-1 > .ct-toc-item > .ct-toc-row a { font-weight: 650; }
.compro-terms .ct-toc-depth-3 .ct-toc-row a { font-size: 0.86rem; color: var(--ct-muted); padding: 4px 10px; }
.compro-terms .ct-toc-row a:hover { background: var(--ct-soft); color: var(--ct-accent); }
.compro-terms .ct-toc-row a.is-active { background: var(--ct-soft); color: var(--ct-accent); font-weight: 650; }
.compro-terms .ct-toc-item.is-trail > .ct-toc-row a { color: var(--ct-accent); }
.compro-terms .ct-toc-toggle {
    flex: none; width: 30px; height: 30px; margin-top: 1px; border: 0; border-radius: 8px;
    background: transparent; cursor: pointer; position: relative; color: var(--ct-muted); padding: 0;
}
.compro-terms .ct-toc-toggle:hover { background: var(--ct-soft); }
.compro-terms .ct-toc-toggle::before {
    content: ""; position: absolute; left: 11px; top: 10px; width: 7px; height: 7px;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
    transform: rotate(45deg); transition: transform 0.15s ease;
}
.compro-terms .ct-toc-toggle[aria-expanded="false"]::before { transform: rotate(-45deg); left: 9px; top: 11px; }
.compro-terms .ct-toc-children[hidden] { display: none; }

/* Content */
.compro-terms .ct-content { min-width: 0; max-width: 860px; font-size: 1rem; line-height: 1.7; }
.compro-terms .ct-content p { margin: 0 0 1em; }
.compro-terms .ct-content a { color: var(--ct-accent); }
.compro-terms .ct-content ul:not(.ct-history-docs) { margin: 0 0 1.1em; padding-left: 1.4em; }
.compro-terms .ct-content li { margin: 0 0 0.45em; }
.compro-terms .ct-content li::marker { color: var(--ct-accent); }

.compro-terms .ct-notice {
    margin: 0 0 28px; padding: 14px 18px; border-radius: 14px;
    background: rgba(20, 120, 255, 0.07); border: 1px solid rgba(20, 120, 255, 0.25); font-weight: 600;
}

.compro-terms .ct-doc,
.compro-terms .ct-documents,
.compro-terms .ct-history { margin: 0 0 64px; }
.compro-terms .ct-doc-title {
    margin: 0 0 20px; padding-bottom: 14px; border-bottom: 2px solid var(--ct-line);
    font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1.2; letter-spacing: -0.015em; color: var(--ct-navy);
}

/* Downloads */
.compro-terms .ct-doc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.compro-terms .ct-doc-card {
    display: flex; align-items: center; gap: 14px; padding: 18px;
    background: var(--ct-card); border: 1px solid var(--ct-line); border-radius: var(--ct-radius);
}
.compro-terms .ct-doc-icon {
    flex: none; display: grid; place-items: center; width: 46px; height: 54px; border-radius: 10px;
    background: var(--ct-navy); color: #fff; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
}
.compro-terms .ct-doc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.compro-terms .ct-doc-label { font-weight: 700; color: var(--ct-navy); }
.compro-terms .ct-doc-sub { font-size: 0.86rem; color: var(--ct-muted); }
.compro-terms a.ct-doc-button {
    flex: none; padding: 9px 16px; border-radius: 999px; background: var(--ct-accent); color: #fff;
    font-weight: 700; font-size: 0.9rem; text-decoration: none; white-space: nowrap;
}
.compro-terms a.ct-doc-button:hover { background: var(--ct-accent-dark); color: #fff; }
.compro-terms .ct-doc-missing { font-size: 0.86rem; color: var(--ct-muted); }

/* Definitions */
.compro-terms .ct-defs { margin: 8px 0 0; }
.compro-terms .ct-def { padding: 18px 0; border-top: 1px solid var(--ct-line); }
.compro-terms .ct-def:first-child { border-top: 0; }
.compro-terms .ct-def dt { font-weight: 700; color: var(--ct-navy); font-size: 1.05rem; margin: 0 0 6px; }
.compro-terms .ct-def dd { margin: 0; }
.compro-terms .ct-def dd > :last-child { margin-bottom: 0; }

/* Terms sections */
.compro-terms .ct-lead { font-weight: 600; font-size: 1.04rem; }
.compro-terms .ct-section { margin: 44px 0 0; }
.compro-terms .ct-section h3 {
    margin: 0 0 18px; font-size: clamp(1.3rem, 2vw, 1.55rem); line-height: 1.25; color: var(--ct-navy);
    letter-spacing: -0.01em;
}
.compro-terms .ct-section h3 .ct-num { color: var(--ct-accent); }
.compro-terms .ct-sub { margin: 0 0 26px; }
.compro-terms .ct-sub h4 { margin: 0 0 8px; font-size: 1.06rem; line-height: 1.35; color: var(--ct-navy); }
.compro-terms .ct-sub h4 .ct-num { color: var(--ct-muted); font-variant-numeric: tabular-nums; margin-right: 4px; }

/* Revision history */
.compro-terms .ct-table-wrap { overflow-x: auto; border: 1px solid var(--ct-line); border-radius: var(--ct-radius); background: var(--ct-card); }
.compro-terms .ct-table { width: 100%; border-collapse: collapse; font-size: 0.94rem; line-height: 1.45; margin: 0; }
.compro-terms .ct-table th,
.compro-terms .ct-table td { padding: 14px 16px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--ct-line); }
.compro-terms .ct-table thead th {
    font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ct-muted);
    background: rgba(16, 30, 58, 0.03);
}
.compro-terms .ct-table tbody tr:last-child > * { border-bottom: 0; }
.compro-terms .ct-table tbody th { font-weight: 700; color: var(--ct-navy); white-space: nowrap; }
.compro-terms .ct-history-docs { list-style: none; margin: 0; padding: 0; }
.compro-terms .ct-history-docs li { margin: 0 0 4px; }
.compro-terms .ct-history-size { color: var(--ct-muted); font-size: 0.84rem; margin-left: 4px; }
.compro-terms .ct-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap;
}
.compro-terms .ct-badge-current { background: rgba(22, 163, 74, 0.12); color: #13703a; }
.compro-terms .ct-badge-upcoming { background: rgba(20, 120, 255, 0.12); color: var(--ct-accent-dark); }
.compro-terms .ct-badge-superseded { background: rgba(16, 30, 58, 0.08); color: var(--ct-muted); }

/* Tablet / phone: contents panel above the text */
@media (max-width: 980px) {
    .compro-terms .ct-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 24px; }
    .compro-terms .ct-toc { position: static; }
    .compro-terms .ct-toc-summary { display: flex; justify-content: space-between; align-items: center; }
    .compro-terms .ct-toc-summary::after {
        content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
        transform: rotate(45deg); margin-right: 4px;
    }
    .compro-terms .ct-toc-panel[open] .ct-toc-summary::after { transform: rotate(-135deg); }
    .compro-terms .ct-toc-scroll { max-height: 60vh; }
}
@media (min-width: 981px) {
    .compro-terms .ct-toc-summary { pointer-events: none; }
}
@media (max-width: 640px) {
    .compro-terms .ct-doc-grid { grid-template-columns: minmax(0, 1fr); }
    .compro-terms .ct-doc-card { flex-wrap: wrap; }
}

/* Print: text only */
@media print {
    .compro-terms .ct-toc,
    .compro-terms .ct-documents,
    .compro-terms .ct-doc-button { display: none !important; }
    .compro-terms .ct-layout { display: block; width: auto; padding: 0; }
    .compro-terms .legal-page-hero, .compro-terms .legal-page-hero * { background: none !important; color: #000 !important; }
    .compro-terms .ct-meta span { color: #000; border-color: #999; background: none; }
    .compro-terms .ct-content { max-width: none; }
    .compro-terms .ct-sub { break-inside: avoid-page; }
}
