/* Mad Men — site animations. Everything sits under html.mmfx, which is only set
   when the visitor's device does not ask to reduce motion. */

/* 1. Content revealed on scroll. Hidden from first paint (no flash); shown as it
   comes into view. If the script never runs, html.mmfx-safe shows everything. */
html.mmfx:not(.mmfx-safe) .mm-main :is(.mm-intro, .mm-feature, .mm-room, .mmm-team__member, .mmm-moment__menu, .mm-band, .mm-contact-grid > *, .mm-form, .mm-menu-content > :not(.mmfx-secnav)):not(.is-in) {
	opacity: 0;
	transform: translateY(26px);
}
html.mmfx .mm-main :is(.mm-intro, .mm-feature, .mm-room, .mmm-team__member, .mmm-moment__menu, .mm-band, .mm-contact-grid > *, .mm-form, .mm-menu-content > :not(.mmfx-secnav)) {
	transition: opacity .8s cubic-bezier(.2, .7, .2, 1) var(--mmfx-d, 0s), transform .8s cubic-bezier(.2, .7, .2, 1) var(--mmfx-d, 0s);
}

/* 2. Slow zoom on the photo at the top of each page. */
html.mmfx .mm-hero-photo { overflow: hidden; }
html.mmfx .mm-hero-photo img { animation: mmfx-zoom 16s ease-out both; transform-origin: 50% 45%; will-change: transform; }
@keyframes mmfx-zoom { from { transform: scale(1); } to { transform: scale(1.08); } }
html.mmfx .mm-hero h1, html.mmfx .mm-hero > p, html.mmfx .mm-hero .wp-block-buttons {
	animation: mmfx-rise .9s cubic-bezier(.2, .7, .2, 1) both;
}
html.mmfx .mm-hero > p { animation-delay: .15s; }
html.mmfx .mm-hero .wp-block-buttons { animation-delay: .3s; }
@keyframes mmfx-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* 3. Hover on photos and buttons (computers only: phones have no hover). */
@media (hover: hover) {
	html.mmfx .mm-feature figure, html.mmfx .mm-room-photo { overflow: hidden; }
	html.mmfx .mm-feature figure img, html.mmfx .mm-room-photo img, html.mmfx .mmm-team__member img {
		transition: transform .7s cubic-bezier(.2, .7, .2, 1), filter .5s ease;
	}
	html.mmfx .mm-feature:hover figure img, html.mmfx .mm-room:hover .mm-room-photo img { transform: scale(1.05); filter: brightness(.92); }
	html.mmfx .mmm-team__member:hover img { filter: brightness(.94) saturate(1.05); }

	html.mmfx .mm-site .wp-block-button__link, html.mmfx .mm-site .mm-button {
		transition: background-color .25s ease, color .25s ease, transform .25s ease, box-shadow .25s ease;
	}
	html.mmfx .mm-site .wp-block-button__link:hover, html.mmfx .mm-site .mm-button:hover {
		transform: translateY(-2px);
		box-shadow: 0 8px 20px rgba(16, 43, 80, .22);
	}

	/* Navigation: an underline that draws in from the centre. */
	html.mmfx .mm-links a, html.mmfx .mm-menu-switch a { position: relative; }
	html.mmfx .mm-links a::after {
		content: ""; position: absolute; left: 50%; right: 50%; bottom: -6px; height: 2px;
		background: currentColor; transition: left .3s ease, right .3s ease;
	}
	html.mmfx .mm-links a:hover::after, html.mmfx .mm-links a[aria-current]::after { left: 0; right: 0; }
}

/* 5. Header that stays at the top and shrinks once the visitor scrolls. */
html.mmfx .mm-header.mmfx-stuck {
	position: fixed;
	background: var(--mmm-brand, #103c69);
	box-shadow: 0 4px 18px rgba(10, 30, 55, .25);
	animation: mmfx-drop .35s ease both;
}
html.mmfx .mm-header .mm-nav, html.mmfx .mm-header .mm-logo { transition: padding .3s ease, width .3s ease; }
html.mmfx .mm-header.mmfx-stuck .mm-nav { padding-top: 10px; padding-bottom: 10px; }
html.mmfx .mm-header.mmfx-stuck .mm-logo { width: 130px; }
@media (max-width: 700px) { html.mmfx .mm-header.mmfx-stuck .mm-logo { width: 110px; } }
/* The header is pushed down by the announcement banner while it sits at the top;
   once stuck, it hugs the top of the screen (below the admin bar when logged in). */
html.mmfx .mm-header.mmfx-stuck { top: 0 !important; }
html.mmfx .admin-bar .mm-header.mmfx-stuck { top: 32px !important; }
@media (max-width: 782px) { html.mmfx .admin-bar .mm-header.mmfx-stuck { top: 46px !important; } }
@media (max-width: 600px) { html.mmfx .admin-bar .mm-header.mmfx-stuck { top: 0 !important; } }
/* Jumping to a room or section from a link: leave room for the stuck header. */
html.mmfx .mm-main [id] { scroll-margin-top: 90px; }
@keyframes mmfx-drop { from { transform: translateY(-100%); } to { transform: none; } }

/* 6. Pop-ups open a little more softly. */
html.mmfx .mmm-pop { transition: opacity .3s ease; }
html.mmfx .mmm-pop__box { transform: translateY(18px) scale(.98); transition: transform .45s cubic-bezier(.2, .8, .2, 1); }
html.mmfx .mmm-pop.is-on .mmm-pop__box { transform: none; }

/* 7. Home page: the logo settles into the blue band, then the line and buttons below. */
html.mmfx .mm-hero .mm-hero-logo { animation: mmfx-logo 1.4s cubic-bezier(.2, .7, .2, 1) .1s both; }
@keyframes mmfx-logo {
	from { opacity: 0; transform: translateY(16px) scale(.94); filter: blur(6px); }
	to { opacity: 1; transform: none; filter: none; }
}
html.mmfx .mm-hero-under > * { animation: mmfx-rise .9s cubic-bezier(.2, .7, .2, 1) both; }
html.mmfx .mm-hero-under > :nth-child(1) { animation-delay: .75s; }
html.mmfx .mm-hero-under > :nth-child(2) { animation-delay: .9s; }
html.mmfx .mm-hero-under > :nth-child(n+3) { animation-delay: 1.05s; }

/* 8. Smooth change from one page to the next (browsers that support it; others
   load pages as usual). The header stays put and the active menu tab slides
   to its new place. */
@media (prefers-reduced-motion: no-preference) {
	@view-transition { navigation: auto; }
}
html.mmfx .mm-header { view-transition-name: mmfx-header; }
html.mmfx .mm-menu-switch { view-transition-name: mmfx-tabs; }
html.mmfx .mm-menu-switch a[aria-current] { view-transition-name: mmfx-tab; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .38s; animation-timing-function: ease; }
::view-transition-group(mmfx-tab) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(mmfx-tab), ::view-transition-new(mmfx-tab) { height: 100%; animation-duration: .3s; }

/* 9. Section bar on long menus: stays below the header, follows the reading. */
.mmfx-secnav {
	position: sticky;
	top: var(--mmfx-top, 0px);
	z-index: 20;
	margin: 0 0 30px;
	background: rgba(255, 255, 255, .95);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid rgba(16, 46, 159, .14);
}
.mmfx-secnav__in {
	display: flex;
	gap: 8px;
	overflow-x: auto;
	scrollbar-width: none;
	padding: 12px 2px;
}
.mmfx-secnav__in::-webkit-scrollbar { display: none; }
.mmfx-secnav a {
	flex: none;
	padding: 7px 15px;
	border: 1px solid var(--mmm-brand, #253f63);
	border-radius: 999px;
	color: var(--mmm-brand, #253f63);
	font-size: 12px;
	letter-spacing: .1em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: background-color .25s ease, color .25s ease;
}
.mmfx-secnav a:hover { background: rgba(16, 46, 159, .08); }
.mmfx-secnav a.is-on { background: var(--mmm-brand, #253f63); color: #fff; }

/* 10. Phones: one menu photo above the menu and one below it. */
.mmfx-mphoto { display: none; }
@media (max-width: 700px) {
	.mmfx-mphoto { display: block; margin: 0 0 28px !important; border-radius: 12px; overflow: hidden; }
	.mmfx-mphoto--bottom { margin: 28px 0 8px !important; }
	.mmfx-mphoto img { display: block; width: 100%; height: 240px !important; object-fit: cover; margin: 0; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
	html.mmfx *, html.mmfx *::before, html.mmfx *::after { animation: none !important; transition: none !important; }
}
