/* === VARIABLES NATIVAS === */
:root {
  --rojo: #ED3632;
  --fondo: #F9F6F0;
  --texto: #333;
  --gris: #555;
  --cristal: rgba(255, 255, 255, 0.65);
  --cristal-panel: rgba(249, 246, 240, 0.85);
  --borde-cristal: rgba(255, 255, 255, 0.8);
  --fondo-tarjeta: #EAE6DF;
  --nav-bg-fixed: rgba(255, 255, 255, 0.9);
  --sombra: 0 10px 30px rgba(0,0,0,0.05);
  --curva-apple: cubic-bezier(0.25, 1, 0.5, 1);
}

/* === MODO OSCURO === */
[data-theme="dark"] {
  --fondo: #121212;
  --texto: #F9F6F0;
  --gris: #A0A0A0;
  --cristal: rgba(20, 20, 20, 0.75);
  --cristal-panel: rgba(30, 30, 30, 0.9);
  --borde-cristal: rgba(255, 255, 255, 0.05);
  --fondo-tarjeta: #1E1E1E;
  --nav-bg-fixed: rgba(18, 18, 18, 0.95);
  --sombra: 0 10px 30px rgba(0,0,0,0.5);
}

/* === SCROLL MAGNÉTICO === */
html { scroll-snap-type: y mandatory; scroll-behavior: smooth; }
.snap-section { scroll-snap-align: start; scroll-snap-stop: always; min-height: 100svh; }

/* === BASE === */
body { 
  margin: 0; font-family: 'Exo 2', sans-serif; background: var(--fondo); color: var(--texto); overflow-x: hidden; 
  transition: background-color 0.5s ease, color 0.5s ease; /* Transición suave al cambiar de tema */
}

/* === HERO Y LUPA LIGERA === */
.hero { position: relative; width: 100vw; height: 100svh; overflow: hidden; display: flex; background: #111; }
.plano, .real { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.plano { z-index: 1; opacity: 1; }
.real { 
  z-index: 2; --x: 50vw; --y: 50vh; --lens: clamp(125px, 17.5vw, 200px); 
  clip-path: circle(var(--lens) at var(--x) var(--y));
  -webkit-clip-path: circle(var(--lens) at var(--x) var(--y));
}

/* === ENVOLTORIO NAVBAR === */
.navbar-wrapper {
  position: fixed; top: 0; left: 0; width: 100%; height: 95px; 
  z-index: 1000; pointer-events: none; 
  transform: translateY(calc(100svh - 95px)); 
  will-change: transform; transition: transform 0.8s var(--curva-apple);
}
.navbar-wrapper.fixed-top { transform: translateY(0); }

.navbar-glass {
  pointer-events: auto; display: inline-flex; align-items: center; justify-content: space-between; 
  height: 100%; padding: 0 40px 0 25px; width: 100%; max-width: 850px; 
  background: var(--cristal); backdrop-filter: blur(25px); -webkit-backdrop-filter: blur(25px);
  border: 2px solid var(--rojo); border-bottom-color: transparent; border-radius: 0 45px 0 0; 
  box-shadow: 15px -10px 40px rgba(0,0,0,0.15); box-sizing: border-box;
  transition: all 0.7s var(--curva-apple), background-color 0.5s ease;
}

.fixed-top .navbar-glass {
  max-width: 100vw; padding: 0 5%; border-radius: 0; 
  border-color: transparent transparent var(--rojo) transparent; background: var(--nav-bg-fixed); 
}

/* === INTERNOS DEL MENÚ Y BOTONES === */
.nav-brand { display: flex; align-items: center; gap: 20px; flex-shrink: 0; height: 100%; }
.nav-logo { height: clamp(45px, 4vw, 60px); width: auto; flex-shrink: 0; transition: height 0.7s var(--curva-apple); }
.fixed-top .nav-logo { height: 40px; }

.nav-title { font-size: clamp(1.2rem, 1.8vw, 1.6rem); font-weight: 700; line-height: 1.15; color: var(--rojo); margin: 0; min-width: max-content; transition: font-size 0.7s var(--curva-apple); }
.fixed-top .nav-title { font-size: 1.1rem; }

/* Contenedor para alinear Tema y Cotizar sin romper diseño */
.nav-actions { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }

.theme-btn {
  background: none; border: none; font-size: 1.6rem; cursor: pointer; padding: 5px;
  transition: transform 0.3s var(--curva-apple), filter 0.3s; line-height: 1;
}
.theme-btn:hover { transform: scale(1.15) rotate(-15deg); filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }

.cta-btn { 
  background: var(--rojo); color: #FFF; padding: 12px 35px; font-size: 1.1rem; font-weight: 700; text-decoration: none; 
  border-radius: 10px; border: none; box-shadow: 0 6px 20px rgba(237, 54, 50, 0.4);
  transition: all 0.4s ease; cursor: pointer; white-space: nowrap;
}
.fixed-top .cta-btn { padding: 10px 30px; font-size: 1.05rem; border-radius: 8px; }
.cta-btn:hover { background: #d12e2b; transform: translateY(-3px); }
.fixed-top .cta-btn:hover { transform: translateY(-2px); }

/* === INDICADORES VISUALES === */
.scroll-indicator {
  position: absolute; bottom: 40px; right: 6%; width: 26px; height: 44px; border: 3px solid #FFF; border-radius: 50px;
  z-index: 15; pointer-events: none; box-shadow: 0 4px 15px rgba(0,0,0,0.5); background: rgba(0,0,0,0.15); opacity: 0;
}
.scroll-indicator::before {
  content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px;
  background: #FFF; border-radius: 50%; box-shadow: 0 0 8px rgba(255,255,255,0.8); animation: scrollWheel 2s infinite;
}
@keyframes scrollWheel { 0% { top: 8px; opacity: 1; } 100% { top: 26px; opacity: 0; } }

.mobile-hint {
  display: none; position: absolute; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65); color: #FFF; padding: 12px 25px; border-radius: 30px; font-weight: 700;
  z-index: 50; pointer-events: none; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2); box-shadow: 0 4px 15px rgba(0,0,0,0.3); animation: pulseHint 2s infinite ease-in-out;
}
@keyframes pulseHint { 0%, 100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.05); } }

/* === BENTO BOX GRID === */
.servicios-bento { padding: 120px 5% 40px 5%; display: flex; flex-direction: column; }
.bento-header { text-align: center; margin-bottom: 50px; }
.bento-header h2 { font-size: clamp(2rem, 3vw, 3rem); color: var(--rojo); margin: 0 0 10px 0; }
.bento-header p { font-size: 1.1rem; color: var(--gris); margin: 0; transition: color 0.5s ease; }

.bento-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 250px; gap: 20px;
  grid-auto-flow: dense; width: 100%; max-width: 1400px; margin: 0 auto;
}

.card-large { grid-column: span 2; grid-row: span 2; }
.card-wide  { grid-column: span 2; grid-row: span 1; }
.card-tall  { grid-column: span 1; grid-row: span 2; }
.card-regular { grid-column: span 1; grid-row: span 1; }

.bento-card {
  position: relative; background: var(--fondo-tarjeta); border-radius: 24px; overflow: hidden;
  cursor: pointer; box-shadow: var(--sombra); transition: box-shadow 0.4s ease, background-color 0.5s ease;
}

.bento-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.6s var(--curva-apple), filter 0.6s; filter: blur(8px) brightness(0.85); 
}

.bento-glass {
  position: absolute; inset: 15px; background: var(--cristal); 
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border-radius: 16px; border: 1px solid var(--borde-cristal); padding: 25px;
  display: flex; flex-direction: column; justify-content: space-between; transition: all 0.5s var(--curva-apple), background-color 0.5s ease;
}

.bento-text h3 { font-size: 1.25rem; color: var(--texto); margin: 0 0 8px 0; transition: color 0.4s; }
.bento-text p { font-size: 0.95rem; color: var(--gris); margin: 0; line-height: 1.4; transition: opacity 0.4s, transform 0.4s, color 0.5s ease; }
.bento-arrow { align-self: flex-end; font-size: 1.5rem; color: var(--texto); font-weight: 700; transition: all 0.4s; }

@media (hover: hover) {
  .bento-card:hover { box-shadow: 0 20px 40px rgba(237, 54, 50, 0.15); }
  .bento-card:hover .bento-img { filter: blur(0px) brightness(1); transform: scale(1.05); }
  .bento-card:hover .bento-glass { top: auto; height: max-content; background: var(--nav-bg-fixed); border-color: var(--rojo); }
  .bento-card:hover .bento-text h3, .bento-card:hover .bento-arrow { color: var(--rojo); }
  .bento-card:hover .bento-text p { opacity: 0; transform: translateY(10px); position: absolute; }
  .bento-card:hover .bento-arrow { transform: translateX(5px); }
}

/* === FOOTER Y ENLACES LEGALES === */
.site-footer {
  margin-top: auto; padding-top: 80px; text-align: center;
  font-size: 0.95rem; color: var(--gris); padding-bottom: 20px; transition: color 0.5s ease;
}
.footer-links { margin-bottom: 12px; display: flex; justify-content: center; gap: 20px; font-size: 0.9rem; }
.footer-links span { color: var(--gris); opacity: 0.5; }
.footer-links a { color: var(--rojo); text-decoration: none; font-weight: 700; transition: color 0.3s; }
.footer-links a:hover { color: #d12e2b; }

/* === FIRMA iCOREMEX === */
.icoremex-brand { font-family: 'Michroma', sans-serif; color: #FACC14; text-decoration: none; font-size: 1rem; transition: text-shadow 0.3s ease; }
.icoremex-brand .mex-color { color: #FA7416; }
.icoremex-brand:hover { text-shadow: 0 0 10px rgba(250, 204, 20, 0.5); }
.icoremex-brand:hover .mex-color { text-shadow: 0 0 10px rgba(250, 116, 22, 0.5); }

/* === PANEL OFF-CANVAS (CONTACTO) === */
.panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 1500; opacity: 0; pointer-events: none; transition: background-color 0.5s ease;
}
.offcanvas-panel {
  position: fixed; top: 0; right: 0; width: 450px; height: 100svh;
  background: var(--cristal-panel); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  z-index: 2000; box-shadow: -10px 0 40px rgba(0,0,0,0.1); display: flex; flex-direction: column;
  padding: 50px 40px; box-sizing: border-box; border-left: 1px solid var(--borde-cristal);
  transform: translateX(100%); will-change: transform; transition: background-color 0.5s ease, border-color 0.5s ease;
}

.contact-icon { width: 35px; height: 35px; object-fit: contain; }

.close-btn { position: absolute; top: 25px; right: 30px; background: none; border: none; font-size: 1.8rem; color: var(--texto); cursor: pointer; transition: all 0.3s; padding: 5px; z-index: 10; }
.close-btn:hover { color: var(--rojo); transform: rotate(90deg); }

.panel-content { margin-top: 30px; }
.panel-content h2 { color: var(--rojo); font-size: 1.8rem; margin-bottom: 15px; line-height: 1.2; }
.panel-content p { color: var(--gris); font-size: 1.05rem; line-height: 1.5; margin-bottom: 40px; transition: color 0.5s ease; }

.contact-links { display: flex; flex-direction: column; gap: 20px; }
.contact-card {
  display: flex; align-items: center; gap: 20px; padding: 20px; background: var(--cristal);
  border-radius: 16px; text-decoration: none; color: var(--texto); border: 1px solid var(--borde-cristal);
  box-shadow: var(--sombra); transition: all 0.3s, background-color 0.5s ease;
}
.contact-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(237, 54, 50, 0.15); background: var(--fondo); border-color: var(--rojo); }
.contact-info { display: flex; flex-direction: column; }
.contact-info strong { font-size: 1.1rem; margin-bottom: 3px; }
.contact-info span { font-size: 0.95rem; color: var(--gris); }

/* === MODAL LEGAL (Términos y Privacidad) === */
.legal-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 90%; max-width: 650px; max-height: 85vh;
  background: var(--cristal-panel); backdrop-filter: blur(30px); -webkit-backdrop-filter: blur(30px);
  z-index: 2500; border-radius: 24px; border: 1px solid var(--borde-cristal); box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  padding: 40px; box-sizing: border-box; display: flex; flex-direction: column;
  overflow-y: auto; transition: background-color 0.5s ease, border-color 0.5s ease;
}
.legal-body { overflow-y: auto; padding-right: 15px; margin-top: 10px; font-size: 0.95rem; color: var(--gris); line-height: 1.6; }
.legal-body h3 { color: var(--texto); font-size: 1.1rem; margin: 25px 0 10px 0; transition: color 0.5s ease; }
.legal-body p { margin-bottom: 15px; }

/* === ADAPTACIONES MÓVILES === */
@media (max-width: 900px) { .bento-grid { grid-template-columns: repeat(2, 1fr); } }

@media (max-width: 768px) {
  .mobile-hint { display: block; top: 90px; opacity: 1 !important; }
  
  .navbar-wrapper { height: 70px; transform: translateY(calc(100svh - 70px)); }
  .navbar-glass { max-width: calc(100vw - 15px); padding: 0 15px 0 10px; border-radius: 0 30px 0 0; gap: 10px; }
  .nav-brand { gap: 8px; }
  .nav-logo { height: 35px; max-width: 50px; }
  .fixed-top .nav-logo { height: 30px; }
  .nav-title { font-size: 0.8rem; }
  .fixed-top .nav-title { font-size: 0.8rem; }
  
  .nav-actions { gap: 10px; }
  .theme-btn { font-size: 1.3rem; }
  .cta-btn { padding: 8px 12px; font-size: 0.85rem; }
  .fixed-top .cta-btn { padding: 8px 12px; font-size: 0.85rem; }
  .fixed-top .navbar-glass { max-width: 100vw; padding: 0 15px; }

  .scroll-indicator { display: block; bottom: 95px; left: 50%; right: auto; transform: translateX(-50%) scale(0.85); background: rgba(0,0,0,0.4); }
  .scroll-indicator::after { content: 'Desliza'; position: absolute; top: -24px; left: 50%; transform: translateX(-50%); color: #FFF; font-size: 0.95rem; font-weight: 700; letter-spacing: 1px; }

  .offcanvas-panel {
    top: auto; bottom: 0; left: 0; width: 100vw; height: auto; min-height: 50svh;
    border-left: none; border-top: 1px solid var(--borde-cristal); border-radius: 35px 35px 0 0;
    padding: 40px 25px 50px 25px; transform: translateY(100%);
  }
  .close-btn { top: 15px; right: 20px; }
  .panel-content h2 { font-size: 1.5rem; }
  .panel-content p { font-size: 1rem; margin-bottom: 30px; }
  
  .legal-modal { padding: 30px 20px; width: 95%; max-height: 80vh; }
  .site-footer { padding-top: 50px; padding-bottom: 20px; }
}

@media (max-width: 600px) {
  .servicios-bento { padding-top: 100px; }
  .bento-grid { grid-template-columns: 1fr; grid-auto-rows: 280px; }
  .card-large, .card-wide, .card-tall, .card-regular { grid-column: span 1 !important; grid-row: span 1 !important; }
  .bento-img { filter: blur(0px) brightness(0.9); }
  
  .bento-glass { top: auto; bottom: 15px; height: max-content; background: var(--cristal-panel); padding: 15px 20px; flex-direction: row; align-items: center; }
  .bento-text { flex-grow: 1; }
  .bento-text p { display: none; } 
  .bento-text h3 { font-size: 1.15rem; margin: 0; }
  .bento-arrow { color: var(--rojo); font-size: 1.5rem; align-self: center; }
}