/*
 * Think Digitally - iPhone Duo / foldable and short-viewport fixes.
 * Plan and findings: DIVI5-IPHONE-DUO-PLAN.md. Loaded on every screen; each block is scoped by a media query.
 * Duo CSS viewports are about 382-951 px wide and 368-902 px tall (outer closed, inner open, half-folded, Split View).
 * Principle: the same layout expands and contracts; nothing here switches content on or off.
 */

/* 1. Page colour behind everything: Safari paints this into any margin strip (outer display side controls).
      Light page = white; dark mode follows the body class set by assets/js/site.js. */
html {
	background-color: #fff;
}
html:has(body.et-dark-mode) {
	background-color: var(--td-dm-bg, #23282d);
}

/* 2. Tap targets (>= 44 px) for text links and form fields across the whole compact range up to the desktop breakpoint. */
@media (max-width: 980px) {
	[class*="_tb_footer"] a,
	.et_pb_section a.td-tap,
	.forminator-ui .forminator-input,
	.forminator-ui .forminator-textarea,
	.forminator-ui select {
		min-height: 44px;
	}
	[class*="_tb_footer"] a {
		display: inline-flex;
		align-items: center;
	}
	.forminator-ui .forminator-checkbox__label a,
	.td-lead-popup a,
	.et_pb_text_inner a {
		/* inline links inside sentences keep their flow, but get a taller hit area without moving the text */
		padding-block: 0.4em;
		margin-block: -0.4em;
	}
}

/* 3. Short viewports (outer display landscape ~382 px tall, half-folded, landscape phones). */
@media (max-height: 480px) {
	/* Header: smaller logo, no extra row height. */
	[class*="_tb_header"] .et_pb_menu__logo img,
	[class*="_tb_header"] .et_pb_menu__logo-wrap img {
		max-height: 40px !important;
		width: auto !important;
	}
	[class*="_tb_header"] .et_pb_column {
		padding-block: 4px !important;
	}
	[class*="_tb_header"] .et_pb_row {
		min-height: 0 !important;
	}
	/* Dark/light toggle: smaller and kept inside the shorter header. */
	[class*="_tb_header"] .et-dark-toggle {
		transform: scale(0.7) translateY(-30px);
		transform-origin: right top;
	}
	/* Heroes: padding scales with the screen height, not the width, so the headline shows without scrolling. */
	.et_pb_fullwidth_header {
		padding-top: 12vh !important;
		padding-bottom: 6vh !important;
	}
	.et_pb_fullwidth_header .header-content {
		margin-top: 0;
		margin-bottom: 0;
	}
	.tileHeaderFull .et_pb_slide_description,
	.tileHeaderCrop .et_pb_slide_description {
		padding-block: 12vh !important;
	}
}

/* 4. Popups and dialogs: always fully reachable on short screens. */
.td-lead-popup {
	max-height: calc(100dvh - 16px);
}
@media (max-height: 480px) {
	.td-lead-popup {
		padding: 16px 12px;
	}
	.td-lead-popup__header {
		padding-bottom: 12px;
	}
	.td-lead-popup__title {
		font-size: 22px;
	}
}

/* 5. Respect safe areas for fixed UI if the browser ever reports them (zero today without viewport-fit=cover). */
.navLockFixed {
	margin-inline: max(10%, env(safe-area-inset-left));
}

/* 6. Divi reserves 80 px above the page on screens up to 980 px for a fixed header; our Theme Builder header is not
      fixed, so on the team, profile and insights pages that became a blank band above the header (found in Duo testing). */
@media (max-width: 980px) {
	body #page-container {
		padding-top: 0 !important;
	}
}

/* 7. Duo open / wide compact (861-980 px): desktop-like layout instead of the stretched single column.
      Rules W1-W14 are in DIVI5-DUO-OPEN-DESIGN-RULES.md. Applies to every page; site.js (wideLayout) tags bands,
      cards and per-device content that CSS cannot tell apart.
      Safari on the Duo gets WP Rocket's mobile CSS, which drops Divi's icon font for the header toggle: declare it. */
@font-face {
	font-family: 'FontAwesome';
	font-style: normal;
	font-weight: 900;
	font-display: swap;
	src: url('../../../Divi/core/admin/fonts/fontawesome/fa-solid-900.woff2') format('woff2');
}
@media (min-width: 861px) and (max-width: 980px) {
	body {
		--td-w-gutter: 32px;
		--td-w-gap: 24px;
		--td-w-section: 56px;
	}

	/* W1. Columns: rows keep their desktop column structure instead of stacking. */
	#page-container .et_pb_section > .et_pb_row,
	#page-container .et_pb_section .et_pb_row_inner {
		display: flex !important;
		flex-flow: row nowrap !important;
		align-items: stretch;
		--g: var(--td-w-gap);
		gap: var(--g);
		width: 100% !important;
		max-width: none !important;
		margin-inline: 0 !important;
		padding-inline: var(--td-w-gutter) !important;
		box-sizing: border-box;
	}
	#page-container .et_pb_section .et_pb_row_inner {
		padding-inline: 0 !important;
	}
	/* One page gutter: sections add none of their own, rows carry it. */
	#page-container #et-main-area .et_pb_section.et_pb_section.et_pb_section {
		padding-inline: 0 !important;
	}
	#page-container .et_pb_section .et_pb_row.et_pb_gutters1,
	#page-container .et_pb_section .et_pb_row_inner.et_pb_gutters1 {
		--g: 0px;
	}
	/* The first section starts under the header: the builder's tablet values pull it up behind the header. */
	#page-container #et-main-area .et-l--post .et_builder_inner_content > .et_pb_section:first-child,
	#page-container #et-main-area .et-l--body .et_builder_inner_content > .et_pb_section:first-child {
		margin-top: 0 !important;
		top: 0 !important;
		transform: none !important;
	}
	/* W13. Split bands (tagged .td-w-bleed by site.js) run edge to edge: no page gutter. */
	#page-container #et-main-area .et_pb_section > .et_pb_row.et_pb_row.td-w-bleed {
		padding-inline: 0 !important;
	}
	/* W14. Rounded cards that are a whole section or row (tagged .td-w-card) sit inside the page gutter. */
	#page-container #et-main-area .et_pb_section.et_pb_section.et_pb_section.td-w-card,
	#page-container #et-main-area .et_pb_section > .et_pb_row.et_pb_row.td-w-card {
		width: auto !important;
		max-width: none !important;
		margin-inline: var(--td-w-gutter) !important;
	}
	/* Divi's clearfix pseudo-elements would become empty flex items and add a stray gap. */
	#page-container .et_pb_section > .et_pb_row::before,
	#page-container .et_pb_section > .et_pb_row::after,
	#page-container .et_pb_section .et_pb_row_inner::before,
	#page-container .et_pb_section .et_pb_row_inner::after {
		content: none !important;
	}
	/* Column widths keep the desktop proportions. Each column gets its exact share of the row minus its share of
	   the gaps (--g), so padded and unpadded columns in one row come out the same width. */
	#page-container .et_pb_section .et_pb_row > .et_pb_column,
	#page-container .et_pb_section .et_pb_row_inner > .et_pb_column {
		float: none !important;
		width: auto !important;
		min-width: 0;
		margin: 0 !important;
		box-sizing: border-box !important;
		flex: 1 1 0 !important; /* fallback for structures not listed below */
	}
	#page-container .et_pb_section .et_pb_row > .et_pb_column_4_4,
	#page-container .et_pb_section .et_pb_row_inner > .et_pb_column_4_4 { flex: 0 0 100% !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_1_2 { flex: 0 0 calc(50% - var(--g) / 2) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_1_3 { flex: 0 0 calc(33.333% - var(--g) * 2 / 3) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_2_3 { flex: 0 0 calc(66.667% - var(--g) / 3) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_1_4 { flex: 0 0 calc(25% - var(--g) * 3 / 4) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_3_4 { flex: 0 0 calc(75% - var(--g) / 4) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_2_5 { flex: 0 0 calc(40% - var(--g) / 2) !important; }
	#page-container .et_pb_section .et_pb_row > .et_pb_column_3_5 { flex: 0 0 calc(60% - var(--g) / 2) !important; }
	/* Nested rows inside a half-width column: quarter-page columns are half of that column. */
	#page-container .et_pb_section .et_pb_column_1_2 > .et_pb_row_inner > .et_pb_column_1_4 { flex: 0 0 calc(50% - var(--g) / 2) !important; }

	/* W3. Type: between phone and desktop */
	#et-main-area h1 { font-size: 48px !important; line-height: 1.12 !important; }
	#et-main-area h2 { font-size: 30px !important; line-height: 1.2 !important; }
	#et-main-area h3 { font-size: 22px !important; line-height: 1.3 !important; }
	#et-main-area p,
	#et-main-area li { font-size: 16px !important; line-height: 1.6 !important; }

	/* W4. Buttons: sized to their label, never the full width of a column */
	#page-container .et_pb_section .et_pb_button.et_pb_button {
		display: inline-flex !important;
		width: auto !important;
		min-width: 200px;
		min-height: 48px;
		align-items: center;
		justify-content: center;
		padding: 8px 28px !important;
		font-size: 17px !important;
	}

	/* W5. Nested quarter-width columns: smaller heading and text so words never break */
	#et-main-area .et_pb_row_inner > .et_pb_column_1_4 :is(h1, h2, h3) { font-size: 22px !important; line-height: 1.25 !important; }
	#et-main-area .et_pb_row_inner > .et_pb_column_1_4 :is(p, li) { font-size: 14px !important; line-height: 1.55 !important; }
	#et-main-area :is(h1, h2, h3, p, li) { overflow-wrap: normal; word-break: normal; hyphens: manual; }

	/* Carousels stay inside their column (the track is wider than the page) */
	#page-container .et_pb_group_carousel { max-width: 100%; overflow: hidden; }

	/* Picture-only columns (a background image, no modules; tagged .td-w-picture by site.js) are hidden by Divi
	   below 981px. On desktop they are the picture half of a text + picture row, so they show here too. */
	#page-container #et-main-area .et_pb_row > .et_pb_column.et_pb_column_empty.td-w-picture {
		display: block !important;
		min-height: 240px;
	}
	/* W5b. Rows of five or six columns: small card labels. */
	#et-main-area .et_pb_column_1_5 :is(h1, h2, h3, h4),
	#et-main-area .et_pb_column_1_6 :is(h1, h2, h3, h4) { font-size: 16px !important; line-height: 1.25 !important; }
	#et-main-area .et_pb_column_1_5 :is(p, li),
	#et-main-area .et_pb_column_1_6 :is(p, li) { font-size: 13px !important; line-height: 1.5 !important; }
	/* Post and profile cards: card-sized titles, not underlined. */
	#et-main-area .et_pb_post h2.entry-title,
	#et-main-area .et_pb_post h2.entry-title a,
	#et-main-area .tdGrid article h2,
	#et-main-area .tdProfiles article h2 { font-size: 20px !important; line-height: 1.3 !important; text-decoration: none !important; min-height: 0 !important; }
	/* Blog pagination: a plain text link inside the grid (the desktop arrow block hangs outside the page here). */
	.et_pb_blog .pagination,
	.tdGrid .pagination,
	.tdProfiles .pagination { position: static !important; width: auto !important; margin: 8px 0 0 !important; display: flex !important; justify-content: space-between; }
	.et_pb_blog .pagination .alignleft,
	.et_pb_blog .pagination .alignright { float: none !important; }
	.et_pb_blog .pagination .alignleft a,
	.et_pb_blog .pagination .alignright a { display: inline-block !important; width: auto !important; height: auto !important; overflow: visible !important; padding: 11px 0; background: none !important; color: #3d3bdb !important; font-weight: 500; }
	body.et-dark-mode .et_pb_blog .pagination .alignleft a,
	body.et-dark-mode .et_pb_blog .pagination .alignright a { color: var(--td-dm-link, #8f93ff) !important; }
	/* Cards whose icon is pinned to the top-right corner (tagged by site.js): keep the text clear of it. */
	.td-w-icon-abs .et_pb_main_blurb_image,
	.td-w-icon-abs .et_pb_main_blurb_image .et_pb_image_wrap,
	.td-w-icon-abs .et_pb_main_blurb_image img { width: 44px !important; max-width: 44px !important; height: auto !important; }
	.td-w-icon-abs .et_pb_blurb_container { padding-right: 84px !important; }

	/* W9. Same content as desktop: site.js tags what the builder hides on tablets (.td-w-show) and what it hides
	   on desktop (.td-w-hide). */
	#page-container .td-w-show.td-w-show { display: block !important; }
	#page-container .et_pb_row.td-w-show.td-w-show,
	#page-container .et_pb_row_inner.td-w-show.td-w-show { display: flex !important; }
	#page-container .td-w-hide.td-w-hide { display: none !important; }

	/* W7. Hero: same gutter as the page, balanced headline */
	.et_pb_fullwidth_header { padding-inline: var(--td-w-gutter) !important; min-height: clamp(380px, 56vh, 560px); align-items: center; }
	.et_pb_fullwidth_header .et_pb_fullwidth_header_container { width: 100% !important; max-width: none !important; margin: 0 !important; }
	.et_pb_fullwidth_header .et_pb_module_header { max-width: 15em; text-wrap: balance; }

	/* Footer: desktop footer type in four columns */
	[class*="_tb_footer"] :is(h2, h3, h4) { font-size: 18px !important; line-height: 1.3 !important; }
	[class*="_tb_footer"] :is(p, li, a) { font-size: 14px !important; line-height: 1.6 !important; }
	#page-container [class*="_tb_footer"] .et_pb_row:last-of-type > .et_pb_column.et_pb_column:nth-child(3) { flex: 1 1 0 !important; }
	[class*="_tb_footer"] .et_pb_row:last-of-type > .et_pb_column:nth-child(4):not(:has(a, img, p)) { display: none !important; }

	/* W8. Header: desktop navigation, not the hamburger */
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__menu { display: flex !important; }
	[class*="_tb_header"] .et_pb_menu .et_mobile_nav_menu { display: none !important; }
	[class*="_tb_header"] .et_pb_blurb.et-dark-toggle { display: block !important; }
	[class*="_tb_header"] .et_pb_menu { padding-right: 98px !important; }
	[class*="_tb_header"] .et_pb_menu .et-menu > li.cta-fix-right { padding: 0 !important; }
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__logo-wrap { flex: 0 0 auto !important; width: auto !important; max-width: none !important; }
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__logo img { height: 36px !important; max-height: 36px !important; width: auto !important; max-width: none !important; }
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__wrap { flex: 1 1 auto !important; justify-content: flex-end !important; }
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__menu,
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__menu > nav,
	[class*="_tb_header"] .et_pb_menu .et-menu { flex-wrap: nowrap !important; white-space: nowrap; }
	[class*="_tb_header"] .et_pb_menu .et-menu .sub-menu { white-space: normal; } /* dropdown items stack */
	[class*="_tb_header"] .et_pb_menu .et-menu > li { padding-inline: 7px !important; margin: 0 !important; }
	[class*="_tb_header"] .et_pb_menu .et-menu > li > a { font-size: 14px !important; }
	[class*="_tb_header"] .et_pb_column { padding-inline: 7px !important; }
}

/* Narrow end of the range: tighter navigation so the toggle never touches the Contact Us button. */
@media (min-width: 861px) and (max-width: 899px) {
	[class*="_tb_header"] .et_pb_menu .et_pb_menu__logo img { height: 32px !important; max-height: 32px !important; }
	[class*="_tb_header"] .et_pb_menu .et-menu > li { padding-inline: 4px !important; }
	[class*="_tb_header"] .et_pb_menu .et-menu > li > a { font-size: 13px !important; }
}

/* Background video never shows player controls (all widths) */
.et-pb-background-video .mejs-controls,
.et-pb-background-video .mejs-layers,
.et-pb-background-video .mejs-offscreen { display: none !important; }
