/* Bloom with Fatma — طبقة «التطبيق» (PWA)
   =========================================
   شكل وحركة فقط: شريط سفلي للمشتركات على الهاتف، انتقال ناعم بين الصفحات،
   شاشة افتتاح عند الفتح من الشاشة الرئيسية، وبطاقة «أضيفيه إلى الشاشة الرئيسية».
   لا تغيّر أي نص ولا أي وظيفة. حذف سطرَي app.css و app.js من الصفحة يعيدها كما كانت تمامًا. */

html{-webkit-tap-highlight-color:transparent}

/* ---------- انتقال ناعم بين الصفحات (للمتصفحات التي تدعمه؛ غيرها ينتقل كالمعتاد) ---------- */
@media (prefers-reduced-motion:no-preference){
  @view-transition{navigation:auto}
  ::view-transition-old(root){animation:appOut .16s ease both}
  ::view-transition-new(root){animation:appIn .3s cubic-bezier(.2,.7,.2,1) both}
  @keyframes appOut{to{opacity:0}}
  @keyframes appIn{from{opacity:0;transform:translateY(10px)}}
  #appTabs{view-transition-name:app-tabs}
  ::view-transition-group(app-tabs){animation-duration:.01s}
  ::view-transition-old(app-tabs){display:none}
  ::view-transition-new(app-tabs){animation:none}
}

/* ---------- وضع التطبيق: احترام حدود الشاشة في الآيفون (كما في الصفحة الرئيسية) ---------- */
@supports (padding: env(safe-area-inset-top)){
  @media (display-mode: standalone){
    body{padding-top:env(safe-area-inset-top);padding-bottom:env(safe-area-inset-bottom)}
  }
}

/* ---------- شاشة الافتتاح (عند الفتح من الشاشة الرئيسية فقط، مرة في كل جلسة) ---------- */
html.app-splash::before{content:"";position:fixed;inset:0;z-index:2147483000;
  background:#162C26 url(icons/icon-512.png) center/min(52vw,230px) no-repeat;opacity:1;transition:opacity .45s ease}
html.app-splash::after{content:"";position:fixed;z-index:2147483001;left:50%;bottom:calc(64px + env(safe-area-inset-bottom,0px));
  width:34px;height:34px;margin-left:-17px;border-radius:50%;border:3px solid rgba(216,178,106,.25);border-top-color:#D8B26A;
  opacity:1;transition:opacity .3s ease}
html.app-splash.app-splash-out::before,html.app-splash.app-splash-out::after{opacity:0;pointer-events:none}
@media (prefers-reduced-motion:no-preference){
  html.app-splash::after{animation:appSpin .9s linear infinite}
  @keyframes appSpin{to{transform:rotate(360deg)}}
}

/* ---------- شريط رفيع أعلى الصفحة أثناء الانتقال ---------- */
#appProg{position:fixed;top:0;inset-inline-start:0;height:3px;width:0;opacity:0;z-index:130;pointer-events:none;
  background:linear-gradient(90deg,#B98C3E,#E8C77E);border-radius:0 3px 3px 0}
#appProg.go{opacity:1;width:86%;transition:width 2.6s cubic-bezier(.1,.7,.2,1),opacity .15s}
@media (prefers-reduced-motion:reduce){#appProg.go{width:60%;transition:none}}

/* ---------- الشريط السفلي (هاتف + مشتركة مسجّلة فقط) ---------- */
#appTabs{display:none}
@media (max-width:720px){
  html.app-tabs #appTabs{position:fixed;z-index:55;inset-inline:10px;bottom:calc(10px + env(safe-area-inset-bottom,0px));
    display:flex;gap:2px;padding:6px;border-radius:26px;direction:inherit;
    background:rgba(247,240,232,.93);-webkit-backdrop-filter:blur(14px) saturate(1.3);backdrop-filter:blur(14px) saturate(1.3);
    border:1px solid rgba(30,58,50,.14);box-shadow:0 16px 36px -14px rgba(22,44,38,.5),0 2px 6px rgba(22,44,38,.06)}
  #appTabs a{flex:1 1 0;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    padding:8px 2px 7px;border-radius:20px;text-decoration:none;color:#6A6258;
    font-family:'Tajawal','Hanken Grotesk',sans-serif;font-size:11.5px;font-weight:700;line-height:1.25;white-space:nowrap;
    -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
    transition:background .22s ease,color .22s ease,transform .12s ease}
  #appTabs a span{max-width:100%;overflow:hidden;text-overflow:ellipsis}
  #appTabs svg{width:23px;height:23px;flex:none;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
  #appTabs a.on{background:#1E3A32;color:#F7F0E8}
  #appTabs a.on svg{stroke:#D8B26A}
  #appTabs a:active{transform:scale(.94)}
  html[lang="en"] #appTabs a{font-size:11px;letter-spacing:.01em}

  /* الشريط العلوي للروابط يختفي على الهاتف (يبقى شريط «تصفّحي كمشتركة» إن وُجد) */
  html.app-tabs .mnav .in{display:none}
  html.app-tabs .mnav{border-bottom:0}
  /* مساحة للشريط حتى لا يغطي آخر الصفحة، ورفع زر اللغة فوقه */
  html.app-tabs body{padding-bottom:calc(92px + env(safe-area-inset-bottom,0px))}
  html.app-tabs .lang,html.app-tabs .lang-toggle{bottom:calc(90px + env(safe-area-inset-bottom,0px))}
}
@media (prefers-reduced-motion:reduce){#appTabs a{transition:none!important}#appTabs a:active{transform:none}}

/* ---------- زر «رجوع إلى صفحتي» (المشتركة المسجّلة، أعلى العادة والمقالات والمحاضرات) ---------- */
#appBack{position:sticky;top:0;z-index:44;max-width:1080px;margin:0 auto;padding:10px 16px 2px;box-sizing:border-box;pointer-events:none}
#appBack a{pointer-events:auto}
#appBack a{display:inline-flex;align-items:center;gap:8px;text-decoration:none;
  font-family:'Tajawal','Hanken Grotesk',sans-serif;font-size:14.5px;font-weight:700;line-height:1.3;
  color:#1E3A32;background:#fff;border:1px solid rgba(30,58,50,.18);border-radius:24px;padding:9px 18px 9px 16px;
  box-shadow:0 8px 20px -14px rgba(30,58,50,.45);transition:background .2s ease,color .2s ease,transform .12s ease}
#appBack a .ar{color:#B98C3E;font-size:16px;line-height:1}
#appBack a:hover{background:#1E3A32;color:#F7F0E8;border-color:#1E3A32}
#appBack a:hover .ar{color:#D8B26A}
#appBack a:active{transform:scale(.97)}
@media (prefers-reduced-motion:reduce){#appBack a{transition:none}#appBack a:active{transform:none}}

/* ---------- لمسة الضغط على الأزرار في شاشات اللمس ---------- */
@media (hover:none) and (prefers-reduced-motion:no-preference){
  .btn:active,.fb-btn:active,.site-link:active,.app-card button:active{transform:scale(.97)}
}

/* ---------- بطاقة «أضيفيه إلى الشاشة الرئيسية» ---------- */
.app-card{position:fixed;z-index:110;inset-inline:12px;bottom:calc(96px + env(safe-area-inset-bottom,0px));max-width:440px;margin-inline:auto;
  display:flex;gap:13px;align-items:flex-start;padding:15px 15px 13px;border-radius:22px;
  background:linear-gradient(160deg,#1E3A32,#162C26);color:#F7F0E8;border:1px solid rgba(216,178,106,.35);
  box-shadow:0 24px 50px -18px rgba(22,44,38,.7);font-family:'Tajawal','Hanken Grotesk',sans-serif;
  opacity:0;transform:translateY(18px);transition:opacity .35s ease,transform .35s cubic-bezier(.2,.7,.2,1)}
.app-card.in{opacity:1;transform:none}
.app-card img{width:48px;height:48px;border-radius:13px;flex:none;box-shadow:0 0 0 1px rgba(216,178,106,.4)}
.app-card .tx{flex:1;min-width:0}
.app-card b{display:block;font-size:15.5px;line-height:1.5;color:#F7F0E8}
.app-card p{font-size:13.5px;line-height:1.65;color:#E9E0D3;margin:2px 0 0}
.app-card .ac{display:flex;gap:8px;margin-top:11px;flex-wrap:wrap}
.app-card button{font:inherit;font-size:13.5px;font-weight:700;border-radius:22px;padding:8px 18px;cursor:pointer;border:1px solid rgba(247,240,232,.35);background:none;color:#F7F0E8}
.app-card button.go{background:#B98C3E;border-color:#B98C3E;color:#162C26}
@media (prefers-reduced-motion:reduce){.app-card{transition:none;transform:none}}

/* ---------- تنبيه انقطاع الإنترنت ---------- */
.app-off{position:fixed;z-index:140;top:calc(10px + env(safe-area-inset-top,0px));left:50%;transform:translateX(-50%);
  max-width:calc(100vw - 24px);box-sizing:border-box;background:#162C26;color:#F7F0E8;border:1px solid rgba(216,178,106,.45);
  border-radius:22px;padding:8px 16px;font:700 13px/1.6 'Tajawal','Hanken Grotesk',sans-serif;text-align:center;
  box-shadow:0 14px 30px -14px rgba(22,44,38,.7)}

/* ---------- هيكل تحميل هادئ تحت عبارة التحميل في «صفحتي» ---------- */
#loading::after{content:"";display:block;height:230px;margin:26px auto 0;max-width:724px;border-radius:20px;
  background:
    linear-gradient(#EFE4D6,#EFE4D6) 0 0/100% 92px no-repeat,
    linear-gradient(#EFE4D6,#EFE4D6) 0 108px/48% 122px no-repeat,
    linear-gradient(#EFE4D6,#EFE4D6) 100% 108px/48% 122px no-repeat;
  opacity:.75}
@media (prefers-reduced-motion:no-preference){
  #loading::after{animation:appPulse 1.4s ease-in-out infinite}
  @keyframes appPulse{50%{opacity:.35}}
}
