/* ==========================================================================
   Legal modal + document styles (scoped, reusable)
   - Looks the same everywhere (settings, login, register, index)
   - Does NOT depend on other CSS files
   - Uses strong scoping via #modal-legal to avoid conflicts
   ========================================================================== */

/* ---------- design tokens (local to this file when used inside the modal) */
:root {
    /* legal-doc palette */
    --legal-fg: #0f172a;
    --legal-muted: #475569;
    --legal-accent: #0ea5e9;
    --legal-bg-soft: #f8fafc;
    --legal-border: #e2e8f0;
    --legal-callout: #eef6ff;

    /* modal chrome */
    --legal-white: #fff;
    --legal-black: #000;
    --legal-overlay: rgba(0, 0, 0, .6);
}

/* ==========================================================================
   LEGAL MODAL CHROME (overlay, panel, close)
   These override any generic .modal styles on the page.
   ========================================================================== */

#modal-legal.modal {
    /* ensure we win over other .modal rules */
    display: none;
    position: fixed;
    inset: 0;
    background: var(--legal-overlay);
    z-index: 10050;
    /* higher than most app overlays */
}

#modal-legal .modal-content {
    /* match the “settings” modal look */
    background: var(--legal-white);
    color: var(--legal-black);
    /* larger for reading legal text, but still responsive */
    max-width: min(900px, 92vw);
    margin: 8% auto;
    padding: 24px 28px;
    border-radius: 12px;
    position: relative;
    box-sizing: border-box;

    /* smooth pop-in */
    animation: legal-zoomIn .25s;
    /* if some global .modal-content sets max-height/overflow, reset here */
    max-height: none;
    overflow: visible;
}

#modal-legal .modal-close {
    position: absolute;
    top: 10px;
    right: 16px;
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: var(--legal-black);
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    border-radius: 0;
}

#modal-legal h3 {
    margin: 0 0 10px;
    font: 600 1.15rem/1.3 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    color: var(--legal-black);
}

@keyframes legal-zoomIn {
    from {
        transform: scale(.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* container around the legal document body (scrolls vertically) */
#modal-legal .legal-body {
    max-height: 60vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--legal-border);
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    box-sizing: border-box;
}

/* selector at the top (dropdown) */
#modal-legal .pretty-select,
#modal-legal select {
    appearance: none;
    padding: 6px 32px 6px 10px;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background:
        #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='black'><polygon points='0,0 14,0 7,8'/></svg>") right 8px center / 10px no-repeat;
    color: #000;
}

#modal-legal .pretty-select:focus,
#modal-legal select:focus {
    outline: none;
    border-color: #666;
}

/* small helper for error text if AJAX fails */
#modal-legal .legal-error {
    padding: .75rem;
    border: 1px solid #e0b4b4;
    background: #fff6f6;
    color: #912d2b;
    border-radius: 8px;
}

/* keep the modal comfortable on small screens */
@media (max-width: 540px) {
    #modal-legal .modal-content {
        margin: 6% auto;
        padding: 16px 16px 18px;
        max-width: 94vw;
        border-radius: 10px;
    }

    #modal-legal .legal-body {
        max-height: 68vh;
        padding: 10px 12px;
    }
}

/* ==========================================================================
   LEGAL DOCUMENT TYPOGRAPHY (independent of the modal)
   Applies to the markup inside your terms.php / privacy.php / dpa.php / oss.php.
   ========================================================================== */

.legal-doc {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    color: var(--legal-fg);
    line-height: 1.6;
    max-width: 860px;
    margin: 0 auto;
    padding: 0;
    /* padding comes from .legal-body container */
    background: transparent;
    box-sizing: border-box;
}

.legal-doc h1 {
    font-size: 1.9rem;
    line-height: 1.2;
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.legal-doc .meta {
    color: var(--legal-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.legal-doc .badge {
    display: inline-block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--legal-bg-soft);
    border: 1px solid var(--legal-border);
    border-radius: 999px;
    padding: 3px 8px;
    margin-left: 8px;
}

.legal-doc .lede {
    background: var(--legal-bg-soft);
    border-left: 3px solid var(--legal-accent);
    padding: 12px 14px;
    margin: 16px 0 24px;
}

.legal-doc .toc {
    border: 1px solid var(--legal-border);
    border-radius: 10px;
    padding: 12px 16px;
    background: #fff;
    margin: 18px 0 26px;
}

.legal-doc .toc h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--legal-muted);
}

.legal-doc .toc ul {
    margin: 0;
    padding-left: 18px;
    columns: 2;
    gap: 24px;
}

@media (max-width: 640px) {
    .legal-doc .toc ul {
        columns: 1;
    }
}

.legal-doc a {
    color: var(--legal-accent);
    text-decoration: none;
}

.legal-doc a:hover {
    text-decoration: underline;
}

.legal-doc h2 {
    font-size: 1.25rem;
    margin: 28px 0 8px;
    padding-top: 6px;
    border-top: 1px solid var(--legal-border);
}

.legal-doc h3 {
    font-size: 1.05rem;
    margin: 18px 0 6px;
    color: var(--legal-fg);
}

.legal-doc p {
    margin: 10px 0;
}

.legal-doc ul,
.legal-doc ol {
    margin: 8px 0 14px 20px;
}

.legal-doc .callout {
    background: var(--legal-callout);
    border: 1px solid #cde5ff;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 14px 0;
}

.legal-doc .muted {
    color: var(--legal-muted);
}

.legal-doc .kv {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 6px 14px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--legal-border);
    border-radius: 10px;
    margin: 12px 0 20px;
}

.legal-doc .kv div:nth-child(odd) {
    color: var(--legal-muted);
}

.legal-doc .note {
    font-size: 0.92rem;
    color: var(--legal-muted);
}

.legal-doc table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 18px;
    font-size: 0.95rem;
}

.legal-doc th,
.legal-doc td {
    border: 1px solid var(--legal-border);
    padding: 8px 10px;
    vertical-align: top;
}

.legal-doc th {
    background: var(--legal-bg-soft);
    text-align: left;
}

.legal-doc--text {
    max-width: 100%;
}

.legal-doc .legal-plain-text {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font: 0.93rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* optional page-break helpers if someone prints the doc */
.legal-doc .page-break {
    break-before: page;
}

@media print {
    #modal-legal.modal {
        background: none !important;
    }

    /* cleaner print */
    #modal-legal .modal-content {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        max-width: none;
    }

    #modal-legal .modal-close {
        display: none;
    }

    #modal-legal .legal-body {
        max-height: none;
        overflow: visible;
        border: none;
        padding: 0;
    }

    .legal-doc {
        padding: 0;
    }

    .legal-doc .toc {
        page-break-inside: avoid;
    }

    .legal-doc h2 {
        page-break-after: avoid;
    }

    .legal-doc .page-break {
        break-before: page;
    }
}

/* Centered big title helper if you need it in your PHP docs */
.legal-title {
    font-size: clamp(1.2rem, 2.5vw, 1.6rem);
    text-align: center;
    margin: 0 0 .5rem;
}
