/* ==========================================================================
   MÁQUINAS ERGISA PERÚ EIRL — MODERN RESPONSIVE & MOBILE-FIRST SYSTEM V2
   Breakpoints: 1024px (Tablet Landscape), 768px (Tablet Portrait / Mobile),
                480px (Mobile Large), 390px (Mobile Standard), 360px (Mobile Compact)
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. REGLAS BASE DE CONTENCIÓN Y PREVENCIÓN DE HORIZONTAL OVERFLOW
   -------------------------------------------------------------------------- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
  touch-action: manipulation;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Tipografía de títulos auto-ajustable con cortes seguros */
h1, h2, h3, .hero-title-cinematic, .hero-heading-h1 {
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: manual;
}

/* --------------------------------------------------------------------------
   1. BREAKPOINT: TABLET LANDSCAPE / NETBOOKS (max-width: 1024px)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .container {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .nav-links-clean {
    gap: 1rem;
  }

  .nav-link-item {
    font-size: 0.82rem;
  }

  /* Tira técnica: 3 col arriba, 2 abajo balanceadas */
  .hero-tech-strip,
  .hero-tech-strip-v2 {
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
  }

  .hero-tech-card:nth-child(1),
  .hero-tech-card:nth-child(2),
  .hero-tech-card:nth-child(3),
  .tech-card:nth-child(1),
  .tech-card:nth-child(2),
  .tech-card:nth-child(3) {
    grid-column: span 2;
  }

  .hero-tech-card:nth-child(4),
  .hero-tech-card:nth-child(5),
  .tech-card:nth-child(4),
  .tech-card:nth-child(5) {
    grid-column: span 3;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 0.75rem;
  }

  /* Grids de Contenido */
  .catalog-3col-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .stage-content-body {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2.25rem;
  }

  .clinical-split-grid,
  .calc-grid,
  .workshop-grid,
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  /* Timeline de Fabricación: 3 col arriba, 2 col abajo */
  .process-timeline-steps {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
  }

  .process-step-line {
    display: none;
  }

  /* Footer en 2 columnas */
  .footer-clean-grid {
    grid-template-columns: 1.5fr 1fr;
    gap: 2.5rem;
  }

  .catalog-extended-banner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
}

/* --------------------------------------------------------------------------
   2. BREAKPOINT: TABLET PORTRAIT & MOBILE (max-width: 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Ocultar topbar en móvil para ahorrar espacio útil */
  .topbar-clean, .topbar, .site-topbar {
    display: none !important;
  }

  /* Navbar compacta */
  .navbar-clean, .navbar, .site-nav-wrapper {
    height: 64px;
  }

  .navbar-clean .container, .navbar .container, .site-nav-container {
    height: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  /* Enlaces horizontales ocultos y botón hamburguesa activo */
  .nav-links-clean, .nav-menu, .nav-desktop-menu {
    display: none !important;
  }

  .mobile-menu-trigger {
    display: flex !important;
  }

  .btn-text-full {
    display: none;
  }

  .btn-text-short {
    display: inline;
  }

  /* Brand compacto */
  .brand-logo-img, .brand-logo {
    height: 34px;
  }

  .brand-heading, .brand-name, .brand-title {
    font-size: 0.92rem;
  }

  .brand-subheading, .brand-tagline {
    font-size: 0.6rem;
  }

  /* Hero cinemático fluido: Video desactivado en móvil para Core Web Vitals */
  .hero-cinematic, .hero-industrial-v2 {
    min-height: auto;
    padding: 3.5rem 0 2.5rem 0;
  }

  .hero-video-player,
  .hero-bg-video {
    display: none !important; /* Salva ~7 MB de datos en móvil */
  }

  .hero-title-cinematic,
  .hero-heading-h1 {
    font-size: clamp(1.85rem, 6.5vw, 2.3rem);
    line-height: 1.18;
    margin-bottom: 1rem;
  }

  .hero-subtitle-cinematic,
  .hero-subtext {
    font-size: 0.98rem;
    line-height: 1.6;
    margin-bottom: 1.75rem;
  }

  .hero-actions-cinematic,
  .hero-actions-deck {
    flex-direction: column;
    width: 100%;
    gap: 0.85rem;
    margin-bottom: 2.25rem;
  }

  .hero-actions-cinematic .btn-clean,
  .hero-actions-deck .hero-cta-btn {
    width: 100%;
    min-height: 48px; /* Touch target accesible */
    font-size: 0.92rem;
    justify-content: center;
  }

  /* Tira de Autoridad Técnica: Cuadrícula 2x2 + 1 span (<180px de alto) */
  .hero-tech-strip,
  .hero-tech-strip-v2 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .hero-tech-card,
  .tech-card {
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.5rem 0.25rem;
    grid-column: span 1 !important;
  }

  .hero-tech-card:nth-child(4),
  .hero-tech-card:nth-child(5),
  .tech-card:nth-child(4),
  .tech-card:nth-child(5) {
    border-bottom: none;
  }

  .hero-tech-card:nth-child(5),
  .tech-card:nth-child(5) {
    grid-column: span 2 !important;
    background: rgba(56, 189, 248, 0.08);
    border-radius: var(--radius-sm);
  }

  .hero-tech-card .tech-val,
  .tech-card .tech-metric {
    font-size: 1.15rem;
  }

  .hero-tech-card .tech-lbl,
  .tech-card .tech-label {
    font-size: 0.7rem;
  }

  /* Showcase Multi-Sector con Scroll Horizontal Suave */
  .showcase-stage-container {
    border-radius: var(--radius-lg);
  }

  .stage-tab-bar {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .stage-tab {
    flex: 0 0 190px;
    min-width: 190px;
    padding: 0.85rem 1rem;
    scroll-snap-align: center;
  }

  .stage-content-body {
    padding: 1.5rem 1.25rem;
    gap: 1.5rem;
  }

  .stage-info-title {
    font-size: 1.4rem;
  }

  .stage-media-display {
    height: 240px;
  }

  .stage-metrics-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .stage-metric-val {
    font-size: 1.15rem;
  }

  .stage-metric-lbl {
    font-size: 0.68rem;
  }

  .stage-mobile-dots {
    display: flex;
  }

  /* Slider Antes/Después */
  .ba-master-card {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .ba-slider-view {
    height: 280px;
    border-radius: var(--radius-md);
  }

  .ba-drag-btn {
    width: 44px;
    height: 44px;
  }

  .ba-metrics-row {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  /* Video Feature */
  .video-container-fluid {
    min-height: 320px;
  }

  .video-play-center-btn {
    width: 56px;
    height: 56px;
    top: 35%;
  }

  /* Timeline de Fabricación 5 Pasos: Vertical con Riel Continuo */
  .process-timeline-steps {
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    position: relative;
    padding-left: 2.25rem;
  }

  .process-timeline-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    bottom: 20px;
    left: 19px;
    width: 2px;
    background: var(--steel-border);
    z-index: 1;
  }

  .process-step-item {
    position: relative;
  }

  .process-step-indicator {
    position: absolute;
    top: 0;
    left: -2.25rem;
    margin-bottom: 0;
    z-index: 3;
  }

  .process-step-dot {
    width: 38px;
    height: 38px;
  }

  .process-step-line {
    display: none;
  }

  .process-step-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-md);
  }

  .national-advantage-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .advantage-card-lux {
    padding: 2rem 1.5rem;
  }

  /* Catálogo Serie MEP en 1 columna */
  .catalog-3col-grid,
  .product-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }

  /* Casos Documentados & FAQs en 1 Columna */
  .cases-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .case-card {
    padding: 1.75rem 1.35rem;
  }

  .faq-summary {
    padding: 1.15rem 1.25rem;
    font-size: 1rem;
  }

  .faq-answer {
    padding: 0 1.25rem 1.25rem 1.25rem;
    font-size: 0.95rem;
  }

  /* Banner CTA Final */
  .cta-master-clean {
    padding: 3.5rem 0;
  }

  .cta-master-card {
    padding: 3rem 1.5rem;
    border-radius: var(--radius-lg);
  }

  .cta-master-actions {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .btn-cta-large {
    width: 100%;
    justify-content: center;
    padding: 0.95rem 1.5rem;
  }

  .cta-trust-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    text-align: left;
  }

  /* Tablas de Especificaciones con Primera Columna Fija (Sticky) */
  .specs-table-wrap {
    position: relative;
    border-radius: var(--radius-lg);
    -webkit-overflow-scrolling: touch;
  }

  .specs-table th, 
  .specs-table td {
    padding: 0.85rem 1rem;
    font-size: 0.84rem;
  }

  .specs-table th:first-child,
  .specs-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f8fafc;
    font-weight: 700;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.06);
  }

  .specs-table th:first-child {
    background: var(--bg-subtle);
  }

  /* Tarjetas Generales */
  .clinical-report-card,
  .calc-master-box,
  .calc-inputs-panel,
  .calc-result-panel,
  .workshop-card,
  .info-card,
  .bio-card {
    padding: 1.75rem 1.25rem;
    border-radius: var(--radius-lg);
  }

  /* Footer en 1 Columna */
  .footer-clean-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-clean-bottom {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  /* Botón Flotante WhatsApp Compacto */
  .floating-whatsapp-clean {
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    right: 1.25rem;
    padding: 0.85rem;
    border-radius: 50%;
  }

  .floating-whatsapp-clean span {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   3. BREAKPOINT: MOBILE LARGE (max-width: 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  h1 { font-size: 1.85rem !important; }
  h2 { font-size: 1.45rem !important; }
  h3 { font-size: 1.2rem !important; }

  /* Filtros de Catálogo (Touch Target >= 44px) */
  .filter-buttons {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    gap: 0.5rem;
  }

  .filter-btn {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
  }

  .currency-switcher {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .currency-btn {
    flex: 1;
    min-height: 40px;
    font-size: 0.85rem;
  }

  /* Formulario de Contacto en 1 Columna */
  .contact-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Antes / Después */
  .ba-label-pill {
    position: static;
    display: inline-block;
    margin: 0.35rem;
    font-size: 0.7rem;
    text-align: center;
  }

  .ba-slider-view {
    height: 240px;
  }

  /* Normalización de Grids Inline en nosotros-fabrica.html */
  div[style*="grid-template-columns: 1fr 1.5fr"],
  div[style*="grid-template-columns: 1.2fr 0.8fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
  }

  .cta-trust-bar {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
}

/* --------------------------------------------------------------------------
   4. BREAKPOINT: MOBILE STANDARD (max-width: 390px - iPhone Standard)
   -------------------------------------------------------------------------- */
@media (max-width: 390px) {
  .brand-title {
    font-size: 0.92rem;
  }

  .brand-tagline {
    font-size: 0.58rem;
  }

  .hero-heading-h1 {
    font-size: 1.7rem !important;
  }

  .stage-tab {
    min-width: 160px;
    flex: 0 0 160px;
    padding: 0.65rem 0.8rem;
  }

  .stage-metrics-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .calc-result-value {
    font-size: 1.8rem;
  }

  .cta-master-title {
    font-size: 1.55rem;
  }
}

/* --------------------------------------------------------------------------
   5. BREAKPOINT: MOBILE COMPACT (max-width: 360px - Android Entry / Galaxy A)
   -------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .stage-tab {
    min-width: 145px;
    flex: 0 0 145px;
    padding: 0.55rem 0.65rem;
  }

  .stage-tab-title {
    font-size: 0.76rem;
  }

  .stage-tab-sub {
    font-size: 0.62rem;
  }

  .tech-card .tech-metric,
  .hero-tech-card .tech-val {
    font-size: 1.05rem;
  }

  .tech-card .tech-label,
  .hero-tech-card .tech-lbl {
    font-size: 0.64rem;
  }

  .btn-cta-large {
    font-size: 0.9rem;
    padding: 0.85rem 1rem;
  }

  .cta-master-title {
    font-size: 1.4rem;
  }
}
