﻿/* ===== Responsive – последний в очереди подключения ===== */

/* ===== Tablet (≤1023px) ===== */
@media (max-width: 1023px) {
  /* Header */
  .nav-main { display: none; }
  .header-tel { display: none; }
  .header-phones { display: none; }
  .burger { display: inline-flex; }

  /* Manifest sticky-pairs – слова в горизонтальную ленту над карточками */
  .pairs { grid-template-columns: 1fr; gap: var(--space-6); }
  .pairs__words {
    position: relative;
    top: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    align-items: baseline;
  }
  /* 4 слова в сетке 2×2 на мобильной (num — полная ширина сверху) */
  .pairs__words {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2) var(--space-4);
  }
  .pairs__num { grid-column: 1 / -1; margin-bottom: 0; }
  .pairs__word { font-size: 22px; padding: 0; }
  /* На мобильной все слова сразу активные (анимация не нужна) */
  .pairs__word,
  .pairs__word.is-active {
    color: var(--accent);
    transform: none;
    transition: none;
  }
  .pairs__word .dot,
  .pairs__word.is-active .dot {
    color: var(--accent);
  }

  /* Hero */
  .hero {
    padding-top: 100px;
    align-items: flex-start;
  }
  .hero__inner {
    flex-direction: column;
    gap: var(--space-10);
  }
  .hero__left,
  .hero__right {
    flex: 1 1 auto;
    min-width: 0;
  }
  .hero__right {
    flex-direction: column;
    gap: var(--space-6);
  }
  .hero__title { font-size: clamp(32px, 5vw, 52px); }

  /* Sections common */
  .section { padding: clamp(48px, 7vw, 96px) var(--space-pad-x); }
  .section-header { flex-direction: column; align-items: flex-start; gap: var(--space-5); }

  /* Services 6→2 */
  .services-grid { grid-template-columns: repeat(2, 1fr); }

  /* Industry 7→3 */
  .industry-grid { grid-template-columns: repeat(3, 1fr); }

  /* Cases – карусель сама подстроится; уменьшаем карточку */
  .case-card { flex-basis: 320px; }

  /* Process 5→2 */
  .process { grid-template-columns: repeat(2, 1fr); }

  /* Production split → stacked */
  .production { grid-template-columns: 1fr; gap: var(--space-8); }

  /* Calc → stacked */
  .calc { grid-template-columns: 1fr; gap: var(--space-8); padding: var(--space-8); }

  /* Stats 4→2 */
  .stats { grid-template-columns: repeat(2, 1fr); gap: var(--space-6); }

  /* Clients/certs 5→3 */
  .clients-row { grid-template-columns: repeat(3, 1fr); }
  .certs { grid-template-columns: repeat(3, 1fr); }

  /* Cottages → stacked */
  .cottages { grid-template-columns: 1fr; gap: var(--space-8); }

  /* CTA → stacked */
  .cta { grid-template-columns: 1fr; gap: var(--space-8); padding: var(--space-8); }

  /* Footer 4→2 */
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
}

/* ===== Mobile (≤767px) ===== */
@media (max-width: 767px) {
  /* Hero */
  .hero { padding: 96px var(--space-pad-x) var(--space-10); }
  .hero__title { font-size: clamp(28px, 7vw, 40px); }
  .hero__manifest { font-size: 15px; }
  .hero__metric-num { font-size: 64px; }
  .hero__case-name { font-size: 17px; }
  .hero__ctas .btn { flex: 1 1 100%; min-width: 0; }

  /* Manifest sticky-pairs – на моб слова в строку, карточки уже */
  .manifest { padding: var(--space-12) var(--space-pad-x); }
  .pair {
    grid-template-columns: clamp(120px, 32vw, 160px) 1fr;
  }
  .pair__arrow { display: none; }

  /* Sections */
  .section { padding: var(--space-12) var(--space-pad-x); }
  /* Кнопка-ссылка в шапке секции — выравнивание с заголовком слева на мобильной */
  .section-header .btn--ghost {
    padding-left: 0;
    padding-right: 0;
  }
  .section-title {
    font-size: clamp(24px, 7.2vw, 40px);
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
  }
  .section-sub { font-size: 15px; }
  .svc-hero__title {
    font-size: clamp(26px, 7.6vw, 44px);
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
  }

  /* Services 2→1 */
  .services-grid { grid-template-columns: 1fr; gap: var(--space-4); }
  .service-card__photo { aspect-ratio: 16 / 10; }
  .services-extra { padding: var(--space-5); }
  .services-extra__pill { padding: 6px 12px; font-size: 13px; }

  /* Industry → горизонтальная карусель с peek следующей карточки и
     scroll-snap. Принцип тот же, что у .cases-track ниже — pure CSS,
     без JS. Negative-margin'ы расширяют ленту за пределы padding'а
     секции, а внутренний padding возвращает первую/последнюю карточку
     в визуальную сетку. */
  .industry-grid {
    display: flex;
    grid-template-columns: none;
    gap: var(--space-3);
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    scroll-padding-left: var(--space-pad-x);
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--space-pad-x) * -1);
    padding: 4px var(--space-pad-x) var(--space-3);
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
  }
  .industry-grid::-webkit-scrollbar { display: none; }
  .industry-grid > .industry-card {
    flex: 0 0 min(82vw, 320px);
    scroll-snap-align: start;
  }
  /* nth-child(7) override из десктопа убираем — в карусели не нужен */
  .industry-grid > *:nth-child(7) { grid-column: auto; }

  /* Cases – на моб карточка ~85% экрана, контролы скрыты (свайп) */
  .case-card { flex-basis: min(85vw, 320px); }
  .cases-toolbar { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .cases-filters { gap: 6px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; width: 100%; }
  .cases-filter { padding: 8px 14px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
  .cases-controls { display: none; } /* на тач-устройствах – нативный свайп */

  /* Process 2→1 */
  .process { grid-template-columns: 1fr; gap: var(--space-3); }
  .process-step__num { font-size: 36px; }

  /* Stats 2→2 (компактнее) */
  .stats { gap: var(--space-5); }
  .stat__num { font-size: clamp(48px, 13vw, 72px); }
  .stat__label { font-size: 14px; }

  /* Clients/certs 3→2 */
  .clients-row { grid-template-columns: repeat(2, 1fr); }
  .client-logo { font-size: 14px; padding: var(--space-4); min-height: 64px; }

  /* Сертификаты – горизонтальная snap-карусель с peek-эффектом */
  .certs {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 var(--space-pad-x);
    gap: var(--space-3);
    padding: var(--space-2) var(--space-pad-x) var(--space-4);
    margin: 0 calc(-1 * var(--space-pad-x));
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .certs::-webkit-scrollbar { display: none; }
  .certs .cert {
    flex: 0 0 70%;
    scroll-snap-align: center;
    transition: none;
  }

  /* Cottages gallery – горизонтальный slider */
  .cottages__gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    -webkit-overflow-scrolling: touch;
  }
  .cottages__gallery > div {
    flex: 0 0 75%;
    aspect-ratio: 1 / 1 !important;
    grid-row: auto !important;
    scroll-snap-align: start;
  }
  .cottages__gallery > div:nth-child(1) { aspect-ratio: 1 / 1 !important; }
  .cottages__ctas .btn { flex: 1 1 100%; }

  /* FAQ */
  .faq__q { font-size: 17px; padding: var(--space-5) 0; }
  .faq__a-inner { font-size: 15px; padding-bottom: var(--space-5); }

  /* CTA form */
  .cta__form { padding: var(--space-5); }
  .cta__title { font-size: clamp(24px, 7vw, 36px); }

  /* Footer 2→1 */
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-6) var(--space-5);
  }
  /* Бренд (первая колонка) – на всю ширину сверху */
  .footer-grid--three > .footer-col:first-child {
    grid-column: 1 / -1;
  }
  /* Брендовое имя – горизонтально на мобильном (вместо вертикального стека) */
  .footer-grid .brand--full .brand__name {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 16px;
  }
  .footer-grid .brand--full .brand__line {
    display: inline;
  }
  .footer-bottom { font-size: 12px; flex-direction: column; gap: var(--space-2); align-items: flex-start; }

  /* Sticky bottom bar – показать */
  .sticky-bar { display: flex; }
  .wa-fab { display: none; }

  /* Body padding compensate – sticky-bar высота ~56px + safe-area */
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

  /* Header кнопка primary скрыта (sticky bottom) */
  .site-header .btn--primary { display: none; }

  /* Mobile-only переносы строк в заголовках */
  .br-mobile-only { display: inline; }

  /* Шапка на мобильном – компактнее */
  .site-header__inner {
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
  }
  .site-header.is-scrolled .site-header__inner {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
  }
  .brand__name { font-size: 13px; letter-spacing: 0.02em; }
  .brand__bar { width: 3px; height: 14px; }

  /* Cookie – компактнее на моб, поднята выше sticky-bar (учитывая safe-area) */
  .cookie {
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--space-3) + 52px + env(safe-area-inset-bottom));
    padding: var(--space-4);
  }
  .cookie__text { font-size: 13px; }
  .cookie__buttons .btn { flex: 1; }
}

/* =================================================================
   Touch fix через JS-класс .is-touch на <html> — побеждает любой
   :hover по специфичности (html.is-touch имеет специфичность выше
   media-query). Срабатывает на ВСЕХ touch-устройствах независимо от
   ширины экрана и от того, как iOS Chrome репортит `hover: hover`. */
html.is-touch .service-card:hover,        html.is-touch .service-card:focus,        html.is-touch .service-card:focus-within,        html.is-touch .service-card:active,
html.is-touch .industry-card:hover,       html.is-touch .industry-card:focus,       html.is-touch .industry-card:focus-within,       html.is-touch .industry-card:active,
html.is-touch .case-card:hover,           html.is-touch .case-card:focus,           html.is-touch .case-card:focus-within,           html.is-touch .case-card:active,
html.is-touch .hero__case-card:hover,     html.is-touch .hero__case-card:focus,     html.is-touch .hero__case-card:focus-within,     html.is-touch .hero__case-card:active,
html.is-touch .cert:hover,                html.is-touch .cert:focus,                html.is-touch .cert:focus-within,                html.is-touch .cert:active,
html.is-touch .floors-stat:hover,         html.is-touch .floors-stat:focus,         html.is-touch .floors-stat:focus-within,
html.is-touch .svc-type-card:hover,       html.is-touch .svc-type-card:focus,       html.is-touch .svc-type-card:focus-within,       html.is-touch .svc-type-card:active,
html.is-touch .svc-sys-card:hover,        html.is-touch .svc-sys-card:focus,        html.is-touch .svc-sys-card:focus-within,        html.is-touch .svc-sys-card:active,
html.is-touch .svc-related-card:hover,    html.is-touch .svc-related-card:focus,    html.is-touch .svc-related-card:focus-within,    html.is-touch .svc-related-card:active,
html.is-touch .svc-material-card:hover,   html.is-touch .svc-material-card:focus,   html.is-touch .svc-material-card:focus-within,   html.is-touch .svc-material-card:active,
html.is-touch .services-extra__pill:hover, html.is-touch .services-extra__pill:focus, html.is-touch .services-extra__pill:active,
html.is-touch .pair:hover,                html.is-touch .pair:focus,                html.is-touch .pair:focus-within,                html.is-touch .pair:active {
  transform: none !important;
  box-shadow: var(--sh-sm) !important;
  border-color: var(--line) !important;
  outline: none !important;
}

/* padding-left обнуляем ТОЛЬКО для .pair — у него на hover анимируется
   padding-left (sections.css:487), и после тапа значение залипает.
   Остальные карточки имеют симметричный padding, и общий reset съезжал
   контент влево на тапе. */
html.is-touch .pair:hover,
html.is-touch .pair:focus,
html.is-touch .pair:focus-within,
html.is-touch .pair:active {
  padding-left: 0 !important;
}

/* .hero__case-card имеет дефолтную тень --sh-md (а не "ноль", как другие
   карточки). Возвращаем её во всех тап-состояниях, иначе на тапе тень
   схлопывается в --sh-sm и карточка визуально "проседает". */
html.is-touch .hero__case-card:hover,
html.is-touch .hero__case-card:focus,
html.is-touch .hero__case-card:focus-within,
html.is-touch .hero__case-card:active {
  box-shadow: var(--sh-md) !important;
}

/* Дочерние стрелки/фото на touch */
html.is-touch .hero__case-arrow,
html.is-touch .hero__case-card:hover .hero__case-arrow,
html.is-touch .hero__case-card:focus .hero__case-arrow,
html.is-touch .hero__case-card:focus-within .hero__case-arrow,
html.is-touch .hero__case-card:active .hero__case-arrow {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  transform: none !important;
  transition: none !important;
}
html.is-touch .service-card:hover .service-card__arrow,
html.is-touch .service-card:focus .service-card__arrow,
html.is-touch .service-card:active .service-card__arrow,
html.is-touch .case-card:hover .case-card__photo img,
html.is-touch .case-card:focus .case-card__photo img,
html.is-touch .case-card:active .case-card__photo img,
html.is-touch .service-card:hover .service-card__photo img,
html.is-touch .service-card:focus .service-card__photo img,
html.is-touch .service-card:active .service-card__photo img,
html.is-touch .cert:hover .cert__img,
html.is-touch .cert:focus .cert__img,
html.is-touch .cert:active .cert__img,
html.is-touch .pair:hover .pair__arrow,
html.is-touch .pair:focus .pair__arrow,
html.is-touch .pair:active .pair__arrow,
html.is-touch .btn:hover .arrow,
html.is-touch .btn:focus .arrow,
html.is-touch .btn:active .arrow {
  transform: none;
}

/* Кнопки primary — не поднимаются */
html.is-touch .btn--primary:hover,
html.is-touch .btn--primary:focus,
html.is-touch .btn--primary:active {
  transform: none;
}

/* Полностью отключаем transitions на интерактивных блоках на touch */
html.is-touch .service-card,
html.is-touch .industry-card,
html.is-touch .case-card,
html.is-touch .hero__case-card,
html.is-touch .hero__case-arrow,
html.is-touch .cert,
html.is-touch .svc-type-card,
html.is-touch .svc-sys-card,
html.is-touch .svc-related-card,
html.is-touch .svc-material-card,
html.is-touch .pair {
  transition: none;
}

/* Убираем системный тёмный flash на тапе */
html.is-touch a,
html.is-touch button,
html.is-touch [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* =================================================================
   Touch / mobile: полностью отключаем интерактивные анимации.
   Используем max-width вместо @media (hover: none) — надёжнее на iOS Safari,
   где `hover: hover` может неожиданно сработать на iPad/iPhone в некоторых
   режимах. Покрываем ВСЕ интерактивные псевдоклассы: hover, focus,
   focus-within, focus-visible, active. На <a class="...-card"> при тапе
   браузер ставит :focus, который без этих правил «залипает».
   ================================================================= */
@media (max-width: 1023px) {
  /* Убираем системный flash при тапе на интерактивных элементах */
  .service-card,
  .industry-card,
  .case-card,
  .hero__case-card,
  .cert,
  .floors-stat,
  .svc-type-card,
  .svc-sys-card,
  .svc-related-card,
  .svc-material-card,
  .services-extra__pill,
  .pair,
  .btn,
  a {
    -webkit-tap-highlight-color: transparent;
  }

  /* Полностью убираем transition + фиксируем дефолтный border-color
     на проблемных карточках (Chrome iOS залипает на :hover после тапа,
     поэтому переопределяем border даже для базового селектора) */
  .service-card,
  .industry-card,
  .case-card,
  .hero__case-card,
  .cert,
  .floors-stat,
  .svc-type-card,
  .svc-sys-card,
  .svc-related-card,
  .svc-material-card,
  .services-extra__pill,
  .pair {
    transition: none !important;
    transform: none !important;
  }
  /* Border фиксируем в дефолт, кроме модификаторов «выделение» */
  .service-card:not(.is-popular):not(.is-flagman),
  .industry-card:not(.industry-card--b2c),
  .case-card,
  .hero__case-card,
  .cert,
  .floors-stat,
  .svc-type-card:not(.svc-type-card--popular):not(.is-popular),
  .svc-sys-card:not(.svc-sys-card--popular):not(.is-popular),
  .svc-related-card,
  .svc-material-card:not(.svc-material-card--popular):not(.is-popular) {
    border-color: var(--line) !important;
  }

  /* Все интерактивные состояния = дефолт */
  .service-card:hover,    .service-card:focus,    .service-card:focus-within,    .service-card:focus-visible,    .service-card:active,
  .industry-card:hover,   .industry-card:focus,   .industry-card:focus-within,   .industry-card:focus-visible,   .industry-card:active,
  .case-card:hover,       .case-card:focus,       .case-card:focus-within,       .case-card:focus-visible,       .case-card:active,
  .hero__case-card:hover, .hero__case-card:focus, .hero__case-card:focus-within, .hero__case-card:focus-visible, .hero__case-card:active,
  .cert:hover,            .cert:focus,            .cert:focus-within,            .cert:focus-visible,            .cert:active,
  .floors-stat:hover,     .floors-stat:focus,     .floors-stat:focus-within,     .floors-stat:focus-visible,
  .svc-type-card:hover,   .svc-type-card:focus,   .svc-type-card:focus-within,   .svc-type-card:focus-visible,   .svc-type-card:active,
  .svc-sys-card:hover,    .svc-sys-card:focus,    .svc-sys-card:focus-within,    .svc-sys-card:focus-visible,    .svc-sys-card:active,
  .svc-related-card:hover, .svc-related-card:focus, .svc-related-card:focus-within, .svc-related-card:focus-visible, .svc-related-card:active,
  .svc-material-card:hover, .svc-material-card:focus, .svc-material-card:focus-within, .svc-material-card:focus-visible, .svc-material-card:active,
  .services-extra__pill:hover, .services-extra__pill:focus, .services-extra__pill:focus-visible, .services-extra__pill:active,
  .pair:hover,            .pair:focus,            .pair:focus-within,            .pair:focus-visible,            .pair:active {
    transform: none !important;
    box-shadow: var(--sh-sm) !important;
    border-color: var(--line) !important;
    outline: none !important;
  }

  /* padding-left обнуляем ТОЛЬКО для .pair (у него hover-анимация
     padding-left залипает на touch). Прочие карточки имеют симметричный
     padding — общий reset съезжал их контент влево на тапе. */
  .pair:hover,
  .pair:focus,
  .pair:focus-within,
  .pair:focus-visible,
  .pair:active {
    padding-left: 0 !important;
  }

  /* .hero__case-card имеет дефолтную тень --sh-md, поэтому общий
     `box-shadow: --sh-sm` сверху делает её визуально "проседающей" на тапе.
     Возвращаем её собственный дефолт во всех тап-состояниях. */
  .hero__case-card:hover,
  .hero__case-card:focus,
  .hero__case-card:focus-within,
  .hero__case-card:focus-visible,
  .hero__case-card:active {
    box-shadow: var(--sh-md) !important;
  }

  /* Дочерние трансформы, цвета фона, фото-зум — тоже выключаем */
  .service-card:hover .service-card__arrow,
  .service-card:focus .service-card__arrow,
  .service-card:focus-within .service-card__arrow,
  .service-card:active .service-card__arrow,
  .case-card:hover .case-card__photo img,
  .case-card:focus .case-card__photo img,
  .case-card:focus-within .case-card__photo img,
  .case-card:active .case-card__photo img,
  .service-card:hover .service-card__photo img,
  .service-card:focus .service-card__photo img,
  .service-card:focus-within .service-card__photo img,
  .service-card:active .service-card__photo img,
  .cert:hover .cert__img,
  .cert:focus .cert__img,
  .cert:focus-within .cert__img,
  .cert:active .cert__img,
  .hero__case-card:hover .hero__case-arrow,
  .hero__case-card:focus .hero__case-arrow,
  .hero__case-card:focus-within .hero__case-arrow,
  .hero__case-card:active .hero__case-arrow,
  .pair:hover .pair__arrow,
  .pair:focus .pair__arrow,
  .pair:focus-within .pair__arrow,
  .pair:active .pair__arrow,
  .svc-related-card:hover .svc-related-card__cta,
  .svc-related-card:focus .svc-related-card__cta,
  .svc-related-card:focus-within .svc-related-card__cta,
  .svc-related-card:active .svc-related-card__cta,
  .btn:hover .arrow,
  .btn:focus .arrow,
  .btn:active .arrow,
  .nav-dropdown a:hover .arrow {
    transform: none !important;
    gap: inherit !important;
  }

  /* hero__case-arrow — фиксируем дефолтные цвета на ВСЕХ состояниях родителя */
  .hero__case-arrow,
  .hero__case-card:hover .hero__case-arrow,
  .hero__case-card:focus .hero__case-arrow,
  .hero__case-card:focus-within .hero__case-arrow,
  .hero__case-card:focus-visible .hero__case-arrow,
  .hero__case-card:active .hero__case-arrow {
    background: var(--accent-soft) !important;
    color: var(--accent) !important;
    transition: none !important;
  }

  /* Фото внутри карточек — никогда не зумится */
  .case-card__photo img,
  .service-card__photo img,
  .cert__img,
  .hero__case-photo img,
  .svc-hero__photo img {
    transition: none !important;
    transform: none !important;
  }

  /* Кнопка primary — не поднимается на тапе */
  .btn--primary:hover,
  .btn--primary:focus,
  .btn--primary:focus-visible,
  .btn--primary:active {
    transform: none !important;
  }

  /* Бегущая лента клиентов — не останавливается на touch */
  .client-ticker:hover .client-ticker__track {
    animation-play-state: running !important;
  }
}

/* ===== Small (≤479px) ===== */
@media (max-width: 479px) {
  .hero__title { font-size: 28px; }
  .hero__metric-num { font-size: 56px; }
  .hero__eyebrow { font-size: 11px; gap: var(--space-3); }
  .hero__eyebrow .dash { width: 32px; }
  .manifest__words { font-size: 44px; }
  .stats { grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-5); }
  .stat { padding: var(--space-4) 0; gap: var(--space-2); }
  .stat__num { font-size: 40px; line-height: 0.95; }
  .stat__num .plus { font-size: 0.4em; }
  .stat__label { font-size: 13px; line-height: 1.3; }
  .stat__sub { font-size: 11px; line-height: 1.35; }
  .clients-row { grid-template-columns: 1fr 1fr; }
  .certs .cert { flex: 0 0 78%; }
  .cta__form { padding: var(--space-4); }
}

/* ===== Wide (≥1536px) ===== */
@media (min-width: 1536px) {
  .hero__inner { gap: 100px; }
  .hero__right { flex-basis: 420px; }
}

/* ===== Landscape mobile (учитываем notch) ===== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero {
    padding-top: max(80px, env(safe-area-inset-top));
    padding-left: max(var(--space-pad-x), env(safe-area-inset-left));
    padding-right: max(var(--space-pad-x), env(safe-area-inset-right));
  }
}
