/* ===== АДАПТИВНЫЕ СТИЛИ ===== */

/* ===== ПЕРЕМЕННЫЕ ДЛЯ BREAKPOINTS ===== */
:root {
  --mobile-s: 320px;
  --mobile-m: 375px; 
  --mobile-l: 425px;
  --tablet: 768px;
  --laptop: 1024px;
  --laptop-l: 1440px;
  --desktop: 2560px;
}

/* ===== ОСНОВНЫЕ КОНТЕЙНЕРЫ ===== */
@media (max-width: 1200px) {
  .container {
    max-width: 100%;
    padding: 0 var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--spacing-md);
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 var(--spacing-sm);
  }
}

/* ===== НАВИГАЦИЯ ===== */
@media (max-width: 1024px) {
  /* .floating-header позиционирование УБРАНО - полностью управляется из main.css */
  /* ВАЖНО: Это правило ПЕРЕОПРЕДЕЛЯЛО все исправления позиционирования! */
  
  .nav-container {
    padding: var(--spacing-sm) var(--spacing-lg);
    /* 🔧 КРИТИЧЕСКИЙ ФИК: Сдвигаем элементы на 20% ниже */
    align-items: center !important;
    padding-top: 16px !important;  /* Было ~6px, стало 16px = +10px сдвиг вниз */
    padding-bottom: 4px !important; /* Уменьшили нижний отступ */
    min-height: 48px !important;   /* Гарантируем минимальную высоту */
  }
  
  .nav-menu {
    gap: var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  .nav-menu {
    /* ПОЛНОСТЬЮ СКРЫТО по умолчанию - ПРОСТОЙ подход */
    display: none;
    position: fixed;
    top: 4rem;
    left: 1rem;
    right: 1rem;
    background: rgba(10, 25, 41, 0.95);
    border: 2px solid rgba(0, 245, 160, 0.3);
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    transform: translateY(0);
    transition: none;
  }
  
  .nav-menu.active {
    /* 🔥 КРИТИЧЕСКИЙ ФИК: УСИЛЕННОЕ ОТОБРАЖЕНИЕ МОБИЛЬНОГО МЕНЮ */
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    top: 4rem !important;
    left: 1rem !important;
    right: 1rem !important;
    background: rgba(10, 25, 41, 0.95) !important;
    border: 2px solid rgba(0, 245, 160, 0.3) !important;
    border-radius: 1.5rem !important;
    padding: 2rem 1.5rem !important;
    z-index: 9999 !important;
    min-height: 200px !important;
    min-width: 300px !important;
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
  }
  
  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  
  .mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
  }
}

@media (max-width: 480px) {
  /* .floating-header позиционирование УБРАНО - управляется из main.css */
  /* ВАЖНО: НЕ переопределяем top - это создавало конфликты! */
  
  .nav-container {
    padding: var(--spacing-xs) var(--spacing-md);
    /* 🔧 КРИТИЧЕСКИЙ ФИК: Максимальный сдвиг элементов на 20% ниже для мобильных */
    align-items: center !important;
    padding-top: 20px !important;  /* Увеличиваем для мобильных - элементы ещё ниже */
    padding-bottom: 2px !important; /* Минимальный нижний отступ */
    min-height: 52px !important;   /* Увеличена высота контейнера */
  }
  
  .logo-3d {
    font-size: var(--text-lg);
  }
  
  .logo-icon {
    font-size: var(--text-xl);
  }
}

/* ===== HERO СЕКЦИЯ ===== */
@media (max-width: 1024px) {
  .hero-section {
    min-height: 80vh;
    padding: var(--spacing-3xl) 0;
    /* 🔧 ОПТИМАЛЬНЫЙ отступ для планшетов - убираем пустоту, сохраняем воздух */
    padding-top: 3.5rem;
  }
  
  .hero-container {
    gap: var(--spacing-2xl);
  }
  
  .python-logo-3d {
    width: 250px;
    height: 250px;
  }
  
  .logo-symbol {
    font-size: 4rem;
  }
}

@media (max-width: 768px) {
  /* КРИТИЧЕСКАЯ БЛОКИРОВКА: хедер ПОЛНОСТЬЮ статичен на мобильных */
  .floating-header {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1 !important;
    transition: none !important;
    will-change: auto !important;
  }
  
  /* УСИЛЕННАЯ блокировка: nav-hidden НЕ работает на мобильных */
  .floating-header.nav-hidden {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  /* ДОПОЛНИТЕЛЬНАЯ блокировка через псевдоселектор */
  .floating-header[style*="transform"] {
    transform: translateX(-50%) translateY(0) !important;
  }
  
  /* МАКСИМАЛЬНАЯ блокировка всех возможных JS изменений */
  .floating-header[style*="opacity"] {
    opacity: 1 !important;
  }
  
  .floating-header[style*="visibility"] {
    visibility: visible !important;
  }

  .hero-container {
    grid-template-columns: 1fr;
    text-align: center;
    gap: var(--spacing-xl);
    /* 🔧 ОПТИМАЛЬНЫЙ отступ под навигацию - убираем пустоту, сохраняем воздух */
    padding-top: 3.2rem;
  }
  
  .hero-text {
    max-width: none;
  }
  
  /* .hero-status стили убраны по запросу пользователя */
  
  .hero-title {
    font-size: clamp(2rem, 8vw, 3rem);
  }
  
  .hero-subtitle {
    font-size: var(--text-base);
  }
  
  .hero-stats {
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
  }
  
  .stat-item {
    min-width: 120px;
  }
  
  .hero-actions {
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
  }
  
  .btn {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
  
  .python-logo-3d {
    width: 200px;
    height: 200px;
  }
  
  .logo-symbol {
    font-size: 3rem;
  }
  
  .code-lines {
    font-size: var(--text-xs);
    left: 5%;
    top: 10%;
  }
}

@media (max-width: 480px) {
  .hero-section {
    min-height: 70vh;
    padding: var(--spacing-2xl) 0;
    /* 🔧 ОПТИМАЛЬНЫЙ отступ для маленьких экранов - убираем пустоту, сохраняем воздух */
    padding-top: 2.7rem;
  }
  
  .hero-badge {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--text-xs);
  }
  
  .hero-title {
    font-size: clamp(1.5rem, 7vw, 2.5rem);
    margin-bottom: var(--spacing-md);
  }
  
  .hero-subtitle {
    font-size: var(--text-sm);
    margin-bottom: var(--spacing-xl);
  }
  
  .hero-stats {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .stat-number {
    font-size: var(--text-xl);
  }
  
  .stat-label {
    font-size: var(--text-xs);
  }
  
  .python-logo-3d {
    width: 150px;
    height: 150px;
  }
  
  .logo-symbol {
    font-size: 2.5rem;
  }
  
  .ring-1 { inset: 10px; }
  .ring-2 { inset: 20px; }
  .ring-3 { inset: 30px; }
}

/* ===== О РАЗРАБОТЧИКЕ ===== */
@media (max-width: 768px) {
  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
  }
  
  .about-card {
    padding: var(--spacing-lg);
  }
  
  .card-icon {
    font-size: var(--text-3xl);
    margin-bottom: var(--spacing-md);
  }
  
  .card-title {
    font-size: var(--text-lg);
  }
}

@media (max-width: 480px) {
  .about-card {
    padding: var(--spacing-md);
  }
  
  .card-icon {
    font-size: var(--text-2xl);
  }
  
  .card-description {
    font-size: var(--text-sm);
  }
}

/* ===== УСЛУГИ ===== */
@media (max-width: 1024px) {
  .services-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-lg);
  }
}

@media (max-width: 768px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
  
  .service-card {
    padding: var(--spacing-xl);
  }
  
  .service-icon {
    font-size: 2.5rem;
  }
  
  .service-title {
    font-size: var(--text-lg);
  }
  
  .service-features {
    margin-bottom: var(--spacing-lg);
  }
  
  .service-features li {
    font-size: var(--text-xs);
    margin-bottom: var(--spacing-xs);
  }
}

@media (max-width: 480px) {
  .service-card {
    padding: var(--spacing-lg);
  }
  
  .service-icon {
    font-size: 2rem;
  }
  
  .service-description {
    font-size: var(--text-sm);
  }
  
  .service-price {
    font-size: var(--text-base);
    padding: var(--spacing-sm);
  }
}

/* ===== ДЕМО СЕКЦИЯ ===== */
@media (max-width: 768px) {
  .demo-grid {
    grid-template-columns: 1fr;
  }
  
  .demo-card {
    padding: var(--spacing-xl);
  }
  
  .demo-chat {
    height: 250px;
  }
  
  .chat-messages {
    padding: var(--spacing-md);
  }
  
  .message-content {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
  }
  
  .chat-input {
    padding: var(--spacing-sm);
  }
  
  .chat-input input {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
  }
}

@media (max-width: 480px) {
  .demo-card {
    padding: var(--spacing-md);
  }
  
  .demo-title {
    font-size: var(--text-base);
    margin-bottom: var(--spacing-md);
  }
  
  .demo-chat {
    height: 200px;
  }
  
  .calc-label {
    padding: var(--spacing-md);
    font-size: var(--text-sm);
  }
  
  .calc-result {
    padding: var(--spacing-md);
  }
  
  .result-price {
    font-size: var(--text-xl);
  }
}

/* ===== ТЕХНОЛОГИИ (Новый дизайн) ===== */
@media (max-width: 768px) {
  .tech-showcase {
    gap: var(--spacing-xl);
    margin: var(--spacing-2xl) 0;
  }
  
  .tech-row {
    gap: var(--spacing-sm);
    justify-content: center;
  }
  
  .tech-item {
    min-width: 100px;
    max-width: 120px;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .tech-icon {
    font-size: 1.4rem;
  }
  
  .tech-name {
    font-size: 0.75rem;
    line-height: 1.2;
  }
  
  .tech-python {
    padding: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    min-width: 160px;
  }
  
  .tech-python .tech-icon {
    font-size: 2.2rem;
  }
  
  .tech-python .tech-name {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  .tech-row {
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    max-width: 300px;
    margin: 0 auto;
    justify-content: center;
  }
  
  .tech-item {
    min-width: 85px;
    max-width: 85px;
    padding: var(--spacing-xs) var(--spacing-sm);
  }
  
  .tech-icon {
    font-size: 1.1rem;
  }
  
  .tech-python {
    min-width: 140px;
    max-width: 180px;
    padding: var(--spacing-md);
    margin-top: var(--spacing-xl);
  }
  
  .tech-python .tech-icon {
    font-size: 1.8rem;
  }
  
  .tech-name {
    font-size: 0.65rem;
  }
}

/* ===== ПРОЦЕСС РАБОТЫ ===== */
@media (max-width: 768px) {
  .timeline-3d::before {
    left: 30px;
    transform: none;
  }
  
  .timeline-marker {
    left: 30px;
    transform: none;
    width: 50px;
    height: 50px;
  }
  
  .timeline-item:nth-child(even) .timeline-content,
  .timeline-item:nth-child(odd) .timeline-content {
    margin: 0 0 0 80px;
    text-align: left;
  }
  
  .timeline-content {
    padding: var(--spacing-lg);
  }
  
  .timeline-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-md);
  }
  
  .timeline-title {
    font-size: var(--text-lg);
  }
  
  .timeline-description {
    font-size: var(--text-sm);
    margin-bottom: var(--spacing-md);
  }
}

@media (max-width: 480px) {
  .timeline-3d::before {
    left: 20px;
  }
  
  .timeline-marker {
    left: 20px;
    width: 40px;
    height: 40px;
  }
  
  .marker-number {
    font-size: var(--text-base);
  }
  
  .timeline-item:nth-child(even) .timeline-content,
  .timeline-item:nth-child(odd) .timeline-content {
    margin-left: 70px;
  }
  
  .timeline-content {
    padding: var(--spacing-md);
  }
  
  .timeline-icon {
    font-size: 1.2rem;
  }
  
  .timeline-title {
    font-size: var(--text-base);
    margin-bottom: var(--spacing-sm);
  }
  
  .timeline-duration {
    padding: var(--spacing-xs) var(--spacing-md);
    font-size: var(--text-xs);
  }
}

/* ===== КОНТАКТЫ ===== */
@media (max-width: 1024px) {
  .contact-grid {
    gap: var(--spacing-2xl);
  }
  
  .contact-form-wrapper {
    position: static;
  }
}

@media (max-width: 768px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-xl);
  }
  
  .contact-title {
    font-size: var(--text-2xl);
  }
  
  .contact-subtitle {
    font-size: var(--text-base);
  }
  
  .contact-methods {
    gap: var(--spacing-md);
  }
  
  .contact-method {
    padding: var(--spacing-md);
    flex-direction: column;
    text-align: center;
    gap: var(--spacing-md);
  }
  
  .method-icon {
    width: 60px;
    height: 60px;
    font-size: var(--text-3xl);
  }
}

@media (max-width: 480px) {
  .contact-title {
    font-size: var(--text-xl);
  }
  
  .contact-method {
    padding: var(--spacing-sm);
  }
  
  .method-icon {
    width: 50px;
    height: 50px;
    font-size: var(--text-2xl);
  }
  
  .method-value {
    font-size: var(--text-base);
  }
}

/* ===== ФУТЕР ===== */
@media (max-width: 768px) {
  .footer-content {
    flex-direction: column;
    gap: var(--spacing-lg);
    text-align: center;
  }
  
  .footer-contacts {
    flex-direction: column;
    gap: var(--spacing-md);
  }
  
  .footer-contact {
    font-size: var(--text-base);
  }
}

@media (max-width: 480px) {
  .main-footer {
    padding: var(--spacing-xl) 0;
  }
  
  .footer-logo {
    font-size: var(--text-lg);
    justify-content: center;
  }
  
  .footer-description {
    font-size: var(--text-sm);
  }
  
  .footer-contact {
    font-size: var(--text-sm);
  }
  
  .footer-copyright {
    font-size: var(--text-xs);
  }
}

/* ===== СПЕЦИАЛЬНЫЕ АДАПТИВНЫЕ КЛАССЫ ===== */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
  
  .mobile-hidden {
    display: none !important;
  }
}

/* ===== АДАПТИВНАЯ ТИПОГРАФИКА ===== */
@media (max-width: 768px) {
  :root {
    --text-xs: 0.7rem;
    --text-sm: 0.8rem;
    --text-base: 0.9rem;
    --text-lg: 1rem;
    --text-xl: 1.1rem;
    --text-2xl: 1.3rem;
    --text-3xl: 1.6rem;
    --text-4xl: 2rem;
    --text-5xl: 2.5rem;
    --text-6xl: 3rem;
  }
}

@media (max-width: 480px) {
  :root {
    --text-xs: 0.65rem;
    --text-sm: 0.75rem;
    --text-base: 0.85rem;
    --text-lg: 0.95rem;
    --text-xl: 1rem;
    --text-2xl: 1.2rem;
    --text-3xl: 1.4rem;
    --text-4xl: 1.8rem;
    --text-5xl: 2.2rem;
    --text-6xl: 2.8rem;
  }
}

/* ===== АДАПТИВНЫЕ ИНТЕРВАЛЫ ===== */
@media (max-width: 768px) {
  :root {
    --spacing-xs: 0.2rem;
    --spacing-sm: 0.4rem;
    --spacing-md: 0.8rem;
    --spacing-lg: 1.2rem;
    --spacing-xl: 1.6rem;
    --spacing-2xl: 2.4rem;
    --spacing-3xl: 3.2rem;
  }
  
  section {
    padding: var(--spacing-2xl) 0;
  }
}

@media (max-width: 480px) {
  :root {
    --spacing-xs: 0.15rem;
    --spacing-sm: 0.3rem;
    --spacing-md: 0.6rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.4rem;
    --spacing-2xl: 2rem;
    --spacing-3xl: 2.8rem;
  }
  
  section {
    padding: var(--spacing-xl) 0;
  }
}

/* ===== LANDSCAPE ОРИЕНТАЦИЯ ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    min-height: 100vh;
    padding: var(--spacing-lg) 0;
  }
  
  .hero-container {
    gap: var(--spacing-lg);
  }
  
  .hero-title {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin-bottom: var(--spacing-md);
  }
  
  .hero-subtitle {
    font-size: var(--text-sm);
    margin-bottom: var(--spacing-lg);
  }
  
  .hero-stats {
    flex-direction: row;
    justify-content: center;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
  }
  
  .python-logo-3d {
    width: 120px;
    height: 120px;
  }
  
  .logo-symbol {
    font-size: 2rem;
  }
}

/* ===== ШИРОКИЕ ЭКРАНЫ ===== */
@media (min-width: 1920px) {
  .container {
    max-width: 1600px;
  }
  
  .hero-container {
    gap: var(--spacing-3xl);
  }
  
  .python-logo-3d {
    width: 400px;
    height: 400px;
  }
  
  .logo-symbol {
    font-size: 8rem;
  }
  
  .services-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .about-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ===== АНИМАЦИИ ДЛЯ МОБИЛЬНЫХ ===== */
@keyframes menuSlideDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== ОПТИМИЗАЦИЯ ДЛЯ TOUCH УСТРОЙСТВ ===== */
@media (hover: none) and (pointer: coarse) {
  .card-3d:hover,
  .hover-lift:hover,
  .hover-tilt:hover,
  .hover-scale:hover,
  .hover-glow:hover,
  .hover-bounce:hover {
    transform: none;
    box-shadow: none;
  }
  
  .btn:hover {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  
  /* Увеличиваем размер кликабельных элементов */
  .btn {
    min-height: 48px;
    padding: var(--spacing-md) var(--spacing-xl);
  }
  
  .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  
  .contact-method {
    min-height: 60px;
  }
  
  .mobile-menu-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ===== ПОРТРЕТНАЯ ОРИЕНТАЦИЯ ===== */
@media (max-width: 768px) and (orientation: portrait) {
  .hero-container {
    /* 🔧 ОПТИМАЛЬНЫЙ отступ для портретных устройств - убираем пустоту, сохраняем воздух */
    padding-top: 4.2rem;
  }
}

/* ===== ВЫСОКОЕ DPI ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
  /* Оптимизация для Retina экранов */
  .logo-3d,
  .python-logo-3d,
  .service-icon,
  .tech-icon {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}
