/* ===== МОБИЛЬНАЯ ОПТИМИЗАЦИЯ ПРОИЗВОДИТЕЛЬНОСТИ ===== */
/* Подключается после основного CSS */

/* === 0. Исправление пустого пространства сверху === */
@media (max-width: 768px) {
    body {
        padding-top: 70px !important;
    }
}
    
/* === 1. Отключение тяжёлых анимаций на мобильных === */
@media (max-width: 768px) {
    /* Отключаем все анимации частиц */
    .hero-particles,
    .hero-particle {
        display: none !important;
    }
    
    /* Упрощаем градиенты */
    .hero-gradient-overlay,
    .hero-overlay {
        background: rgba(0, 0, 0, 0.5) !important;
        backdrop-filter: none !important;
    }
    
    /* Отключаем плавающие анимации */
    .floating-badge,
    .feature-card,
    .opportunity-card-modern,
    .benefit-card-modern,
    .hero-stat-card {
        animation: none !important;
        transform: none !important;
    }
    
    /* Отключаем hover-эффекты на тач-устройствах */
    .tour-card-wide:hover,
    .btn:hover,
    .card:hover {
        transform: none !important;
        box-shadow: inherit !important;
    }
    
    /* Упрощаем тени */
    .tour-card-wide,
    .card,
    .modal-window,
    .header {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Отключаем сложные градиенты на кнопках */
    .btn-glow,
    .btn-primary {
        background: #FF6B35 !important;
        box-shadow: none !important;
    }
    
    /* Упрощаем шапку */
    .header-contact-info {
        display: none !important;
    }
    
    /* Отключаем анимации появления */
    .tour-card-wide,
    .tour-section-card,
    .calendar-tour-card {
        animation: none !important;
        opacity: 1 !important;
    }
    
    /* Оптимизация календаря */
    .calendar-widget {
        transform: none !important;
    }
    
    .calendar-tour-card {
        transform: none !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.08) !important;
    }
    
    .calendar-day {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    .calendar-nav-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Упрощаем формы */
    .form-input,
    .form-textarea {
        background: #f5f5f5 !important;
        box-shadow: none !important;
    }
}

/* === 2. Аппаратное ускорение для анимированных элементов === */
.will-animate {
    will-change: transform, opacity;
}

@media (max-width: 768px) {
    .will-animate {
        will-change: auto;
    }
}
    
/* === 3. Content visibility для улучшения рендеринга === */
.tours-list,
.footer-modern,
.map-section,
.how-to-reach {
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

/* === 4. Оптимизация изображений === */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Lazy loading placeholder */
img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === 5. Упрощение для очень слабых устройств === */
@media (max-width: 480px) {
    /* Ещё больше упрощаем */
    .hero-title-line {
        text-shadow: none !important;
    }
    
    .section-title {
        background: #FF6B35 !important;
        -webkit-background-clip: unset !important;
        background-clip: unset !important;
        -webkit-text-fill-color: white !important;
        color: white !important;
    }
    
    /* Исключение для секций "Карта" и "Как пройти" - оставляем белый фон */
    .map-section .section-title,
    .how-to-reach .section-title {
        background: transparent !important;
        -webkit-background-clip: unset !important;
        background-clip: unset !important;
        -webkit-text-fill-color: #1a1a1a !important;
        color: #1a1a1a !important;
    }
    
    /* Отключаем все transition на слабых устройствах */
    * {
        transition: none !important;
    }
    
    /* Разрешаем только важные transition */
    .btn,
    .mobile-menu-btn,
    input,
    textarea {
        transition: background-color 0.2s !important;
    }
}
    
/* === 6. Оптимизация скролла === */
@media (max-width: 768px) {
    html {
        scroll-behavior: auto !important;
    }
    
    body {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
        overflow-y: scroll;
    }
    
    /* iPhone-specific скролл оптимизация */
    @supports (-webkit-touch-callout: none) {
        /* iOS Safari только */
        html {
            scroll-padding-top: 20px;
        }
        
        body, html {
            -webkit-text-size-adjust: 100%;
            touch-action: pan-x pan-y;
        }
        
        /* Убираем задержку скролла на iOS */
        * {
            -webkit-tap-highlight-color: transparent;
        }
        
        /* Плавный скролл только для модальных окон и навигации */
        .modal-overlay,
        .mobile-menu,
        nav {
            -webkit-overflow-scrolling: touch;
        }
        
        /* Улучшаем реакцию на touch-события */
        .btn,
        .mobile-menu-btn,
        .calendar-day,
        input,
        textarea,
        select {
            touch-action: manipulation;
            -webkit-touch-callout: none;
            user-select: none;
            -webkit-user-select: none;
        }
        
        /* Оптимизация скролла к форме на iPhone */
        .contact-school-modern,
        #contactForm,
        #bookingForm {
            scroll-margin-top: 120px;
            -webkit-scroll-margin-top: 120px;
        }
    }
    
    /* Android Chrome оптимизация */
    @supports not (-webkit-touch-callout: none) {
        html {
            scroll-padding-top: 20px;
        }
    }
}

/* === 6.1 Жёсткая оптимизация для iPhone === */
@supports (-webkit-touch-callout: none) {
    /* Отключаем scroll-behavior на iOS для мгновенного отклика */
    html, body {
        scroll-behavior: auto !important;
    }
    
    /* Аппаратное ускорение для скролл-контейнеров */
    .modal-overlay,
    .mobile-menu,
    nav,
    .tours-list,
    .tour-content-page {
        transform: translate3d(0, 0, 0);
        backface-visibility: hidden;
        perspective: 1000px;
    }
    
    /* Улучшаем отклик скролла */
    body {
        position: relative;
        overflow-y: scroll;
    }
    
    /* Предотвращаем "bounce" эффект на iOS */
    .header {
        position: sticky !important;
        top: 0;
        z-index: 1000;
    }
}

/* === 7. Предотвращение перерисовок === */
.fixed-header,
.sticky-element {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* === 8. Оптимизация модальных окон === */
@media (max-width: 768px) {
    .modal-overlay {
        background: rgba(0, 0, 0, 0.7) !important;
        backdrop-filter: none !important;
    }
    
    .modal-window {
        animation: none !important;
        transform: none !important;
    }
}

/* === 9. Упрощение поиска === */
@media (max-width: 768px) {
    .search-suggestions-modern {
        display: none !important;
    }
    
    .search-date-filters-modern {
        flex-wrap: wrap !important;
    }
}

/* === 10. Оптимизация слайдера === */
@media (max-width: 768px) {
    .reach-slider {
        transform: none !important;
    }
    
    .reach-slide {
        transition: none !important;
    }
}

/* === 11. Убираем оранжевый фон с секций "Карта" и "Как пройти" === */
@media (max-width: 768px) {
    .map-section,
    .how-to-reach {
        background: var(--white) !important;
    }
    
    .map-section .section-title,
    .how-to-reach .section-title {
        background: transparent !important;
        -webkit-background-clip: unset !important;
        background-clip: unset !important;
        -webkit-text-fill-color: #1a1a1a !important;
        color: #1a1a1a !important;
    }
}

/* === 12. Убираем оранжевый фон с секций "Туры" === */
@media (max-width: 768px) {
    .tours,
    .tours-section {
        background: var(--white) !important;
    }
    
    .tours .section-title,
    .tours-section .section-title,
    .tour-section-card .tour-section-title-page {
        background: transparent !important;
        -webkit-background-clip: unset !important;
        background-clip: unset !important;
        -webkit-text-fill-color: #1a1a1a !important;
        color: #1a1a1a !important;
    }
}

/* === 13. Скругление углов кнопок === */
@media (max-width: 768px) {
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-book-page,
    .btn-book-submit {
        border-radius: 12px !important;
    }
}

/* === 14. Скругление мобильного меню === */
@media (max-width: 768px) {
    .mobile-menu-btn {
        border-radius: 8px !important;
    }
}

/* === 15. Оптимизация модального окна бронирования === */
@media (max-width: 768px) {
    #tourBookingModal .modal-window {
        width: 95% !important;
        padding: 25px 15px !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    #tourBookingModal h2 {
        font-size: 20px !important;
        margin-bottom: 8px !important;
    }
    
    #tourBookingModal > p {
        font-size: 13px !important;
        margin-bottom: 20px !important;
    }
    
    #tourBookingModal input,
    #tourBookingModal select,
    #tourBookingModal textarea {
        padding: 14px !important;
        font-size: 14px !important;
    }
    
    #tourBookingModal .btn-book-submit {
        padding: 16px !important;
        font-size: 15px !important;
    }
    
    #tourBookingModal .consent-checkbox {
        font-size: 12px !important;
    }
    
    #tourBookingModal .modal-note {
        font-size: 11px !important;
        margin-top: 15px !important;
    }
}

/* === 17. Мобильная оптимизация отзывов === */
@media (max-width: 768px) {
    /* Секция формы отзыва */
    .reviews-form-section {
        padding: 40px 15px !important;
    }
    
    .review-form {
        padding: 25px 15px !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.08) !important;
    }

    .review-form .form-group {
        margin-bottom: 16px !important;
    }
    
    .review-form label {
        font-size: 14px !important;
        margin-bottom: 6px !important;
    }
    
    .review-form input,
    .review-form textarea,
    .review-form select {
        padding: 12px 14px !important;
        font-size: 15px !important;
        border-radius: 10px !important;
    }
    
    .review-form textarea {
        min-height: 100px !important;
    }
    
    /* Звёздочный рейтинг */
    .star-rating {
        font-size: 36px !important;
        gap: 10px !important;
    }
    
    .star-rating span {
        padding: 4px !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Кнопка отправки */
    .review-form .btn {
        padding: 16px 24px !important;
        font-size: 16px !important;
        border-radius: 12px !important;
        width: 100% !important;
    }
    
    /* Список отзывов */
    .reviews-section {
        padding: 40px 15px !important;
    }
    
    .reviews-grid,
    .direction-reviews-list {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        padding: 0 !important;
    }
    
    .review-card,
    .review-card-gallery {
        padding: 20px !important;
        border-radius: 16px !important;
        margin: 0 !important;
    }
    
    .review-header-gallery {
        flex-direction: row !important;
        gap: 12px !important;
        margin-bottom: 16px !important;
    }
    
    .review-avatar-gallery {
        width: 48px !important;
        height: 48px !important;
        font-size: 20px !important;
    }
    
    .review-author-gallery {
        font-size: 16px !important;
    }
    
    .review-stars-gallery {
        font-size: 16px !important;
        letter-spacing: 1px !important;
    }
    
    .review-text-gallery {
        font-size: 14px !important;
        line-height: 1.6 !important;
        margin-bottom: 16px !important;
    }
    
    .review-meta-gallery {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    
    .review-tour-badge {
        font-size: 12px !important;
        padding: 6px 12px !important;
    }
    
    .review-date-gallery {
        font-size: 12px !important;
    }
    
    /* Заголовки */
    .reviews-section .section-title,
    .direction-reviews-title {
        font-size: 24px !important;
        margin-bottom: 8px !important;
    }
    
    .reviews-section p,
    .direction-reviews-subtitle {
        font-size: 14px !important;
        margin-bottom: 30px !important;
    }
    
    /* Кнопка написать отзыв */
    .btn-write-review {
        padding: 14px 28px !important;
        font-size: 15px !important;
        border-radius: 12px !important;
        margin-top: 30px !important;
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Пустое состояние */
    .reviews-empty-gallery,
    .reviews-empty {
        padding: 40px 15px !important;
    }
    
    .reviews-empty-gallery span,
    .reviews-empty span {
        font-size: 48px !important;
        margin-bottom: 12px !important;
    }
    
    .reviews-empty-gallery h4,
    .reviews-empty h3 {
        font-size: 18px !important;
    }
    
    .reviews-empty-gallery p,
    .reviews-empty p {
        font-size: 14px !important;
    }
    
    /* Фотоотчёты */
    .gallery-hero {
        padding: 80px 15px 60px !important;
    }
    
    .gallery-hero h1 {
        font-size: 32px !important;
    }
    
    .gallery-hero p {
        font-size: 15px !important;
    }
    
    .directions-section {
        padding: 40px 0 !important;
    }
    
    .directions-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .direction-card {
        border-radius: 16px !important;
    }
    
    .direction-image {
        height: 200px !important;
    }
    
    .direction-title {
        font-size: 20px !important;
    }
    
    .direction-info {
        padding: 16px !important;
    }
    
    .direction-info p {
        font-size: 13px !important;
        margin-bottom: 10px !important;
    }
    
    .direction-stats {
        gap: 12px !important;
        font-size: 12px !important;
    }
    
    /* Галерея фото */
    .direction-gallery-section {
        position: fixed !important;
    }
    
    .direction-gallery-header {
        padding: 100px 15px 60px !important;
        min-height: 280px !important;
    }
    
    .direction-gallery-header h2 {
        font-size: 26px !important;
    }
    
    .direction-gallery-header p {
        font-size: 15px !important;
    }
    
    .close-gallery-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
        top: 15px !important;
        right: 15px !important;
    }
    
    .gallery-photo-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        padding: 15px !important;
    }
    
    .gallery-photo-item {
        border-radius: 12px !important;
    }
    
    /* Модальное окно просмотра фото */
    .photo-zoom-modal img {
        max-width: 98% !important;
        max-height: 85vh !important;
        border-radius: 12px !important;
    }
    
    .photo-zoom-modal button {
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
    }
    
    .photo-zoom-modal button:nth-child(2),
    .photo-zoom-modal button:nth-child(3) {
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 48px !important;
        height: 48px !important;
    }
    
    .photo-zoom-modal div:last-child {
        font-size: 12px !important;
        padding: 6px 14px !important;
        bottom: 20px !important;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .review-form {
        padding: 20px 12px !important;
    }
    
    .review-form input,
    .review-form textarea {
        padding: 11px 12px !important;
        font-size: 14px !important;
    }
    
    .star-rating {
        font-size: 32px !important;
        gap: 8px !important;
    }
    
    .review-text-gallery {
        font-size: 13px !important;
    }
    
    .gallery-photo-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .direction-gallery-header h2 {
        font-size: 22px !important;
    }
    
    .review-avatar-gallery {
        width: 42px !important;
        height: 42px !important;
        font-size: 18px !important;
    }
    
    .review-author-gallery {
        font-size: 15px !important;
    }
}

