/* تحسينات واجهة الجوال - لا تؤثر على سطح المكتب */
@media (max-width: 768px) {
  html {
    scroll-padding-top: 72px;
  }

  body {
    overflow-x: hidden;
  }

  .page-shell,
  main,
  .section-card,
  .hero,
  .hero-modern {
    width: min(100%, 100vw);
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-shell {
    padding-inline: 10px;
  }

  .topbar,
  header.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
  }

  .yl-header-shortcuts {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .yl-header-link {
    flex: 0 0 auto;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    white-space: nowrap;
    padding: 8px 12px;
  }

  .nav-toggle,
  .yl-header-menu-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .main-nav {
    max-height: calc(100vh - 74px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .main-nav a,
  .contact-link,
  .seo-internal-link,
  .claim-link,
  .case-title-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .hero h1,
  .section-head h2,
  .case-card h2 {
    line-height: 1.55;
    word-break: normal;
    overflow-wrap: anywhere;
  }

  .posts-grid,
  .contact-grid,
  .seo-internal-links-grid {
    grid-template-columns: 1fr !important;
  }

  .case-card,
  .post-card,
  .service-card,
  .section-card {
    border-radius: 16px;
    padding: 14px;
  }

  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

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

  .yl-floating-share-wrap {
    inset-inline: auto 10px;
    bottom: 12px;
  }

  /* زر واتساب داخل الهيرو: مستطيل واضح ومتوافق مع الجوال */
  .hero .yl-global-hero-actions,
  .hero .yl-service-hero-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 16px auto 0 !important;
    gap: 10px !important;
  }

  .hero .yl-global-hero-whatsapp,
  .hero .service-whatsapp-button.yl-global-hero-whatsapp,
  .hero .service-whatsapp-button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 56px !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    padding: 13px 16px !important;
    border-radius: 16px !important;
    text-align: center !important;
    line-height: 1.7 !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  .hero .yl-global-hero-whatsapp span,
  .hero .service-whatsapp-button span {
    display: inline !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important;
  }

  .hero .yl-global-hero-whatsapp::after,
  .hero .service-whatsapp-button::after {
    display: none !important;
    content: none !important;
  }

  .hero .yl-global-hero-whatsapp i,
  .hero .service-whatsapp-button i {
    flex: 0 0 auto !important;
    font-size: 1.2rem !important;
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding-inline: 8px;
  }

  .hero h1 {
    font-size: clamp(24px, 8vw, 34px);
  }

  .section-card {
    padding: 12px;
  }

  .hero .yl-global-hero-whatsapp,
  .hero .service-whatsapp-button.yl-global-hero-whatsapp,
  .hero .service-whatsapp-button {
    min-height: 54px !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    font-size: .95rem !important;
  }
}

/* YL_SCROLL_UNLOCK_FIX_START
   يمنع أي طبقة تحميل أو كلاس مؤقت من تعطيل سحب الصفحة للأعلى/الأسفل عند الدخول أو الرجوع للصفحة. */
html,
body {
  min-height: 100% !important;
  height: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-x pan-y !important;
}

body.yl-page-waiting,
html.yl-page-waiting,
body.yl-ai-keyboard-active,
html.yl-ai-keyboard-active {
  overflow-y: auto !important;
  height: auto !important;
  position: relative !important;
  touch-action: pan-x pan-y !important;
}

.yl-page-wait-overlay,
html.yl-page-waiting .yl-page-wait-overlay,
body.yl-page-waiting .yl-page-wait-overlay {
  pointer-events: none !important;
  touch-action: none !important;
}

.page-shell,
main,
body > main,
.library-page,
.posts-page,
.site-page {
  overflow-y: visible !important;
  touch-action: pan-x pan-y !important;
}
/* YL_SCROLL_UNLOCK_FIX_END */

/* YL_MOBILE_SCROLL_FREEZE_FINAL_FIX */
@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100% !important;
    position: relative !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.yl-ai-keyboard-active,
  html.yl-ai-keyboard-active,
  body.yl-page-waiting,
  html.yl-page-waiting {
    overflow-y: auto !important;
    height: auto !important;
    position: relative !important;
    touch-action: pan-y !important;
  }

  .yl-page-wait-overlay {
    pointer-events: none !important;
  }

  #homeSmartLegalSearch,
  .yl-home-ai-search-section,
  .ai-search-page,
  .page-shell,
  main {
    overflow: visible !important;
    touch-action: pan-y !important;
  }
}\n\n/* YL_HOME_SEARCH_LOADING_TOUCH_FIX */
@media (max-width: 900px) {
  .ai-search-loading-notice {
    pointer-events: none !important;
    touch-action: none !important;
  }

  #homeSmartLegalSearch {
    touch-action: pan-y !important;
  }

  #homeSmartLegalSearch input,
  #homeSmartLegalSearch button {
    touch-action: manipulation !important;
  }
}\n

/* YL_AI_SEARCH_LAZY_TOUCH_FIX_ALL_PAGES */
@media (max-width: 900px) {
  .ai-search-loading-notice {
    pointer-events: none !important;
    touch-action: none !important;
  }

  #homeSmartLegalSearch,
  #aiSearchForm,
  .ai-search-box,
  .ai-search-page {
    touch-action: pan-y !important;
  }

  #aiSearchInput,
  #homeSmartLegalSearch input,
  #homeSmartLegalSearch button,
  #aiSearchForm input,
  #aiSearchForm button,
  .ai-search-box input,
  .ai-search-box button {
    touch-action: manipulation !important;
  }
}
