/**
 * Nexus — cross-browser fixes and responsive enhancements.
 * Chrome, Firefox, Safari, Edge (last ~4 years). No IE11.
 *
 * @package Nexus
 */

/* --------------------------------------------------------------------------
   Document & overflow (100vw full-bleed sections)
   -------------------------------------------------------------------------- */

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	overflow-x: hidden;
	overscroll-behavior-x: none;
}

@supports (overflow: clip) {
	html {
		overflow-x: clip;
	}
}

body {
	width: 100%;
	max-width: 100%;
	overscroll-behavior-x: none;
}

body:not(.nexus-builder-active) {
	overflow-x: clip;
}

@supports not (overflow: clip) {
	body:not(.nexus-builder-active) {
		overflow-x: hidden;
	}
}

/* --------------------------------------------------------------------------
   Mobile viewport height (iOS Safari address bar)
   -------------------------------------------------------------------------- */

body.nexus-hero-full-height .nexus-hero,
body.nexus-hero-full-height .nexus-hero-slider,
body.nexus-sticky-footer {
	min-height: 100vh;
	min-height: calc(var(--nexus-vh, 1vh) * 100);
	min-height: 100dvh;
}

/* --------------------------------------------------------------------------
   Media & embeds
   -------------------------------------------------------------------------- */

video,
audio,
canvas,
svg:not(.nexus-menu-icon-svg):not(.nexus-svg-icon) {
	max-width: 100%;
	height: auto;
}

iframe,
embed,
object {
	max-width: 100%;
}

.nexus-video-embed iframe,
.nexus-map-embed iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.nexus-video-embed-static {
	padding-bottom: 0;
	height: auto;
	overflow: visible;
}

.nexus-video-embed-static iframe {
	position: static;
	width: 100%;
	height: auto;
	min-height: 200px;
}

/* WordPress & builder content */
.entry-content img,
.entry-content video,
.entry-content iframe,
.site-main img,
.wp-block-image img,
.wp-block-embed__wrapper iframe {
	max-width: 100%;
	height: auto;
}

.wp-block-embed__wrapper {
	position: relative;
	overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive tables
   -------------------------------------------------------------------------- */

.entry-content table,
.site-main table,
.wp-block-table table {
	width: 100%;
	border-collapse: collapse;
}

.nexus-table-scroll,
.entry-content .wp-block-table,
.site-main .wp-block-table {
	display: block;
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
	.entry-content table:not(.nexus-pricing-table-sc table),
	.site-main table:not(.nexus-pricing-table-sc table) {
		display: block;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
}

/* --------------------------------------------------------------------------
   Touch targets & header utilities (mobile)
   -------------------------------------------------------------------------- */

@media (max-width: 782px) {
	.menu-toggle,
	.nexus-header-utilities-menu .nexus-header-icon-btn,
	.nexus-search-toggle {
		min-width: 44px;
		min-height: 44px;
	}

	body.nexus-sticky-sidebar .widget-area {
		position: static;
		top: auto;
	}

	.nexus-back-to-top {
		bottom: max(1rem, env(safe-area-inset-bottom, 0px));
		right: max(1rem, env(safe-area-inset-right, 0px));
	}

	.site {
		padding-left: max(20px, env(safe-area-inset-left, 0px));
		padding-right: max(20px, env(safe-area-inset-right, 0px));
	}
}

/* --------------------------------------------------------------------------
   Grid fallbacks (Safari / older engines without min() in minmax)
   -------------------------------------------------------------------------- */

@supports not (grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 260px))) {
	.nexus-team-grid {
		grid-template-columns: repeat(auto-fit, minmax(200px, 260px));
	}
	.nexus-services-grid {
		grid-template-columns: repeat(auto-fit, minmax(240px, 320px));
	}
	.nexus-clients-grid {
		grid-template-columns: repeat(auto-fit, minmax(120px, 180px));
	}
	.nexus-gallery-grid {
		grid-template-columns: repeat(auto-fit, minmax(180px, 240px));
	}
	.nexus-testimonials-grid,
	.nexus-blog-teaser-grid,
	.nexus-pricing-grid {
		grid-template-columns: repeat(auto-fit, minmax(260px, 360px));
	}
}

/* Flex gap fallback for legacy flex rows (margin on children) */
@supports not (gap: 1rem) {
	.footer-social .nexus-social-icons ul > li + li,
	.nexus-topbar-menu > li + li {
		margin-left: 0.75rem;
	}
	.nexus-newsletter-form > * + * {
		margin-left: 0.5rem;
	}
}

/* --------------------------------------------------------------------------
   Reduced motion (respect user preference)
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

/* --------------------------------------------------------------------------
   High-DPI / retina demo & content images
   -------------------------------------------------------------------------- */

.woocommerce img,
.woocommerce-page img {
	max-width: 100%;
	height: auto;
}

.woocommerce div.product div.images img,
.woocommerce ul.products li.product a img {
	display: block;
}
.nexus-gallery-grid img,
.nexus-image-text-img img,
.nexus-video-thumb-img,
.nexus-blog-teaser-thumb img,
.nexus-team-item img,
.nexus-listing-card img {
	image-rendering: auto;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

/* --------------------------------------------------------------------------
   Mobile UX: touch, forms, safe areas (782px = WP admin-bar breakpoint)
   -------------------------------------------------------------------------- */

@media (max-width: 782px) {
	a,
	button,
	input[type="button"],
	input[type="submit"],
	input[type="reset"],
	.button,
	.nexus-btn {
		-webkit-tap-highlight-color: rgba(15, 118, 110, 0.18);
		touch-action: manipulation;
	}

	input[type="text"],
	input[type="email"],
	input[type="url"],
	input[type="password"],
	input[type="search"],
	input[type="number"],
	input[type="tel"],
	select,
	textarea,
	.woocommerce form .form-row input.input-text,
	.woocommerce form .form-row textarea,
	.woocommerce form .form-row select {
		font-size: max(16px, 1rem);
	}

	.button,
	.nexus-btn,
	input[type="button"],
	input[type="submit"],
	input[type="reset"] {
		min-height: 44px;
	}

	.woocommerce .nexus-wc-icon-btn,
	.woocommerce .nexus-wc-loop-actions .button {
		min-height: 0;
	}

	body.nexus-wc-mobile-bar-active .nexus-back-to-top {
		bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
	}
}
