/**
 * تحسين تجربة الجوال — مركز بن حمران التجاري
 * يُحمَّل فوق الأنماط الحالية دون تغيير روح الهوية على سطح المكتب.
 */

@media (max-width: 900px) {
  /* هيرو أوضح وأقل إرهاقًا على الشاشات القصيرة */
  .home-page #hero .slide-link,
  .home-page #hero .slide-link--full,
  .home-page #hero .hero-split,
  .home-page #hero .hero-full:not(.hero-full--facade) {
    min-height: min(100svh, 760px);
  }
  .home-page #hero .hero-carousel,
  .home-page #hero .slides,
  .home-page #hero .slide,
  .home-page #hero .hero-full--facade,
  .home-page #hero .hero-full__stage--facade {
    height: calc(100svh - var(--home-header-h, 64px));
    min-height: min(calc(100svh - var(--home-header-h, 64px)), 640px);
    max-height: 820px;
  }
  .home-page #hero .hero-full--facade .hero-full__img {
    transform: scale(1.08) !important;
    object-position: center 42%;
  }
  .slide-caption {
    bottom: max(18px, env(safe-area-inset-bottom, 0px));
    width: min(920px, 92%);
    padding: 14px 16px;
    border-radius: 14px;
  }
  .slide-caption h1,
  .hero-caption h1 {
    font-size: clamp(1.55rem, 7vw, 2.1rem) !important;
    line-height: 1.35;
  }
  .slide-caption .btn,
  .hero-caption .btn {
    min-height: 46px;
    padding: 12px 20px;
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  html {
    -webkit-text-size-adjust: 100%;
  }
  body {
    overflow-x: hidden;
  }

  /* هيدر ثابت بمساحة آمنة */
  .site-header {
    padding-top: env(safe-area-inset-top, 0px);
  }
  body.has-unified-chrome,
  body:not(.home-page) {
    padding-top: calc(clamp(64px, 9vh, 76px) + env(safe-area-inset-top, 0px));
  }
  .home-page {
    --home-header-h: calc(58px + env(safe-area-inset-top, 0px));
  }

  .site-header .container.nav {
    min-height: 56px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
  .site-header .brand {
    width: 42px;
    height: 42px;
  }
  .nav-toggle {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    position: relative;
    z-index: 60;
    font-size: 0 !important;
    color: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
  }
  .nav-toggle::before,
  .nav-toggle::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    color: #0d1b2a;
    transform: translateX(-50%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), top 0.32s ease, opacity 0.2s ease;
  }
  .nav-toggle::before {
    top: 16px;
    box-shadow: 0 6px 0 currentColor;
  }
  .nav-toggle::after {
    top: 28px;
  }
  .nav-toggle[aria-expanded="true"] {
    background: rgba(27, 53, 91, 0.08);
  }
  .nav-toggle[aria-expanded="true"]::before {
    top: 21px;
    box-shadow: none;
    transform: translateX(-50%) rotate(45deg);
  }
  .nav-toggle[aria-expanded="true"]::after {
    top: 21px;
    transform: translateX(-50%) rotate(-45deg);
  }
  .lang-toggle {
    min-width: 44px;
    height: 40px;
  }

  /* خلفية معتمة خلف القائمة */
  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(8, 18, 32, 0.45);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .nav-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* قائمة مخفية → تنزل كشريط أنيق تحت الهيدر */
  .menu {
    display: flex !important;
    flex-direction: column;
    position: fixed !important;
    inset: calc(56px + env(safe-area-inset-top, 0px)) 10px auto 10px !important;
    z-index: 55;
    max-height: min(78svh, 560px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
    margin: 0 !important;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 22px 48px rgba(15, 34, 51, 0.22);
    border: 1px solid rgba(27, 53, 91, 0.08);
    border-radius: 18px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-14px) scale(0.98);
    transform-origin: top center;
    transition:
      opacity 0.28s ease,
      visibility 0.28s ease,
      transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .menu.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .menu > * {
    opacity: 0;
    transform: translateY(10px);
    transition:
      opacity 0.28s ease,
      transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .menu.open > * {
    opacity: 1;
    transform: translateY(0);
  }
  .menu.open > *:nth-child(1) { transition-delay: 0.04s; }
  .menu.open > *:nth-child(2) { transition-delay: 0.08s; }
  .menu.open > *:nth-child(3) { transition-delay: 0.12s; }
  .menu.open > *:nth-child(4) { transition-delay: 0.16s; }
  .menu.open > *:nth-child(5) { transition-delay: 0.2s; }
  .menu.open > *:nth-child(6) { transition-delay: 0.24s; }
  .menu.open > *:nth-child(7) { transition-delay: 0.28s; }

  .menu a,
  .menu .drop-toggle,
  .menu .btn {
    display: inline-flex !important;
    width: 100%;
    align-items: center;
    justify-content: center !important;
    text-align: center !important;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px !important;
    border-radius: 12px;
    box-sizing: border-box;
  }
  .menu .has-dropdown {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .menu .drop-toggle::after {
    margin-inline-start: 10px;
    margin-inline-end: 0;
  }
  .menu a::after {
    display: none;
  }
  .menu a:active,
  .menu .drop-toggle:active {
    background: rgba(27, 53, 91, 0.06);
  }
  .menu .drop-menu {
    width: 100%;
    text-align: center;
  }
  .menu .drop-menu a {
    display: flex !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 15px;
  }
  .menu.open .auth-toggle {
    margin-top: 6px;
    width: 100% !important;
    justify-content: center !important;
    min-height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, #1b355b, #1f6aa5);
    color: #fff !important;
  }

  /* زر «اكتشف المزيد» — قراءة واضحة بدون لصق الحروف */
  .hero .hero-facade__overlay {
    right: 50% !important;
    left: auto !important;
    top: auto !important;
    bottom: max(72px, calc(12vh + env(safe-area-inset-bottom, 0px))) !important;
    transform: translateX(50%) !important;
    width: min(92vw, 340px) !important;
    max-width: min(92vw, 340px) !important;
    padding: 22px 18px 20px !important;
    box-sizing: border-box;
  }
  .hero .hero-facade__name {
    font-size: clamp(1.25rem, 5.5vw, 1.55rem) !important;
    letter-spacing: 0 !important;
  }
  .hero .hero-facade__trade {
    font-size: clamp(1.85rem, 8vw, 2.45rem) !important;
    letter-spacing: 0 !important;
  }
  .hero .hero-facade__tagline {
    font-size: 0.98rem !important;
    line-height: 1.7 !important;
    margin-bottom: 18px !important;
    letter-spacing: 0 !important;
    max-width: 18ch;
  }
  .hero .hero-split__btn,
  .hero .hero-split__btn--discover,
  .hero .hero-full--facade .hero-split__btn--discover {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    max-width: 100%;
    min-width: min(100%, 200px);
    min-height: 50px;
    padding: 13px 28px !important;
    font-size: 1.08rem !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    letter-spacing: normal !important; /* لا نكسر اتصال الحروف العربية */
    word-spacing: 0.18em !important;
    white-space: nowrap !important;
    overflow: visible !important;
    transform: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
  body.nav-open {
    overflow: hidden;
  }

  /* أقسام الرئيسية: مسافات أوضح للتمرير بالإبهام */
  .section,
  .about-block,
  .features-block,
  .building-services,
  .news-events,
  .stats-block,
  .nearby-block,
  .clients-block {
    scroll-margin-top: 72px;
  }
  .section-title {
    font-size: clamp(1.35rem, 6vw, 1.7rem) !important;
    line-height: 1.4;
    padding-inline: 4px;
  }

  /* عناصر المبنى وخدماته: تقليل الفراغات الزائدة */
  .features-showcase {
    gap: 18px !important;
  }
  .feat-card__media {
    height: 180px !important;
  }
  .feat-card__body {
    padding: 16px 16px 18px !important;
  }
  .feat-card__title {
    font-size: 1.15rem !important;
  }
  .bs-grid {
    gap: 16px !important;
    padding-top: 8px !important;
  }
  .bs-card,
  .bs-card--featured,
  .bs-card--light {
    padding: 22px 18px !important;
    border-radius: 18px !important;
  }
  .bs-card__icon {
    width: 64px !important;
    height: 64px !important;
    margin-top: 0 !important;
  }
  .bs-card__icon i {
    font-size: 1.6rem !important;
  }

  /* تواصل معنا */
  .contact-block__inner {
    padding: 40px 14px 28px !important;
  }
  .contact-form--premium {
    padding: 22px 16px 20px !important;
    gap: 12px !important;
  }
  .contact-form--premium input,
  .contact-form--premium select,
  .contact-form--premium textarea {
    min-height: 48px;
    font-size: 16px !important; /* يمنع تكبير iOS المزعج */
    border-radius: 12px;
  }
  .contact-form--premium textarea {
    min-height: 120px;
  }
  .contact-send-btn {
    width: 100% !important;
    max-width: none !important;
    min-height: 52px;
    font-size: 16px;
  }

  /* صفحات عناصر المبنى */
  .be-content {
    padding-inline: 14px !important;
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .be-card-grid {
    gap: 12px !important;
  }
  .be-card {
    padding: 18px 16px !important;
  }
  .be-card h3 {
    font-size: 1.05rem !important;
  }
  .be-lease-panel {
    padding: 18px 14px 20px !important;
    border-radius: 16px !important;
  }
  .be-lease-form input,
  .be-lease-form textarea {
    min-height: 48px;
    font-size: 16px !important;
  }
  .be-lease-form textarea {
    min-height: 110px;
  }
  .be-lease-form__btn {
    width: 100%;
    min-height: 50px;
  }
  .be-tabs-wrap {
    gap: 6px;
    padding: 6px;
  }
  .building-elements-tabs .tab,
  body.building-elements-page .events-section .tab {
    min-height: 42px;
    padding: 10px 12px !important;
    font-size: 0.82rem !important;
  }
  .be-back-home {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* نماذج الخدمات */
  body.service-form-page .page-wrap {
    margin: 14px auto 36px !important;
    padding: 0 12px !important;
  }
  body.service-form-page .form-card {
    border-radius: 18px !important;
  }
  body.service-form-page .form-card__hero {
    padding: 28px 16px 22px !important;
  }
  body.service-form-page .form-card__hero h1 {
    font-size: clamp(1.45rem, 6.5vw, 1.8rem) !important;
  }
  body.service-form-page .form-body {
    padding: 18px 14px 26px !important;
  }
  body.service-form-page .form-section {
    padding: 16px 14px !important;
    border-radius: 14px;
  }
  body.service-form-page input,
  body.service-form-page select,
  body.service-form-page textarea {
    min-height: 48px;
    font-size: 16px !important;
  }
  body.service-form-page textarea {
    min-height: 120px;
  }
  body.service-form-page .submit-button {
    width: 100%;
    min-height: 52px;
    font-size: 16px;
    border-radius: 14px;
  }
  body.service-form-page .scope-tags {
    gap: 8px;
    justify-content: center;
  }
  body.service-form-page .scope-tags span {
    font-size: 0.82rem;
    padding: 6px 10px;
  }

  /* تذييل أخف على الجوال */
  .site-footer.fat-footer .footer-widgets {
    gap: 18px;
  }
  .site-footer.fat-footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 380px) {
  .slide-caption {
    padding: 12px 12px;
  }
  .feat-card__stat,
  .feat-card__badge {
    font-size: 0.72rem !important;
  }
  .bs-card__title {
    font-size: 1.05rem !important;
  }
}
