/**
 * Safety Garage — capa responsive global (carga al final)
 * Breakpoints unificados: sm ≤576, md ≤768, lg ≤1024
 */

:root {
	--sg-rg-dark: #122d5c;
	--sg-rg-red: #c01617;
	--sg-rg-white: #ffffff;
	--sg-rg-nav-maxw: min(22rem, 100vw);
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

/* Evita desbordes horizontales por elementos full-bleed */
body {
	padding-left: env(safe-area-inset-left, 0);
	padding-right: env(safe-area-inset-right, 0);
}

/* Hero: en pantallas estrechas, evitar 100vw + margen negativo que desbordan */
@media (max-width: 1024px) {
	.hero {
		width: 100%;
		max-width: 100%;
		margin-left: 0;
	}
}

/* Contenedores: padding fluido */
.site-container,
.header-inner {
	padding-left: clamp(0.75rem, 4vw, 1.5rem);
	padding-right: clamp(0.75rem, 4vw, 1.5rem);
}

.site-main .site-container {
	padding-left: clamp(0.75rem, 4vw, 1.5rem);
	padding-right: clamp(0.75rem, 4vw, 1.5rem);
}

/* Medios responsivos */
embed,
iframe,
object,
video {
	max-width: 100%;
}

/* WooCommerce: tablas y formularios en pantallas estrechas */
.woocommerce table.shop_table,
.woocommerce-page table.shop_table {
	display: table;
	width: 100%;
}

@media (max-width: 768px) {
	.woocommerce-cart .woocommerce,
	.woocommerce-checkout .woocommerce,
	.woocommerce-account .woocommerce {
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.woocommerce .col2-set .col-1,
	.woocommerce .col2-set .col-2,
	.woocommerce-page .col2-set .col-1,
	.woocommerce-page .col2-set .col-2 {
		width: 100%;
		float: none;
		margin-bottom: 1.5rem;
	}

	.woocommerce #payment ul.payment_methods li input[type="radio"] {
		min-height: 1.25rem;
		min-width: 1.25rem;
	}

	.woocommerce form .form-row input.input-text,
	.woocommerce form .form-row textarea,
	.woocommerce form .form-row select {
		min-height: 2.75rem;
		font-size: 1rem;
	}
}

/* Botones y enlaces táctiles razonables */
@media (max-width: 1024px) {
	.btn,
	.woocommerce a.button,
	.woocommerce button.button,
	.woocommerce input.button,
	.woocommerce #respond input#submit {
		min-height: 2.75rem;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}
}

/* ========== Botón menú móvil ========== */
.menu-toggle {
	display: none;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	margin: 0 0 0 0.5rem;
	border: 1px solid rgba(255, 255, 255, 0.35);
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: var(--sg-rg-white);
	cursor: pointer;
	flex-shrink: 0;
	z-index: 2002;
	transition: background 0.2s, border-color 0.2s;
}

.menu-toggle:hover,
.menu-toggle:focus-visible {
	background: rgba(255, 255, 255, 0.15);
	border-color: rgba(255, 255, 255, 0.55);
	outline: none;
}

.menu-toggle__bar {
	display: block;
	width: 1.25rem;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	position: relative;
	transition: transform 0.25s ease;
}

.menu-toggle__bar::before,
.menu-toggle__bar::after {
	content: "";
	position: absolute;
	left: 0;
	width: 100%;
	height: 2px;
	background: currentColor;
	border-radius: 1px;
	transition: transform 0.25s ease, top 0.25s ease;
}

.menu-toggle__bar::before {
	top: -6px;
}

.menu-toggle__bar::after {
	top: 6px;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar {
	background: transparent;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar::before {
	top: 0;
	transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .menu-toggle__bar::after {
	top: 0;
	transform: rotate(-45deg);
}

.menu-backdrop {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	z-index: 1998;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.menu-backdrop.is-visible {
	display: block;
	opacity: 1;
}

body.sg-menu-open {
	overflow: hidden;
	overscroll-behavior: none;
}

/*
 * Menú móvil abierto — portal a <body>:
 * El JS mueve .menu-backdrop y #primary-navigation a document.body para que
 * escapen del stacking context de .site-header / .header-main.is-sticky.
 * Como hijos directos de <body>, z-index se compara sin conflictos:
 *   backdrop 99996  <  nav 99998  <  WP admin bar 99999
 */
body.sg-menu-open .menu-backdrop {
	z-index: 99996;
}

body.sg-menu-open .site-navigation.is-open {
	z-index: 99998;
}

body.sg-menu-open .menu-toggle {
	position: relative;
	z-index: 99999;
}

body.sg-menu-open #content.site-main {
	pointer-events: none;
}

body.sg-menu-open .site-footer {
	pointer-events: none;
}

body.sg-menu-open .floating-contact {
	z-index: 1990;
}

@media (max-width: 1024px) {
	.menu-toggle {
		display: inline-flex;
		order: 2;
		margin-left: auto !important;
	}

	.header-inner {
		flex-wrap: wrap;
		align-items: center;
		row-gap: 0.65rem;
		column-gap: 0.5rem;
	}

	.site-branding {
		flex: 1 1 auto;
		min-width: 0;
		order: 1;
	}

	/* CTA en segunda fila (ancho completo) — evita amontonar con logo + menú */
	.header-cta {
		order: 10;
		flex-basis: 100%;
		width: 100%;
		margin-left: 0 !important;
		justify-content: center;
		gap: 0.5rem;
		flex-wrap: wrap;
	}

	.header-cta .btn--primary {
		white-space: normal;
		text-align: center;
		line-height: 1.25;
		max-width: 100%;
	}

	.site-navigation {
		position: fixed;
		top: 0;
		right: 0;
		width: var(--sg-rg-nav-maxw);
		height: 100vh;
		height: 100dvh;
		max-height: -webkit-fill-available;
		margin: 0;
		padding: 5rem 1.25rem 2rem;
		background: var(--sg-rg-dark);
		box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
		z-index: 2000;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		transform: translateX(100%);
		visibility: hidden;
		transition: transform 0.3s ease, visibility 0.3s;
		display: block;
	}

	.site-navigation.is-open {
		transform: translateX(0);
		visibility: visible;
		touch-action: pan-y;
	}

	.site-navigation .primary-menu {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
		margin: 0;
		padding: 0;
	}

	.site-navigation .primary-menu > li {
		border-bottom: 1px solid rgba(255, 255, 255, 0.12);
	}

	.site-navigation .primary-menu > li > a {
		display: block;
		padding: 1rem 0.25rem;
		font-size: 1rem;
	}

	/* Submenús: desplegados en columna (touch-friendly) */
	.site-navigation .primary-menu .sub-menu {
		position: static;
		opacity: 1;
		visibility: visible;
		transform: none;
		left: auto;
		min-width: auto;
		margin: 0 0 0.75rem 0.5rem;
		padding: 0.25rem 0;
		background: rgba(255, 255, 255, 0.06);
		border-radius: 8px;
		box-shadow: none;
	}

	.site-navigation .primary-menu .sub-menu::before {
		display: none;
	}

	.site-navigation .primary-menu > li.menu-item-has-children:hover > .sub-menu {
		margin-top: 0;
	}

	.site-navigation .primary-menu .sub-menu a {
		padding: 0.65rem 1rem;
		color: rgba(255, 255, 255, 0.95) !important;
		border-left: none;
	}

	.site-navigation .primary-menu > li.menu-item-has-children > a::after {
		display: none;
	}

	/* Barra superior: permitir wrap */
	.header-utility .header-inner {
		flex-wrap: wrap;
		row-gap: 0.35rem;
	}

	.header-utility__menu {
		flex-wrap: wrap;
		justify-content: flex-end;
		gap: 0.75rem;
	}

	/*
	 * Inicio / tienda Woo: el CTA sigue en segunda fila ancha (o oculto en home v. regla abajo).
	 * Resto de páginas (Quiénes somos, contacto, etc.): botón compacto en la misma fila que
	 * logo + menú — evita el bloque rojo enorme debajo del header.
	 */
	body:not(.home):not(.front-page):not(.woocommerce):not(.woocommerce-page) .header-cta {
		order: 2;
		flex-basis: auto;
		width: auto;
		max-width: min(42vw, 10.5rem);
		margin-left: 0.35rem;
		flex-wrap: nowrap;
		justify-content: flex-end;
	}

	body:not(.home):not(.front-page):not(.woocommerce):not(.woocommerce-page) .menu-toggle {
		order: 3;
		margin-left: 0.25rem !important;
	}

	body:not(.home):not(.front-page):not(.woocommerce):not(.woocommerce-page) .header-cta .btn--primary {
		font-size: 0.58rem;
		padding: 0.45rem 0.55rem;
		letter-spacing: 0.03em;
		line-height: 1.2;
		white-space: normal;
		text-align: center;
		hyphens: auto;
		-webkit-hyphens: auto;
	}
}

@media (max-width: 576px) {
	.header-utility {
		font-size: 0.8125rem;
	}

	.header-cta .btn--primary {
		font-size: 0.7rem;
		padding: 0.55rem 0.85rem;
		letter-spacing: 0.02em;
	}

	body:not(.home):not(.front-page):not(.woocommerce):not(.woocommerce-page) .header-cta .btn--primary {
		font-size: 0.55rem;
		padding: 0.4rem 0.5rem;
	}
}

/* Inicio: quitar CTA duplicado del header (mismo texto que el botón rojo del hero) */
@media (max-width: 768px) {
	body.home .header-cta .btn.btn--primary,
	body.front-page .header-cta .btn.btn--primary {
		display: none !important;
	}
}

/* Logo un poco más visible en móvil */
@media (max-width: 768px) {
	.site-branding__logo {
		max-height: 52px;
		width: auto;
	}
}

/* Flotante: más arriba para no tapar cards / CTAs de productos */
@media (max-width: 768px) {
	.floating-contact {
		right: max(12px, env(safe-area-inset-right, 12px));
		bottom: max(88px, calc(1rem + env(safe-area-inset-bottom, 0px)));
		z-index: 9998;
	}
}

/* ========== Hero móvil: altura unificada, legibilidad, flechas fuera de los botones ========== */
@media (max-width: 768px) {
	/* Misma altura de caja para todos los slides (viewport estable) */
	.hero {
		aspect-ratio: auto;
		height: clamp(480px, 68svh, 600px);
		min-height: clamp(480px, 68svh, 600px);
		max-height: clamp(480px, 68svh, 600px);
	}

	.hero-slider,
	.hero-slider__track {
		height: 100%;
		min-height: 100%;
	}

	.hero-slide {
		align-items: flex-start;
		justify-content: flex-start;
		overflow: hidden;
	}

	/* Oscurecido extra sobre fotos claras (encima del gradiente ::before) */
	.hero-slide::after {
		content: "";
		position: absolute;
		inset: 0;
		background: rgba(0, 0, 0, 0.3);
		z-index: 1;
		pointer-events: none;
	}

	.hero__inner {
		padding-top: clamp(0.85rem, 3vw, 1.35rem);
		padding-bottom: 3.75rem;
		padding-left: clamp(0.75rem, 4vw, 1.25rem);
		padding-right: clamp(0.75rem, 4vw, 1.25rem);
		max-height: 100%;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}

	.hero__content {
		flex: 1 1 auto;
		min-height: 0;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		padding-right: 0.15rem;
	}

	.hero__title,
	.hero__subtitle,
	.hero__text {
		text-shadow:
			0 2px 16px rgba(0, 0, 0, 0.55),
			0 1px 4px rgba(0, 0, 0, 0.45);
	}

	.hero__text--highlight {
		text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
	}

	.hero__title {
		font-size: clamp(1.3rem, 6vw, 1.85rem);
		line-height: 1.12;
	}

	.hero__subtitle {
		font-size: clamp(0.82rem, 3.4vw, 0.98rem);
	}

	.hero-slider__dots {
		bottom: 1rem;
		gap: 0.4rem;
	}

	.hero-slider__dot {
		width: 10px;
		height: 10px;
	}
}

@media (max-width: 480px) {
	.hero {
		height: clamp(460px, 65svh, 580px);
		min-height: clamp(460px, 65svh, 580px);
		max-height: clamp(460px, 65svh, 580px);
	}

	.hero__inner {
		padding-bottom: 4rem;
	}
}

/* Sección productos destacados: aire inferior para botón flotante */
@media (max-width: 768px) {
	.featured-products {
		padding-bottom: 6rem;
		padding-top: 2.5rem;
	}

	.featured-products__header {
		margin-bottom: 2rem;
	}

	.featured-products__title {
		margin-bottom: 0.75rem;
	}
}
