/*
 * АД Студия — адаптивный слой 1.3.0
 * Подключается после styles.css и отвечает за телефоны, планшеты,
 * ноутбуки, широкие экраны, горизонтальную ориентацию и печать.
 */

:root {
  --page-gutter: clamp(12px, 2.4vw, 32px);
  --content-reading: 76ch;
}

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

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

main,
section,
article,
header,
footer,
nav,
.container,
.hero-grid > *,
.page-hero-grid > *,
.feature-split > *,
.contact-grid > *,
.product-grid > *,
.cards > *,
.price-grid > *,
.footer-grid > * {
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

img {
  height: auto;
}

h1,
h2,
h3,
h4,
p,
li,
a,
strong,
span,
label,
summary,
td,
th {
  overflow-wrap: break-word;
}

p,
li,
.article,
.legal {
  hyphens: auto;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

button,
.btn,
.nav-toggle,
.mobile-actions a,
summary {
  touch-action: manipulation;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid rgba(57, 229, 255, 0.9);
  outline-offset: 3px;
}

.container {
  width: min(calc(100% - (var(--page-gutter) * 2)), var(--container));
}

.section > .container,
.page-hero > .container {
  isolation: isolate;
}

.section-head > div:first-child,
.page-hero-grid > div:first-child,
.hero-copy {
  max-width: 850px;
}

.section-head p,
.lead,
.article p,
.legal p,
.card p,
.product-card p,
.feature-row p,
.process-step p,
.answer {
  text-wrap: pretty;
}

.article,
.legal {
  width: 100%;
}

.article p,
.article li,
.legal p,
.legal li {
  line-height: 1.75;
}

.article img,
.legal img {
  width: 100%;
  margin: 28px 0;
  border-radius: clamp(16px, 2vw, 26px);
}

.card,
.price-card,
.product-card,
.process-step,
.kpi-box,
.problem,
.contact-card,
.form-card,
.feature-panel,
.article-callout,
.cta-panel {
  min-width: 0;
}

.cards > .card,
.price-grid > .price-card,
.product-grid > .product-card {
  height: 100%;
}

.card,
.price-card,
.product-card,
.process-step,
.kpi-box,
.problem,
.contact-card,
.form-card,
.feature-panel,
.cta-panel {
  contain: paint;
}

.card-link,
.contact-link,
.footer-links a,
.breadcrumbs a {
  max-width: 100%;
}

.contact-link > span:last-child,
.contact-link strong,
.footer-links a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.hero {
  position: relative;
  isolation: isolate;
}

.hero-logo,
.logo-panel img,
.brand img,
.offline-logo {
  object-fit: cover;
}

.hero-logo,
.logo-panel img {
  aspect-ratio: 1;
}

.hero-visual,
.logo-panel {
  max-width: 100%;
}

.logo-panel {
  min-height: clamp(330px, 45vw, 520px);
}

.btn {
  max-width: 100%;
  text-align: center;
  white-space: normal;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.hero-actions,
.product-actions {
  align-items: stretch;
}

.hero-actions .btn,
.product-actions .btn {
  min-width: 0;
}

.badge {
  max-width: 100%;
  white-space: normal;
}

.table-wrap {
  width: 100%;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(57, 229, 255, 0.55) rgba(255, 255, 255, 0.04);
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(57, 229, 255, 0.55);
  background-clip: padding-box;
}

.price-table th,
.price-table td {
  min-width: 130px;
}

.price-table th:first-child,
.price-table td:first-child {
  min-width: 220px;
}

.field input,
.field textarea,
.field select {
  min-width: 0;
  max-width: 100%;
}

.field textarea {
  field-sizing: content;
  max-height: 420px;
}

.consent span {
  min-width: 0;
}

.faq details {
  overflow: clip;
}

.faq summary {
  min-height: 58px;
}

.breadcrumbs {
  overflow: hidden;
}

.breadcrumbs ol {
  min-width: 0;
}

.breadcrumbs li {
  min-width: 0;
}

.site-header {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header) + env(safe-area-inset-top));
}

.main-nav.is-open {
  max-height: calc(100dvh - var(--header) - env(safe-area-inset-top) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

body.nav-open {
  overflow-x: clip;
  overflow-y: auto;
  touch-action: auto;
}

.mobile-actions {
  padding-bottom: max(7px, env(safe-area-inset-bottom));
}

.toast {
  max-width: calc(100% - 28px);
}

.mt-16 { margin-top: 16px !important; }
.mt-18 { margin-top: 18px !important; }
.mt-20 { margin-top: 20px !important; }
.mt-28 { margin-top: 28px !important; }
.min-h-auto { min-height: auto !important; }
.min-h-400 { min-height: 400px !important; }
.center-actions { justify-content: center !important; }
.offline-shell { max-width: 760px; text-align: center; }
.offline-logo { margin: 0 auto 28px; border-radius: 50%; }

.system-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.system-page main {
  width: min(100%, 680px);
  padding: clamp(28px, 6vw, 54px);
  border: 1px solid var(--line);
  border-radius: clamp(20px, 4vw, 32px);
  text-align: center;
  background: rgba(7, 18, 31, 0.84);
  box-shadow: var(--shadow);
}

.system-page h1 {
  font-size: clamp(2rem, 8vw, 4.4rem);
}

.system-page p {
  margin-top: 16px;
  color: var(--muted);
}

@supports (content-visibility: auto) {
  .section:not(:first-of-type) {
    content-visibility: auto;
    contain-intrinsic-size: auto 700px;
  }
}

/* Широкие мониторы и 2K/4K */
@media (min-width: 1440px) {
  :root {
    --container: 1260px;
  }

  .section {
    padding-block: 108px;
  }

  .section--compact {
    padding-block: 76px;
  }

  .hero-grid {
    gap: 78px;
  }

  .cards,
  .price-grid {
    gap: 22px;
  }
}

@media (min-width: 1920px) {
  :root {
    --container: 1360px;
  }

  body {
    font-size: 17px;
  }

  .hero-logo {
    width: min(100%, 520px);
  }
}

/* Небольшие ноутбуки: меню и кнопки не сталкиваются */
@media (min-width: 1051px) and (max-width: 1230px) {
  .header-inner {
    gap: 14px;
  }

  .main-nav a {
    padding-inline: 9px;
    font-size: 0.88rem;
  }

  .header-cta {
    padding-inline: 13px;
  }

  .brand-tagline {
    display: none;
  }
}

/* Планшеты и небольшие ноутбуки */
@media (max-width: 1049px) {
  .site-header {
    backdrop-filter: blur(14px);
  }

  .main-nav.is-open {
    top: calc(var(--header) + env(safe-area-inset-top));
    left: var(--page-gutter);
    right: var(--page-gutter);
    padding: 12px;
  }

  .main-nav.is-open a {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  .hero,
  .page-hero {
    min-height: auto;
  }

  .hero-grid,
  .page-hero-grid {
    gap: 40px;
  }

  .hero-visual {
    width: min(100%, 620px);
    margin-inline: auto;
  }

  .page-kpi {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .page-hero-grid > .product-card,
  .page-hero-grid > .feature-panel,
  .page-hero-grid > .page-kpi {
    width: 100%;
  }

  .contact-grid {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.15fr);
  }
}

@media (max-width: 900px) {
  .section {
    padding-block: 82px;
  }

  .section--compact {
    padding-block: 58px;
  }

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

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

  .process-step {
    min-height: 190px;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .contact-card,
  .form-card {
    width: 100%;
  }

  .feature-split {
    gap: 32px;
  }

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

  .cta-panel .btn {
    width: fit-content;
  }

  .footer-grid {
    gap: 34px 24px;
  }
}

/* Телефоны и небольшие планшеты */
@media (max-width: 760px) {
  :root {
    --page-gutter: 12px;
  }

  body {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .section {
    padding-block: clamp(56px, 12vw, 72px);
  }

  .section--compact {
    padding-block: clamp(42px, 9vw, 56px);
  }

  .section--top {
    padding-top: 38px;
  }

  h1 {
    font-size: clamp(2.3rem, 10.5vw, 3.5rem);
    letter-spacing: -0.045em;
  }

  h2 {
    font-size: clamp(1.85rem, 8vw, 2.75rem);
    letter-spacing: -0.035em;
  }

  h3 {
    font-size: clamp(1.16rem, 5vw, 1.45rem);
  }

  .lead {
    font-size: clamp(1rem, 4.3vw, 1.15rem);
    line-height: 1.65;
  }

  .eyebrow {
    font-size: 0.75rem;
    letter-spacing: 0.11em;
  }

  .header-inner {
    gap: 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand-name {
    font-size: 0.96rem;
  }

  .hero {
    padding-block: 46px 54px;
  }

  .hero:after {
    width: 420px;
    height: 420px;
    right: -250px;
    opacity: 0.65;
  }

  .hero-grid,
  .page-hero-grid {
    gap: 30px;
  }

  .hero-copy .lead,
  .page-hero p.lead {
    margin-top: 18px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 26px;
  }

  .hero-actions .btn,
  .product-actions .btn,
  .form-card button[type="submit"] {
    width: 100%;
  }

  .hero-note {
    gap: 10px;
    margin-top: 22px;
  }

  .hero-visual {
    min-height: clamp(260px, 78vw, 360px);
  }

  .hero-logo {
    width: min(82vw, 350px);
  }

  .page-hero {
    padding-block: 46px 48px;
  }

  .page-kpi {
    grid-template-columns: 1fr;
  }

  .kpi-box {
    padding: 17px;
  }

  .cards,
  .product-grid,
  .price-grid,
  .problem-grid,
  .solution-grid,
  .process-grid,
  .stats-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .card,
  .product-card,
  .price-card,
  .contact-card,
  .form-card,
  .feature-panel {
    padding: clamp(21px, 5.5vw, 27px);
    border-radius: 22px;
  }

  .product-card {
    min-height: auto;
  }

  .product-top {
    align-items: flex-start;
    margin-bottom: 22px;
  }

  .product-mark {
    width: 58px;
    height: 58px;
    border-radius: 17px;
    font-size: 1.1rem;
  }

  .product-actions {
    display: grid;
    grid-template-columns: 1fr;
    padding-top: 24px;
  }

  .process-step {
    min-height: auto;
    padding: 22px;
  }

  .process-step::before {
    margin-bottom: 18px;
  }

  .feature-row {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 11px;
    padding: 13px;
  }

  .feature-number {
    width: 38px;
    height: 38px;
  }

  .logo-panel,
  .min-h-400 {
    min-height: clamp(290px, 82vw, 380px) !important;
  }

  .cta-panel {
    padding: clamp(24px, 6vw, 30px);
    border-radius: 24px;
  }

  .cta-panel .btn {
    width: 100%;
  }

  .form-grid {
    gap: 13px;
  }

  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  .consent {
    font-size: 0.82rem;
  }

  .contact-link {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 11px;
    padding: 12px;
  }

  .contact-ico {
    width: 42px;
    height: 42px;
  }

  .faq summary {
    padding: 18px 52px 18px 18px;
  }

  .faq summary::after {
    right: 18px;
  }

  .faq .answer {
    padding: 0 18px 19px;
  }

  .breadcrumbs {
    padding-top: 16px;
    font-size: 0.79rem;
  }

  .article h2,
  .legal h2 {
    margin-top: 42px;
    font-size: clamp(1.65rem, 7vw, 2.15rem);
  }

  .article h3,
  .legal h3 {
    margin-top: 28px;
  }

  .article p,
  .article li,
  .legal p,
  .legal li {
    font-size: 1rem;
  }

  .article ul,
  .article ol,
  .legal ul,
  .legal ol {
    padding-left: 22px;
  }

  .article-callout {
    margin-block: 24px;
    padding: 18px;
  }

  .price-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
  }

  .price-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .price-table,
  .price-table tbody,
  .price-table tr,
  .price-table td {
    display: block;
    width: 100%;
  }

  .price-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .price-table tr {
    overflow: hidden;
    border: 1px solid rgba(120, 218, 255, 0.15);
    border-radius: 16px;
    background: rgba(7, 18, 31, 0.78);
  }

  .price-table td {
    min-width: 0 !important;
    display: grid;
    grid-template-columns: minmax(92px, 0.38fr) minmax(0, 0.62fr);
    gap: 12px;
    padding: 13px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
  }

  .price-table td::before {
    content: attr(data-label);
    color: #8cecff;
    font-size: 0.77rem;
    font-weight: 850;
    letter-spacing: 0.03em;
  }

  .price-table td:last-child {
    border-bottom: 0;
  }

  .site-footer {
    padding-top: 44px;
  }

  .footer-grid {
    gap: 30px;
  }

  .footer-bottom {
    gap: 10px;
    margin-top: 34px;
  }

  .mobile-actions {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 560px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat {
    min-height: auto;
    padding: 20px;
  }

  .section-head {
    margin-bottom: 26px;
  }

  .badges {
    gap: 7px;
  }

  .badge {
    width: fit-content;
    font-size: 0.78rem;
  }

  .price-label {
    position: static;
    width: fit-content;
    margin-bottom: 14px;
  }

  .price {
    margin-top: 12px;
  }

  .problem {
    gap: 13px;
    padding: 19px;
  }

  .problem-marker {
    width: 34px;
    height: 34px;
  }

  .mobile-actions a {
    min-height: 52px;
    font-size: 0.69rem;
  }
}

@media (max-width: 390px) {
  :root {
    --page-gutter: 9px;
  }

  h1 {
    font-size: clamp(2.05rem, 11.5vw, 2.65rem);
  }

  h2 {
    font-size: clamp(1.7rem, 9vw, 2.15rem);
  }

  .brand-copy {
    max-width: 150px;
  }

  .brand-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .card,
  .product-card,
  .price-card,
  .contact-card,
  .form-card,
  .feature-panel {
    padding: 20px;
  }

  .price-table tbody {
    padding: 8px;
  }

  .price-table td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .mobile-actions {
    gap: 4px;
    padding: 5px;
  }

  .mobile-actions a {
    font-size: 0.65rem;
  }

  .mobile-actions svg {
    width: 19px;
    height: 19px;
  }
}

/* Горизонтальная ориентация телефона */
@media (max-height: 520px) and (orientation: landscape) {
  .hero,
  .page-hero,
  .error-page {
    min-height: auto;
    padding-block: 38px;
  }

  .hero-grid,
  .page-hero-grid {
    gap: 28px;
  }

  .hero-visual {
    min-height: 250px;
  }

  .main-nav.is-open {
    max-height: calc(100dvh - var(--header) - 12px);
  }
}

/* Устройства без точного курсора */
@media (hover: none), (pointer: coarse) {
  .btn:hover {
    transform: none;
  }

  .main-nav a,
  .footer-links a,
  .card-link,
  summary {
    min-height: 44px;
  }
}

/* Высокая контрастность Windows */
@media (forced-colors: active) {
  .btn,
  .card,
  .price-card,
  .product-card,
  .contact-card,
  .form-card,
  .faq details,
  .mobile-actions {
    border: 1px solid CanvasText;
  }

  .text-gradient,
  .error-page__code {
    color: CanvasText;
    background: none;
  }
}

/* Печать коммерческих страниц и статей */
@media print {
  :root {
    color-scheme: light;
  }

  body {
    color: #111;
    background: #fff;
    padding: 0 !important;
  }

  body::before,
  .site-header,
  .site-footer,
  .mobile-actions,
  .toast,
  .hero-orbit,
  .hero-actions,
  .cta-panel .btn,
  .contact-grid,
  .skip-link {
    display: none !important;
  }

  .container,
  .article,
  .legal {
    width: 100%;
    max-width: none;
  }

  .section,
  .section--compact,
  .page-hero {
    padding: 20px 0;
  }

  h1,
  h2,
  h3,
  p,
  li,
  td,
  th,
  .muted,
  .lead {
    color: #111 !important;
  }

  .card,
  .price-card,
  .product-card,
  .process-step,
  .feature-panel,
  .article-callout,
  .faq details,
  .table-wrap {
    break-inside: avoid;
    color: #111;
    background: #fff;
    border: 1px solid #bbb;
    box-shadow: none;
  }

  a {
    text-decoration: underline;
  }
}


/* АД Студия — исправление стабильности мобильной навигации 2.1.0 */
@media (max-width: 1050px) {
  body:not(.offline-page):not(.system-page) {
    padding-top: calc(var(--header) + env(safe-area-inset-top));
  }

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 6000;
    overflow: visible;
    transform: translateZ(0);
  }

  .header-inner {
    position: relative;
  }

  .main-nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    margin-left: 0;
    padding: 12px;
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(4, 12, 21, 0.99);
    box-shadow: var(--shadow);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
  }

  .main-nav.is-open {
    position: absolute;
    inset: auto 0 auto 0;
    top: calc(100% + 8px);
    display: grid;
    max-height: calc(100dvh - var(--header) - env(safe-area-inset-top) - 28px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .main-nav.is-open a {
    width: 100%;
    min-height: 48px;
  }

  /* Не блокируем весь экран: именно это ломало касания и sticky-шапку. */
  body.nav-open {
    overflow-x: clip;
    overflow-y: auto;
    touch-action: auto;
  }

  body.nav-open .mobile-actions {
    pointer-events: none;
    opacity: 0.35;
  }
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .site-header {
    background: rgba(3, 7, 13, 0.98);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  body::before {
    display: none;
  }

  .hero-logo,
  .hero-orbit,
  .ai-lab__visual::before,
  .ai-lab__visual::after,
  .region-pulse {
    animation: none !important;
  }

  .reveal-ready,
  .reveal-ready.is-revealed {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .section:not(:first-of-type) {
    content-visibility: visible !important;
    contain-intrinsic-size: none !important;
  }

  /* На телефоне модальное окно не меняет режим прокрутки body. */
  body.modal-open {
    overflow-x: clip;
    overflow-y: auto;
    touch-action: auto;
  }

  .callback-modal {
    align-items: start;
    padding-top: calc(var(--header) + env(safe-area-inset-top) + 12px);
    overscroll-behavior: contain;
  }

  .callback-modal__dialog {
    max-height: calc(100dvh - var(--header) - env(safe-area-inset-top) - 28px);
    -webkit-overflow-scrolling: touch;
  }
}
