/* Legal documents page (site/legal.php) — 2026-10-28. Colours come from the site theme variables set inline by the page
   (same set as login.css). The PDF itself is shown untouched: inline viewer on desktop, open / download elsewhere. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
.legal-body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg4);
    color: var(--text1);
    font-family: 'Inter', 'Rubik', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
[dir="rtl"] .legal-body { font-family: 'Rubik', 'Inter', system-ui, sans-serif; }
.legal-body a { color: inherit; }
.legal-body a:focus-visible,
.legal-main:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.legal-skip {
    position: absolute;
    inset-inline-start: 8px;
    top: -48px;
    z-index: 10;
    padding: 8px 12px;
    background: var(--primary);
    color: var(--on-primary) !important;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
}
.legal-skip:focus { top: 8px; }
.legal-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* header */
.legal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border1);
}
.legal-logo img { display: block; height: 34px; width: auto; }
.legal-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.legal-nav a {
    padding: 6px 12px;
    border: 1px solid var(--border1);
    border-radius: var(--radius);
    color: var(--text2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}
.legal-nav a:hover { color: var(--primary); border-color: var(--primary); }
.legal-nav a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* main */
.legal-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
    min-height: 0;
}
.legal-titlebar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.legal-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--text1); }
/* title-bar actions belong to the inline viewer; without it the open / download card below carries them (no duplicates) */
.legal-actions { display: none; flex-wrap: wrap; gap: 8px; }
.legal-inline .legal-actions { display: flex; }
.legal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid var(--border1);
    border-radius: var(--radius);
    background: var(--bg3);
    color: var(--text1);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}
.legal-btn:hover { border-color: var(--primary); color: var(--primary); }
.legal-btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary) !important; }
.legal-btn-primary:hover { filter: brightness(1.08); color: var(--on-primary); }
.legal-btn-lg { min-height: 48px; padding: 12px 28px; font-size: 15px; }

/* inline viewer (desktop with a built-in PDF viewer) */
.legal-viewer {
    flex: 1;
    display: flex;
    min-height: 0;
    border: 1px solid var(--border1);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg3);
}
.legal-frame {
    flex: 1;
    width: 100%;
    min-height: 70vh;
    height: calc(100vh - 190px);
    height: calc(100dvh - 190px);
    border: 0;
    display: block;
}

/* open / download card (phones, no viewer, no JS, missing document) */
.legal-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin: 24px auto;
    padding: 32px 20px;
    width: 100%;
    max-width: 480px;
    text-align: center;
    background: var(--bg2);
    border: 1px solid var(--border1);
    border-radius: var(--radius);
}
.legal-fallback p { margin: 0; color: var(--text2); }
.legal-fallback-icon { width: 48px; height: 48px; color: var(--primary); }
.legal-link { color: var(--text3) !important; font-size: 13px; }
.legal-link:hover { color: var(--primary) !important; }

/* footer */
.legal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border1);
    background: var(--bg2);
    color: var(--text3);
    font-size: 12px;
}
.legal-footer a { color: var(--text3); text-decoration: none; }
.legal-footer a:hover { color: var(--primary); }

@media (max-width: 768px) {
    .legal-header { flex-direction: column; align-items: stretch; }
    .legal-logo { align-self: center; }
    .legal-nav { justify-content: center; }
    .legal-main { padding: 12px; }
    .legal-title { font-size: 18px; width: 100%; text-align: center; }
    .legal-actions { width: 100%; }
    .legal-actions .legal-btn { flex: 1; }
    .legal-footer { justify-content: center; text-align: center; }
}
