/**
 * Event pop-up (axelle-announcement), design 1b: the loader bird draws its
 * spiral, then the invitation fades in. Texts, images and buttons come from
 * the synced pattern "Pop-up: book launch (bird)".
 */

/* ---------- Shared ---------- */

html:has(dialog.axelle-popup[open]) {
	overflow: hidden;
}

.axelle-popup {
	box-sizing: border-box;
	max-width: calc(100vw - 32px);
	max-height: calc(100svh - 32px);
	padding: 0;
	border: 0;
	overflow: auto;
	overscroll-behavior: contain;
	color: inherit;
	background: var(--wp--preset--color--background, #fff);
	font: inherit;
	text-align: center;
}

.axelle-popup:focus {
	outline: none;
}

.axelle-popup__inner {
	padding: var(--wp--preset--spacing--60, 40px) var(--wp--preset--spacing--50, 24px);
}

.axelle-popup__content > * + * {
	margin-block-start: 0.6em;
}

.axelle-popup__content :is(p, h2) {
	margin-block-end: 0;
}

.axelle-popup__content h2 {
	margin-block-start: 0.2em;
}

.axelle-popup__content .wp-block-image {
	margin-inline: auto;
	margin-block-end: 0;
}

.axelle-popup__content .wp-block-image img {
	max-width: 100%;
	height: auto;
}

.axelle-popup__content .wp-block-buttons {
	justify-content: center;
	margin-block-start: var(--wp--preset--spacing--50, 24px);
}

/* Buttons: the outline style's padding and a 2px border (same height in both styles). */
.axelle-popup .axelle-popup__content .wp-block-button > .wp-block-button__link {
	padding: 0.667em 1.33em;
	border: 2px solid #000;
}

/*
 * The filled button: white text (the site's button text is grey-blue), and
 * reversed on hover, as the outline one: white with black text. In CSS, not as
 * a block text colour: preset colour classes are !important and would block
 * the hover.
 */
.axelle-popup__content .wp-block-button:not(.is-style-outline) > .wp-block-button__link {
	color: var(--wp--preset--color--background, #fff);
}

.axelle-popup__content .wp-block-button:not(.is-style-outline) > .wp-block-button__link:hover {
	background-color: var(--wp--preset--color--background, #fff);
	color: #000;
}

.axelle-popup__close {
	position: absolute;
	top: 4px;
	right: 4px;
	z-index: 1;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	color: inherit;
	background: none;
	font: inherit;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
}

.axelle-popup__close:hover,
.axelle-popup__close:focus-visible {
	text-decoration: underline;
}

/* ---------- Bird ---------- */

.axelle-popup {
	width: 460px;
}

.axelle-popup::backdrop {
	background: rgba(255, 255, 255, 0.88);
}

.axelle-popup[open] {
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.axelle-popup__bird {
	display: block;
	width: auto;
	height: min(26svh, 190px);
	aspect-ratio: 440 / 600;
	margin: 0 auto var(--wp--preset--spacing--40, 16px);
	overflow: visible;
}

.axelle-popup__line {
	fill: none;
	stroke: #fff;
	stroke-width: 16;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 1 1;
	stroke-dashoffset: 1;
}

.axelle-popup__spiral-full {
	opacity: 0;
}

/* Drawn once (1.6 s), then the unmasked spiral takes over (exact drawing). */
.axelle-popup[open] .axelle-popup__line {
	animation: axelle-popup-draw 1.6s cubic-bezier(0.45, 0.05, 0.4, 1) 0.2s forwards;
}

.axelle-popup[open] .axelle-popup__spiral {
	animation: axelle-popup-hide 0s linear 1.8s forwards;
}

.axelle-popup[open] .axelle-popup__spiral-full {
	animation: axelle-popup-show 0s linear 1.8s forwards;
}

.axelle-popup[open] .axelle-popup__content {
	opacity: 0;
	animation: axelle-popup-rise 0.6s ease-out 1.2s forwards;
}

@keyframes axelle-popup-draw {
	to {
		stroke-dashoffset: 0;
	}
}

@keyframes axelle-popup-hide {
	to {
		opacity: 0;
	}
}

@keyframes axelle-popup-show {
	to {
		opacity: 1;
	}
}

@keyframes axelle-popup-rise {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

/* Short phones (320×568): less padding, smaller drawing. */
@media (max-height: 640px) {
	.axelle-popup__inner {
		padding: 36px var(--wp--preset--spacing--40, 16px) var(--wp--preset--spacing--50, 24px);
	}

	.axelle-popup__bird {
		height: 18svh;
		margin-block-end: 8px;
	}

	.axelle-popup__content .wp-block-buttons {
		margin-block-start: var(--wp--preset--spacing--40, 16px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.axelle-popup[open],
	.axelle-popup[open] * {
		animation: none !important;
	}

	.axelle-popup .axelle-popup__content {
		opacity: 1;
	}

	.axelle-popup__spiral {
		opacity: 0;
	}

	.axelle-popup__spiral-full {
		opacity: 1;
	}
}
