/* MBBUH — mobile layer (320–768px). Desktop styles untouched; load after site.min.css */

/* ——— Tokens & overflow guard ——— */
@media (max-width: 768px) {
  :root {
    --mb-mobile-section-y: 40px;
    --mb-mobile-gap: 16px;
    --mb-mobile-btn-gap: 14px;
  }

  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    max-width: 100%;
    font-size: clamp(16px, 4.2vw, 18px);
  }

  main,
  .hero,
  .section-inner,
  .calc-cta__box {
    max-width: 100%;
    box-sizing: border-box;
  }

  .hero__inner > *,
  .trust__grid > *,
  .section-inner > *,
  .header__inner > *,
  .site-footer__main > * {
    min-width: 0;
  }
}

/* ——— Typography (clamp on mobile only) ——— */
@media (max-width: 768px) {
  h1,
  .hero h1,
  .page-hero h1,
  .sd-hero h1,
  .service-detail-page .sd-hero h1 {
    font-size: clamp(26px, 7.2vw, 34px) !important;
    line-height: 1.12;
    overflow-wrap: anywhere;
    hyphens: auto;
  }

  h2,
  .section-title,
  .page-hero h2,
  .calc-cta__box h2 {
    font-size: clamp(22px, 5.8vw, 28px);
    line-height: 1.22;
    overflow-wrap: anywhere;
  }

  h3,
  .trust-card h3,
  .svc-card h3,
  .sd-card h3 {
    font-size: clamp(17px, 4.6vw, 20px);
    line-height: 1.32;
  }

  p,
  .section-lead,
  .hero__lead,
  .hero__sub,
  li {
    font-size: clamp(16px, 4vw, 18px);
  }

  small,
  .text-small,
  .sd-kicker,
  .about-eyebrow,
  caption,
  .geo-hub-links p {
    font-size: max(14px, 0.875rem);
  }
}

@media (max-width: 390px) {
  h1,
  .hero h1,
  .page-hero h1 {
    font-size: clamp(24px, 7.5vw, 30px) !important;
  }
}

/* ——— Header (телефон ≤767px) ——— */
@media (max-width: 767px) {
  :root {
    --header-h: 72px;
    --header-height: 72px;
  }

  .header {
    height: 72px;
  }

  .header.is-open .header__nav {
    top: 72px;
  }

  .header__inner {
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    height: 100%;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
    overflow: visible;
  }

  .header__logo {
    flex: 0 0 auto;
    flex-shrink: 0;
    min-width: 0;
    max-width: none;
    margin-right: 0;
    overflow: visible;
  }

  .header__logo img,
  .header__logo picture {
    flex-shrink: 0;
    display: block;
    width: clamp(110px, 31vw, 120px);
    max-width: 120px;
    min-width: 110px;
    height: auto;
    max-height: 44px;
    object-fit: contain;
    object-position: left center;
  }

  .header-consultation-btn,
  .header .header__cta.btn-primary {
    display: none !important;
  }

  .nav-toggle {
    flex-shrink: 0;
    margin-left: auto;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .header.is-open .header__nav a.header__nav-cta {
    order: -1;
    margin-top: 0;
    margin-bottom: 12px;
  }
}

/* ——— Hero & photos ——— */
@media (max-width: 768px) {
  .hero,
  .page-hero,
  .sd-hero {
    padding-top: calc(var(--header-h, 75px) + 12px);
  }

  .hero__inner,
  .page-hero .section-inner {
    gap: var(--mb-mobile-gap);
  }

  .hero__text,
  .hero__lead {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .hero__photo,
  .about-hero__photo,
  .sd-hero__photo {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
  }

  .hero__photo picture,
  .hero__photo img,
  .sd-hero__photo img,
  .about__photo img,
  .about-office__media img {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    object-fit: cover;
    aspect-ratio: 4 / 5;
  }

  .hero__buttons,
  .page-hero .buttons,
  .buttons {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--mb-mobile-btn-gap);
  }

  .hero__chips {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .hero__chips li {
    width: 100%;
    white-space: normal;
    height: auto;
    min-height: 36px;
  }

  /* Floating / glass cards off faces */
  .hp-glass-calc,
  .lp-glass {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100%;
    margin: 16px 0 0;
  }

  .hp-team__grid,
  .about-page .about-team__grid {
    grid-template-columns: 1fr !important;
    gap: var(--mb-mobile-gap);
  }

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

/* ——— Cards (1 col, even spacing) ——— */
@media (max-width: 768px) {
  .trust__grid,
  .services__grid,
  .svc-grid,
  .svc-grid--3,
  .svc-grid--4,
  .blog-page .blog__grid,
  .legal-page .trust__grid,
  .service-detail-page .sd-grid,
  .about-page .about-values__grid,
  .about-page .about-stats__grid,
  .about-nav-cards .trust__grid {
    grid-template-columns: 1fr !important;
    gap: var(--mb-mobile-gap);
  }

  .trust-card,
  .svc-card,
  .mb-card,
  .blog-card,
  .pr-card {
    width: 100%;
    min-height: 0;
    height: auto;
    box-sizing: border-box;
  }

  .trust-card h3,
  .trust-card p,
  .svc-card p {
    overflow-wrap: anywhere;
  }
}

/* ——— Tables ——— */
@media (max-width: 768px) {
  .price-table-wrap,
  .table-scroll,
  .calc-summary-table-wrap,
  .mb-table-wrap,
  .guide-table-wrap,
  .section-inner > table,
  .geo-deep-content table,
  .privacy-page table,
  .offer-page table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--card-radius, 24px);
    border: 1px solid var(--border, #d7e3f4);
    margin: 16px 0;
    padding: 0;
    box-sizing: border-box;
  }

  .price-table-wrap table,
  .table-scroll table,
  .calc-summary-table-wrap table,
  .section-inner > table,
  .geo-deep-content table {
    display: table;
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    margin: 0;
  }

  .price-table {
    min-width: 520px;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* ——— Calculator ——— */
@media (max-width: 768px) {
  .calculator,
  .calculator--v5 {
    padding-left: var(--container-padding, 16px);
    padding-right: var(--container-padding, 16px);
    box-sizing: border-box;
  }

  .calculator__layout,
  .calculator__layout--v5,
  .calculator--v5 .calculator__layout--v5 {
    grid-template-columns: 1fr !important;
    gap: var(--mb-mobile-gap);
  }

  .calculator input,
  .calculator select,
  .calculator textarea,
  .calculator--v5 input,
  .calculator--v5 select,
  .calculator--v5 textarea,
  .calc-v5-field input,
  .calc-v5-field select,
  .calc-prem-field input,
  .calc-prem-field select {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  .calculator__result,
  .calc-result-premium,
  .calc-v5-result,
  .calculator__result-panel {
    position: static !important;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .calculator .btn,
  .calculator--v5 .btn,
  .calc-v5-wa-btn,
  .calc-result-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  .calc-mobile-bar {
    max-width: 100vw;
    box-sizing: border-box;
  }
}

/* ——— Forms ——— */
@media (max-width: 768px) {
  .lead-form label,
  .lead-form label input,
  .lead-form label select,
  .lead-form label textarea,
  .contacts-panel input,
  .contacts-panel textarea,
  .hp-tax input,
  .hp-tax select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .lead-form label input,
  .lead-form label textarea,
  input[type="tel"],
  input[type="email"],
  input[type="text"] {
    min-height: 48px;
    font-size: 16px;
  }

  .lead-form button,
  .lead-form .btn,
  form .btn[type="submit"] {
    width: 100%;
    min-height: 48px;
  }
}

/* ——— CTA buttons ——— */
@media (max-width: 768px) {
  .btn,
  .btn-primary,
  .btn--outline,
  .header__cta,
  .float-wa,
  .site-footer .btn,
  .instagram__box .btn,
  .map-card .btn,
  .center-action .btn {
    min-height: 48px;
  }

  .btn:not(.header__cta):not(.float-wa):not(.to-top) {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }

  .buttons .btn + .btn {
    margin-top: 0;
  }
}

/* ——— Images ——— */
@media (max-width: 768px) {
  img,
  picture,
  video,
  iframe {
    max-width: 100%;
    height: auto;
  }

  .blog-card__img img,
  .review-card img,
  .map-card iframe {
    width: 100%;
    object-fit: cover;
  }

}

/* ——— Sections spacing ——— */
@media (max-width: 768px) {
  .trust,
  .svc-block,
  .about-mission,
  .about-values,
  .about-timeline,
  .about-office,
  .calc-cta,
  .reviews,
  .instagram,
  .geo-ai-snippet,
  .geo-eeat,
  .geo-when,
  .geo-price,
  .geo-hub-links,
  .section-pad,
  .home-page .home-block {
    padding-top: var(--mb-mobile-section-y);
    padding-bottom: var(--mb-mobile-section-y);
  }

  .trust + .trust {
    padding-top: 0;
  }

  .section-inner {
    padding-left: var(--container-padding, 16px);
    padding-right: var(--container-padding, 16px);
  }
}

/* ——— Footer ——— */
@media (max-width: 768px) {
  .site-footer {
    margin-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .site-footer__main {
    grid-template-columns: 1fr !important;
    gap: 24px;
    text-align: left;
  }

  .site-footer__nav,
  .site-footer__contacts,
  .site-footer__links {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .site-footer__nav a,
  .site-footer__contacts a,
  .site-footer a {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 4px 0;
  }

  .site-footer .btn {
    width: 100%;
    min-height: 48px;
  }

  .site-footer__bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 24px;
  }
}

/* ——— Float actions & touch targets ——— */
@media (max-width: 768px) {
  .float-wa {
    width: 52px;
    height: 52px;
    right: max(12px, env(safe-area-inset-right, 12px));
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    z-index: 220;
  }

  .to-top {
    right: max(12px, env(safe-area-inset-right, 12px));
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    min-width: 44px;
    min-height: 44px;
  }

  a[href^="tel:"],
  a[href^="mailto:"],
  a[href*="wa.me"],
  a[href*="instagram.com"],
  a[href*="2gis.com"] {
    touch-action: manipulation;
  }
}

/* ——— Guides / GEO longform ——— */
@media (max-width: 768px) {
  .faq-page .section-inner,
  .guides-page .section-inner {
    overflow-wrap: anywhere;
  }

  .geo-hub-links .section-inner p {
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  .about-office__grid {
    grid-template-columns: 1fr !important;
    gap: var(--mb-mobile-gap);
  }
}

/* ——— Legal hub cards ——— */
@media (max-width: 768px) {
  .services-page.legal-page .trust__grid > a.trust-card.legal-svc-card {
    min-height: 0 !important;
    padding: 18px 16px;
  }

  .legal-page .legal-work .process__line {
    grid-template-columns: 1fr !important;
  }
}

/* ——— Statistical reporting landing ——— */
@media (max-width: 768px) {
  .statistical-page .sd-grid,
  .statistical-page .process__line {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  :root {
    --container-padding: 16px;
    --mb-mobile-section-y: 36px;
  }

  .float-wa {
    width: 48px;
    height: 48px;
  }
}

/* Desktop header: centered nav + CTA справа (override site.min до пересборки) */
@media (min-width: 1280px) {
  .header .header__inner {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) auto minmax(min(100%, 220px), 1fr);
    align-items: center;
    column-gap: 16px;
  }

  .header__logo {
    justify-self: start;
    margin-right: 0;
  }

  .header__nav {
    justify-self: center;
    grid-column: 2;
    justify-content: center;
    gap: clamp(16px, 1.15vw, 24px);
    padding-right: 0;
    flex: 0 1 auto;
  }

  .header__cta {
    justify-self: end;
    grid-column: 3;
    margin-left: 0;
  }
}

@media (min-width: 1440px) {
  .header__nav {
    gap: clamp(16px, 1.25vw, 28px);
  }
}

@media (min-width: 1600px) {
  .header__nav {
    gap: 32px;
  }
}

/* CTA «Получить консультацию» в бургер-меню (desktop — только header__cta) */
@media (min-width: 1280px) {
  .header__nav a.header__nav-cta {
    display: none !important;
  }
}

@media (max-width: 1279px) {
  .header__nav a.header__nav-cta {
    display: none;
    width: 100%;
    margin-top: 12px;
    border-bottom: none !important;
    border-radius: 16px;
    justify-content: center;
    text-align: center;
    box-shadow: 0 8px 22px rgba(0, 158, 127, 0.28);
  }

  .header.is-open .header__nav a.header__nav-cta {
    display: flex;
    align-items: center;
    min-height: 48px;
  }
}

@media (max-width: 767px) {
  .header__nav a.header__nav-cta {
    margin-top: 0;
  }

  .header.is-open .header__nav {
    display: flex;
    flex-direction: column;
  }

  .header.is-open .header__nav a.header__nav-cta {
    order: -1;
    margin-bottom: 12px;
  }
}
