/*
 * Promptable effects. Opt-in classes (add them to a block's "Additional CSS class"):
 *   cc-sticky-header  header group: sticks to the top; on scroll gets a background and,
 *                     if a site logo is set, hides the site title (logo only)
 *   cc-hero           first section of a page: the sticky header floats transparently over it
 *                     until the visitor scrolls
 *   cc-intro          fades up on page load (cc-intro-2/-3/-4 add a delay)
 *   cc-reveal         fades up when scrolled into view
 *   cc-reveal-stagger same, one child after another
 *   cc-scroll-zoom    tilts and scales into place as the page scrolls (linked to scroll position)
 * Always on: smooth anchor scrolling and an animated accordion for Details blocks.
 * All motion is off for visitors who ask their system for reduced motion.
 */

html {
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--cc-header-h, 0px) + 16px);
}

/* Sticky header */
.wp-site-blocks > header:has(.cc-sticky-header) {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 100;
}
/* On phones the admin bar scrolls away instead of staying fixed, so stick to the very top. */
@media screen and (max-width: 600px) {
	.wp-site-blocks > header:has(.cc-sticky-header) { top: 0; }
}
.cc-sticky-header {
	background-color: var(--wp--preset--color--base);
	transition: background-color 0.35s ease, box-shadow 0.35s ease, color 0.35s ease;
}
.cc-scrolled .cc-sticky-header {
	box-shadow: 0 8px 30px rgb(0 0 0 / 0.08);
}
.cc-sticky-header .wp-block-site-title {
	max-width: 32ch;
	overflow: hidden;
	white-space: nowrap;
	transition: max-width 0.45s ease, opacity 0.3s ease;
}
.cc-scrolled .cc-sticky-header:has(.wp-block-site-logo img) .wp-block-site-title {
	max-width: 0;
	opacity: 0;
}

/* Transparent header over a hero until scrolled */
.cc-has-hero .wp-site-blocks > header:has(.cc-sticky-header) {
	margin-bottom: calc(-1 * var(--cc-header-h, 0px));
}
.cc-has-hero .cc-sticky-header {
	color: var(--wp--preset--color--base);
	background-color: var(--wp--preset--color--contrast);
}
.cc-has-hero:not(.cc-scrolled) .cc-sticky-header {
	background-color: transparent;
	box-shadow: none;
}
.cc-has-hero .cc-sticky-header :where(a, .wp-block-navigation-item__content, .wp-block-site-title, button) {
	color: inherit;
}

/* Intro on page load */
@keyframes cc-fade-up {
	from { opacity: 0; transform: translateY(18px); }
	to { opacity: 1; transform: none; }
}
.cc-intro { animation: cc-fade-up 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.cc-intro-2 { animation-delay: 0.15s; }
.cc-intro-3 { animation-delay: 0.3s; }
.cc-intro-4 { animation-delay: 0.45s; }

/* Reveal on scroll (only hidden once the script is running) */
.cc-js .cc-reveal,
.cc-js .cc-reveal-stagger > * {
	opacity: 0;
	transform: translateY(28px);
	transition: opacity 0.7s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
	transition-delay: calc(var(--cc-i, 0) * 110ms);
}
.cc-js .cc-reveal.is-revealed,
.cc-js .cc-reveal-stagger.is-revealed > * {
	opacity: 1;
	transform: none;
}

/* Scroll-linked zoom: --cc-p goes 0 -> 1 as the element moves up the screen */
.cc-scroll-zoom {
	transform: perspective(1400px) rotateX(calc((1 - var(--cc-p, 1)) * 16deg)) scale(calc(0.9 + var(--cc-p, 1) * 0.1));
	transform-origin: 50% 0;
	will-change: transform;
}

/* Accordion (Details block) */
.wp-block-details {
	border: 1px solid rgb(0 0 0 / 0.1);
	border-radius: 12px;
	padding: 0 1.25rem;
	background-color: var(--wp--preset--color--base);
	overflow: hidden;
}
.wp-block-details summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 0;
	font-weight: 600;
	cursor: pointer;
	list-style: none;
}
.wp-block-details summary::-webkit-details-marker { display: none; }
.wp-block-details summary::after {
	content: "+";
	font-size: 1.5em;
	line-height: 1;
	transition: transform 0.3s ease;
}
.wp-block-details[open] summary::after { transform: rotate(45deg); }
.wp-block-details > :not(summary):last-child { padding-bottom: 1rem; }

@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	.cc-intro { animation: none; }
	.cc-js .cc-reveal,
	.cc-js .cc-reveal-stagger > * { opacity: 1; transform: none; transition: none; }
	.cc-scroll-zoom { transform: none; }
	.cc-sticky-header,
	.cc-sticky-header .wp-block-site-title,
	.wp-block-details summary::after { transition: none; }
}
