/*
 * Motion: a small, quiet layer on top of the design. Three things move:
 *
 *   1. Hero zoom    – the hero's arch photo eases from 106% to 100% once, on load.
 *   2. Fade-ups     – cards, photos and bands fade up as they scroll into view.
 *                     motion.js picks them (and anything with class="is-reveal") and
 *                     adds .is-visible when they appear. See docs/motion.md.
 *   3. Hovers       – cards lift, arch photos zoom a touch, nav/footer underlines grow.
 *                     Only on devices with a real mouse (@media (hover: hover)).
 *
 * Everything is switched off for people who ask for less motion (bottom of the file).
 * Loads after theme.css and the section CSS (inc/setup.php), so equal selectors win.
 */

/* ==========================================================================
   1. Hero zoom-in. The photo starts slightly larger and settles. The arch wrapper
   (.pe-arch) has overflow: hidden, so the extra 6% is clipped by the arch shape.
   ========================================================================== */
@keyframes pe-hero-zoom {
	from { transform: scale(1.06); }
	to { transform: scale(1); }
}

.pe-hero__photo .pe-arch__img {
	animation: pe-hero-zoom 1.4s ease-out both;
}

/* ==========================================================================
   2. Fade-ups ("reveal").
   The hidden state only applies under html.pe-js, which motion.js adds. If the
   script never runs, nothing is hidden.
   motion.js only adds .is-reveal to things below the first screen, so nothing that
   is already on screen at load fades or jumps.

   The movement uses the `translate` property (not `transform`), and an animation
   (not a transition), so it never fights a card's own hover transform/transition.
   --pe-reveal-delay is set by motion.js to stagger cards that appear together.
   ========================================================================== */
@keyframes pe-reveal {
	from {
		opacity: 0;
		translate: 0 16px;
	}
}

html.pe-js .is-reveal:not(.is-visible) {
	opacity: 0;
	translate: 0 16px;
}

html.pe-js .is-reveal.is-visible {
	animation: pe-reveal 0.6s ease-out var(--pe-reveal-delay, 0s) backwards;
}

/* ==========================================================================
   3. Hovers (mouse only; touch screens have no hover and would "stick").
   Buttons already lift with a shadow in theme.css, so they are left alone.
   ========================================================================== */
@media (hover: hover) {

	/* ---------- Cards: lift 4px with a soft shadow ---------- */
	.pe-card {
		transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
	}

	/* FAQ items, cafe menu cards, the events calendar and the enquiry form's cards are
	   for reading or typing, not links, so they don't lift. */
	.pe-card:not(.pe-faq__item):not(.pe-cafe-menu__card):not(.pe-events-calendar__card):not(.pe-enquiry-form__card):not(.pe-enquiry-form__aside):hover {
		transform: translateY(-4px);
		box-shadow: 0 10px 24px rgb(32 61 54 / 0.1);
	}

	/* Feature cards already lift 6px (section-feature-cards.css). They are an arch
	   photo on a panel, so a box-shadow would draw a rectangle around the arch;
	   drop-shadow follows the real shape instead. */
	.pe-feature-cards__card {
		transition: transform 0.3s ease-out, filter 0.3s ease-out;
	}

	.pe-feature-cards__card:hover {
		filter: drop-shadow(0 10px 24px rgb(32 61 54 / 0.1));
	}

	/* ---------- Arch photos: the image zooms a touch, the arch clips it ---------- */
	.pe-gallery .pe-arch,
	.pe-split__media .pe-arch,
	.pe-feature-cards .pe-arch {
		isolation: isolate; /* keeps Safari clipping the corners while the image scales */
	}

	.pe-gallery .pe-arch__img,
	.pe-split__media .pe-arch__img,
	.pe-feature-cards .pe-arch__img {
		transition: transform 0.5s ease-out;
	}

	.pe-gallery__item:hover .pe-arch__img,
	.pe-split__media:hover .pe-arch__img,
	.pe-feature-cards__card:hover .pe-arch__img {
		transform: scale(1.03);
	}

	/* ---------- Footer links: a fainter line that grows the same way ---------- */
	.pe-footer__menu li:not(.current-menu-item):not(.current_page_item) > a {
		background: linear-gradient(color-mix(in srgb, currentColor 55%, transparent) 0 0) no-repeat left bottom / 0 1px;
		transition: background-size 0.3s ease-out;
	}

	.pe-footer__menu li:not(.current-menu-item):not(.current_page_item) > a:hover {
		background-size: 100% 1px;
		text-decoration: none; /* theme.css underlines on hover; the line replaces it */
	}
}

/* ---------- Header menu: an underline that grows from the left ----------
   Desktop row only: under 1024px the links are full-width rows in the mobile panel.
   The current page keeps theme.css's underline; the line sits in the same spot
   (the bottom of the 1.2 line box is about 0.2em under the letters, like the
   text-underline-offset there). */
@media (hover: hover) and (min-width: 1024px) {
	.pe-menu li:not(.current-menu-item):not(.current_page_item) > a {
		background: linear-gradient(currentColor 0 0) no-repeat left bottom / 0 1px;
		transition: background-size 0.3s ease-out;
	}

	.pe-menu li:not(.current-menu-item):not(.current_page_item) > a:hover {
		background-size: 100% 1px;
		text-decoration: none;
	}
}

/* ==========================================================================
   Less motion. Nothing animates, nothing moves, everything is visible.
   (Hover shadows stay: they don't move anything.)
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
	.pe-hero__photo .pe-arch__img,
	html.pe-js .is-reveal:not(.is-visible),
	html.pe-js .is-reveal.is-visible {
		animation: none;
		opacity: 1;
		translate: none;
	}

	.pe-card,
	.pe-card:hover,
	.pe-feature-cards__card,
	.pe-feature-cards__card:hover,
	.pe-gallery .pe-arch__img,
	.pe-split__media .pe-arch__img,
	.pe-feature-cards .pe-arch__img {
		transition: none;
		transform: none;
	}

	.pe-menu a,
	.pe-footer__menu a {
		transition: none;
	}
}
