/* ALM — Cross-device optimizations */

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

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

body.nav-open {
  overflow: hidden;
  touch-action: none;
}

body.scroll-locked {
  position: fixed;
  width: 100%;
  left: 0;
  right: 0;
  overflow: hidden;
  touch-action: none;
}

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

/* 16px+ inputs — no iOS zoom on focus */
@media (max-width: 768px) {
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 16px;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .section { padding: 80px 0; }
  .hero { padding: 110px 0 64px; min-height: auto; }
  .advisor-form, .advisor-result, .contact-form { padding: 22px; }
}

/* Mobile */
@media (max-width: 768px) {
  .container { padding: 0 16px; }

  .header {
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: max(8px, env(safe-area-inset-top));
  }

  .header__inner {
    height: 56px;
    padding: 0 4px 0 12px;
    gap: 8px;
  }

  .logo__text { display: none; }
  .logo__mark { width: 36px; height: 36px; font-size: 0.75rem; border-radius: 10px; }

  .header__actions { gap: 6px; }
  .header__actions .header__btn-call,
  .header__actions .header__btn-book {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  .nav {
    top: calc(68px + env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .nav__link {
    padding: 14px 16px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .nav__link--phone {
    display: flex !important;
    color: var(--accent) !important;
    background: rgba(79, 140, 255, 0.1) !important;
    font-weight: 700;
  }

  .hero {
    padding: 96px 0 48px;
  }

  .hero__title { font-size: clamp(2rem, 9vw, 2.8rem); }
  .hero__desc { font-size: 1rem; margin-bottom: 28px; }
  .hero__actions { flex-direction: column; }
  .hero__actions .btn { width: 100%; }
  .hero__stats { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .hero__stat { padding: 14px 12px; }
  .hero__stat-num { font-size: 1.5rem; }
  .hero__stat-label { font-size: 0.72rem; }
  .hero__card { padding: 22px; }
  .hero__card-icon { font-size: 3rem; }
  .hero__card-item {
    font-size: 0.82rem;
    flex-wrap: wrap;
    gap: 8px;
  }
  .hero__card-item span:last-child {
    margin-left: 0;
    width: 100%;
    text-align: right;
  }

  .section { padding: 64px 0; }
  .section__header { margin-bottom: 36px; }
  .section__desc { font-size: 0.95rem; }

  .service-card { padding: 22px 18px; }
  .price-card { padding: 20px 18px; }

  .advisor-wrap { padding: 4px; }
  .advisor-panel { padding: 16px 12px; }
  .advisor-form, .advisor-result, .contact-form { padding: 18px; min-height: auto; }
  .advisor-result__placeholder { padding: 32px 12px; }
  .advisor-tab { padding: 10px 12px; font-size: 0.72rem; min-width: 64px; }

  .health-score { flex-direction: column; text-align: center; }
  .timeline-item__title { font-size: 0.85rem; }

  .contact-map {
    min-height: 220px;
    border-radius: var(--radius-sm);
  }

  .cta-banner { padding: 48px 0; }
  .cta-banner__inner { padding: 32px 20px; }

  .floating-btn {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
    width: 52px;
    height: 52px;
  }

  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal__content {
    max-width: none;
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 28px 20px max(28px, calc(20px + env(safe-area-inset-bottom)));
    max-height: 92dvh;
    overflow-y: auto;
  }

  .footer { padding: 48px 0 24px; }
  .footer__grid { gap: 32px; }
}

/* Small phones */
@media (max-width: 380px) {
  .hero__stats { grid-template-columns: 1fr; }
  .header__actions .header__btn-book span { display: none; }
  .header__actions .header__btn-book::after { content: 'Запись'; }
  .header__actions .header__btn-call span { display: none; }
  .header__actions .header__btn-call::after { content: 'Звонок'; }
  .advisor-tab { font-size: 0.68rem; padding: 9px 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .floating-btn { animation: none; }
}

/* Coarse pointer — larger tap targets */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .symptom-chip { min-height: 48px; }
  .burger { min-width: 44px; min-height: 44px; }
}