/**
 * Mobile-only fixes — loaded after style.css / unified-ui.css.
 * Desktop (min-width: 981px) is not affected.
 */

html {
  overflow-x: clip;
}

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

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

/* —— Mobile navigation —— */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(15, 17, 21, 0.92);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

body.nav-open {
  overflow: hidden;
}

@media (max-width: 980px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    position: relative;
    z-index: 1002;
  }

  .site-header .header-inner {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    text-align: left;
  }

  .site-header .brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 10px;
  }

  .site-header .brand-text {
    font-size: clamp(12px, 3.4vw, 15px);
    line-height: 1.25;
  }

  .site-header .site-logo {
    height: 40px !important;
  }

  .site-header .main-nav {
    position: fixed;
    top: 72px;
    left: 16px;
    right: 16px;
    z-index: 1001;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    max-height: calc(100dvh - 88px);
    overflow-y: auto;
    background: rgba(15, 17, 21, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 18px;
    backdrop-filter: blur(18px);
  }

  body.nav-open .main-nav,
  .site-header .main-nav.is-open {
    display: flex;
  }

  .site-header .main-nav > a,
  .site-header .nav-dropdown > a {
    display: block;
    padding: 14px 12px;
    font-size: 15px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .site-header .nav-dropdown {
    width: 100%;
  }

  .site-header .nav-dropdown .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    display: block;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0 0 8px 8px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .site-header .nav-dropdown .dropdown-menu a {
    padding: 10px 12px;
    font-size: 14px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }
}

@media (max-width: 768px) {
  .container,
  .narrow {
    width: min(1200px, calc(100% - 32px));
  }

  .section {
    padding: 56px 0;
  }

  .page-hero,
  .page-split-hero {
    padding: 64px 0 44px;
  }

  .btn {
    min-height: 44px;
  }

  /* Hero carousel */
  .hero-carousel-section {
    min-height: 620px;
    height: auto;
    max-height: none;
    overflow: hidden;
  }

  .hero-carousel-container {
    min-height: 620px;
    height: auto;
    position: relative;
  }

  .hero-slide {
    position: absolute;
    inset: 0;
    min-height: 620px;
    background-size: cover;
    background-position: center;
    opacity: 0;
  }

  .hero-slide.active {
    opacity: 1;
  }

  .hero-overlay {
    z-index: 2;
  }

  .hero-content-wrapper {
    position: relative;
    z-index: 5;
    min-height: 620px;
    height: auto;
    display: flex;
    align-items: center;
    padding: 90px 0 80px;
  }

  .hero-content {
    padding-bottom: 0;
  }

  .hero-content h1 {
    font-size: clamp(1.65rem, 8vw, 2rem);
  }

  .hero-lead {
    font-size: clamp(0.9rem, 3.8vw, 1rem);
  }

  .hero-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-buttons .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-meta {
    gap: 10px 16px;
  }

  .hero-meta span {
    font-size: 12px;
  }

  .carousel-prev,
  .carousel-next {
    bottom: 24px;
    width: 34px;
    height: 34px;
    z-index: 8;
  }

  .carousel-prev {
    right: 62px;
  }

  .carousel-next {
    right: 16px;
  }

  .carousel-dots {
    bottom: 24px;
    z-index: 8;
    max-width: calc(100% - 120px);
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Ecosystem mobile accordion */
  .ecosystem-section {
    min-height: auto;
    padding: 56px 0;
    overflow: visible;
  }

  .ecosystem-container {
    display: none !important;
  }

  .ecosystem-mobile {
    display: block;
    position: relative;
    z-index: 5;
    width: calc(100% - 32px);
    max-width: none;
    margin: 0 auto;
    padding: 0;
  }

  .ecosystem-mobile-accordion {
    display: grid;
    gap: 14px;
  }

  .ecosystem-accordion-item {
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    overflow: hidden;
  }

  .ecosystem-accordion-trigger {
    width: 100%;
    padding: 16px;
    color: #fff;
    background: transparent;
    border: none;
    text-align: left;
  }

  .ecosystem-accordion-panel {
    padding: 0 16px 16px;
  }

  .ecosystem-mobile-node {
    width: 100%;
    display: block;
    margin-top: 10px;
    padding: 12px;
    background: rgba(255, 122, 0, 0.06);
    border: 1px solid rgba(255, 122, 0, 0.18);
    border-radius: 14px;
    color: #fff;
    text-align: left;
  }

  .ecosystem-mobile-node small {
    display: block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.65);
  }

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

  .stat-number {
    font-size: clamp(2rem, 10vw, 2.75rem);
  }

  .stat-card,
  .stat-item {
    padding: 18px 14px;
    min-width: 0;
  }

  .stat-desc {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.4;
  }

  /* Partners logo cloud (home) */
  .partners-logo-cloud {
    gap: 20px 24px;
  }

  .partners-logo-cloud img {
    max-width: min(170px, 42vw);
    max-height: 58px;
  }

  .partners-logo-cloud img.partner-logo-lg {
    max-width: min(200px, 48vw);
    max-height: 72px;
  }

  .partners-logo-cloud img.partner-logo-sm {
    max-width: min(150px, 38vw);
    max-height: 52px;
  }

  /* Assistant promo (home) */
  .assistant-card {
    flex-direction: column;
    text-align: center;
    padding: 24px 20px;
    min-height: 0;
  }

  .assistant-content .btn {
    width: 100%;
    justify-content: center;
  }

  .assistant-avatar {
    width: 100%;
    justify-content: center;
  }

  /* Directions grid (inline styles override) */
  .directions-grid {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* Direction popup */
  .direction-popup-root {
    padding: 16px;
  }

  .direction-popup-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: min(88vh, calc(100dvh - 32px));
  }

  /* Rich text / long content */
  .direction-popup-description,
  .direction-popup-description p,
  .project-detail-body,
  .w-richtext,
  .rich-text {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Partner detail cards */
  .partner-detail-card {
    flex-direction: column;
  }

  .partner-image-col {
    flex: none;
    width: 100%;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    text-align: center;
  }

  .contacts-list li {
    justify-content: center;
  }

  /* Contacts & cooperation forms */
  .contacts-form-card,
  .contact-cooperation-card {
    padding: 24px 18px;
  }

  .contact-field input,
  .contact-field textarea,
  .contact-cooperation-card input,
  .contact-cooperation-card textarea {
    width: 100%;
    max-width: 100%;
  }

  .contact-cooperation-actions .btn,
  .contacts-form-card .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .container,
  .narrow {
    width: min(1200px, calc(100% - 24px));
  }

  .section {
    padding: 44px 0;
  }

  html {
    font-size: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .partners-logo-cloud {
    gap: 16px 18px;
  }

  .partners-logo-cloud img,
  .partners-logo-cloud img.partner-logo-lg,
  .partners-logo-cloud img.partner-logo-sm {
    max-width: min(140px, 40vw);
    max-height: 48px;
  }

  .hero-carousel-section {
    min-height: 560px;
  }

  .hero-carousel-container,
  .hero-content-wrapper,
  .hero-slide {
    min-height: 560px;
  }

  .carousel-prev,
  .carousel-next {
    display: none;
  }

  .brand-text br {
    display: none;
  }

  .brand-text {
    white-space: normal;
  }
}

@media (max-width: 380px) {
  .site-header .brand-text {
    font-size: 11px;
  }

  .hero-meta span {
    flex: 1 1 100%;
  }

  .assistant-corner-logo {
    top: 68px;
    right: 8px;
  }

  .assistant-corner-logo img {
    width: 84px !important;
  }
}
