/**
 * Responsive layout fixes.
 *
 * style.css is a minified build whose Sass source no longer exists, so layout
 * fixes that touch its rules live here instead. Loaded after style.css and
 * css/navigation.css. Some rules also restate or extend Customizer
 * "Additional CSS" (marked below); those copies can go once that CSS moves
 * into the theme.
 *
 * Breakpoints used across the theme:
 *   below 600px   phones
 *   600-781px     large phones, small tablets
 *   782-1023px    tablets: two-column sections stay stacked
 *   1024-1279px   tablet landscape, small laptops
 *   1280px+       desktop
 *
 * Card grids (therapy, post, icon, A-Z, provider) size themselves from the
 * space they get instead of the screen width; see each block's style.css.
 */

/* ==========================================================================
   Two-column sections (core Columns)
   ========================================================================== */

/*
 * style.css stacks columns at 850px and below, but between 851px and 1023px
 * the editor's 40/60, 30/70 and 20/80 splits leave text columns 150-300px
 * wide, so headings wrap a word per line. Stay stacked through 1023px.
 * :where() keeps the weight of the old rule, so Customizer rules for specific
 * columns (.hero-ask, .cols-keep-ratio) still win.
 */
@media (max-width: 1023px) {
	.wp-block-columns:where(:not(.is-style-floating-cards):not(.is-not-stacked-on-mobile)) {
		flex-direction: column;
	}

	.wp-block-columns:where(:not(.is-style-floating-cards):not(.is-not-stacked-on-mobile)) > .wp-block-column {
		flex-basis: 100% !important;
		width: 100%;
	}

	/* Customizer copy (850px): image-first columns put their text on top. */
	.wp-block-columns.is-reverse-mobile > .wp-block-column:first-child {
		order: 2;
	}

	/* Customizer copy (850px): stacked section padding. */
	.mobile-column {
		padding: 80px 36px !important;
	}
}

/*
 * Side by side, a narrow text column (20% or 30% in the editor) still ends up
 * too tight on small laptops and next to wide images. Text columns in a pair
 * keep at least 24rem; the other column gives up the space.
 */
@media (min-width: 1024px) {
	.wp-block-columns:not(.is-not-stacked-on-mobile):not(.cols-keep-ratio) > .wp-block-column:is(:first-child:nth-last-child(2), :last-child:nth-child(2)):has(h2, h3, h4) {
		min-width: min(24rem, 50%);
	}
}

/* ==========================================================================
   Hero (Cover, "Home Hero" style)
   ========================================================================== */

/*
 * Stacked hero, 1023px and below: same breakpoint as the columns above, so
 * the full-width text always gets the full-width overlay. style.css only
 * switched the overlay at 781px, which left white text on the bare photo
 * from 782px to 850px.
 */
@media (max-width: 1023px) {
	.wp-block-cover.is-style-home-hero {
		--hero-mobile-overlay: radial-gradient(130.1% 77.49% at 12.82% 10.24%, #2179bd 37.61%, rgba(33, 121, 189, 0.46) 64.16%, rgba(33, 121, 189, 0) 80.03%);
		align-items: flex-start;
	}

	.wp-block-cover.is-style-home-hero::before {
		background: var(--hero-mobile-overlay);
		-webkit-mask-image: none;
		mask-image: none;
	}

	.wp-block-cover.is-style-home-hero .wp-block-cover__image-background {
		object-position: center bottom;
	}

	/* Customizer copy (850px): small mascot under the search card, bottom left. */
	.hero-ask {
		justify-content: flex-start !important;
		gap: 30px !important;
	}

	.hero-ask > .wp-block-column:first-child {
		flex: 0 0 150px !important;
		width: 150px;
		max-width: 45%;
		margin: 8px auto 0 0 !important;
	}

	.hero-ask > .wp-block-column:first-child figure {
		float: none !important;
		margin: 0 !important;
	}

	.hero-ask > .wp-block-column:first-child img {
		display: block;
		width: 100% !important;
		height: auto !important;
	}

	.hero-cover {
		min-height: 0 !important;
		padding-bottom: 0 !important;
		align-items: flex-end;
	}

	.hero-cover .wp-block-cover__inner-container,
	.hero-cover .wp-block-columns,
	.hero-cover .wp-block-column {
		margin-bottom: 0 !important;
	}

	.hero-cover .hide-mobile {
		display: none !important;
	}

	.left-home-column {
		margin-bottom: -114px !important;
	}

	/*
	 * Inner-page heroes (About) have the chameleon image on its own, with no
	 * search card. It sits larger in the bottom-left corner and hangs a little
	 * past the hero's bottom edge. The cover stops clipping so it can overhang;
	 * its photo and overlays keep the rounded corners themselves.
	 */
	.wp-block-cover.is-style-home-hero:has(.hero-ask > .hero-mascot:only-child) {
		--hero-chameleon-width: min(43vw, 240px);
		overflow: visible;
	}

	.wp-block-cover.is-style-home-hero:has(.hero-ask > .hero-mascot:only-child) > .wp-block-cover__image-background,
	.wp-block-cover.is-style-home-hero:has(.hero-ask > .hero-mascot:only-child) > .wp-block-cover__background,
	.wp-block-cover.is-style-home-hero:has(.hero-ask > .hero-mascot:only-child)::before {
		border-radius: inherit;
	}

	/* Stretch to the cover's bottom edge so the chameleon can be placed against it. */
	.wp-block-cover.is-style-home-hero:has(.hero-ask > .hero-mascot:only-child) > .wp-block-cover__inner-container {
		align-self: stretch;
	}

	.hero-ask > .hero-mascot:only-child {
		position: absolute;
		left: calc(2vw - 2rem); /* the cover has 2rem side padding on mobile */
		bottom: calc(var(--hero-chameleon-width) * -0.09);
		width: var(--hero-chameleon-width) !important;
		max-width: none !important;
		margin: 0 !important;
	}
}

/*
 * Side by side on small laptops the text column is 60% of the hero and the
 * mascot takes 35% of that, squeezing the search card to ~375px and cutting
 * off its placeholder. Widen the text column and carry the overlay further
 * across to match.
 */
@media (min-width: 1024px) and (max-width: 1279px) {
	.wp-block-cover.is-style-home-hero {
		--hero-fade-start: 45%;
		--hero-fade-end: 85%;
	}

	.wp-block-cover.is-style-home-hero .left-home-column {
		flex-basis: 72% !important;
	}

	.hero-ask > .hero-mascot {
		flex-basis: 28% !important;
	}
}

/* Wide "Find Care" style buttons don't need to span a stacked hero. */
@media (max-width: 1023px) {
	.wp-block-cover.is-style-home-hero .ivy-btn--wide .wp-block-button__link {
		width: auto;
		min-width: min(100%, 20rem);
	}
}

/* ==========================================================================
   Trust bar under the home hero (Group, .row-stack-mobile)
   ========================================================================== */

/*
 * The four items sit on one line and don't wrap, which needs ~1240px. From
 * 1020px to 1240px the last item ran off the screen and the page scrolled
 * sideways. Two by two until there is room for all four.
 */
@media (max-width: 1239px) {
	.wp-block-cover.is-style-home-hero + .wp-block-group.row-stack-mobile {
		display: grid;
		grid-template-columns: repeat(2, max-content);
		justify-content: center;
		gap: 12px 48px;
	}
}

@media (max-width: 781px) {
	.wp-block-cover.is-style-home-hero + .wp-block-group.row-stack-mobile {
		grid-template-columns: max-content;
		gap: 12px;
	}
}

/* Small phones: the longest item is wider than the screen, so let it wrap. */
@media (max-width: 479px) {
	.wp-block-cover.is-style-home-hero + .wp-block-group.row-stack-mobile {
		grid-template-columns: minmax(0, max-content);
		padding: 32px 16px 16px !important;
	}

	.wp-block-cover.is-style-home-hero + .wp-block-group.row-stack-mobile > .wp-block-columns > .wp-block-column:last-child {
		flex: 0 1 auto !important;
	}

	.wp-block-cover.is-style-home-hero + .wp-block-group.row-stack-mobile p {
		white-space: normal;
	}
}

/* ==========================================================================
   Feature cover: intro text beside a row of post cards
   ("What Pediatric Therapy Can Look Like", "Clinical Care Across Every Specialty")
   ========================================================================== */

/*
 * The intro is a 20% column next to 80% of cards: 150-240px wide at every
 * size, with the heading breaking mid-word. Put the intro above the cards
 * until both fit side by side: three cards need ~800px next to the intro.
 */
@media (max-width: 1365px) {
	.wp-block-cover .wp-block-columns:has(> .wp-block-column .wp-block-ivy-post-cards) {
		flex-direction: column;
		align-items: stretch !important;
	}

	.wp-block-cover .wp-block-columns:has(> .wp-block-column .wp-block-ivy-post-cards) > .wp-block-column {
		flex-basis: auto !important;
		width: 100%;
	}

	.wp-block-cover .wp-block-columns:has(> .wp-block-column .wp-block-ivy-post-cards) > .wp-block-column:not(:has(.wp-block-ivy-post-cards)) {
		align-self: flex-start;
		max-width: 36rem;
	}
}

/* White intro text sits straight on the photo; give it a scrim to stay legible. */
.wp-block-cover .wp-block-columns:has(> .wp-block-column .wp-block-ivy-post-cards) > .wp-block-column:not(:has(.wp-block-ivy-post-cards)) {
	padding: 24px;
	border-radius: 16px;
	background: rgba(20, 57, 84, 0.55);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
}

@media (min-width: 1366px) {
	.wp-block-cover .wp-block-columns:has(> .wp-block-column .wp-block-ivy-post-cards) > .wp-block-column:not(:has(.wp-block-ivy-post-cards)) {
		min-width: 18rem;
	}
}

/* ==========================================================================
   Mascots positioned with page-level CSS
   ========================================================================== */

/*
 * Areas of Support hero: the block's own CSS pins the mascot to the bottom
 * left at every size, so on phones and tablets it covers the intro and the
 * search field. Put it back in the flow, centred under the search.
 */
@media (max-width: 1023px) {
	.wp-block-image.icon-hero-areas-of-support.has-custom-css {
		position: static;
		width: 120px;
		margin: 24px auto -1px;
	}

	.wp-block-image.icon-hero-areas-of-support.has-custom-css img {
		width: 100%;
		height: auto;
	}
}

/*
 * "In the Spotlight" (Therapies, Specialties): the hanging mascot sits at the
 * bottom right and ran into the full-width intro below 1440px. Keep the intro
 * to a reading width and drop the mascot where the two would still touch.
 */
.wp-block-column:has(> .hanging-logo) > p {
	max-width: 40rem;
	margin-inline: auto;
}

@media (max-width: 1199px) {
	.hanging-logo {
		display: none !important;
	}
}

/* ==========================================================================
   Provider single (single-provider.php)
   ========================================================================== */

/* Plain content (paragraphs, lists) gets the site gutters and a reading width;
   full-width sections keep their own padding like on the other pages. */
.cpt-single--provider .cpt-single__header,
.cpt-single--provider .entry-content > :not(.alignfull):not(.wp-block-group):not(.wp-block-columns):not(.wp-block-cover) {
	width: min(100% - 4rem, 50rem);
	margin-inline: auto;
}

.cpt-single--provider .cpt-single__header {
	padding-top: 4rem;
}

.cpt-single--provider .entry-content {
	padding-bottom: 4rem;
}

@media (max-width: 781px) {
	.cpt-single--provider .cpt-single__header,
	.cpt-single--provider .entry-content > :not(.alignfull):not(.wp-block-group):not(.wp-block-columns):not(.wp-block-cover) {
		width: calc(100% - 2rem);
	}

	.cpt-single--provider .cpt-single__header {
		padding-top: 2.5rem;
	}

	.cpt-single--provider .entry-content {
		padding-bottom: 2.5rem;
	}
}

/* ==========================================================================
   Header search
   ========================================================================== */

/*
 * The top bar search was a fixed 12.25rem, cutting its placeholder to
 * "Search by therapy,". Let it grow into the free space in the bar.
 */
.top-nav-bar .header-search {
	flex: 1 1 12.25rem;
	min-width: 12.25rem;
	max-width: 22rem;
}

.top-nav-bar .header-search .search-form {
	width: 100%;
}

/* ==========================================================================
   Footer
   ========================================================================== */

/* Hidden resource download section on single location pages. */
.resource-download-locations {
	display: none;
}

/*
 * style.css keeps the phone layout (two centred columns) all the way to
 * 1180px. From tablet up, four left-aligned columns under the logo.
 */
@media (min-width: 782px) and (max-width: 1180px) {
	.site-footer__brand {
		justify-content: flex-start;
	}

	.site-footer__menus {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 2rem 1.5rem;
	}

	.site-footer__nav {
		justify-items: start;
		justify-self: stretch;
		text-align: left;
	}

	.site-footer .footer-menu:not(.footer-menu--legal),
	.site-footer .footer-menu--secondary > li > .sub-menu {
		justify-content: flex-start;
		text-align: left;
	}
}

/*
 * Phones: one centred column, as in the "Footer Mobile" design. Logo, then
 * each menu stacked under its heading, then the legal links in two short
 * rows. Spacing is taken from the design at 375px.
 */
@media (max-width: 781px) {
	.site-footer {
		padding: 0;
	}

	.site-footer__inner {
		width: 100%;
		padding: 3.5rem 1.5rem 2.25rem;
		gap: 3rem;
	}

	.site-footer__top {
		gap: 2.5rem;
	}

	.site-footer__logo .custom-logo,
	.site-footer__logo img {
		max-width: 226px;
	}

	.site-footer__menus {
		grid-template-columns: minmax(0, 1fr);
		gap: 2rem;
	}

	.site-footer .site-footer__heading {
		margin-bottom: 0.625rem;
	}

	.site-footer .footer-menu:not(.footer-menu--legal) li + li,
	.site-footer .footer-menu--secondary > li > .sub-menu li + li {
		margin-top: 0.625rem;
	}

	.site-footer .footer-menu--secondary > li > .sub-menu {
		margin-top: 0.625rem;
	}

	.site-footer .footer-menu--legal {
		gap: 0 0.625rem;
	}
}
