/* Base y colores */
:root {
    --rey-blue: #002366;
    --dark-blue: #001f4d;
    --light-blue: #004080;
    --white: #fff;
    --gray: #f8f9fa;
    --gray-dark: #343a40;
    --gray-light: #e9ecef;
    --accent: #0065d1;
    --success: #187d38;
    --muted: #596570;
    --header-height: 80px;
    --shadow: 0 4px 16px rgb(0 31 77 / 8%);
    --shadow-lg: 0 12px 28px rgb(0 31 77 / 14%);
    --transition: background-color .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: var(--header-height); }
body { font-family: 'Inter', system-ui, sans-serif; line-height: 1.6; color: var(--gray-dark); overflow-wrap: anywhere; }
body.menu-open, body.modal-open { overflow: hidden; }
button { font: inherit; cursor: pointer; }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--rey-blue); text-underline-offset: .2em; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #ffbd59; outline-offset: 4px; }
[hidden] { display: none !important; }
.container { width: calc(100% - 48px); max-width: 1200px; margin-inline: auto; }
section { padding: 72px 0; scroll-margin-top: 16px; }
.skip-link { position: fixed; top: 8px; left: 16px; z-index: 3000; padding: 12px 20px; background: white; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.section-title { text-align: center; font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.25; color: var(--rey-blue); margin-bottom: 16px; font-weight: 700; }
.section-subtitle { text-align: center; color: var(--muted); margin: 0 auto 36px; max-width: 600px; }

/* Cabecera: la altura medida en JS mantiene el menú y las anclas alineados. */
.navbar { position: sticky; top: 0; z-index: 1000; background: linear-gradient(135deg, var(--rey-blue), var(--dark-blue)); color: white; box-shadow: 0 2px 10px rgb(0 0 0 / 10%); }
.navbar .container { min-height: 80px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: white; text-decoration: none; font-size: 1.65rem; font-weight: 700; flex-shrink: 0; }
.logo i { color: #8dbbff; font-size: 1.8rem; }
.nav-menu { display: flex; align-items: center; gap: 20px; }
.nav-menu a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 0; color: white; text-decoration: none; font-weight: 500; transition: var(--transition); }
.nav-menu a:hover { color: #bbd8ff; }
.nav-menu .btn-contacto { padding: 10px 18px; background: var(--accent); border-radius: 6px; }
.nav-menu .btn-contacto:hover { background: var(--light-blue); color: white; }
.hamburger { display: none; width: 44px; height: 44px; flex-shrink: 0; flex-direction: column; align-items: center; justify-content: center; gap: 5px; background: transparent; border: 1px solid rgb(255 255 255 / 35%); border-radius: 6px; }
.hamburger span { width: 23px; height: 2px; background: white; border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Una sola fotografía, independiente del ancho del texto. */
.hero { position: relative; isolation: isolate; display: flex; align-items: center; min-height: min(680px, calc(100svh - var(--header-height))); padding: 80px 0; color: white; background: var(--dark-blue); }
.hero-image { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero::before { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, rgb(0 20 55 / 94%) 0%, rgb(0 25 65 / 85%) 48%, rgb(0 25 65 / 35%) 100%); }
.hero-overlay { width: 100%; }
.hero-content { max-width: 730px; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3.5rem); font-weight: 800; line-height: 1.13; letter-spacing: -.03em; margin-bottom: 24px; text-wrap: balance; }
.hero p { font-size: 1.15rem; max-width: 600px; margin-bottom: 28px; }
.hero .hero-location { color: #c7ddff; font-size: .95rem; font-weight: 600; margin-bottom: 18px; }
.hero-buttons { display: flex; flex-wrap: wrap; gap: 12px; }

/* Acciones con contraste y áreas táctiles consistentes. */
.btn-primary, .btn-whatsapp, .btn-map, .btn-call, .btn-whatsapp-sm { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px; border: 2px solid transparent; border-radius: 7px; color: white; font-size: 1rem; font-weight: 600; line-height: 1.4; text-align: center; text-decoration: none; transition: var(--transition); }
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--light-blue); }
.btn-whatsapp, .btn-whatsapp-sm { background: var(--success); }
.btn-whatsapp:hover, .btn-whatsapp-sm:hover { background: #12632c; }
.btn-map { background: #a84300; }
.btn-map:hover { background: #863600; }
.btn-call { background: var(--rey-blue); }
.btn-call:hover { background: var(--dark-blue); }
.btn-large { padding: 16px 24px; }

/* Servicios: cuatro columnas amplias, dos intermedias, una en móvil. */
.services, .sucursales { background: var(--gray); }
.services-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; }
.service-card { min-width: 0; position: relative; background: white; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); transition: var(--transition); }
.service-card img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; }
.service-icon { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: white; background: var(--rey-blue); border-radius: 50%; font-size: 1.15rem; }
.service-card h3 { padding: 22px 20px 10px; color: var(--rey-blue); font-size: 1.15rem; line-height: 1.4; }
.service-card p { padding: 0 20px 24px; color: var(--muted); }
.refacciones { background: linear-gradient(var(--gray), white); }
.refacciones-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.refaccion { min-width: 0; padding: 24px 16px; background: white; border: 1px solid var(--gray-light); border-radius: 10px; text-align: center; }
.refaccion i { display: block; font-size: 2rem; color: var(--rey-blue); margin-bottom: 10px; }
.refaccion span { font-weight: 600; }
.por-que { background: var(--rey-blue); color: white; }
.por-que .section-title { color: white; margin-bottom: 32px; }
.por-que-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.por-que-item { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 24px 16px; background: rgb(255 255 255 / 8%); border-radius: 10px; }
.por-que-item i { font-size: 2rem; color: #9bc6ff; }
.por-que-item span { font-weight: 600; }

/* Sucursales y horarios */
.sucursales-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 32px; }
.sucursal-card { min-width: 0; display: flex; flex-direction: column; padding: 28px; background: white; border-radius: 12px; box-shadow: var(--shadow); }
.sucursal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; color: var(--rey-blue); }
.sucursal-header i { font-size: 1.6rem; flex-shrink: 0; }
.sucursal-header h3 { font-size: clamp(1.25rem, 2vw, 1.6rem); line-height: 1.3; }
.sucursal-details { display: flex; flex-direction: column; flex: 1; }
.sucursal-details p { margin-bottom: 10px; }
.sucursal-details p > i { width: 20px; color: var(--rey-blue); }
.sucursal-details p a { display: inline-block; padding-block: 5px; }
.sucursal-details .whatsapp-link { color: var(--success); }
.sucursal-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 16px; margin-top: auto; }
.sucursal-actions a { flex: 1 1 130px; font-size: .9rem; }
.sucursal-actions .btn-map { flex-basis: 100%; }
.horarios-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 28px; }
.horario { display: flex; align-items: center; gap: 12px; background: var(--gray-light); border-radius: 10px; padding: 20px; }
.horario strong { display: block; color: var(--rey-blue); }
.contact-trigger { background: var(--rey-blue); color: white; text-align: center; }
.contact-trigger .section-title { color: white; }
.contact-trigger p { margin-bottom: 24px; }

/* Dialog nativo: fondo inerte, foco contenido y cierre con Escape. */
.modal { position: fixed; inset: 0; width: min(600px, calc(100% - 32px)); max-width: none; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 0; border: 0; border-radius: 12px; color: var(--gray-dark); background: white; box-shadow: var(--shadow-lg); overflow: auto; overscroll-behavior: contain; }
.modal::backdrop { background: rgb(0 15 40 / 75%); backdrop-filter: blur(4px); }
.modal-content { padding: 28px; }
.modal[open] { animation: modalOpen .2s ease; }
@keyframes modalOpen { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.modal-content h2 { color: var(--rey-blue); margin: 12px 0; font-size: 1.5rem; line-height: 1.3; }
.modal-content > p { margin-bottom: 24px; }
.modal-content h3 { color: var(--dark-blue); font-size: 1.15rem; }
.modal-section { padding-block: 16px; border-top: 1px solid var(--gray-light); }
.modal-section p { margin-top: 8px; }
.modal-section a { display: inline-block; padding-block: 6px; }
.modal-section i { width: 20px; color: var(--rey-blue); }
.close { position: sticky; top: 8px; display: block; margin-left: auto; width: 44px; height: 44px; border: 1px solid #c5cdd7; border-radius: 50%; font-size: 28px; line-height: 1; color: var(--rey-blue); background: white; z-index: 1; }
.close:hover { background: var(--gray-light); }

/* Contacto flotante y pie */
.whatsapp-float { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 900; display: flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; background: var(--success); color: white; font-size: 28px; box-shadow: var(--shadow-lg); text-decoration: none; transition: var(--transition); }
body.menu-open .whatsapp-float { visibility: hidden; }
.footer { background: var(--dark-blue); color: white; padding: 56px 0 calc(100px + env(safe-area-inset-bottom)); }
.footer-content { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px; margin-bottom: 32px; }
.footer-info h3, .footer-hours h4 { color: #a0c4ff; margin-bottom: 12px; }
.footer-info h3 { font-size: 1.5rem; }
.footer-links a { display: block; width: fit-content; min-height: 44px; padding-block: 8px; color: #c0d8ff; }
.footer-links a:hover { color: white; }
.footer-hours { font-size: .95rem; }
.footer-bottom { border-top: 1px solid rgb(255 255 255 / 15%); padding-top: 24px; text-align: center; color: #c0d8ff; font-size: .9rem; }

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .service-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
    .whatsapp-float:hover { transform: scale(1.05); }
}
@media (max-width: 1099px) {
    .services-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .navbar .container { flex-wrap: wrap; gap: 0; }
    .nav-menu { width: 100%; flex-wrap: wrap; padding-bottom: 12px; }
    .js .hamburger { display: flex; }
    .js .nav-menu { display: none; position: absolute; top: 100%; left: 0; width: 100%; max-height: calc(100vh - var(--header-height)); max-height: calc(100dvh - var(--header-height)); overflow-y: auto; overscroll-behavior: contain; padding: 16px 24px calc(24px + env(safe-area-inset-bottom)); background: var(--rey-blue); flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; }
    .js .nav-menu.active { display: flex; }
    .nav-menu a { padding: 12px 16px; flex-shrink: 0; }
    .nav-menu .btn-contacto { margin-top: 8px; padding: 12px 16px; }
    .por-que-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .container { width: calc(100% - 32px); }
    section { padding: 48px 0; }
    .navbar .container { min-height: 72px; }
    .hero { min-height: auto; padding: 56px 0; }
    .hero::before { background: rgb(0 25 65 / 84%); }
    .hero p { font-size: 1.05rem; }
    .hero-buttons { flex-direction: column; align-items: stretch; }
    .hero-buttons a { width: 100%; }
    .sucursales-grid, .horarios-grid, .footer-content { grid-template-columns: minmax(0, 1fr); }
    .sucursal-card { padding: 22px; }
    .sucursal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; width: 100%; }
    .sucursal-actions a { min-width: 0; width: 100%; min-height: 44px; padding: 8px 10px; gap: 6px; font-size: .875rem; }
    .sucursal-actions .btn-map { grid-column: 1 / -1; }
    .horarios-grid { gap: 12px; }
    .horario strong { display: inline; }
    .footer { padding-top: 40px; }
    .footer-content { gap: 28px; }
    .whatsapp-float { width: 52px; height: 52px; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + env(safe-area-inset-bottom)); }
    /* Espacio de paso para que el flotante no tape los enlaces al enfocarlos. */
    a, button { scroll-margin-bottom: 88px; }
}
@media (max-width: 599px) {
    .services-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .refacciones-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .por-que-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .por-que-item { flex-direction: row; text-align: left; padding: 18px; }
    .por-que-item i { width: 36px; flex-shrink: 0; text-align: center; }
    .modal-content { padding: 20px; }
    .section-subtitle { margin-bottom: 28px; }
}
@media (max-height: 500px) and (orientation: landscape) {
    .hero { min-height: auto; padding: 36px 0; }
    .js .nav-menu { gap: 0; padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
