/* =======================
   MEDIA QUERIES
======================= */
@media (max-width: 1024px) {
  form.collect select {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
  }
  .subnav {
    display: none !important;
  }
}

@media (max-width: 768px) {
  /* Сервисы и принципы по одному */
  .services-grid,
  .principles-grid {
    grid-template-columns: 1fr;
  }

  /* Lightbox */
  .lightbox {
    justify-content: center;
    align-items: center;
    padding: 0;
  }

  .lightbox img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--border-radius);
    position: relative;
  }

  /* About секция */
  .about-inner {
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
    padding: 2em 1em;
  }

  .about-video,
  .about-text {
    width: 100%;
    max-width: 100%;
    order: unset;
    flex: none;
  }

  .about-text {
    text-align: left;
    padding: 0;
  }

  .about-text p {
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  .about-section {
    padding: 2em 1em;
  }

  /* FAQ */
  #FAQ {
    padding: 2em 1em;
    box-sizing: border-box;
  }

  .faq-item {
    width: 100%;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
    box-sizing: border-box;
  }

  .faq-question {
    width: 100%;
    padding: 0.75em 1em;
    font-size: clamp(1rem, 4vw, 1.2rem);
    background: var(--color-bg);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    box-sizing: border-box;
  }

  .faq-answer {
    overflow: hidden;
    transform-origin: top;
    transform: scaleY(0);
    transition: transform 0.35s ease, padding 0.35s ease;
    padding: 0 1em;
    font-size: clamp(0.85rem, 3vw, 1rem);
    line-height: 1.5;
    box-sizing: border-box;
  }

  .faq-item.open .faq-answer {
    transform: scaleY(1);
    padding: 0.5em 1em;
  }

  .faq-icon {
    font-size: clamp(1rem, 4vw, 1.25rem);
    transition: transform 0.3s ease;
  }

  .faq-item.open .faq-icon {
    transform: rotate(45deg);
  }

  /* Этапы */
  .stage {
    flex-direction: row;
    gap: 1rem;
  }

  .stage-number {
    flex: 0 0 auto;
  }

  .stage-number h3 {
    font-size: clamp(1.5rem, 4vw, 2rem);
  }

  .stage-content h4 {
    font-size: clamp(1rem, 3vw, 1.2rem);
  }

  .stage-content p {
    font-size: clamp(0.9rem, 2.5vw, 1rem);
  }

  /* Testimonials */
  .portfolio-item {
    flex: 0 0 80%;
  }

  #prevTestimonial {
    left: -1rem;
  }

  #nextTestimonial {
    right: -1rem;
  }

  .testimonial {
    font-size: clamp(0.9rem, 3vw, 1rem);
  }

  .testimonial .author {
    font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  }
}

@media (max-width: 480px) {
  .menu-container {
    display: none !important;
  }

  .burger {
    display: flex !important;
  }
}

/* =======================
   FAQ (общие стили)
======================= */
.faq-answer {
  overflow: hidden;
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 0.35s ease, padding 0.35s ease;
  padding: 0 1em;
  line-height: 1.5;
  box-sizing: border-box;
}

.faq-item.open .faq-answer {
  transform: scaleY(1);
  padding: 0.5em 1em;
}

/* =======================
   Services
======================= */
.services-wrapper {
  position: relative;
}

.service-item {
  position: relative;
  z-index: 1;
}

.services-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: clamp(1.5rem, 4vw, 2rem);
  cursor: pointer;
  color: var(--color-accent);
  z-index: 2;
  transition: color 0.3s ease;
}

.services-nav-button:hover {
  color: var(--color-subtle);
}

#prevService { left: -2rem; }
#nextService { right: -2rem; }

.slider-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slider-container {
  overflow: hidden;
  width: 100%;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: clamp(1.5rem, 4vw, 2rem);
  cursor: pointer;
  color: var(--color-accent);
  z-index: 10;
  transition: color 0.3s ease;
}

.slider-btn.prev { left: -2rem; }
.slider-btn.next { right: -2rem; }

/* =======================
   Principles & Services Grid
======================= */
.principles-grid,
.services-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.875rem;
  justify-items: center;
}

@media (min-width: 768px) {
  .principles-grid:has(.principle-item:nth-child(4)),
  .services-grid:has(.service-item:nth-child(4)) {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Контейнер слайдера отзывов */
.testimonial-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Карточки отзывов */
.testimonial-container {
  overflow: hidden;
  width: 100%;
}

.testimonial-track {
  display: flex;
  gap: 1.5rem;
  transition: transform 0.4s ease;
}

/* Стрелки */
.testimonial-nav-button {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: clamp(1.5rem, 4vw, 2rem);
  color: var(--color-accent);
  cursor: pointer;
  z-index: 10;
  transition: color 0.3s ease;
}

.testimonial-nav-button:hover {
  color: var(--color-subtle);
}

/* Левая стрелка */
#prevTestimonial {
  left: -3rem; /* за пределы видимого контейнера */
}

/* Правая стрелка */
#nextTestimonial {
  right: -2.5rem; /* за пределы видимого контейнера */
}

/* Блок этапов */
.stages {
  display: flex;
  flex-direction: column;
  gap: 2rem; /* расстояние между этапами */
}

.stage {
  display: flex;
  gap: 1.5rem; /* расстояние между номером и текстом */
  align-items: flex-start;
  flex-wrap: wrap; /* чтобы на мобильных блоки не ломались */
}

.stage-number {
  flex: 0 0 auto;
  text-align: center;
}

.stage-content {
  flex: 1 1 0;
  text-align: left; /* главное правило для выравнивания текста */
}

.stage-content h4 {
  margin-top: 0;
  margin-bottom: 0.5em;
}

.stage-content p {
  margin: 0;
  line-height: 1.6;
}

/* На экранах от 768px — проверяем, если больше 3 элементов → 2 в ряд */ 
@media (min-width: 768px) { .principles-grid:has(.principle-item:nth-child(4)) { grid-template-columns: repeat(2, 1fr); } } 

/* На экранах до 767px — принципы всегда по одному */ 
@media (max-width: 767px) { .principles-grid { grid-template-columns: 1fr !important; } }

/* На экранах от 768px — если больше 3 элементов → 2 в ряд */ 
@media (min-width: 768px) { 
  .services-grid:has(.service-item:nth-child(4)) { 
    grid-template-columns: repeat(2, 1fr); 
  } 
} 

/* На экранах до 767px — услуги всегда по одному */ 
@media (max-width: 767px) { 
  .services-grid { 
    grid-template-columns: 1fr !important; 
  } 
}

/* =======================
   LIGHTBOX - MOBILE READY
======================= */
@media (max-width: 768px) {
  #lightbox {
    flex-direction: row; /* стрелки по бокам сохраняем */
    padding: 4%; /* немного больше отступа для сенсорных экранов */
  }

  #lightbox img {
    max-width: 90%;      /* оставляем место для стрелок */
    max-height: 80vh;    /* подстраиваем под высоту экрана */
    object-fit: contain;
    border-radius: var(--border-radius, 0.5rem);
  }

  /* Кнопка закрытия */
  #lightbox .lightbox-close {
    top: 0.25rem;
    right: 0.25rem;
    font-size: clamp(1.2rem, 6vw, 2rem);
    padding: 0.2em;
  }

  /* Стрелки навигации */
  #lightbox .lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    padding: 0.2em;
  }

  #lightbox .lightbox-nav.left {
    left: 0.5rem;
  }

  #lightbox .lightbox-nav.right {
    right: 0.5rem;
  }
}

/* =======================
   МОДАЛКА - MOBILE ADAPTATION
======================= */
@media (max-width: 480px) {
  .modal-content {
    max-width: 95%;       /* расширяем модалку почти на весь экран */
    padding: 1.5rem 1rem; /* уменьшаем внутренние отступы для мобильного */
  }

  .modal-close {
    top: 0.5rem;          /* отступ от верхнего края меньше */
    right: 0.5rem;        /* отступ от правого края меньше */
    font-size: 1.3rem;    /* немного уменьшаем крестик */
  }

  /* Чтобы текст не прилипал к крестику */
  .modal-content p,
  .modal-content h1,
  .modal-content h2,
  .modal-content h3 {
    margin-top: 1.5rem;   /* отступ сверху */
  }
}


/* =======================
   SECTIONS - MOBILE ADAPTATION
======================= */
@media (max-width: 768px) {
  /* Общие секции */
  .section {
    max-width: 95%;
    margin: 2rem auto;
    padding: 0 3vw;
    scroll-margin-top: 5rem;
  }

  .section h2 {
    font-size: clamp(1.6rem, 6vw, 2rem);
    margin-bottom: 1.5rem;
  }

  /* ABOUT SECTION */
  .about-section {
    flex-direction: column;
    padding: 2rem 3vw;
    gap: 2rem;
  }

  .about-inner {
    flex-direction: column;
    gap: 1.5rem;
    align-items: flex-start;
  }

  .about-text {
    flex: 1 1 100%;
    min-width: auto;
    order: 1;
    text-align: left;
  }

  .about-text h2 {
    font-size: clamp(1.8rem, 5vw, 2.2rem);
  }

  .about-text p {
    font-size: clamp(0.95rem, 3vw, 1.05rem);
    line-height: 1.6;
    margin-bottom: 1rem;
  }

  .about-stats {
    justify-content: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
  }

  .about-stat h3 {
    font-size: clamp(1.2rem, 4vw, 1.6rem);
  }

  .about-stat p {
    font-size: clamp(0.75rem, 3vw, 0.85rem);
  }

  .about-video {
    flex: 1 1 100%;
    min-width: auto;
    max-width: 100%;
    order: 2;
    justify-content: center;
  }

  .video-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
  }

  .video-wrapper iframe {
    width: 100%;
    height: 100%;
  }
}

/* =======================
   Мобильная адаптация видео
======================= */
@media (max-width: 768px) {
  .about-video {
    flex: 1 1 100%;
    max-width: 100%;
    margin-top: 2rem;
  }

  .video-wrapper {
    width: 100%;
    aspect-ratio: 16/9;
  }

  .video-play {
    width: 3rem;
    height: 3rem;
  }

  .video-play::after {
    width: 1rem;
    height: 1.2rem;
    transform: translate(-40%, -50%);
  }
}

@media (max-width: 480px) {
  .video-play {
    width: 2.5rem;
    height: 2.5rem;
  }

  .video-play::after {
    width: 0.8rem;
    height: 1rem;
    transform: translate(-40%, -50%);
  }
}

.about-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  text-align: center; /* ← центрирует текст внутри блоков */
  margin-top: 2rem;
}

.about-stat h3 {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center; /* ← явное центрирование */
}

.about-stat p {
  font-size: 1rem;
  line-height: 1.4;
}

/* 📱 Мобильная адаптация */
@media (max-width: 768px) {
  .about-stats {
    flex-direction: column;
    align-items: center;
    gap: 2rem;
  }

  .about-stat h3 {
    font-size: 2rem;
  }

  .about-stat p {
    font-size: 0.95rem;
  }
}

/* 📱 Очень маленькие экраны */
@media (max-width: 480px) {
  .about-stat h3 {
    font-size: 1.8rem;
  }

  .about-stat p {
    font-size: 0.9rem;
  }
}
