/* Shared modal close treatment, including Bootstrap buttons rendered dynamically. */
html body :is(.modal .btn-close, .se-modal-close) {
    box-sizing: border-box;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--se-accent, var(--zv2-accent-2, #4ea1ff)) 35%, var(--se-border, var(--zv2-border, #2f333e)));
    border-radius: var(--se-radius-control, 0px);
    background-color: var(--se-card-alt, var(--zv2-surface-2, #20232b));
    background-image: none !important;
    color: var(--se-text, var(--zv2-text, #e7e9ee));
    filter: none !important;
    opacity: 1 !important;
    box-shadow: none;
    cursor: pointer;
}

html body :is(.modal .btn-close, .se-modal-close):is(:hover, :focus-visible) {
    color: var(--se-accent, var(--zv2-accent-2, #4ea1ff));
    border-color: var(--se-accent, var(--zv2-accent-2, #4ea1ff));
    background-color: color-mix(in srgb, var(--se-accent, var(--zv2-accent-2, #4ea1ff)) 12%, var(--se-card-alt, var(--zv2-surface-2, #20232b)));
}

html body :is(.modal .btn-close, .se-modal-close):focus-visible {
    outline: 2px solid var(--se-accent, var(--zv2-accent-2, #4ea1ff));
    outline-offset: 3px;
}

html body .se-modal-close > svg { width: 24px; height: 24px; flex: none; pointer-events: none; }
.se-modal-close__frame { color: var(--se-accent, var(--zv2-accent-2, #4ea1ff)); }

/* Generic Bootstrap markup needs no JavaScript or DOM replacement. */
html body .modal .btn-close::before,
html body .modal .btn-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    background: currentColor;
    mask: var(--se-modal-close-mask) center / contain no-repeat;
}

html body .modal .btn-close::before {
    color: var(--se-accent, #4ea1ff);
    --se-modal-close-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
}

html body .modal .btn-close::after {
    --se-modal-close-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m8 8 8 8m0-8-8 8' stroke='black' stroke-width='2.2'/%3E%3C/svg%3E");
}

body .modal .modal-header {
    position: relative;
    align-items: flex-start;
    min-height: calc(44px + 2 * var(--bs-modal-header-padding-y, 1rem));
}

body .modal .modal-header > :not(.btn-close):not(.se-modal-close) {
    min-width: 0;
    max-width: calc(100% - 60px);
}

body .modal .modal-header :is(.btn-close, .se-modal-close) {
    position: absolute;
    top: var(--bs-modal-header-padding-y, 1rem);
    right: var(--bs-modal-header-padding-x, 1rem);
    margin: 0;
    z-index: 2;
}

body .modal .modal-content > .btn-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 2;
}

body .se-admin-command__top { align-items: flex-start; }
body .se-admin-command__top .se-modal-close { margin-left: auto; }
body #photoLightboxOverlay .se-lightbox-close-btn.se-modal-close {
    position: absolute;
    left: auto;
    right: calc(16px + env(safe-area-inset-right, 0px));
    top: calc(16px + env(safe-area-inset-top, 0px));
    z-index: 6;
}

html body .zv2-lightbox__close.se-modal-close {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: calc(16px + env(safe-area-inset-right, 0px));
    transform: none;
}

@media (forced-colors: active) {
    html body :is(.modal .btn-close, .se-modal-close) { border-color: ButtonText; color: ButtonText; background-color: Canvas; }
    .se-modal-close__frame, html body .modal .btn-close::before { color: ButtonText; }
    html body .modal .btn-close::before, html body .modal .btn-close::after { forced-color-adjust: none; }
}
