/* ================================================================
   Legal documents — privacy, terms, copyright, Connect legal pages
   One readable column with a table of contents. Theme variables only.
   ================================================================ */

.legal-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding-inline: clamp(2rem, 7vw, 5rem);
}

/* ---------- Header ---------- */

.legal-hero {
    padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(2rem, 4vw, 3rem);
}

.legal-hero h1 {
    font-size: clamp(2.75rem, 6.5vw, 5rem);
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    margin: 0 0 1.25rem;
}

.legal-intro {
    max-width: 62ch;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0 0 1.25rem;
}

.legal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.legal-meta a {
    color: var(--brand-primary);
}

.legal-meta a[aria-current="page"] {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: none;
}

/* ---------- Layout ---------- */

.legal-layout {
    display: grid;
    gap: 2rem;
    padding-block: clamp(2rem, 5vw, 3.5rem) clamp(3rem, 7vw, 5rem);
}

@media (min-width: 1024px) {
    .legal-layout {
        grid-template-columns: 15rem minmax(0, 72ch);
        gap: 4rem;
        align-items: start;
    }
}

/* ---------- Table of contents ---------- */

.legal-toc {
    font-size: 0.9375rem;
    border-block: 1px solid var(--border-light);
    padding: 1.25rem 0;
}

@media (min-width: 1024px) {
    .legal-toc {
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 112px);
        overflow-y: auto;
        border: 0;
        padding: 0;
    }
}

.legal-toc h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.legal-toc ol {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-muted);
}

.legal-toc li {
    margin: 0 0 0.4rem;
    padding-left: 0.15rem;
}

.legal-toc a {
    color: var(--text-secondary);
    text-decoration: none;
}

.legal-toc a:hover {
    color: var(--brand-primary);
    text-decoration: underline;
}

/* ---------- Document body ---------- */

.legal-body {
    min-width: 0;
    max-width: 72ch;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.65;
}

.legal-body section {
    scroll-margin-top: 88px;
    padding-top: 2.5rem;
    margin-top: 3rem;
    border-top: 1px solid var(--border-light);
}

.legal-body section:first-child {
    padding-top: 0;
    margin-top: 0;
    border-top: 0;
}

.legal-body h2 {
    display: flex;
    gap: 0.5rem;
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    line-height: 1.12;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0 0 1rem;
}

.legal-num {
    flex: none;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.legal-body h3 {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-primary);
    margin: 1.5rem 0 0.4rem;
}

.legal-body h2 + h3,
.legal-body h2 + p + h3 {
    margin-top: 1rem;
}

.legal-body p,
.legal-body li,
.legal-body dd {
    color: var(--text-secondary);
}

.legal-body p {
    margin: 0 0 1rem;
}

.legal-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.legal-body a {
    color: var(--brand-primary);
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

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

.legal-body a:focus-visible,
.legal-toc a:focus-visible,
.legal-meta a:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

.legal-body ul,
.legal-body ol {
    margin: 0 0 1rem;
    padding-left: 1.25rem;
}

.legal-body li {
    margin-bottom: 0.4rem;
}

.legal-body li::marker {
    color: var(--text-muted);
}

/* Term + definition lists (rights, prohibited uses, highlights) */

.legal-terms {
    margin: 0 0 1rem;
}

.legal-terms dt {
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 1rem;
}

.legal-terms dt:first-child {
    margin-top: 0;
}

.legal-terms dd {
    margin: 0.15rem 0 0;
}

/* Paired lists: do / don't, you can / please don't */

.legal-pair {
    display: grid;
    gap: 0 2rem;
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    .legal-pair {
        grid-template-columns: 1fr 1fr;
    }
}

.legal-pair h3 {
    margin-top: 0.5rem;
}

/* Small asides: tips, notes, "data shared" lines */

.legal-note {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin: -0.5rem 0 1rem;
}

.legal-body .legal-note {
    color: var(--text-muted);
}

/* ---------- Tables ---------- */

.legal-table-wrap {
    overflow-x: auto;
    margin: 0.5rem 0 1.25rem;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.legal-table caption {
    caption-side: top;
    text-align: left;
    padding: 0.75rem 1rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.legal-table th,
.legal-table td {
    text-align: left;
    vertical-align: top;
    padding: 0.65rem 1rem 0.65rem 0;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.legal-table thead th {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom-color: var(--text-primary);
}

.legal-table tbody th {
    color: var(--text-primary);
    font-weight: 500;
}

.legal-table .legal-group th {
    padding-top: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
    border-bottom-color: var(--border-medium);
}

.legal-table .legal-group small {
    font-weight: 400;
    display: block;
    margin-top: 0.15rem;
    color: var(--text-muted);
}

.legal-table .is-center {
    text-align: center;
}

.legal-yes {
    color: var(--success-text);
    font-weight: 600;
}

.legal-no {
    color: var(--text-muted);
}

@media (max-width: 479px) {
    .legal-table {
        font-size: 0.8125rem;
    }

    .legal-table th,
    .legal-table td {
        padding: 0.5rem 0.35rem;
    }

    .legal-table th:first-child,
    .legal-table td:first-child {
        padding-left: 0;
    }
}

.legal-table thead small {
    font-weight: 400;
    color: var(--text-muted);
}

/* ---------- Attribution examples ---------- */

.legal-examples {
    display: grid;
    grid-template-columns: minmax(0, 10rem) minmax(0, 1fr);
    margin: 0 0 1rem;
    border-top: 1px solid var(--text-primary);
}

.legal-examples dt,
.legal-examples dd {
    margin: 0;
    padding: 0.75rem 1rem 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.legal-examples dt {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.legal-examples code {
    padding: 0;
    background: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 479px) {
    .legal-examples {
        grid-template-columns: 1fr;
    }

    .legal-examples dt {
        padding-bottom: 0;
        border-bottom: 0;
    }
}

/* ---------- Print ---------- */

@media print {
    .legal-toc,
    .legal-meta a {
        display: none;
    }

    .legal-layout {
        display: block;
    }

    .legal-body {
        max-width: none;
    }

    .legal-body section {
        break-inside: avoid-page;
    }
}

/* ---------- Showcase terms (apps/showcase/templates/showcase/terms.html) ---------- */

.showcase-terms {
    padding: clamp(2rem, 5vw, 3rem) 0 clamp(3rem, 8vw, 5rem);
}

.showcase-terms__status {
    margin: 0 0 2rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--warning-border);
    border-radius: 12px;
    background: var(--warning-bg);
    color: var(--warning-text);
}

.showcase-terms__status.is-accepted {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success-text);
}

.showcase-terms__status a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.showcase-terms__summary p {
    margin: 0 0 0.5rem;
}

.showcase-terms__accept {
    display: grid;
    gap: 1rem;
    margin-top: 2.5rem;
    padding: 1.25rem;
    border: 1px solid var(--border-medium);
    border-radius: 14px;
    background: var(--bg-card);
}

.showcase-terms__accept label {
    display: flex;
    gap: 0.6rem;
    align-items: flex-start;
    font-weight: 600;
}

.showcase-terms__accept input[type="checkbox"] {
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.2rem;
    accent-color: var(--brand-primary);
}

.showcase-terms__accept button {
    justify-self: start;
    padding: 0.65rem 1.4rem;
    border: 0;
    border-radius: 999px;
    background: var(--btn-primary-bg);
    color: var(--btn-primary-text);
    font-weight: 600;
    cursor: pointer;
}

.showcase-terms__accept button:hover {
    background: var(--brand-primary-strong);
}
