/**
 * Auto Car Finder — responsive rules (mobile-first enhancements).
 *
 * @package HG_Automotive
 * @since 0.1.0
 * @updated 0.41.9 Global overflow containment + narrow mobile header/layout
 * @updated 0.45.7 Footer accordion gap override for the 4-column widget area
 */

/* Prevent accidental page-level horizontal scroll without breaking sticky header. */
html {
	overflow-x: clip;
}

body {
	overflow-x: clip;
	max-width: 100%;
}

.hg-auto-main,
.hg-auto-shell__container,
.hg-auto-shell__container--header,
.hg-auto-shell__container--footer,
.hg-auto-container {
	max-width: 100%;
	min-width: 0;
}

.hg-auto-main {
	overflow-x: clip;
}

@media (min-width: 640px) {
	.hg-auto-grid--2 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.hg-auto-grid--4 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.hg-auto-nav--primary {
		display: block;
	}

	.hg-auto-nav-toggle,
	.hg-auto-shell__mobile-toggle,
	.hg-auto-nav--mobile {
		display: none !important;
	}

	.hg-auto-grid--3 {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.hg-auto-grid--4 {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.hg-auto-footer__bottom {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
}

@media (max-width: 782px) {
	.admin-bar .hg-auto-header {
		top: 46px;
	}
}

/* Comparison bar + enquiry sticky helpers */
@media (max-width: 767px) {
	.hg-auto-compare-bar,
	.hg-buyer-compare-bar {
		padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
	}

	.hg-auto-compare-bar__actions .hg-auto-button,
	.hg-buyer-compare-bar .hg-auto-button {
		flex: 1 1 auto;
	}

	.hg-auto-search__actions {
		flex-direction: column;
		align-items: stretch;
	}

	.hg-auto-archive-controls__tools {
		align-items: flex-start;
	}

	/* Header: keep logo + menu toggle inside the viewport at ~320–390px. */
	.hg-auto-shell__row {
		gap: 0.35rem;
		min-width: 0;
		width: 100%;
	}

	.hg-auto-shell__zone--left {
		flex: 1 1 auto;
		min-width: 0;
		max-width: calc(100% - 3.25rem);
	}

	.hg-auto-shell__zone--right {
		flex: 0 0 auto;
		min-width: 0;
	}

	.hg-auto-shell__zone--right .hg-auto-shell__sell--desktop,
	.hg-auto-shell__zone--right .hg-auto-shell__account--desktop,
	.hg-auto-shell__zone--right .hg-auto-shell__saved--desktop {
		display: none !important;
	}

	.hg-auto-shell__branding,
	.hg-auto-branding,
	.hg-auto-branding__logo,
	.hg-auto-branding__logo a {
		display: block;
		min-width: 0;
		max-width: 100%;
	}

	.hg-auto-shell__branding img,
	.hg-auto-branding__logo img,
	.hg-auto-branding__logo .custom-logo {
		display: block;
		width: var(--mobile-logo-width, 160px);
		max-width: 100%;
		height: auto;
		max-height: calc(var(--hg-header-mobile-height, 60px) - 14px);
		object-fit: contain;
		object-position: left center;
	}

	.hg-auto-shell__mobile-toggle {
		flex: 0 0 auto;
		min-width: 2.75rem;
		min-height: 2.75rem;
		justify-content: center;
	}

	.hg-auto-shell__mobile-drawer,
	.hg-auto-shell__mobile-actions {
		max-width: 100%;
		min-width: 0;
	}

	.hg-auto-shell__mobile-actions .hg-auto-shell__link,
	.hg-auto-shell__mobile-actions .hg-auto-shell__sell-toggle,
	.hg-auto-shell__mobile-actions .hg-auto-shell__account-toggle,
	.hg-auto-shell__mobile-actions .hg-auto-shell__saved-toggle {
		max-width: 100%;
		min-width: 0;
	}

	.hg-auto-footer__widgets {
		gap: 1.25rem;
	}

	.hg-auto-footer__widgets[data-hg-footer-accordions] {
		gap: 0;
	}
}

@media (max-width: 359px) {
	.hg-auto-shell__container,
	.hg-auto-shell__container--header,
	.hg-auto-shell__container--footer,
	.hg-auto-container {
		width: min(100% - 1rem, var(--hg-container-width, var(--hg-auto-container)));
	}

	.hg-auto-shell__container--header {
		width: min(100% - 1rem, var(--hg-container-width, var(--hg-auto-container)));
		max-width: min(100%, var(--hg-container-width, var(--hg-auto-container)));
	}

	.hg-auto-shell__container--footer {
		width: min(100% - 1rem, var(--hg-footer-container-width, var(--hg-container-width, var(--hg-auto-container))));
	}
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
