/**
 * Shared legal document modal (portal + auth pages).
 * @author Kaido Mägi
 * @copyright 2026
 */

.mekry-legal-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.mekry-legal-modal[hidden] {
    display: none;
}

body.mekry-legal-modal-open {
    overflow: hidden;
}

.mekry-legal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 14, 22, 0.72);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.mekry-legal-modal-dialog {
    position: relative;
    background: #182637;
    border: 1px solid #243447;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mekryLegalModalIn 0.18s ease-out;
}

@keyframes mekryLegalModalIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.mekry-legal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid #243447;
    background: linear-gradient(180deg, rgba(15, 31, 48, 0.6), rgba(24, 38, 55, 0));
}

.mekry-legal-modal-title {
    margin: 0;
    color: #e2e8f0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
}

body.mekry-portal-page .mekry-legal-modal-close,
body.mekry-auth-page .mekry-legal-modal-close {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    accent-color: transparent;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    width: 32px;
    height: 32px;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border: 1px solid transparent !important;
    border-radius: 6px;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
    flex: 0 0 auto;
    outline: none !important;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

body.mekry-portal-page .mekry-legal-modal-close-x,
body.mekry-auth-page .mekry-legal-modal-close-x {
    display: inline-block;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 22px;
    line-height: 1;
    font-weight: 400;
    color: inherit;
    pointer-events: none;
    transform: translateY(-1px);
}

body.mekry-portal-page .mekry-legal-modal-close:hover,
body.mekry-auth-page .mekry-legal-modal-close:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.18) !important;
}

body.mekry-portal-page .mekry-legal-modal-close:focus,
body.mekry-auth-page .mekry-legal-modal-close:focus {
    outline: none !important;
    border-color: transparent !important;
}

body.mekry-portal-page .mekry-legal-modal-close:focus-visible,
body.mekry-auth-page .mekry-legal-modal-close:focus-visible {
    outline: 2px solid #5FB4F5 !important;
    outline-offset: 2px;
}

.mekry-legal-modal-meta {
    margin: 0;
    padding: 10px 22px 0;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.mekry-legal-modal-body {
    padding: 18px 22px 22px;
    overflow: auto;
    color: #e2e8f0;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.mekry-legal-modal-body h1,
.mekry-legal-modal-body h2,
.mekry-legal-modal-body h3,
.mekry-legal-modal-body h4 {
    color: #e2e8f0;
    margin: 1.5em 0 0.4em;
    line-height: 1.3;
}

.mekry-legal-modal-body h1 { font-size: 1.25rem; }
.mekry-legal-modal-body h2 { font-size: 1.0625rem; }
.mekry-legal-modal-body h3 { font-size: 0.9375rem; text-transform: uppercase; letter-spacing: 0.04em; color: #94a3b8; }

.mekry-legal-modal-body h1:first-child,
.mekry-legal-modal-body h2:first-child,
.mekry-legal-modal-body h3:first-child {
    margin-top: 0;
}

.mekry-legal-modal-body p {
    margin: 0 0 1em;
}

.mekry-legal-modal-body ul,
.mekry-legal-modal-body ol {
    margin: 0 0 1em;
    padding-left: 1.4em;
}

.mekry-legal-modal-body li + li {
    margin-top: 0.35em;
}

.mekry-legal-modal-body a {
    color: #6EE7B7;
}

.mekry-legal-modal-body a:hover {
    color: #4ade80;
}

.mekry-legal-modal-status {
    margin: 0;
    padding: 18px 0;
    color: rgba(255, 255, 255, 0.55);
    text-align: center;
    font-size: 0.875rem;
}

.mekry-legal-modal-status-error {
    color: #f87171;
}

@media (max-width: 640px) {
    .mekry-legal-modal { padding: 12px; }
    .mekry-legal-modal-dialog { border-radius: 10px; max-height: calc(100vh - 24px); }
    .mekry-legal-modal-header { padding: 14px 16px; }
    .mekry-legal-modal-meta { padding: 8px 16px 0; }
    .mekry-legal-modal-body { padding: 14px 16px 18px; }
}
