/* Halal Scroll — Design System & Tactile UI Styles */

[data-theme="midnight_sanctuary"] {
  --bg-canvas-start: #090A0F;
  --bg-canvas-end: #12151E;
  --bg-ambient-1: rgba(212, 175, 55, 0.14);
  --bg-ambient-2: rgba(16, 185, 129, 0.10);
  --bg-ambient-3: rgba(99, 102, 241, 0.08);
  --surface-glass: rgba(22, 26, 36, 0.78);
  --surface-glass-heavy: rgba(16, 19, 28, 0.94);
  --surface-card: rgba(255, 255, 255, 0.045);
  --surface-card-hover: rgba(255, 255, 255, 0.08);
  --border-specular: rgba(255, 255, 255, 0.09);
  --border-gold: rgba(212, 175, 55, 0.35);
  --text-primary: #F4F1EA;
  --text-secondary: #B8B4AA;
  --text-muted: #7E7B72;
  --accent-gold: #D4AF37;
  --accent-gold-bright: #F5D061;
  --accent-emerald: #10B981;
  --sacred-quran-color: #A7F3D0;
  --sacred-hadith-color: #FCA5A5;
  --sacred-dua-color: #FDE68A;
  --active-word-text: #FFFFFF;
  --active-word-bg: rgba(212, 175, 55, 0.42);
  --active-word-border: #F5D061;
  --hl-allah-text: #FFFBEB;
  --hl-allah-bg: rgba(217, 119, 6, 0.38);
  --hl-allah-border: #FBBF24;
  --hl-prophet-text: #FFF1F2;
  --hl-prophet-bg: rgba(225, 29, 72, 0.36);
  --hl-prophet-border: #FB7185;
  --hl-mercy-text: #ECFDF5;
  --hl-mercy-bg: rgba(5, 150, 105, 0.38);
  --hl-mercy-border: #34D399;
  --hl-sabr-text: #EFF6FF;
  --hl-sabr-bg: rgba(37, 99, 235, 0.38);
  --hl-sabr-border: #60A5FA;
  --hl-akhirah-text: #F5F3FF;
  --hl-akhirah-bg: rgba(124, 58, 237, 0.38);
  --hl-akhirah-border: #A78BFA;
  --hl-custom-text: #FFFBEB;
  --hl-custom-bg: rgba(202, 138, 4, 0.38);
  --hl-custom-border: #FACC15;
  --shadow-elevated: 0 24px 60px rgba(0, 0, 0, 0.65);
}

:root,
[data-theme="andalusian_parchment"] {
  --bg-canvas-start: #FAF6EE;
  --bg-canvas-end: #F2ECE1;
  --bg-ambient-1: rgba(186, 142, 42, 0.14);
  --bg-ambient-2: rgba(16, 140, 98, 0.09);
  --bg-ambient-3: rgba(217, 119, 6, 0.07);
  --surface-glass: rgba(250, 246, 238, 0.84);
  --surface-glass-heavy: rgba(246, 240, 229, 0.96);
  --surface-card: rgba(24, 24, 27, 0.045);
  --surface-card-hover: rgba(24, 24, 27, 0.08);
  --border-specular: rgba(24, 24, 27, 0.10);
  --border-gold: rgba(168, 125, 32, 0.35);
  --text-primary: #18181B;
  --text-secondary: #525049;
  --text-muted: #78756C;
  --accent-gold: #A87D20;
  --accent-gold-bright: #92400E;
  --accent-emerald: #0D9468;
  --sacred-quran-color: #065F46;
  --sacred-hadith-color: #991B1B;
  --sacred-dua-color: #92400E;
  --active-word-text: #451A03;
  --active-word-bg: rgba(245, 158, 11, 0.34);
  --active-word-border: #D97706;
  --hl-allah-text: #78350F;
  --hl-allah-bg: rgba(245, 158, 11, 0.26);
  --hl-allah-border: rgba(180, 83, 9, 0.65);
  --hl-prophet-text: #881337;
  --hl-prophet-bg: rgba(225, 29, 72, 0.18);
  --hl-prophet-border: rgba(190, 18, 60, 0.55);
  --hl-mercy-text: #064E3B;
  --hl-mercy-bg: rgba(16, 185, 129, 0.22);
  --hl-mercy-border: rgba(4, 120, 87, 0.55);
  --hl-sabr-text: #1E3A8A;
  --hl-sabr-bg: rgba(59, 130, 246, 0.20);
  --hl-sabr-border: rgba(29, 78, 216, 0.55);
  --hl-akhirah-text: #4C1D95;
  --hl-akhirah-bg: rgba(139, 92, 246, 0.20);
  --hl-akhirah-border: rgba(109, 40, 217, 0.55);
  --hl-custom-text: #713F12;
  --hl-custom-bg: rgba(234, 179, 8, 0.28);
  --hl-custom-border: rgba(161, 98, 7, 0.6);
  --shadow-elevated: 0 20px 50px rgba(45, 38, 24, 0.16);
}

[data-theme="fajr_dawn"] {
  --bg-canvas-start: #0D1021;
  --bg-canvas-end: #1D1833;
  --bg-ambient-1: rgba(244, 114, 182, 0.15);
  --bg-ambient-2: rgba(129, 140, 248, 0.14);
  --bg-ambient-3: rgba(212, 175, 55, 0.12);
  --surface-glass: rgba(23, 22, 43, 0.80);
  --surface-glass-heavy: rgba(17, 16, 34, 0.95);
  --surface-card: rgba(255, 255, 255, 0.055);
  --surface-card-hover: rgba(255, 255, 255, 0.09);
  --border-specular: rgba(255, 255, 255, 0.11);
  --border-gold: rgba(244, 180, 96, 0.38);
  --text-primary: #F7F4EF;
  --text-secondary: #C7C2D6;
  --text-muted: #8E88A6;
  --accent-gold: #E5B869;
  --accent-gold-bright: #F7D488;
  --accent-emerald: #34D399;
  --sacred-quran-color: #A7F3D0;
  --sacred-hadith-color: #FCA5A5;
  --sacred-dua-color: #FDE68A;
  --active-word-text: #FFFFFF;
  --active-word-bg: rgba(212, 175, 55, 0.42);
  --active-word-border: #F7D488;
  --hl-allah-text: #FFFBEB;
  --hl-allah-bg: rgba(217, 119, 6, 0.38);
  --hl-allah-border: #FBBF24;
  --hl-prophet-text: #FFF1F2;
  --hl-prophet-bg: rgba(225, 29, 72, 0.36);
  --hl-prophet-border: #FB7185;
  --hl-mercy-text: #ECFDF5;
  --hl-mercy-bg: rgba(5, 150, 105, 0.38);
  --hl-mercy-border: #34D399;
  --hl-sabr-text: #EFF6FF;
  --hl-sabr-bg: rgba(37, 99, 235, 0.38);
  --hl-sabr-border: #60A5FA;
  --hl-akhirah-text: #F5F3FF;
  --hl-akhirah-bg: rgba(124, 58, 237, 0.38);
  --hl-akhirah-border: #A78BFA;
  --hl-custom-text: #FFFBEB;
  --hl-custom-bg: rgba(202, 138, 4, 0.38);
  --hl-custom-border: #FACC15;
  --shadow-elevated: 0 24px 60px rgba(5, 6, 18, 0.70);
}

[data-theme="maghrib_dusk"] {
  --bg-canvas-start: #140D18;
  --bg-canvas-end: #24141E;
  --bg-ambient-1: rgba(245, 158, 11, 0.16);
  --bg-ambient-2: rgba(225, 29, 72, 0.12);
  --bg-ambient-3: rgba(139, 92, 246, 0.11);
  --surface-glass: rgba(32, 20, 29, 0.82);
  --surface-glass-heavy: rgba(24, 14, 22, 0.96);
  --surface-card: rgba(255, 255, 255, 0.055);
  --surface-card-hover: rgba(255, 255, 255, 0.09);
  --border-specular: rgba(255, 255, 255, 0.10);
  --border-gold: rgba(245, 158, 11, 0.38);
  --text-primary: #F8F3EC;
  --text-secondary: #D1C3BD;
  --text-muted: #9A8881;
  --accent-gold: #F59E0B;
  --accent-gold-bright: #FBBF24;
  --accent-emerald: #10B981;
  --sacred-quran-color: #A7F3D0;
  --sacred-hadith-color: #FCA5A5;
  --sacred-dua-color: #FDE68A;
  --active-word-text: #FFFFFF;
  --active-word-bg: rgba(212, 175, 55, 0.42);
  --active-word-border: #FBBF24;
  --hl-allah-text: #FFFBEB;
  --hl-allah-bg: rgba(217, 119, 6, 0.38);
  --hl-allah-border: #FBBF24;
  --hl-prophet-text: #FFF1F2;
  --hl-prophet-bg: rgba(225, 29, 72, 0.36);
  --hl-prophet-border: #FB7185;
  --hl-mercy-text: #ECFDF5;
  --hl-mercy-bg: rgba(5, 150, 105, 0.38);
  --hl-mercy-border: #34D399;
  --hl-sabr-text: #EFF6FF;
  --hl-sabr-bg: rgba(37, 99, 235, 0.38);
  --hl-sabr-border: #60A5FA;
  --hl-akhirah-text: #F5F3FF;
  --hl-akhirah-bg: rgba(124, 58, 237, 0.38);
  --hl-akhirah-border: #A78BFA;
  --hl-custom-text: #FFFBEB;
  --hl-custom-bg: rgba(202, 138, 4, 0.38);
  --hl-custom-border: #FACC15;
  --shadow-elevated: 0 24px 60px rgba(10, 4, 12, 0.72);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body, #root {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas-start);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* App Shell & Responsive Viewport */
.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, var(--bg-ambient-1), transparent 55%),
              radial-gradient(circle at 80% 75%, var(--bg-ambient-2), transparent 55%),
              linear-gradient(165deg, var(--bg-canvas-start), var(--bg-canvas-end));
  transition: background 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Film Grain Overlay Disabled for Crisp Retina Sharpness */
.film-grain {
  display: none;
}

/* Main Mobile-First Sanctuary Frame + Optional Desktop Inspector Rail */
.sanctuary-stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-canvas-start) 0%, var(--bg-canvas-end) 100%);
  box-shadow: var(--shadow-elevated);
  border-left: 1px solid var(--border-specular);
  border-right: 1px solid var(--border-specular);
  z-index: 3;
}

@media (min-width: 1080px) {
  .sanctuary-stage {
    height: 94vh;
    max-height: 920px;
    border-radius: 38px;
    border: 1px solid var(--border-specular);
  }
}

/* Slow-breathing ambient shader mesh inside the active card */
@keyframes breatheMesh {
  0%, 100% {
    transform: scale(1) translate(0px, 0px);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.12) translate(8px, -12px);
    opacity: 1;
  }
}

.ambient-mesh {
  position: absolute;
  inset: -15%;
  pointer-events: none;
  background:
    radial-gradient(circle at 30% 28%, var(--bg-ambient-1), transparent 50%),
    radial-gradient(circle at 72% 65%, var(--bg-ambient-2), transparent 52%),
    radial-gradient(circle at 50% 50%, var(--bg-ambient-3), transparent 60%);
  filter: blur(32px);
  animation: breatheMesh 11s ease-in-out infinite;
  z-index: 0;
}

/* Frosted Glass Surfaces */
.glass-pill {
  background: var(--surface-glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-top: 1px solid var(--border-specular);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

/* Vertical Snap Scroll Feed Container */
.vertical-feed {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  z-index: 1;
}

.vertical-feed::-webkit-scrollbar {
  display: none;
}

.feed-card-snap {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px max(18px, calc(10px + env(safe-area-inset-bottom, 0px))) 18px;
  overflow: hidden;
  user-select: none;
}

/* TikTok / Instagram Reels Scroll Physics & Staggered Card Reveal */
.card-content-cluster {
  width: 100%;
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 2px 6px 8px 6px;
  overflow-y: hidden;
  transform-origin: center top;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.40s cubic-bezier(0.22, 1, 0.36, 1);
}

.card-content-cluster::-webkit-scrollbar {
  width: 3px;
}
.card-content-cluster::-webkit-scrollbar-track {
  background: transparent;
}
.card-content-cluster::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.35);
  border-radius: 999px;
}

.feed-card-snap.card-inactive .card-content-cluster {
  transform: translateY(18px);
  opacity: 0.35;
}

.feed-card-snap.card-active .card-content-cluster {
  transform: translateY(0);
  opacity: 1;
}

/* Staggered inner elements on active snap */
.reel-anim-meta,
.reel-anim-arabic,
.reel-anim-translation,
.reel-anim-dock {
  transition:
    transform 0.45s cubic-bezier(0.19, 1, 0.22, 1),
    opacity 0.40s cubic-bezier(0.19, 1, 0.22, 1);
}

.feed-card-snap.card-inactive .reel-anim-meta {
  transform: translateY(12px);
  opacity: 0;
}
.feed-card-snap.card-active .reel-anim-meta {
  transform: translateY(0);
  opacity: 1;
  transition-delay: 0.03s;
}

.feed-card-snap.card-inactive .reel-anim-arabic {
  transform: translateY(16px);
  opacity: 0;
}
.feed-card-snap.card-active .reel-anim-arabic {
  transform: translateY(0);
  opacity: 1;
  transition-delay: 0.08s;
}

.feed-card-snap.card-inactive .reel-anim-translation {
  transform: translateY(18px);
  opacity: 0;
}
.feed-card-snap.card-active .reel-anim-translation {
  transform: translateY(0);
  opacity: 1;
  transition-delay: 0.14s;
}

.reel-anim-dock {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 8px;
  position: relative;
  z-index: 15;
}

.feed-card-snap.card-inactive .reel-anim-dock {
  transform: translateY(20px);
  opacity: 0.25;
}
.feed-card-snap.card-active .reel-anim-dock {
  transform: translateY(0);
  opacity: 1;
  transition-delay: 0.18s;
}

/* Ambient Swipe Glow Burst on Card Snap */
@keyframes cardSnapAura {
  0% {
    opacity: 0;
    transform: scale(0.82);
  }
  40% {
    opacity: 0.55;
  }
  100% {
    opacity: 0;
    transform: scale(1.25);
  }
}

.feed-card-snap.card-active::before {
  content: "";
  position: absolute;
  top: 18%;
  left: 50%;
  width: 260px;
  height: 260px;
  margin-left: -130px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--bg-ambient-1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: cardSnapAura 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Double-Tap Bookmark Burst (TikTok / Reels Style) */
@keyframes doubleTapBurst {
  0% {
    transform: translate(-50%, -50%) scale(0.2) rotate(-12deg);
    opacity: 0;
  }
  30% {
    transform: translate(-50%, -50%) scale(1.25) rotate(6deg);
    opacity: 1;
  }
  55% {
    transform: translate(-50%, -55%) scale(1.0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -85%) scale(1.35) rotate(0deg);
    opacity: 0;
  }
}

.double-tap-burst {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  color: var(--accent-gold-bright);
  filter: drop-shadow(0 8px 24px rgba(212, 175, 55, 0.65));
  animation: doubleTapBurst 0.82s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Subtle Upward Swipe Hint Bounce */
@keyframes swipeHintFloat {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50% { transform: translateY(-4px); opacity: 0.95; }
}

.swipe-hint-indicator {
  animation: swipeHintFloat 2.4s ease-in-out infinite;
}

/* Editorial Typography Pairing */
.arabic-sacred-text {
  direction: rtl;
  width: 100%;
  font-family: "KFGQPC Uthman Taha Naskh", "Amiri Quran", "Scheherazade New", "Geeza Pro", "Traditional Arabic", serif;
  line-height: 1.82;
  letter-spacing: 0;
  text-align: center;
  color: var(--text-primary);
  margin: 4px 0 4px 0;
}

.arabic-word-token {
  display: inline;
  padding: 1px 3px;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              background-color 0.22s ease,
              text-shadow 0.22s ease;
}

.arabic-word-token:hover {
  color: var(--accent-gold-bright);
  background: rgba(212, 175, 55, 0.12);
}

.arabic-word-token.active-word-glow {
  color: var(--active-word-text) !important;
  background: var(--active-word-bg) !important;
  box-shadow: 0 0 0 1.5px var(--active-word-border);
  font-weight: 700;
}

.editorial-translation {
  font-family: "Newsreader", "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-weight: 400;
  line-height: 1.56;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.01em;
}

.transliteration-text {
  font-family: -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", sans-serif;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-secondary);
  text-align: center;
  font-style: italic;
  opacity: 0.88;
}

/* Deep Study Shimmer Button */
@keyframes shimmerBorder {
  0%, 100% { border-color: rgba(212, 175, 55, 0.32); }
  50% { border-color: rgba(245, 208, 97, 0.72); }
}

.deep-study-cta {
  animation: shimmerBorder 3.5s ease-in-out infinite;
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}

.deep-study-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.22);
}

.deep-study-cta:active {
  transform: scale(0.97);
}

/* Circular Audio Waveform Ring */
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(212, 175, 55, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

.audio-playing-ring {
  animation: pulseRing 1.8s infinite;
  border-color: var(--accent-gold-bright) !important;
}

/* Spring Bottom Sheet & Modals */
.spring-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 10, 0.62);
  backdrop-filter: blur(6px);
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  animation: fadeIn 0.22s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUpSpring {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.spring-sheet-panel {
  width: 100%;
  background: var(--surface-glass-heavy);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border-top: 1px solid var(--border-gold);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.65);
  animation: slideUpSpring 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

/* Custom Scrollbars inside Drawers */
.drawer-scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 175, 55, 0.3) transparent;
}

.drawer-scroll::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.drawer-scroll::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 999px;
}

.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

