/* ============================================================
   Islamic eBook Library — V7 Cinematic Animation Edition
   Scoped exclusively to the public homepage (index.html).
   Layered atop public-v6.css so authenticated V3/V4 UI remains
   completely untouched. Uses GPU-friendly transform & opacity.
   ============================================================ */

/* ---------- 1. Night Sky Multi-Layer Depth ---------- */
.star--gold {
  box-shadow: 0 0 10px 2px rgba(242, 217, 141, 0.72);
}

@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .star--deep {
    animation: twinkle 4.2s ease-in-out infinite, v7StarDrift 26s ease-in-out infinite alternate;
  }
}

/* ---------- 2. Golden Crescent Moon Breathing Halo ---------- */
.moon {
  position: absolute;
}
.moon::before {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 217, 141, 0.34) 0%, rgba(212, 175, 55, 0.12) 48%, transparent 72%);
  pointer-events: none;
  z-index: -1;
  animation: v7MoonHalo 6.5s ease-in-out infinite;
}

/* ---------- 3. Islamic Arch Reveal & Soft Feathered Shimmer ---------- */
.hero-arch {
  overflow: visible;
  animation: v7ArchReveal 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero-arch::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 62% 54% at 50% 42%,
    rgba(255, 245, 208, 0.22) 0%,
    rgba(247, 231, 180, 0.1) 48%,
    transparent 74%
  );
  -webkit-mask-image: url('/assets/images/reference-ui/arch.svg');
  mask-image: url('/assets/images/reference-ui/arch.svg');
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  opacity: 0;
  animation: v7ArchShimmer 8.5s ease-in-out 1.1s infinite;
}

/* ---------- 4. Hanging Lanterns Sway & Warm Flame Pulse ---------- */
.hero-lantern--left {
  animation: v7LanternSwayLeft 6.8s ease-in-out infinite;
}
.hero-lantern--right {
  animation: v7LanternSwayRight 8.2s ease-in-out -3.1s infinite;
}
.lantern-flame {
  transform-box: fill-box;
  transform-origin: center;
  animation: v7LanternFlame 3.8s ease-in-out infinite;
}
.lantern-flame--alt {
  animation: v7LanternFlame 4.6s ease-in-out -1.8s infinite;
}

/* ---------- 5. Mosque Silhouette Golden Window Illumination ---------- */
.v7-mosque-glow {
  display: none;
  position: absolute;
  z-index: 1;
  top: 230px;
  width: 240px;
  height: 92px;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255, 207, 114, 0.28) 0%, rgba(212, 175, 55, 0.1) 46%, transparent 74%);
  animation: v7WindowPulse 5.6s ease-in-out infinite;
}
.v7-mosque-glow--left {
  left: 6%;
}
.v7-mosque-glow--right {
  right: 6%;
  animation-delay: -2.6s;
}

/* ---------- 6. Golden Curved Horizon Traveling Highlight ---------- */
.v7-horizon-glint {
  display: none;
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: 325px;
  height: 110px;
  pointer-events: none;
  overflow: visible;
}
.v7-horizon-glint::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 44% 38% at 50% 56%,
    rgba(255, 242, 194, 0.18) 0%,
    rgba(247, 231, 180, 0.06) 52%,
    transparent 74%
  );
  transform: translateX(-35%);
  animation: v7HorizonSweep 10s ease-in-out 1.4s infinite;
}

@media (min-width: 1024px) {
  .v7-mosque-glow,
  .v7-horizon-glint {
    display: block;
  }
}

/* ---------- 7. Arabic Bismillah & Staggered Hero Typography ---------- */
.hero-arabic {
  animation: v7HeroRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.04s both;
}
.hero-eyebrow {
  animation: v7HeroRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}
.hero h1 {
  animation: v7HeroRise 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
}
.hero-sub {
  animation: v7HeroRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both;
}
.hero-ctas {
  animation: v7HeroRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both;
}
.hero-search {
  animation: v7HeroRise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.34s both;
}

/* ---------- 8. Interactive Microanimations ---------- */
/* Navigation smooth hover underline */
.site-nav-link {
  position: relative;
}
.site-nav-link::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 4px;
  height: 1.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--v6-gold-champagne), transparent);
  transform: scaleX(0);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.24s ease;
}
.site-nav-link:hover::after,
.site-nav-link.is-active::after {
  transform: scaleX(1);
  opacity: 0.85;
}

/* Premium CTA hover shine */
.btn-hero-primary,
.btn-hero-secondary,
.hero-ctas .hero-upload-btn {
  position: relative;
  overflow: hidden;
}
.btn-hero-primary::after,
.btn-hero-secondary::after,
.hero-ctas .hero-upload-btn::after {
  content: '';
  position: absolute;
  top: -20%;
  left: -60%;
  width: 44%;
  height: 140%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: skewX(-20deg) translateX(0);
  pointer-events: none;
  opacity: 0;
}
@media (hover: hover) and (pointer: fine) {
  .btn-hero-primary:hover::after,
  .btn-hero-secondary:hover::after,
  .hero-ctas .hero-upload-btn:hover::after {
    opacity: 1;
    animation: v7CtaShine 0.7s ease forwards;
  }
}

/* Search field focus glow */
.hs-field {
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}
.hs-field:focus-within {
  transform: translateY(-1px);
  border-color: var(--v6-gold-champagne);
  box-shadow:
    0 14px 34px rgba(6, 2, 14, 0.58),
    0 0 0 3px rgba(212, 175, 55, 0.24),
    0 0 24px rgba(212, 175, 55, 0.18);
}

/* Statistics staggered entrance */
.stat-card {
  animation: v7HeroRise 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.stat-card:nth-child(1) { animation-delay: 0.36s; }
.stat-card:nth-child(2) { animation-delay: 0.42s; }
.stat-card:nth-child(3) { animation-delay: 0.48s; }

/* Book-card subtle 3D tilt & gold border hover on fine pointer devices */
@media (hover: hover) and (pointer: fine) {
  .book-card {
    transform: perspective(900px) rotateX(var(--v7-rx, 0deg)) rotateY(var(--v7-ry, 0deg)) translateY(0);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.26s ease, border-color 0.26s ease;
  }
  .book-card:hover {
    transform: perspective(900px) rotateX(var(--v7-rx, 0deg)) rotateY(var(--v7-ry, 0deg)) translateY(-5px);
    border-color: rgba(247, 231, 180, 0.68);
    box-shadow: 0 20px 42px rgba(4, 1, 10, 0.64), 0 0 0 1px rgba(242, 217, 141, 0.42);
  }
}

/* Smooth cover-image entrance */
.book-cover.v7-cover-pending {
  opacity: 0;
}
.book-cover.v7-cover-ready {
  opacity: 1;
  transition: opacity 0.35s ease, transform 0.3s ease;
}

/* Lightweight Back-to-Top Control */
.v7-back-to-top {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(242, 217, 141, 0.55);
  background: rgba(29, 13, 49, 0.9);
  color: var(--v6-gold-champagne);
  box-shadow: 0 10px 26px rgba(4, 1, 10, 0.55);
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease, border-color 0.2s ease;
}
.v7-back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.v7-back-to-top:hover {
  background: rgba(54, 27, 86, 0.96);
  border-color: #f7e7b4;
}

/* ---------- Keyframes (Transform & Opacity Only) ---------- */
@keyframes v7StarDrift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(8px, -10px, 0); }
}

@keyframes v7MoonHalo {
  0%, 100% { transform: scale(0.96); opacity: 0.72; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes v7ArchReveal {
  from { opacity: 0; transform: translateX(-50%) scale(0.97); }
  to { opacity: 0.72; transform: translateX(-50%) scale(1); }
}

@keyframes v7ArchShimmer {
  0%, 100% { opacity: 0.18; transform: scale(0.99); }
  50% { opacity: 0.72; transform: scale(1.01); }
}

@keyframes v7LanternSwayLeft {
  0%, 100% { transform: rotate(-1.8deg); }
  50% { transform: rotate(1.8deg); }
}

@keyframes v7LanternSwayRight {
  0%, 100% { transform: rotate(1.5deg); }
  50% { transform: rotate(-1.6deg); }
}

@keyframes v7LanternFlame {
  0%, 100% { opacity: 0.58; transform: scaleY(0.96); }
  50% { opacity: 0.88; transform: scaleY(1.06); }
}

@keyframes v7WindowPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.72; }
}

@keyframes v7HorizonSweep {
  0%, 100% { transform: translateX(-30%); opacity: 0.25; }
  50% { transform: translateX(30%); opacity: 0.85; }
}

@keyframes v7HeroRise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes v7CtaShine {
  from { transform: skewX(-20deg) translateX(0); }
  to { transform: skewX(-20deg) translateX(420%); }
}

/* ---------- Mobile Performance Guard (<= 767px) ---------- */
@media (max-width: 767px) {
  .hero-arch::after,
  .moon::before,
  .v7-mosque-glow,
  .v7-horizon-glint {
    animation: none !important;
  }
  .hero-arch {
    animation: none;
  }
}

/* ---------- Tab-Hidden Pause ---------- */
.is-tab-hidden .hero-arch::after,
.is-tab-hidden .moon::before,
.is-tab-hidden .hero-lantern,
.is-tab-hidden .lantern-flame,
.is-tab-hidden .v7-mosque-glow,
.is-tab-hidden .v7-horizon-glint::before,
.is-tab-hidden .star--deep {
  animation-play-state: paused !important;
}

/* ---------- Full Reduced-Motion Safety ---------- */
@media (prefers-reduced-motion: reduce) {
  .star--deep,
  .moon::before,
  .hero-arch,
  .hero-arch::after,
  .hero-lantern,
  .lantern-flame,
  .v7-mosque-glow,
  .v7-horizon-glint::before,
  .hero-arabic,
  .hero-eyebrow,
  .hero h1,
  .hero-sub,
  .hero-ctas,
  .hero-search,
  .stat-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .hero-arch {
    transform: translateX(-50%) !important;
  }
  .book-card,
  .book-cover,
  .v7-back-to-top,
  .site-nav-link::after {
    transition-duration: 0.01ms !important;
    transform: none !important;
  }
}
