/* Энтелехия — mobile & touch (единый источник мобильной вёрстки) */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

body > header {
    padding-top: env(safe-area-inset-top);
}

/* ——— Burger ——— */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

body.nav-open .nav-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

body.nav-open .nav-toggle span:nth-child(2) {
    opacity: 0;
}

body.nav-open .nav-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

body.nav-open .nav-backdrop {
    display: block;
}

body.nav-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    :root {
        --header-h: 64px;
    }

    /* Только сайт (не /intro/): чуть отдаляем масштаб на мобилке */
    html {
        zoom: 0.9;
    }

    /*
      ПОКА ВИСИТ ЗАСТАВКА — МАСШТАБ РОВНО 1.

      zoom на корне растягивает разметку до 1/0.9 = 111% ширины экрана и сжимает
      её обратно при отрисовке. Chrome учитывает это и для position: fixed, а
      Safari на iOS применяет масштаб такому слою ВТОРОЙ раз: #intro-gate с
      inset: 0 получал 90% экрана по обеим осям, и оставшиеся 10% справа и снизу
      светились белым (замер: разметка 433px при экране 390px, тёмная область на
      скриншоте — 90.2% ширины).

      Класс intro-lock живёт ровно столько, сколько ролик на экране: ставится при
      загрузке, снимается в close() и возвращается при откате назад. Поэтому
      отмена масштаба здесь ничего не говорит о самом сайте — он получает свои
      0.9 сразу после передачи, в тот же кадр, когда пускается каскад первого
      экрана, и перестройка прячется внутри этой анимации.

      Побочная выгода: сцена рисуется в 390 css-пикселей вместо 433 — на четверть
      меньше площади кадра, а это самая дорогая часть заставки на телефоне.
    */
    html.intro-lock {
        zoom: 1;
    }

    html,
    body {
        overflow-x: clip;
        max-width: 100%;
    }

    /* body > header { z-index: 1 } в styles.css — поднимаем, иначе backdrop перекрывает меню */
    body > header {
        z-index: 1000;
    }

    body.nav-open > header {
        z-index: 1002;
    }

    .nav-toggle {
        display: flex;
        order: 3;
        position: relative;
        z-index: 1004;
        margin-left: clamp(8px, 2vw, 12px);
    }

    body.nav-open .nav-toggle {
        z-index: 1004;
    }

    .navbar {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        column-gap: 0;
        gap: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .logo {
        order: 1;
        z-index: 1002;
        margin-right: auto;
        margin-left: 0;
        justify-self: auto;
        grid-column: auto;
        flex-shrink: 0;
    }

    .nav-cta {
        display: none !important;
    }

    .nav-links {
        order: 2;
        position: fixed;
        top: 0;
        right: 0;
        left: auto;
        z-index: 1003;
        width: min(300px, 88vw);
        height: 100%;
        height: 100dvh;
        margin: 0;
        padding: calc(env(safe-area-inset-top) + 72px) 20px calc(env(safe-area-inset-bottom) + 24px);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        overflow-y: auto;
        overflow-x: hidden;
        flex-wrap: nowrap;
        justify-content: flex-start;
        grid-column: auto;
        justify-self: auto;
        list-style: none;
        background: rgba(30, 38, 50, 0.98);
        border-left: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: none;
        transform: translateX(112%);
        opacity: 1;
        pointer-events: none;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        -webkit-overflow-scrolling: touch;
    }

    body.nav-open .nav-links,
    .nav-links.is-open {
        transform: translateX(0);
        pointer-events: auto;
        box-shadow: -20px 0 60px rgba(0, 0, 0, 0.45);
    }

    .nav-links::after {
        display: none;
    }

    .nav-links li {
        width: 100%;
        min-width: 0;
    }

    .nav-links__cta {
        display: block;
        margin-top: 8px;
        padding-top: 12px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
    }

    .nav-link {
        display: block;
        padding: 14px 12px;
        font-size: 1.05rem;
        border-radius: 12px;
    }

    .nav-link::after {
        display: none;
    }

    .nav-link:hover,
    .nav-link.is-active {
        background: rgba(74, 143, 224, 0.12);
    }

    .nav-link--application {
        text-align: center;
        background: rgba(74, 143, 224, 0.16);
        border: 1px solid rgba(74, 143, 224, 0.35);
    }

    /* Dropdown «Услуги» — аккордеон внутри drawer */
    .nav-item--drop {
        display: block;
        position: static;
        flex-direction: column;
        align-items: stretch;
    }

    .nav-item--drop:hover .nav-drop {
        /* отключаем desktop hover-появление */
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }

    .nav-drop-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0;
        width: 100%;
    }

    .nav-drop-head .nav-link {
        flex: 1;
        min-width: 0;
    }

    .nav-drop-toggle {
        width: 44px;
        height: 44px;
        color: #d5deea;
        flex-shrink: 0;
    }

    .nav-drop-caret {
        width: 16px;
        height: 16px;
    }

    .nav-drop {
        position: static !important;
        left: auto;
        top: auto;
        transform: none !important;
        min-width: 0 !important;
        width: 100%;
        margin: 0;
        padding: 2px 0 6px 12px;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        border-left: 2px solid rgba(74, 143, 224, 0.3);
        border-radius: 0;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        display: none;
        z-index: auto;
    }

    .nav-drop::before {
        display: none;
    }

    .nav-item--drop.is-open .nav-drop {
        display: block;
        transform: none !important;
    }

    .nav-drop__link {
        padding: 12px 14px;
        font-size: 0.95rem;
        white-space: normal;
    }

    body.page-home > header:not(.is-scrolled) {
        background: transparent !important;
        border-bottom: none !important;
        box-shadow: none !important;
    }

    body > header.is-scrolled,
    body.nav-open > header {
        background: rgba(30, 38, 50, 0.92) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    /* Hero */
    .page-home .hero,
    .hero {
        height: auto;
        min-height: 0;
        max-height: none;
        align-items: flex-end;
        justify-content: flex-end;
        padding-bottom: 8px;
        overflow: hidden;
    }

    .hero-inner {
        padding: calc(var(--header-h) + 18px) 16px 12px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .page-home .hero-core {
        transform: none;
        max-width: 100%;
    }

    .hero-overlay {
        background:
            linear-gradient(180deg, rgba(30, 38, 50, 0.12) 0%, rgba(30, 38, 50, 0.42) 36%, rgba(30, 38, 50, 0.92) 78%, var(--bg-0) 100%);
    }

    .hero-bg__video {
        object-position: center 22%;
        transform: scale(1.06);
        filter: saturate(1.05) brightness(0.82);
    }

    .hero h1,
    .hero-title {
        font-size: clamp(1.7rem, 7.5vw, 2.15rem);
        line-height: 1.1;
        max-width: 100%;
        margin-bottom: 12px;
    }

    .hero p {
        font-size: 0.94rem;
        line-height: 1.5;
        margin: 0 0 18px;
        max-width: 100%;
    }

    .hero-eyebrow {
        font-size: 0.7rem;
        padding: 0;
        margin-bottom: 12px;
        letter-spacing: 0.12em;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        margin-bottom: 0;
    }

    .hero-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        padding: 14px 20px;
        box-sizing: border-box;
    }

    /* Блоки направлений — как раньше (иконка + текст) */
    .hero-features {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px;
        margin-top: 20px;
        padding-top: 18px;
        max-width: 100%;
        width: 100%;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
    }

    .hero-feature {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        min-width: 0 !important;
        width: 100%;
        text-align: left;
    }

    .hero-feature__icon {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .hero-feature__label {
        min-width: 0;
    }

    /* Подписи вроде «Исследования и материалы» на телефоне не показываем */
    .hero-feature__desc {
        display: none !important;
    }

    /* Вместо мышки — «Как мы работаем» */
    .hero-continue {
        width: 100%;
        margin: 16px 0 4px;
        padding: 12px 16px;
        box-sizing: border-box;
    }

    .hero-scroll {
        display: none !important;
    }

    .page-home .marquee,
    .marquee {
        margin-top: 0;
        padding: 14px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    .mesh-blob {
        filter: blur(60px);
        opacity: 0.75;
    }

    /* Sections — без горизонтального вылезания */
    .section-shell,
    .depth-section .section-shell {
        padding-left: 16px;
        padding-right: 16px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .depth-section {
        padding-left: 0;
        padding-right: 0;
        overflow-x: clip;
    }

    .section-lead,
    .page-hero__lead {
        font-size: 0.95rem;
        line-height: 1.55;
        max-width: 100%;
    }

    .heading-shine,
    .section-shell > h2,
    .depth-section > .section-shell > h2 {
        font-size: clamp(1.4rem, 5.5vw, 1.75rem);
    }

    .page-hero,
    .page-hero--inner {
        min-height: auto;
        padding: calc(var(--header-h) + 24px) 16px 32px;
        box-sizing: border-box;
    }

    .page-hero__content h1 {
        font-size: clamp(1.65rem, 7vw, 2rem);
    }

    .trust-line {
        font-size: 0.78rem;
        line-height: 1.45;
    }

    /* Process */
    .process-flow {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .process-step {
        padding: 20px 18px 18px;
        min-width: 0;
    }

    .process-step::after {
        display: none !important;
    }

    /* Stats */
    .stats-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .stat {
        padding: 16px 14px;
        min-width: 0;
    }

    /* Bento / cards */
    .bento-grid,
    .bento-grid--4 {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .bento-card {
        min-height: 0;
        min-width: 0;
        padding: 20px 18px;
    }

    .bento-card:hover {
        transform: none !important;
    }

    .contact-grid,
    .innovation-grid,
    .service-list,
    .supervision-cards {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    .contact-card {
        padding: 24px 18px;
        min-width: 0;
    }

    /* Services tabs */
    .services-tabs {
        grid-template-columns: 1fr;
    }

    .services-tabs__nav {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .services-tabs__btn {
        width: 100%;
        flex: 1 1 auto;
        min-width: 0;
        min-height: 48px;
        text-align: left;
        padding: 12px 16px;
        box-sizing: border-box;
    }

    .services-tabs__panel {
        grid-template-columns: 1fr;
    }

    .services-tabs__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .services-tabs__actions .btn {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        box-sizing: border-box;
    }

    .services-tabs__media {
        max-height: 220px;
        border-radius: 16px;
        overflow: hidden;
    }

    /* Innovation */
    .innovation-card__foot {
        justify-content: center;
    }

    .innovation-card__stat {
        width: 100%;
        justify-content: center;
    }

    .innovation-card__stats {
        grid-template-columns: 1fr;
    }

    .page-hero__lead {
        text-align: left;
    }

    /* Work cards */
    .work-cards-stage {
        gap: 14px;
        min-width: 0;
    }

    .work-card__trigger {
        padding: 16px 14px;
        min-height: 56px;
    }

    .work-card.is-expanded .work-card__panel {
        padding: 0 14px 18px;
    }

    .wc-panel-tabs__btn {
        min-height: 46px;
        font-size: 0.92rem;
    }

    .wc-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .work-section__hint {
        font-size: 0.88rem;
        line-height: 1.45;
    }

    .bim-stage,
    .supervision-card {
        padding: 20px 16px;
        min-width: 0;
    }

    .work-panel-float {
        min-width: 0 !important;
        width: min(100%, calc(100vw - 24px)) !important;
    }

    /* Split / about */
    .split-section {
        gap: 20px;
        grid-template-columns: 1fr !important;
    }

    .split-section__media img,
    .split-section__media video {
        border-radius: 16px;
        max-height: 280px;
        width: 100%;
        object-fit: cover;
    }

    .about-pillars {
        grid-template-columns: 1fr;
    }

    /* FAQ & quiz */
    .faq-item > summary {
        padding: 16px 18px;
        font-size: 0.95rem;
    }

    .quiz {
        padding: 20px 16px;
    }

    .quiz__options {
        grid-template-columns: 1fr !important;
    }

    .quiz__nav {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .quiz__nav .btn {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        box-sizing: border-box;
    }

    /* CTA blocks */
    .cta-block,
    .cta-strip {
        margin-left: 16px;
        margin-right: 16px;
        padding: 28px 20px;
        border-radius: 20px;
        box-sizing: border-box;
        max-width: calc(100% - 32px);
    }

    .cta-block .btn,
    .cta-strip .btn {
        width: 100%;
        min-height: 48px;
        justify-content: center;
        box-sizing: border-box;
    }

    .cta-modal {
        padding: 12px;
        align-items: flex-end;
    }

    .cta-modal__dialog {
        width: 100%;
        max-width: 100%;
        max-height: calc(100dvh - 16px);
        border-bottom-left-radius: 18px;
        border-bottom-right-radius: 18px;
        box-sizing: border-box;
    }

    .cta-modal__layout {
        grid-template-columns: 1fr;
    }

    /* Footer — без растягивания колонок и без наезда to-top */
    .footer {
        padding: 28px 16px calc(72px + env(safe-area-inset-bottom));
        box-sizing: border-box;
        overflow: hidden;
    }

    .footer__inner {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 22px;
        width: 100%;
        max-width: 100%;
    }

    .footer__start {
        flex: none;
        width: 100%;
        max-width: 100%;
    }

    .footer__links {
        flex: none !important;
        width: 100%;
        max-width: 100%;
        justify-content: center;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        margin: 0;
        padding: 0;
    }

    .footer__links li {
        width: 100%;
    }

    .footer__links a {
        display: block;
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .footer__copy {
        width: 100%;
        max-width: 100%;
        margin: 4px 0 0;
        padding: 16px 12px 0;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        text-align: center;
        font-size: 0.78rem;
        line-height: 1.55;
        box-sizing: border-box;
    }

    .footer__copy a {
        display: block;
        margin-top: 8px;
        white-space: normal;
        word-break: normal;
        overflow-wrap: anywhere;
    }

    /* To top — выше надёжно, не режет копирайт */
    .to-top {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(18px, env(safe-area-inset-bottom));
        width: 46px;
        height: 46px;
    }

    /* Contacts */
    .contact-layout {
        grid-template-columns: 1fr;
    }

    .contact-map iframe {
        height: min(48vh, 300px);
        width: 100%;
        max-width: 100%;
    }

    /* Application page */
    .application-layout {
        grid-template-columns: 1fr !important;
    }

    .application-form input,
    .application-form textarea,
    .application-form select,
    .cta-modal input,
    .cta-modal textarea,
    .cta-modal select {
        font-size: 16px;
        min-height: 48px;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Gate login */
    .gate-page {
        padding: 20px 16px;
    }

    .gate-card {
        padding: 28px 20px 24px;
        max-width: 100%;
        box-sizing: border-box;
    }

    .turnkey-flow {
        grid-template-columns: 1fr !important;
    }

    .marquee {
        max-width: 100%;
        overflow: hidden;
    }

    /* Disable heavy hover transforms on touch */
    .bento-card,
    .process-step,
    .innovation-card,
    .work-card,
    .faq-item,
    .stat,
    .contact-card {
        transform: none !important;
    }
}

@media (max-width: 480px) {
    :root {
        --header-h: 60px;
    }

    .logo img {
        width: 42px;
        height: 42px;
    }

    .stats-strip,
    .wc-stats {
        grid-template-columns: 1fr;
    }

    .hero h1,
    .hero-title {
        font-size: 1.7rem;
    }

    header {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 900px) and (prefers-reduced-motion: no-preference) {
    .hero-bg__video {
        transform: scale(1.06);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-links {
        transition: none !important;
    }

    .hero-bg__video {
        transform: none !important;
    }
}
