/* Responsive Design */

/* Mobile First Approach */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        padding: 0 var(--spacing-lg);
    }
}

/* Medium devices (tablets, 768px and up) */
@media (max-width: 768px) {
    /* Navigation */
    .desktop-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .logo {
        font-size: var(--font-size-sm);
        flex: 1;
        text-align: left;
        margin-right: var(--spacing-sm);
    }
    
    .nav-container {
        padding: 0 var(--spacing-sm);
        position: relative;
        min-height: 50px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .mobile-menu {
        right: var(--spacing-sm);
        width: 200px;
    }
    
    /* Typography */
    .hero h1 {
        font-size: var(--font-size-2xl);
    }
    
    .hero p {
        font-size: var(--font-size-base);
    }
    
    .section-title {
        font-size: var(--font-size-2xl);
        margin-bottom: var(--spacing-lg);
    }
    
    /* Layout */
    .contact-info {
        flex-direction: column;
        gap: var(--spacing-sm);
    }
    
    .contact-item {
        justify-content: center;
    }
    
    /* Spacing adjustments */
    .section {
        padding: var(--spacing-xl) 0;
    }
    
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    /* Grid adjustments */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    /* Hero adjustments */
    .hero-content {
        padding: 0 var(--spacing-sm);
    }
    
    .hero-features {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
        margin: var(--spacing-lg) 0;
    }
    
    .feature-item {
        padding: var(--spacing-sm);
    }
    
    .feature-item i {
        font-size: 1.5rem;
    }
    
    .hero-cta {
        flex-direction: column;
        align-items: center;
    }
    
    .cta-button {
        width: 100%;
        max-width: 280px;
    }
    
    /* Card adjustments */
    .maestro-info,
    .card-content {
        padding: var(--spacing-sm);
    }
    
    /* Maestros section specific mobile adjustments */
    .maestros-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
        margin-top: var(--spacing-lg);
    }
    
    .maestro-card {
        max-width: 100%;
        margin: 0 auto;
        box-shadow: 0 3px 12px rgba(0,0,0,0.1);
        flex-direction: column;
        min-height: auto;
    }
    
    .maestro-image {
        width: 100%;
        height: 200px;
        background-size: contain;
        background-position: center center;
        background-repeat: no-repeat;
        background-color: var(--light-bg);
        min-width: auto;
        flex-shrink: 1;
        border-radius: 8px 8px 0 0;
    }
    
    .maestro-info {
        text-align: center;
        flex: none;
    }
    
    .maestro-name {
        font-size: 1.1rem;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }
    
    .maestro-specialty {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .maestro-experience {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        margin-bottom: 0.8rem;
    }
    
    .maestro-info p {
        font-size: 0.85rem !important;
        line-height: 1.4;
        margin-top: 0.8rem !important;
    }
    
    /* Maestros section title adjustments for mobile */
    .section-title {
        font-size: 1.8rem;
        line-height: 1.2;
        margin-bottom: 1rem;
    }
    
    .section-title + p {
        font-size: 1rem !important;
        margin-bottom: 0.8rem !important;
    }
    
    .section-title + p + p {
        font-size: 0.9rem !important;
        margin-bottom: 2rem !important;
    }
    
    /* Button adjustments */
    .cta-button,
    .whatsapp-button {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-base);
    }
    
    /* Floating WhatsApp */
    .floating-whatsapp {
        width: 50px;
        height: 50px;
        font-size: var(--font-size-base);
        bottom: 15px;
        right: 15px;
    }
}

/* Small devices (portrait phones, less than 576px) */
@media (max-width: 575px) {
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .section-title {
        font-size: 1.6rem;
        line-height: 1.2;
        padding: 0 0.5rem;
    }
    
    .maestro-name {
        font-size: 1rem;
        line-height: 1.2;
    }
    
    .servicio-title {
        font-size: var(--font-size-base);
    }
    
    .nav-container {
        flex-direction: column;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs) var(--spacing-sm);
    }
    
    .phone-header {
        order: -1;
        margin-bottom: var(--spacing-xs);
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }
    
    /* Extra small maestros adjustments */
    .maestros-grid {
        gap: var(--spacing-md);
        margin-top: var(--spacing-md);
    }
    
    .maestro-card {
        border-radius: 12px;
        overflow: hidden;
        flex-direction: column;
    }
    
    .maestro-image {
        width: 100%;
        height: 180px;
        background-size: contain;
        background-position: center center;
        background-repeat: no-repeat;
        background-color: var(--light-bg);
        min-width: auto;
        border-radius: 8px 8px 0 0;
    }
    
    .maestro-info {
        padding: var(--spacing-sm);
        text-align: center;
    }
    
    .maestro-name {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
    
    .maestro-specialty {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    .maestro-experience {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
        margin-bottom: 0.6rem;
    }
    
    .maestro-info p {
        font-size: 0.8rem !important;
        line-height: 1.3;
        margin-top: 0.6rem !important;
    }
    
    /* Section title and descriptions for very small screens */
    .section-title {
        margin-bottom: 0.8rem;
    }
    
    .section-title + p {
        font-size: 0.9rem !important;
        margin-bottom: 0.6rem !important;
        padding: 0 0.5rem;
    }
    
    .section-title + p + p {
        font-size: 0.8rem !important;
        margin-bottom: 1.5rem !important;
        padding: 0 0.5rem;
    }
    
    /* Container padding for very small screens */
    .container {
        padding: 0 var(--spacing-xs);
    }
}

/* Extra small devices (320px and below) */
@media (max-width: 320px) {
    .section-title {
        font-size: 1.4rem;
        line-height: 1.1;
    }
    
    .maestro-card {
        margin: 0 0.25rem;
    }
    
    .maestro-image {
        height: 160px;
        background-size: contain;
        background-position: center center;
        background-repeat: no-repeat;
        background-color: var(--light-bg);
        border-radius: 8px 8px 0 0;
    }
    
    .maestro-name {
        font-size: 0.9rem;
    }
    
    .maestro-specialty {
        font-size: 0.8rem;
    }
    
    .maestro-experience {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .maestro-info p {
        font-size: 0.75rem !important;
    }
    
    .container {
        padding: 0 0.5rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .maestro-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .maestro-card:active {
        transform: scale(0.98);
    }
    
    .cta-button,
    .whatsapp-button {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }
    
    .floating-whatsapp {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Landscape mobile phones */
@media (max-width: 768px) and (orientation: landscape) {
    .maestros-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .maestro-image {
        height: 120px;
        background-size: contain !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
    }
    
    .maestro-info {
        padding: var(--spacing-xs);
    }
    
    .maestro-info p {
        font-size: 0.8rem !important;
        margin-top: 0.5rem !important;
    }
    
    .section {
        padding: var(--spacing-lg) 0;
    }
}

/* High DPI mobile displays */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .maestro-image {
        background-size: cover;
        background-position: center;
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        padding: 0 var(--spacing-xl);
    }
    
    .section {
        padding: 5rem 0;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize images and icons for retina displays */
    .maestro-image {
        background-size: cover;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 500px) {
    .hero {
        height: auto;
        min-height: 100vh;
        padding: var(--spacing-xl) 0;
    }
    
    .hero h1 {
        font-size: var(--font-size-2xl);
    }
}

/* Print styles */
@media print {
    .header,
    .floating-whatsapp,
    .cta-button,
    .whatsapp-button {
        display: none;
    }
    
    .hero {
        background: none;
        color: var(--text-dark);
        page-break-after: always;
    }
    
    .section {
        padding: var(--spacing-sm) 0;
    }
}

/* Reduce motion for accessibility */
@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;
    }
    
    .hero {
        background-attachment: scroll;
    }
}

/* Image loading optimization for mobile */
@media (max-width: 768px) {
    .maestro-image {
        background-attachment: scroll; /* Better performance on mobile */
        will-change: transform; /* Optimize for animations */
    }
    
    /* Improve text readability on small screens */
    .maestro-name,
    .maestro-specialty,
    .maestro-experience {
        text-shadow: none;
        font-weight: 600;
    }
    
    /* Better spacing for touch interaction */
    .maestro-card {
        margin-bottom: var(--spacing-md);
        min-height: auto;
        transform: translateZ(0); /* Enable hardware acceleration */
    }
    
    /* Optimize animations for mobile */
    .maestro-card.animate-on-scroll {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
}

/* Fix for very small mobile screens */
@media (max-width: 360px) {
    .maestros-grid {
        padding: 0 0.25rem;
    }
    
    .maestro-card {
        min-width: 280px;
        max-width: 100%;
    }
    
    .section-title {
        word-wrap: break-word;
        hyphens: auto;
    }
}

/* Optimización específica para imágenes de maestros en móvil */
@media (max-width: 768px) {
    .maestro-image {
        /* Asegurar que las imágenes se muestren completas sin cortes */
        background-size: contain !important;
        background-position: center center !important;
        background-repeat: no-repeat !important;
        background-color: #f8f9fa !important;
        /* Bordes redondeados solo en la parte superior */
        border-radius: 12px 12px 0 0 !important;
        /* Asegurar que no haya overflow */
        overflow: hidden;
        /* Centrar la imagen verticalmente */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Ajuste para pantallas medianas */
    @media (max-width: 480px) {
        .maestro-image {
            height: 170px !important;
            background-size: contain !important;
        }
    }
    
    /* Ajuste para pantallas pequeñas */
    @media (max-width: 360px) {
        .maestro-image {
            height: 150px !important;
            background-size: contain !important;
        }
    }
    
    /* Ajuste para pantallas muy pequeñas */
    @media (max-width: 320px) {
        .maestro-image {
            height: 130px !important;
            background-size: contain !important;
        }
    }
}

/* Asegurar que las imágenes funcionen bien en landscape móvil */
@media (max-width: 768px) and (orientation: landscape) {
    .maestro-image {
        height: 110px !important;
        background-size: contain !important;
        background-position: center center !important;
    }
}

/* Servicios section responsive */
@media (max-width: 768px) {
    .servicios-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .servicio-image {
        height: 150px;
    }
    
    .servicio-content {
        padding: var(--spacing-md);
    }
    
    .servicio-title {
        font-size: var(--font-size-lg);
    }
    
    .section-subtitle {
        font-size: var(--font-size-base);
        margin-bottom: var(--spacing-lg);
    }
}

/* Huaringas section responsive */
@media (max-width: 768px) {
    .huaringas-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-lg);
    }
    
    .huaringas-image {
        height: 150px;
    }
    
    .huaringas-content {
        padding: var(--spacing-md);
    }
    
    .huaringas-content h3 {
        font-size: var(--font-size-base);
    }
}
