/* v4.6.5 — CSS-only final bottom padding fix */

/*
  الهدف:
  - لا فراغ تحت الهيدر.
  - لا فراغات بين البطاقات.
  - آخر محتوى الصفحة لا يدخل تحت القائمة السفلية.
  - لا JavaScript ولا spacer.
*/

@media (max-width:1024px){

  :root{
    --felah-fixed-bottom-nav-space: calc(132px + env(safe-area-inset-bottom));
  }

  html,
  body{
    overflow-x:hidden !important;
    scroll-padding-bottom:var(--felah-fixed-bottom-nav-space) !important;
  }

  body{
    padding-bottom:var(--felah-fixed-bottom-nav-space) !important;
  }

  /*
    إلغاء الفراغ الخاطئ تحت الهيدر.
  */
  #felah-mobile-master-header{
    margin-bottom:0 !important;
  }

  #felah-mobile-master-header + *{
    margin-top:0 !important;
  }

  /*
    لا نضيف أي margin عام للعناصر حتى لا تتباعد المربعات.
  */
  main,
  .main,
  .content,
  .page-content,
  .public-content,
  .app-content,
  .container,
  .wrapper,
  .page,
  .site-main,
  .layout-main{
    margin-bottom:0 !important;
  }

  /*
    فقط حاوية الصفحة الرئيسية/المحتوى تأخذ padding أسفل الصفحة.
    هذا لا يظهر بين المربعات؛ يظهر فقط عند نهاية التمرير.
  */
  main,
  .main,
  .content,
  .page-content,
  .public-content,
  .app-content,
  .container,
  .wrapper{
    padding-bottom:var(--felah-fixed-bottom-nav-space) !important;
  }

  /*
    لو كانت الصفحة لا تستخدم main أو container واضح،
    يضمن body padding-bottom مساحة كافية.
  */
  body::after{
    content:"" !important;
    display:block !important;
    height:var(--felah-fixed-bottom-nav-space) !important;
    pointer-events:none !important;
  }

  /*
    إزالة أي آثار قديمة للـ spacer.
  */
  #felah-mobile-content-safe-space{
    display:none !important;
    height:0 !important;
    min-height:0 !important;
    margin:0 !important;
    padding:0 !important;
  }

  /*
    إلغاء أي margin-bottom كبير كان قد ثبت على آخر العناصر من تحديث سابق.
  */
  .felah-v457-summary-grid > *,
  .books-grid > *,
  .lessons-grid > *,
  .categories-grid > *,
  .library-grid > *,
  .grid > *,
  .cards-grid > *,
  .felah-v461-block,
  .felah-v457-card{
    margin-bottom:initial !important;
  }

  /*
    الإعلان/المربعات أسفل المكتبة تبقى بمسافة طبيعية فقط.
  */
  .felah-v461-blocks,
  .felah-v457-bottom-ad,
  .felah-v460-library-feature{
    margin-bottom:24px !important;
  }

  footer,
  .footer,
  .site-footer{
    margin-bottom:0 !important;
    padding-bottom:0 !important;
  }

  #felah-mobile-master-bottom{
    min-height:78px !important;
    padding-bottom:calc(8px + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width:420px){
  :root{
    --felah-fixed-bottom-nav-space: calc(148px + env(safe-area-inset-bottom));
  }
}
