/* MKCD Modals – Frontend. Theme-Werte (theme.json-Presets) dienen als Fallback, eigene Werte via Custom Properties. */
.mkcd-modal {
	box-sizing: border-box;
	width: calc(100% - 2rem);
	max-width: var(--mkcd-width, 560px);
	max-height: calc(100dvh - 2rem);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--mkcd-radius, 12px);
	overflow: hidden;
	background: var(--mkcd-bg, var(--wp--preset--color--base, #fff));
	color: var(--mkcd-text, var(--wp--preset--color--contrast, #1e1e1e));
	font: inherit;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.mkcd-modal *, .mkcd-modal *::before, .mkcd-modal *::after { box-sizing: border-box; }
.mkcd-modal::backdrop { background: var(--mkcd-overlay, rgba(0, 0, 0, .6)); }
html:has(.mkcd-modal:modal) { overflow: hidden; }

/* Slide-in-Positionen (nicht modal, ohne Overlay). */
.mkcd-modal--bottom-right,
.mkcd-modal--bottom-left {
	position: fixed;
	inset: auto 1rem 1rem auto;
	z-index: 99999;
	margin: 0;
	max-height: calc(100dvh - 2rem);
}
.mkcd-modal--bottom-left { inset: auto auto 1rem 1rem; }

.mkcd-modal__inner {
	position: relative;
	display: flex;
	flex-direction: column;
	max-height: inherit;
	overflow: auto;
	overscroll-behavior: contain;
}
.mkcd-modal__media img {
	display: block;
	width: 100%;
	height: auto;
	max-height: 45vh;
	object-fit: cover;
}
.mkcd-modal__media-link { display: block; height: 100%; }
.mkcd-modal__media-link img { transition: opacity .2s; }
.mkcd-modal__media-link:hover img { opacity: .92; }
.mkcd-modal__media-link:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.mkcd-modal__body { padding: clamp(1.25rem, 4vw, 2rem); }
.mkcd-modal__title { margin: 0 0 .5em; color: inherit; }
.mkcd-modal__text > :first-child { margin-top: 0; }
.mkcd-modal__text > :last-child { margin-bottom: 0; }
.mkcd-modal__text a:not(.wp-element-button) { color: inherit; }
.mkcd-modal--no-image .mkcd-modal__body { padding-right: clamp(3rem, 6vw, 3.5rem); }
.mkcd-modal--align-center .mkcd-modal__body { text-align: center; padding-right: clamp(1.25rem, 4vw, 2rem); }
.mkcd-modal--align-center.mkcd-modal--no-image .mkcd-modal__body { padding-inline: clamp(3rem, 6vw, 3.5rem); }

/* Bild nicht beschneiden (z. B. Hochformat-Cover): komplett zeigen, Rest bleibt Modal-Hintergrund. */
.mkcd-modal--fit-contain .mkcd-modal__media { padding: clamp(1rem, 3vw, 1.5rem) clamp(1rem, 3vw, 1.5rem) 0; }
.mkcd-modal--fit-contain .mkcd-modal__media img { object-fit: contain; max-height: 40vh; }

@media (min-width: 640px) {
	.mkcd-modal--layout-left .mkcd-modal__inner { flex-direction: row; }
	.mkcd-modal--layout-left .mkcd-modal__media { flex: 0 0 42%; }
	.mkcd-modal--layout-left .mkcd-modal__media img { height: 100%; max-height: none; }
	.mkcd-modal--layout-left .mkcd-modal__body { align-self: center; }
	.mkcd-modal--layout-left.mkcd-modal--fit-contain .mkcd-modal__media { align-self: center; padding: clamp(1rem, 3vw, 1.5rem) 0 clamp(1rem, 3vw, 1.5rem) clamp(1rem, 3vw, 1.5rem); }
	.mkcd-modal--layout-left.mkcd-modal--fit-contain .mkcd-modal__media img { height: auto; max-height: calc(100dvh - 5rem); }
}

/* Schließen-Button: robust gegen globale Theme-Button-Stile. */
.mkcd-modal .mkcd-modal__close {
	position: absolute;
	top: .625rem;
	right: .625rem;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mkcd-bg, var(--wp--preset--color--base, #fff));
	color: var(--mkcd-text, var(--wp--preset--color--contrast, #1e1e1e));
	box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
	opacity: .9;
	cursor: pointer;
	line-height: 1;
}
.mkcd-modal .mkcd-modal__close:hover { opacity: 1; }

/* Buttons */
.mkcd-modal__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .75rem;
	margin-top: 1.5rem;
}
.mkcd-modal--align-center .mkcd-modal__actions { justify-content: center; }
.mkcd-modal__btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }

/* Fallbacks ohne Spezifität (:where) – das Theme gewinnt immer. */
:where(.mkcd-modal__btn--primary, .mkcd-modal__btn--secondary) {
	padding: .75em 1.5em;
	border: 2px solid transparent;
	border-radius: 4px;
	font: inherit;
	line-height: 1.2;
}
:where(.mkcd-modal__btn--primary) {
	background: var(--wp--preset--color--primary, var(--wp--preset--color--contrast, #1e1e1e));
	color: var(--wp--preset--color--base, #fff);
}

.mkcd-modal .mkcd-modal__btn--secondary {
	background: transparent;
	color: inherit;
	border: 2px solid currentColor;
}
.mkcd-modal .mkcd-modal__btn--link {
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	box-shadow: none;
	min-height: 0;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	text-underline-offset: .2em;
}
.mkcd-modal .mkcd-modal__btn:hover { opacity: .9; }

/* Eigene Button-Farben (nur wenn gesetzt). */
.mkcd-modal.has-btn-bg .mkcd-modal__btn--primary { background: var(--mkcd-btn-bg); border-color: var(--mkcd-btn-bg); }
.mkcd-modal.has-btn-bg .mkcd-modal__btn--secondary { color: var(--mkcd-btn-bg); }
.mkcd-modal.has-btn-text .mkcd-modal__btn--primary { color: var(--mkcd-btn-text); }

/* Animationen */
.mkcd-modal[open] { animation: mkcd-fade .3s ease-out; }
.mkcd-modal--anim-slide[open] { animation-name: mkcd-slide; }
.mkcd-modal--anim-zoom[open] { animation-name: mkcd-zoom; }
.mkcd-modal--anim-none[open] { animation: none; }
.mkcd-modal[open]::backdrop { animation: mkcd-fade .3s ease-out; }

@keyframes mkcd-fade { from { opacity: 0; } }
@keyframes mkcd-slide { from { opacity: 0; transform: translateY(2rem); } }
@keyframes mkcd-zoom { from { opacity: 0; transform: scale(.92); } }

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