/*
 * The project pop-up: a project card ("project-card", and the footer's Impressum/Datenschutz links)
 * opens its page in a panel on the right, an iframe of the page with ?project_overlay=1 (script.js).
 * The page behind stays visible in a strip on the left, where the close button sits; on phones the
 * panel takes the whole screen and the button sits top right. Clicking the strip closes it too.
 *
 * The pop-up is added to <body>, outside the page's container, so its sizes follow the window
 * (media queries), not the page.
 */

.project-card {
    position: relative;
    cursor: pointer;
}

/* A card shows it has the keyboard's focus (not after a click) */
.project-card:has(a:focus-visible) {
    outline: 2px solid currentColor;
    outline-offset: 4px;
}

.project-card a:focus-visible {
    outline: none;
}

body.project-modal-open {
    overflow: hidden;
}

.project-modal {
    --project-modal-rail: clamp(190px, 15vw, 285px);

    position: fixed;
    inset: 0;
    z-index: 999999;
    width: 100vw;
    height: 100dvh;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.25s ease,
        visibility 0.25s ease;
}

.project-modal.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* The page behind, dimmed; a click on it closes the pop-up */
.project-modal__backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(232, 232, 232, 0.86);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    cursor: pointer;
}

/* The project page, right of the strip */
.project-modal__stage {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--project-modal-rail);
    z-index: 1;
    overflow: hidden;
    background: var(--mcg-color-surface-dark);
}

.project-modal__iframe {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--mcg-color-surface-dark);
}

/* The close button, in the strip */
.project-modal__close {
    position: absolute;
    top: 22px;
    left: 22px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin: 0;
    padding: 0;
    border: 2px solid var(--mcg-color-primary);
    border-radius: 50%;
    background: transparent;
    color: var(--mcg-color-primary);
    font: inherit;
    font-size: 34px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
}

.project-modal__loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--mcg-color-surface-dark);
    color: var(--mcg-color-text-on-dark);
}

.project-modal.is-loading .project-modal__loading {
    display: flex;
}

/* Tablets: a narrower strip, a smaller button */
@media (min-width: 768px) and (max-width: 1100px) {
    .project-modal {
        --project-modal-rail: clamp(120px, 13vw, 170px);
    }

    .project-modal__close {
        top: 18px;
        left: 18px;
        width: 50px;
        height: 50px;
        font-size: 30px;
    }
}

/* Phones: the project takes the whole screen, the button top right, white */
@media (max-width: 767px) {
    .project-modal {
        --project-modal-rail: 0px;
    }

    .project-modal__close {
        position: fixed;
        top: 14px;
        right: 14px;
        left: auto;
        width: 46px;
        height: 46px;
        border-color: var(--mcg-color-text-on-dark);
        color: var(--mcg-color-text-on-dark);
        font-size: 28px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .project-modal {
        transition: none;
    }
}

/*
 * The page inside the pop-up (?project_overlay=1: script.js puts project-overlay-embed on <html> and
 * <body>): no header, footer or admin bar, nothing around the content. The project's own blocks keep
 * their layout.
 */
html.project-overlay-embed {
    margin-top: 0 !important; /* WordPress's admin-bar margin is !important */
    min-height: 100%;
}

body.project-overlay-embed {
    margin: 0;
    padding: 0;
    min-height: 100dvh;
}

body.project-overlay-embed #wpadminbar,
body.project-overlay-embed .wp-site-blocks > .wp-block-template-part {
    display: none;
}

body.project-overlay-embed .wp-site-blocks {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
}

body.project-overlay-embed .entry-content.wp-block-post-content {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
}

body.project-overlay-embed .project-modal-content {
    position: relative;
}
