/*
 * Modals for content written In Admin (web/js/satrunner-modal.js, docs/modals.html).
 * The content element (.sr-modal) is hidden on the page and shown inside the <dialog> the script builds around it.
 * Light by default: white card, dark text, orange accents; sr-modal--dark for the dark look (SIM pages).
 * Desktop and Tablet: centred card, 560px wide (880px with sr-modal--wide). Mobile: full width minus 16px each side.
 */
.sr-modal {
    display: none;
}

.sr-modal-dialog > .sr-modal {
    display: block;
}

/* While a modal is open the page behind it doesn't scroll. Lock only <html>: from 768px Luma's styles-l.css
   makes body 100% tall, so hiding body's overflow cut the page to one screen and it jumped to the top */
html.sr-modal-is-open {
    overflow: hidden;
}

.sr-modal-dialog {
    box-sizing: border-box;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    margin: auto;
    padding: 40px 40px 32px;
    overflow: auto;
    overscroll-behavior: contain;
    border: 0;
    border-top: 4px solid #f26a21;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    color: #333333;
    font-size: 1.6rem;
    line-height: 1.6;
}

.sr-modal-dialog--wide {
    width: min(880px, calc(100vw - 32px));
}

.sr-modal-dialog::backdrop {
    background: rgba(10, 12, 15, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.sr-modal-dialog[open] {
    animation: sr-modal-in 0.25s ease-out;
}

@keyframes sr-modal-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
}

/* Content: the author's own markup; headings and paragraphs get sensible spacing */
.sr-modal-dialog .sr-modal > :first-child {
    margin-top: 0;
}

.sr-modal-dialog .sr-modal > :last-child {
    margin-bottom: 0;
}

.sr-modal-dialog .sr-modal h1,
.sr-modal-dialog .sr-modal h2,
.sr-modal-dialog .sr-modal h3 {
    margin: 0 48px 12px 0; /* clear of the close button */
    color: #14181c;
    font-family: 'Barlow', sans-serif;
    font-weight: 600;
    line-height: 1.2;
}

.sr-modal-dialog .sr-modal h2 {
    font-size: 2.8rem;
}

.sr-modal-dialog .sr-modal h3 {
    font-size: 2.4rem;
}

.sr-modal-dialog .sr-modal p {
    margin: 0 0 12px;
}

/* Links in the content: brand orange instead of Luma's blue (the site-wide hover still applies) */
.sr-modal-dialog .sr-modal a,
.sr-modal-dialog .sr-modal a:visited {
    color: #f26a21;
    font-weight: 600;
}

/* Close button, top right */
.sr-modal-dialog .sr-modal-dialog__close {
    position: absolute;
    top: 20px;
    right: 20px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: none;
    color: #333333;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sr-modal-dialog .sr-modal-dialog__close:hover,
.sr-modal-dialog .sr-modal-dialog__close:focus-visible {
    border-color: #f26a21;
    background: #f26a21;
    color: #ffffff;
}

.sr-modal-dialog .sr-modal-dialog__close:focus-visible {
    outline: 2px solid #f26a21;
    outline-offset: 2px;
}

.sr-modal-dialog__close svg {
    width: 16px;
    height: 16px;
}

/* Dark look, as on the SIM pages */
.sr-modal-dialog--dark {
    background: #1f2328;
    color: rgba(255, 255, 255, 0.8);
}

.sr-modal-dialog--dark .sr-modal h1,
.sr-modal-dialog--dark .sr-modal h2,
.sr-modal-dialog--dark .sr-modal h3 {
    color: #ffffff;
}

.sr-modal-dialog--dark .sr-modal-dialog__close {
    border-color: rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #ffffff;
}

/* Mobile */
@media (max-width: 448px) {
    .sr-modal-dialog,
    .sr-modal-dialog--wide {
        width: calc(100vw - 32px);
        padding: 32px 20px 24px;
    }

    .sr-modal-dialog .sr-modal-dialog__close {
        top: 12px;
        right: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sr-modal-dialog[open] {
        animation: none;
    }

    .sr-modal-dialog .sr-modal-dialog__close {
        transition: none;
    }
}
