/* ===============================================
   OPTIMIZACIONES DE PERFORMANCE Y RESPONSIVE
   =============================================== */

/* Critical CSS optimizations */
.container {
  contain: layout style;
}

/* Hero image optimization */
.hero-bg-img {
  content-visibility: auto;
  contain-intrinsic-size: 100vw 100vh;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Lazy loading placeholder */
.hero-bg-img[loading="lazy"] {
  background-color: #f0f0f0;
}

/* GPU acceleration para animaciones */
.btn, .card, .hero-content {
  will-change: transform;
  transform: translateZ(0);
}

/* Optimización de scroll */
@supports (scroll-behavior: smooth) {
  html {
    scroll-behavior: smooth;
  }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: #1a1a1a;
    --text-color: #e0e0e0;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #000000;
    --secondary-color: #ffffff;
  }
}

/* ===============================================
   RESPONSIVE BREAKPOINTS MEJORADOS
   =============================================== */

/* Mobile First Approach */
/* Base: 320px - 767px (Mobile) */

/* Small Mobile */
@media screen and (max-width: 375px) {
  .container {
    padding: 0 1rem;
  }
  
  .hero-content h1 {
    font-size: 2rem;
  }
  
  .hero-content p {
    font-size: 0.9rem;
  }
  
  .btn {
    padding: 0.8rem 1.5rem;
    font-size: 0.9rem;
  }
  
  .section {
    padding: 3rem 0;
  }
  
  .development-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .unit-card {
    padding: 1.5rem;
  }
  
  .amenities-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .nav-menu {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .hero {
    min-height: 70vh;
    padding: 2rem 0;
  }
  
  .modal-content {
    margin: 1rem;
    padding: 1rem;
  }
}

/* Tablet Portrait */
@media screen and (min-width: 768px) and (max-width: 1023px) {
  .container {
    max-width: 720px;
  }
  
  .development-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  
  .amenities-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .nav-menu {
    gap: 1.5rem;
  }
  
  .hero-content h1 {
    font-size: 3rem;
  }
  
  .unit-card {
    display: flex;
    align-items: center;
    gap: 2rem;
  }
  
  .unit-image {
    flex: 0 0 40%;
  }
  
  .unit-content {
    flex: 1;
  }
}

/* Tablet Landscape / Small Desktop */
@media screen and (min-width: 1024px) and (max-width: 1199px) {
  .container {
    max-width: 960px;
  }
  
  .development-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }
  
  .amenities-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .hero-content h1 {
    font-size: 3.5rem;
  }
}

/* Large Desktop */
@media screen and (min-width: 1200px) {
  .container {
    max-width: 1140px;
  }
  
  .development-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
  }
  
  .amenities-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .hero-content h1 {
    font-size: 4rem;
  }
}

/* Extra Large Desktop */
@media screen and (min-width: 1400px) {
  .container {
    max-width: 1320px;
  }
  
  .development-grid {
    gap: 4rem;
  }
  
  .hero-content h1 {
    font-size: 4.5rem;
  }
}

/* ===============================================
   OPTIMIZACIONES MÓVILES ESPECÍFICAS
   =============================================== */

/* Touch optimizations */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
  }
  
  .nav-menu a {
    padding: 1rem;
    font-size: 1.1rem;
  }
  
  /* Optimización de tap targets */
  a, button, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Hover effects para touch */
  .btn:active {
    transform: scale(0.98);
  }
  
  .card:active {
    transform: translateY(2px);
  }
  
  /* Mejores espacios para dedos */
  .form-control {
    padding: 1rem;
    font-size: 1rem;
  }
  
  .whatsapp-float {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
}

/* Landscape mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
  .hero {
    min-height: 100vh;
    padding: 1rem 0;
  }
  
  .hero-content {
    text-align: center;
  }
  
  .hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
  }
  
  .hero-content p {
    font-size: 1rem;
    margin-bottom: 1rem;
  }
  
  .section {
    padding: 2rem 0;
  }
  
  .header {
    padding: 0.5rem 0;
  }
}

/* Very small screens */
@media screen and (max-width: 320px) {
  .container {
    padding: 0 0.75rem;
  }
  
  .hero-content h1 {
    font-size: 1.75rem;
  }
  
  .btn {
    padding: 0.75rem 1.25rem;
    font-size: 0.85rem;
  }
  
  .section-title {
    font-size: 1.5rem;
  }
  
  .unit-card {
    padding: 1rem;
  }
  
  .amenity-card {
    padding: 1rem;
  }
}

/* ===============================================
   PRINT STYLES
   =============================================== */

@media print {
  .header,
  .whatsapp-float,
  .btn,
  .footer,
  .nav-menu,
  .menu-toggle {
    display: none !important;
  }
  
  .hero {
    background: none !important;
    color: black !important;
    padding: 2rem 0;
  }
  
  * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
  }
  
  .container {
    max-width: none !important;
    padding: 0;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
  
  .section {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 2rem;
  }
  
  .unit-card, .amenity-card {
    break-inside: avoid;
    border: 1px solid #ccc;
    margin-bottom: 1rem;
  }
  
  a {
    text-decoration: underline !important;
  }
  
  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
  
  .contact-form {
    display: none;
  }
  
  .hero-content h1:after {
    content: "\A Visite: https://kuxnah.com";
    white-space: pre;
    font-size: 0.5em;
  }
}

/* ===============================================
   ACCESSIBILITY IMPROVEMENTS
   =============================================== */

/* Focus management */
*:focus {
  outline: 2px solid var(--secondary-color);
  outline-offset: 2px;
}

.btn:focus {
  outline: 3px solid var(--secondary-color);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to main content */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--primary-color);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: var(--z-tooltip);
  border-radius: 4px;
  font-weight: 600;
}

.skip-link:focus {
  top: 6px;
}

/* High contrast mode improvements */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
    background: white;
    color: black;
  }
  
  .card {
    border: 2px solid currentColor;
  }
  
  .hero {
    background: white !important;
    color: black !important;
  }
  
  .header {
    background: black !important;
    color: white !important;
  }
}

/* Motion sensitivity */
@media (prefers-reduced-motion: reduce) {
  .fade-in-up {
    animation: none;
  }
  
  .loading::after {
    animation: none;
  }
}

/* ===============================================
   PERFORMANCE OPTIMIZATIONS
   =============================================== */

/* Contain layout shifts */
.hero {
  contain: layout style;
}

.section {
  contain: layout;
}

.card {
  contain: layout style;
}

/* Optimize animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

/* Loading states */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: loading 1.5s infinite;
}

@keyframes loading {
  to {
    left: 100%;
  }
}

/* Critical resource hints */
.preload-image {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Intersection Observer animations */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Form optimizations */
.form-control:focus-within {
  transform: translateZ(0);
}

/* Grid optimizations */
.development-grid,
.amenities-grid {
  contain: layout;
}

/* Image optimizations */
.unit-image,
.amenity-icon {
  will-change: transform;
}

.unit-image:hover,
.amenity-icon:hover {
  transform: scale(1.05);
  transition: transform 0.3s ease;
}

/* ===============================================
   UTILITY CLASSES RESPONSIVE
   =============================================== */

/* Visibility utilities */
.mobile-only {
  display: block;
}

.tablet-only,
.desktop-only {
  display: none;
}

@media screen and (min-width: 768px) {
  .mobile-only {
    display: none;
  }
  
  .tablet-only {
    display: block;
  }
}

@media screen and (min-width: 1024px) {
  .tablet-only {
    display: none;
  }
  
  .desktop-only {
    display: block;
  }
}

/* Spacing utilities responsive */
.mb-mobile {
  margin-bottom: 1rem;
}

@media screen and (min-width: 768px) {
  .mb-mobile {
    margin-bottom: 0;
  }
}

/* Text alignment utilities */
.text-center-mobile {
  text-align: center;
}

@media screen and (min-width: 768px) {
  .text-center-mobile {
    text-align: left;
  }
}

/* Flexbox utilities responsive */
.flex-column-mobile {
  display: flex;
  flex-direction: column;
}

@media screen and (min-width: 768px) {
  .flex-column-mobile {
    flex-direction: row;
  }
}