/*
 * Legal pages (privacy.html, terms.html). Builds on homepage.css tokens and
 * the beige panel language used by .support-panel and .services-overview.
 */

.legal-panel {
    --legal-ink-soft: #1f4d4d;
    --legal-ink-muted: #3d6464;
    --legal-rule: rgba(8, 52, 52, 0.13);
    --legal-pad: clamp(1.4rem, 0.9rem + 2.4vw, 3.25rem);

    max-width: 860px;
    margin: 0.5rem auto 4rem;
    padding: var(--legal-pad);
    box-sizing: border-box;
    text-align: left;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(240, 236, 220, 0.96), rgba(227, 223, 205, 0.9));
    border: 1px solid rgba(8, 52, 52, 0.18);
    box-shadow: 0 16px 34px rgba(9, 20, 31, 0.26);
    color: var(--legal-ink-soft);
    font-size: 0.98rem;
    line-height: 1.7;
    overflow-wrap: break-word;
    scroll-margin-top: 120px;
}

.legal-panel h1,
.legal-panel h2 {
    color: var(--primary-color);
    text-shadow: none;
    text-wrap: balance;
}

.legal-panel p {
    color: var(--legal-ink-soft);
    line-height: 1.7;
}

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

.legal-header {
    padding-bottom: 1.4rem;
    margin-bottom: 1.6rem;
    border-bottom: 1px solid var(--legal-rule);
}

.legal-header h1 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.75rem, 1.35rem + 1.6vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.legal-panel .legal-updated {
    color: var(--legal-ink-muted);
    font-size: 0.9rem;
}

/* ---------- Body ---------- */

.legal-body h2 {
    margin: 2rem 0 0.5rem;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.35;
}

.legal-body > h2:first-child,
.legal-body > .legal-section:first-child h2 {
    margin-top: 0;
}

.legal-body hr {
    border: 0;
    border-top: 1px solid var(--legal-rule);
    margin: 1.4rem 0;
}

/* An <hr> directly before a heading is redundant with the heading's spacing. */
.legal-body hr:has(+ h2) {
    margin-bottom: 0;
}

.legal-body hr:has(+ h2) + h2 {
    margin-top: 1.4rem;
}

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

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

.legal-body ul,
.legal-body ol {
    margin: 0.6rem 0 0.9rem;
    padding-left: 1.4rem;
}

.legal-body ul {
    list-style: none;
}

.legal-body li {
    position: relative;
    margin: 0.35rem 0;
    padding-left: 0.2rem;
}

.legal-body ul > li::before {
    content: '';
    position: absolute;
    left: -1.1rem;
    top: 0.62em;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    border: 2px solid var(--dark-purple);
    box-sizing: border-box;
}

.legal-body ol > li::marker {
    color: var(--dark-purple);
    font-weight: 600;
}

.legal-panel a {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(8, 52, 52, 0.35);
    text-underline-offset: 3px;
    transition: text-decoration-color 160ms ease-out, color 160ms ease-out;
}

.legal-panel a:hover {
    color: var(--dark-purple);
    text-decoration-color: currentColor;
}

.legal-panel a:focus-visible,
.legal-panel summary:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

/* ---------- Terms: intro, sections, notice ---------- */

.legal-panel .legal-intro {
    margin-bottom: 1.8rem;
    font-size: 1.05rem;
    color: var(--primary-color);
    text-wrap: pretty;
}

.legal-section {
    padding: 1.3rem 0;
    border-top: 1px solid var(--legal-rule);
    margin: 0;
    text-align: left;
}

.legal-section h2 {
    margin: 0 0 0.4rem;
}

.legal-panel .legal-notice {
    margin-top: 1.4rem;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--legal-rule);
    font-size: 0.9rem;
}

/* ---------- Privacy: regional sections ---------- */

.legal-region {
    margin: 0.75rem 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.45);
    border: 1px solid var(--legal-rule);
}

.legal-region > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1.2rem;
    cursor: pointer;
    list-style: none;
    color: var(--primary-color);
    font-weight: 600;
    border-radius: 12px;
    transition: background-color 160ms ease-out;
}

.legal-region > summary::-webkit-details-marker {
    display: none;
}

.legal-region > summary::after {
    content: '';
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    margin-top: -0.25rem;
    border-right: 2px solid var(--dark-purple);
    border-bottom: 2px solid var(--dark-purple);
    transform: rotate(45deg);
    transition: transform 200ms ease-out, margin 200ms ease-out;
}

.legal-region[open] > summary::after {
    margin-top: 0.25rem;
    transform: rotate(-135deg);
}

.legal-region > summary:hover {
    background: rgba(255, 255, 255, 0.45);
}

.legal-region[open] > summary {
    border-bottom: 1px solid var(--legal-rule);
    border-radius: 12px 12px 0 0;
}

.legal-region-body {
    padding: 0.4rem 1.2rem 1.2rem;
}

.legal-region-body h2:first-child {
    margin-top: 0.8rem;
}

.legal-region-body table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    font-size: 0.9rem;
    display: block;
    overflow-x: auto;
}

.legal-region-body th,
.legal-region-body td {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--legal-rule);
    vertical-align: top;
    text-align: left;
}

.legal-region-body th {
    background: rgba(8, 52, 52, 0.06);
    color: var(--primary-color);
}

/* ---------- Back to top ---------- */

.legal-panel .legal-top {
    margin-top: 2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--legal-rule);
    text-align: center;
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .legal-panel {
        border-radius: 14px;
        margin-bottom: 2.5rem;
    }

    .legal-region > summary,
    .legal-region-body {
        padding-left: 0.9rem;
        padding-right: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .legal-region > summary::after {
        transition: none;
    }
}
