/* =========================================================
   شاشة ترحيب الأنِيس: «كتاب يُفتح في ليلة مضيئة» (المدة ~3.6 ثانية)
   0.00–0.70  النجمة الثمانية تُرسم والقنديل يتّقد
   0.45–1.25  الكتاب ينفتح من كعبه وتظهر سطوره
   1.15–1.95  اسم «الأنِيس» يُكتب من اليمين إلى اليسار
   1.85–2.40  الخط الذهبي ثم «رفيقك في القراءة»
   2.25–2.80  البيت: «وخيرُ جليسٍ في الزمانِ كتابُ»
   2.55–3.05  لمعة على الشعار
   3.05–3.65  الخروج: الشاشة تُقلب كغلاف كتاب من جهة الكعب (اليمين)
   تظهر فقط إذا أضاف سكربت الرأس الصنف splash-on على <html>
   ========================================================= */
.splash { display: none; }
html.splash-on .splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(240, 207, 133, .22) 0%, rgba(217, 173, 82, .08) 24%, rgba(12, 42, 41, 0) 55%),
    radial-gradient(120% 80% at 50% 120%, #0a2221 0%, transparent 60%),
    #0c2a29;
  color: #f0cf85; text-align: center; overflow: hidden;
  --sw: clamp(120px, min(42vw, 26vh), 230px);
  transform-origin: 100% 50%;
  animation: sp-out .62s cubic-bezier(.55, 0, .75, .3) 3.05s both;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
html.splash-on, html.splash-on body { overflow: hidden; }
/* نقش خفيف بزخرفة الهوية */
.splash::before {
  content: ""; position: absolute; inset: -20%;
  background: var(--pattern) 0 0 / 64px;
  opacity: .05; animation: sp-drift 8s linear both;
}
/* حافة الورق تظهر عند القلب */
.splash::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 14px;
  background: linear-gradient(90deg, #f7ecd2, #d9ad52); opacity: 0;
  animation: sp-edge .62s ease-in 3.05s both;
}
.sp-stage { position: relative; display: flex; flex-direction: column; align-items: center; padding: 16px; }

/* ذرات ضوء تصعد كغبار في شعاع قنديل */
.sp-motes { position: absolute; inset: 0; pointer-events: none; }
.sp-motes i {
  position: absolute; bottom: -10px; width: 4px; height: 4px; border-radius: 50%;
  background: #f0cf85; box-shadow: 0 0 8px 2px rgba(240, 207, 133, .55); opacity: 0;
  animation: sp-mote 3.4s ease-in var(--d) both;
}

.sp-logo { width: var(--sw); height: var(--sw); overflow: visible; filter: drop-shadow(0 0 calc(var(--sw) * .12) rgba(240, 207, 133, .35)); }
.sp-star rect { stroke-dasharray: 210; stroke-dashoffset: 210; animation: sp-draw .7s cubic-bezier(.6, 0, .3, 1) both; }
.sp-star rect + rect { animation-delay: .12s; }
.sp-lamp { transform-origin: 60px 39px; animation: sp-lamp .6s cubic-bezier(.2, 1.4, .4, 1) .35s both; }
.sp-halo { transform-origin: 60px 39px; animation: sp-halo 1.6s ease-out .45s both; }
.sp-pg-r, .sp-pg-l { transform-box: view-box; transform-origin: 60px 80px; }
.sp-pg-r { animation: sp-open .8s cubic-bezier(.2, .9, .25, 1) .45s both; }
.sp-pg-l { animation: sp-open .8s cubic-bezier(.2, .9, .25, 1) .55s both; }
.sp-lines path { stroke-dasharray: 32; stroke-dashoffset: 32; animation: sp-draw .35s ease-out both; }
.sp-lines path:nth-child(1) { animation-delay: 1.00s; } .sp-lines path:nth-child(4) { animation-delay: 1.00s; }
.sp-lines path:nth-child(2) { animation-delay: 1.08s; } .sp-lines path:nth-child(5) { animation-delay: 1.08s; }
.sp-lines path:nth-child(3) { animation-delay: 1.16s; } .sp-lines path:nth-child(6) { animation-delay: 1.16s; }
.sp-spine { stroke-dasharray: 42; stroke-dashoffset: 42; animation: sp-draw .4s ease-out .5s both; }
.sp-mark { transform-box: fill-box; transform-origin: 50% 0; animation: sp-mark .5s cubic-bezier(.3, 1.5, .5, 1) 1.2s both; }
.sp-shine { animation: sp-shine .75s ease-in-out 2.55s both; }

.sp-title {
  font-family: "Aref Ruqaa", "Amiri", serif; font-weight: 700;
  font-size: calc(var(--sw) * .44); line-height: 1.25; margin-top: calc(var(--sw) * .02);
  background: linear-gradient(180deg, #f7e2ad, #d9ad52 70%, #b8892f);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding: 0 .15em;
  animation: sp-write .85s cubic-bezier(.45, .05, .35, 1) 1.15s both;
}
.sp-line {
  width: calc(var(--sw) * 1.1); height: 2px; border-radius: 2px; margin-top: calc(var(--sw) * .04);
  background: linear-gradient(90deg, rgba(240, 207, 133, 0), #f0cf85 50%, rgba(240, 207, 133, 0));
  box-shadow: 0 0 14px rgba(240, 207, 133, .5);
  animation: sp-line .5s ease-out 1.85s both;
}
.sp-tag { font-family: "Tajawal", system-ui, sans-serif; font-weight: 700; color: #f7ecd2; font-size: max(14px, calc(var(--sw) * .095)); margin-top: calc(var(--sw) * .07); animation: sp-rise .5s ease-out 2.0s both; }
.sp-verse { font-family: "Amiri", serif; color: rgba(247, 236, 210, .72); font-size: max(13px, calc(var(--sw) * .085)); margin-top: 6px; animation: sp-rise .55s ease-out 2.3s both; }
.sp-skip { position: absolute; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; font: 500 12px "Tajawal", sans-serif; color: rgba(247, 236, 210, .45); animation: sp-rise .4s ease-out 1.4s both; }

@keyframes sp-draw { to { stroke-dashoffset: 0; } }
@keyframes sp-lamp { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sp-halo { 0% { transform: scale(.2); opacity: 0; } 35% { opacity: .9; } 100% { transform: scale(2.6); opacity: 0; } }
@keyframes sp-open { from { transform: scaleX(0); opacity: .4; } to { transform: scaleX(1); opacity: 1; } }
@keyframes sp-mark { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes sp-shine { 0% { transform: translateX(-140px); opacity: 0; } 20%, 80% { opacity: 1; } 100% { transform: translateX(140px); opacity: 0; } }
@keyframes sp-write { from { clip-path: inset(0 0 0 100%); filter: blur(2px); } to { clip-path: inset(0 0 0 0); filter: blur(0); } }
@keyframes sp-line { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sp-mote { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: .9; } 100% { opacity: 0; transform: translate(var(--x), -78vh) scale(1.1); } }
@keyframes sp-drift { from { transform: translateY(0); } to { transform: translateY(-40px); } }
@keyframes sp-edge { 0% { opacity: 0; } 30% { opacity: .9; } 100% { opacity: 0; } }
@keyframes sp-out {
  0% { transform: perspective(1400px) rotateY(0); opacity: 1; visibility: visible; filter: brightness(1); }
  70% { opacity: 1; filter: brightness(.7); }
  100% { transform: perspective(1400px) rotateY(105deg); opacity: 0; visibility: hidden; pointer-events: none; filter: brightness(.5); }
}
/* الصفحة خلف الشاشة تنتظر ثم تظهر مع القلب */
html.splash-on:not(.splash-leaving) #app { opacity: 0; }
html.splash-leaving #app { animation: sp-app .7s ease-out both; }
@keyframes sp-app { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

/* تخطٍّ باللمس */
html.splash-on .splash.is-skipped { animation: sp-out .42s cubic-bezier(.55, 0, .75, .3) both; }

@media (prefers-reduced-motion: reduce) {
  html.splash-on .splash { animation: sp-fade .3s ease 1.1s both; }
  .splash *, .splash::before, .splash::after { animation: none !important; }
  .sp-star rect, .sp-lines path, .sp-spine { stroke-dashoffset: 0; }
  .sp-halo, .sp-motes, .sp-shine { display: none; }
  html.splash-on:not(.splash-leaving) #app { opacity: 1; }
  @keyframes sp-fade { to { opacity: 0; visibility: hidden; } }
}
