/* ========================================================
   NoSFX Quran - Design System & Custom Stylesheet
   Website: nosfx.com
   Slogan: "استمع بهدوء واخشع"
   Theme: Spiritual Deep Navy, Glassmorphism & Gold Accents
   ======================================================== */

:root {
  --bg-primary: #061024;
  --bg-secondary: #0a1b3d;
  --bg-card: rgba(10, 27, 61, 0.65);
  --bg-card-hover: rgba(15, 39, 87, 0.75);
  --border-glass: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(96, 165, 250, 0.65);
  --accent-blue: #3b82f6;
  --accent-gold: #fbbf24;
  --accent-emerald: #10b981;
  --text-primary: #ffffff;
  --text-secondary: rgba(224, 231, 255, 0.82);
  --text-muted: rgba(147, 197, 253, 0.6);
  --app-height: 100%;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

footer {
  margin-top: auto !important;
}

/* Background Atmospheric Layer */
.bg-image-layer {
  background-image: url('https://i.imgur.com/axnh9Cg.jpeg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  animation: slowBgScale 28s ease-out forwards;
  will-change: transform;
}

@keyframes slowBgScale {
  0% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* Glassmorphism Classes */
.glass-panel {
  background: rgba(10, 25, 56, 0.62);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.glass-card {
  background: rgba(12, 30, 68, 0.52);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card:hover {
  background: rgba(20, 48, 107, 0.65);
  border-color: rgba(147, 197, 253, 0.35);
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
}

.glass-input-wrapper {
  background: rgba(10, 25, 56, 0.58);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  transition: all 0.25s ease;
}

.glass-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(6, 16, 36, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(96, 165, 250, 0.25);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(96, 165, 250, 0.5);
}

/* Navigation Link Active State */
.nav-link {
  position: relative;
  transition: all 0.2s ease;
}

.nav-link.active {
  color: #60a5fa !important;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 2.5px;
  background: #60a5fa;
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(96, 165, 250, 0.8);
}

/* Language Slider */
.lang-slider-track {
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.lang-slider-track::-webkit-scrollbar {
  display: none;
}

.lang-pill {
  background: rgba(15, 34, 74, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.2s ease;
}
.lang-pill:hover {
  background: rgba(30, 64, 130, 0.55);
  border-color: rgba(147, 197, 253, 0.4);
}
.lang-pill.active {
  background: rgba(37, 99, 235, 0.85);
  border-color: rgba(147, 197, 253, 0.85);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.45);
  transform: translateY(-1px);
}

/* Switch Toggle - مع مؤثرات */
.effects-toggle-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(30, 58, 110, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 3px;
  background-color: #94a3b8;
  transition: .3s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

input:checked + .toggle-slider {
  background-color: #2563eb;
  border-color: #60a5fa;
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.6);
}

input:checked + .toggle-slider:before {
  transform: translateX(23px);
  background-color: #ffffff;
}

/* Floating Audio Player Dock */
.player-dock {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(6, 18, 43, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  padding: 0.6rem 1rem max(0.6rem, env(safe-area-inset-bottom)) 1rem;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.player-dock.hidden-player {
  transform: translateY(115%);
  pointer-events: none;
}

/* Audio Scrubber (RTL: fills and scrubs from right to left) */
.audio-scrubber {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
  direction: rtl;
  transition: height 0.15s ease;
}

.audio-scrubber:hover {
  height: 8px;
}

.audio-scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #60a5fa;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.9);
  transition: transform 0.15s ease;
}

.audio-scrubber::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.audio-scrubber::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #60a5fa;
  border: 2px solid #ffffff;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.9);
}

.audio-scrubber::-moz-range-progress {
  background: #3b82f6;
  border-radius: 999px;
  height: 6px;
}

/* Playing Animation Waves */
.sound-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 16px;
}

.sound-bar {
  width: 3px;
  background: #60a5fa;
  border-radius: 3px;
  animation: barBounce 1.2s ease-in-out infinite alternate;
}

.sound-bar:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.sound-bar:nth-child(2) { height: 14px; animation-delay: 0.3s; }
.sound-bar:nth-child(3) { height: 9px; animation-delay: 0.2s; }
.sound-bar:nth-child(4) { height: 16px; animation-delay: 0.4s; }

@keyframes barBounce {
  0% { height: 4px; }
  100% { height: 16px; }
}

/* Modal Styling */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 9, 23, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: rgba(10, 25, 56, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}

/* Athkar Tap Counter Ripple */
.thikr-tap-btn {
  transition: transform 0.1s ease, background-color 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}
.thikr-tap-btn:active {
  transform: scale(0.97);
}

/* Tooltip / Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

/* Safe Area Padding for mobile browsers */
.safe-pb {
  padding-bottom: max(6rem, calc(env(safe-area-inset-bottom) + 5.5rem));
}

/* ========================================================
   Lightweight, Non-Heavy Animations (Works on Old Mobiles)
   Using only GPU-accelerated opacity & transform
   ======================================================== */

@keyframes smoothFadeIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Views end with no transform: a lingering transform would turn every
   position: fixed child (fullscreen mode, floating buttons) into section-relative */
@keyframes viewFadeIn {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes subtlePulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(0.96);
  }
}

.app-view:not(.hidden) {
  animation: viewFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-fade-in {
  animation: smoothFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform;
}

.reciter-card-anim {
  animation: smoothFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: opacity, transform;
}

/* Micro-feedback on interactive buttons without layout recalculation */
button:active, 
.interactive-tap:active {
  transform: scale(0.97);
}

/* Respect user's motion preferences or battery saving */
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ========================================================
   PayPal Container Contrast Fix (Prevent White-on-White)
   ======================================================== */
.paypal-solid-card {
  background: #ffffff !important;
  border: 1px solid rgba(226, 232, 240, 0.95) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45) !important;
  color: #0f172a !important;
  border-radius: 24px !important;
  width: 100% !important;
  max-width: 440px !important;
  margin: 0 auto !important;
}

.paypal-solid-card label,
.paypal-solid-card p,
.paypal-solid-card span {
  color: #0f172a !important;
}

#paypal-container-QXDLZPHD339EN {
  width: 100% !important;
  min-width: 100% !important;
  display: block !important;
  min-height: 120px;
}

#paypal-container-QXDLZPHD339EN,
#paypal-container-QXDLZPHD339EN div,
#paypal-container-QXDLZPHD339EN form,
#paypal-container-QXDLZPHD339EN .notranslate {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#paypal-container-QXDLZPHD339EN form {
  display: block !important;
  width: 100% !important;
  margin-bottom: 12px !important;
}

#paypal-container-QXDLZPHD339EN form .form-group {
  width: 100% !important;
}

#paypal-container-QXDLZPHD339EN form .form-group > div {
  display: flex !important;
  width: 100% !important;
  align-items: stretch !important;
}

#paypal-container-QXDLZPHD339EN label {
  color: #0f172a !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  display: block !important;
  width: 100% !important;
  margin-bottom: 8px !important;
  white-space: normal !important;
  text-align: right !important;
  direction: rtl !important;
}

#paypal-container-QXDLZPHD339EN input#hosted-button-amount,
#paypal-container-QXDLZPHD339EN input.form-control {
  width: 100% !important;
  flex: 1 1 auto !important;
  min-width: 80px !important;
  height: 42px !important;
  color: #0f172a !important;
  background-color: #ffffff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 8px 0 0 8px !important;
  padding: 8px 12px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  outline: none !important;
}

#paypal-container-QXDLZPHD339EN input#hosted-button-amount:focus {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2) !important;
}

#paypal-container-QXDLZPHD339EN select#currency-selector {
  color: #0f172a !important;
  background-color: #f1f5f9 !important;
  border: 1.5px solid #cbd5e1 !important;
  border-left: none !important;
  border-radius: 0 8px 8px 0 !important;
  height: 42px !important;
  padding: 0 10px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
}

#paypal-container-QXDLZPHD339EN button,
#paypal-container-QXDLZPHD339EN .paypal-buttons,
#paypal-container-QXDLZPHD339EN iframe {
  width: 100% !important;
  max-width: 100% !important;
  display: block !important;
  border-radius: 12px;
}

/* Reciter image highlight styling */
.reciter-portrait-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%; /* 1:1 Aspect Ratio */
  border-radius: 18px;
  overflow: hidden;
  background: rgba(10, 25, 56, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.reciter-portrait-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-card:hover .reciter-portrait-wrapper {
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.25);
}

.glass-card:hover .reciter-portrait-img {
  transform: scale(1.06);
}

/* ========================================================
   Quran Reader & SurahQuran.com Exact Styling
   ======================================================== */
@font-face {
  font-family: 'conv_original-hafs';
  src: url('../fonts/original-hafs.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

.surah-quran-reader {
  font-family: 'conv_original-hafs', 'Amiri Quran', 'Scheherazade New', 'Traditional Arabic', serif;
  color: #17274a;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  padding: 2.25rem 1.75rem;
  /* 100% = 0.6rem (the old 60%); A−/A+ range 50%–200% */
  font-size: calc(0.6rem * var(--reader-font-scale, 1));
  line-height: 2.2;
  text-align: justify;
  text-justify: inter-word;
  direction: rtl;
  user-select: text;
}

.surah-quran-reader h2 {
  font-family: 'conv_original-hafs', 'Amiri Quran', serif;
  font-size: 1.4rem;
  text-align: center;
  color: #17274a;
  margin-bottom: 1.25rem;
  font-weight: 700;
}

.surah-quran-reader b {
  font-weight: 600;
  color: #ff3335 !important;
}

/* End-of-ayah marker: the Hafs font renders the Arabic-Indic number inside ۝ */
.surah-quran-reader label {
  font-family: 'conv_original-hafs', serif;
  font-weight: 400;
  font-size: 1em;
  color: #0284c7;
  margin: 0 2px;
  white-space: nowrap;
}

/* Tap an ayah to highlight + copy it */
.surah-quran-reader .ayah {
  cursor: pointer; /* also needed for iOS Safari to deliver taps on plain text */
  border-radius: 6px;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.surah-quran-reader .ayah.ayah-active {
  background: #1e3a8a;
  color: #ffffff;
}

.surah-quran-reader .ayah.ayah-active b {
  color: #fca5a5 !important;
}

.surah-quran-reader .ayah.ayah-active label {
  color: #93c5fd;
}

.surah-quran-reader .basmala-text {
  text-align: center;
  margin: 1.5rem 0;
}

.surah-quran-reader img {
  display: block;
  margin: 1.5rem auto;
  max-width: 80%;
  height: auto;
}

.surah-quran-reader .p5 {
  text-align: center;
  font-size: 0.9rem;
  color: #64748b;
  margin-top: 2rem;
  font-family: 'Cairo', sans-serif;
}

.surah-meta-header {
  color: #0284c7;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(2, 132, 199, 0.15);
  font-family: 'Cairo', sans-serif;
}

/* ========================================================
   DAILY WERD ZOOM & PAN VIEWER
   ======================================================== */
.werd-page-viewport {
  position: relative;
  overflow: hidden;
  /* iOS Safari does not clip a transformed (zoomed) child to rounded corners,
     which shows the page image as a hard rectangle; the mask forces the clip */
  isolation: isolate;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  background: radial-gradient(circle at center, #0a1b3d 0%, #030814 100%);
}

.werd-transform-container {
  transition: transform 0.08s ease-out;
  transform-origin: center center;
}

.werd-transform-container.is-animating {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ========================================================
   READ QURAN STICKY TOP NAV BAR
   Stays firmly pinned at the top when scrolling through verses
   ======================================================== */
.reader-sticky-top-bar {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: var(--header-h, 61px) !important;
  z-index: 25 !important;
  background: rgba(6, 18, 41, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  box-shadow: 0 12px 35px -5px rgba(0, 0, 0, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

@media (max-width: 640px) {
  .reader-sticky-top-bar {
    padding: 0.65rem 0.75rem !important;
    border-radius: 1rem !important;
  }
}

/* ========================================================
   FULLSCREEN MODE (Read Quran & Daily Werd, Distraction-Free)
   ======================================================== */
body.app-fullscreen-mode {
  overflow: hidden !important;
}

body.app-fullscreen-mode header,
body.app-fullscreen-mode footer,
body.app-fullscreen-mode #playerDock,
body.app-fullscreen-mode .bg-image-layer,
body.reader-fullscreen-mode #surahsIndexContainer,
body.reader-fullscreen-mode #surahReaderContainer > .glass-panel:first-child,
body.reader-fullscreen-mode #surahReaderContainer > .text-center:last-child {
  display: none !important;
}

body.reader-fullscreen-mode #readView {
  padding: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

body.reader-fullscreen-mode #surahReaderContainer {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
  background-color: #040914 !important;
  overflow-y: auto !important;
  padding: 2.5rem 1rem 4rem 1rem !important;
  margin: 0 !important;
}

@media (min-width: 640px) {
  body.reader-fullscreen-mode #surahReaderContainer {
    padding: 3rem 4rem 5rem 4rem !important;
  }
}

body.reader-fullscreen-mode .surah-quran-reader {
  max-width: 900px;
  margin: 0 auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}

/* Werd: the zoomable page viewport fills the whole screen */
body.werd-fullscreen-mode #werdViewerViewport {
  position: fixed !important;
  inset: 0 !important;
  z-index: 100 !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 0 !important;
  border: 0 !important;
}

body.werd-fullscreen-mode #werdPageImg {
  max-height: 100vh !important;
  max-height: 100dvh !important;
  border-radius: 0 !important;
}

/* Floating Fullscreen Mode Button */
.reader-fullscreen-btn {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* When in fullscreen mode: small, half-transparent exit button that stays available */
body.app-fullscreen-mode .reader-fullscreen-btn {
  position: fixed !important;
  top: 16px !important;
  left: 16px !important;
  bottom: auto !important;
  right: auto !important;
  width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  border-radius: 9999px !important;
  background: rgba(0, 0, 0, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  opacity: 0.5 !important;
  z-index: 150 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
}

body.app-fullscreen-mode .reader-fullscreen-btn:hover,
body.app-fullscreen-mode .reader-fullscreen-btn:focus-visible {
  opacity: 1 !important;
  transform: scale(1.1) !important;
  background: rgba(220, 38, 38, 0.85) !important;
}

body.app-fullscreen-mode .reader-fullscreen-btn .fs-text,
body.app-fullscreen-mode .reader-fullscreen-btn .fs-enter-icon {
  display: none !important;
}

body.app-fullscreen-mode .reader-fullscreen-btn .fs-exit-icon {
  display: block !important;
}

/* ========================================================
   MOBILE SELECT MENU POPUP BOTTOM SHEET
   ======================================================== */
.mobile-select-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mobile-select-item:hover,
.mobile-select-item:active {
  background: rgba(59, 130, 246, 0.2);
  color: #ffffff;
}

.mobile-select-item.is-selected {
  background: rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.4);
}



/* ========================================================
   MOBILE & TABLET APP MODE (below the desktop nav breakpoint)
   App-style bottom tab bar, compact header, safe areas
   (notch / home bar), no sideways scrolling.
   ======================================================== */
:root {
  --tabbar-h: 58px;
  --dock-h: 0px;
}

html {
  touch-action: manipulation; /* no double-tap zoom delay on taps */
}

.app-tabbar {
  display: none;
}

.lang-switch-icon {
  display: none;
}

@media (max-width: 1279px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
    overflow-x: clip;
  }

  /* Header: respects the iPhone status bar / notch when installed */
  .app-header {
    padding-top: max(0.625rem, env(safe-area-inset-top)) !important;
    padding-left: max(0.75rem, env(safe-area-inset-left)) !important;
    padding-right: max(0.75rem, env(safe-area-inset-right)) !important;
  }

  main {
    padding-left: max(1rem, env(safe-area-inset-left)) !important;
    padding-right: max(1rem, env(safe-area-inset-right)) !important;
  }

  /* Language menu becomes a compact globe button (the touch picker shows full names) */
  .lang-switch {
    width: 38px;
    height: 32px;
    flex: none;
  }

  .lang-switch select {
    width: 100%;
    height: 100%;
    padding: 0 !important;
    color: transparent !important;
    -webkit-appearance: none;
    appearance: none;
    background-image: none;
  }

  .lang-switch select option {
    color: #e2e8f0;
  }

  .lang-switch-icon {
    display: block;
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    color: #bfdbfe;
    pointer-events: none;
  }

  /* Bottom tab bar */
  .app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 0 max(0.25rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(0.25rem, env(safe-area-inset-left));
    background: rgba(6, 16, 38, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
  }

  .app-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    padding: 0 2px;
    color: rgba(191, 219, 254, 0.62);
    font-size: 10.5px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    transition: color 0.15s ease;
  }

  .app-tab span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-tab svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s ease;
  }

  .app-tab.active {
    color: #60a5fa;
  }

  .app-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: #60a5fa;
  }

  .app-tab:active svg {
    transform: scale(0.9);
  }

  /* Audio player sits on top of the tab bar */
  .player-dock {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: 0.6rem;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  }

  /* Keep page content clear of the tab bar (and the player once it is open) */
  body.safe-pb {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1.25rem) !important;
  }

  body.safe-pb.player-open {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--dock-h) + 1.25rem) !important;
  }

  body .reader-fullscreen-btn {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1rem);
  }

  body.player-open .reader-fullscreen-btn {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--dock-h) + 0.75rem);
  }

  /* Apps have no page footer: keep it on the home screen only (it holds the site links) */
  body:not([data-route="home"]) > footer {
    display: none;
  }

  body > footer {
    padding-bottom: 0.75rem !important;
  }

  /* iOS zooms into text fields under 16px; keep typing comfortable */
  input[type="text"],
  input[type="email"],
  input[type="search"],
  textarea {
    font-size: 16px !important;
  }
}

/* Fullscreen reading hides the tab bar too */
body.app-fullscreen-mode .app-tabbar {
  display: none !important;
}

/* Installed app (home screen): no rubber-band bounce or pull-to-refresh */
@media (display-mode: standalone) {
  html,
  body {
    overscroll-behavior-y: none;
  }
}

/* Phones: two-row audio player and roomier surah rows */
@media (max-width: 639px) {
  .player-dock .dock-row {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  .player-dock .dock-info {
    order: 1;
    flex: 1 1 0;
  }

  .player-dock .dock-extras {
    order: 2;
  }

  .player-dock .dock-transport {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 0.75rem;
  }

  .player-dock .dock-transport button:not(#playPauseBtn) {
    width: 2.5rem;
    height: 2.5rem;
  }

  .surah-item-row .surah-row-title {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
  }
}

/* Touch screens: dropdowns open the app's list picker on tap (see App.initMobileSelectPicker) */
html.touch-picker select[data-picker] {
  pointer-events: none;
}

html.touch-picker select[data-picker]:disabled {
  opacity: 0.6;
}

/* ========================================================
   PHONE & TABLET PERFORMANCE
   Live background blur (backdrop-filter) on hundreds of cards is
   the main cause of slow scrolling on phones. Use near-opaque
   colors instead - it looks almost the same and scrolls smoothly.
   ======================================================== */
@media (max-width: 1279px), (hover: none) {
  *,
  *::before,
  *::after {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .glass-panel {
    background: rgba(11, 27, 60, 0.94);
  }

  .glass-card {
    background: rgba(13, 32, 70, 0.9);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease, background-color 0.2s ease;
  }

  .modal-overlay {
    background: rgba(3, 9, 23, 0.9);
  }

  .app-header,
  .app-tabbar,
  .player-dock,
  .reader-sticky-top-bar {
    background-color: rgba(7, 18, 42, 0.98) !important;
  }

  /* No endless full-screen background zoom, no permanent GPU layers on list items */
  .bg-image-layer {
    animation: none;
    will-change: auto;
    transform: none;
  }

  .animate-fade-in,
  .reciter-card-anim {
    will-change: auto;
  }

  /* Skip rendering list items that are off-screen until they scroll into view */
  .surah-item-row {
    content-visibility: auto;
    contain-intrinsic-size: auto 84px;
  }

  #allRecitersGrid > *,
  #featuredRecitersContainer > *,
  #readSurahsGrid > * {
    content-visibility: auto;
    contain-intrinsic-size: auto 220px;
  }
}

/* Small round X on the player's top edge (physical right, away from the fullscreen button) */
.player-close-btn {
  position: absolute;
  top: -14px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b1b3d;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  color: #bfdbfe;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.player-close-btn svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.player-close-btn:hover,
.player-close-btn:focus-visible {
  background: #dc2626;
  color: #fff;
}

.player-close-btn::after {
  content: '';
  position: absolute;
  inset: -8px; /* bigger touch target than the visible circle */
}

.player-dock.hidden-player .player-close-btn {
  visibility: hidden;
}

/* ========================================================
   PLAYER VOLUME CONTROL
   ======================================================== */
.volume-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.volume-slider-wrap {
  display: flex;
  align-items: center;
}

#volumeSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 84px;
  height: 4px;
  border-radius: 9999px;
  background: linear-gradient(to right, #60a5fa var(--vol, 100%), rgba(255, 255, 255, 0.18) var(--vol, 100%));
  cursor: pointer;
  outline: none;
}

#volumeSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#volumeSlider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

#volumeSlider:focus-visible {
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.4);
}

/* Touch screens and narrow windows: the slider pops up above the button */
@media (max-width: 1023px), (hover: none) {
  .volume-slider-wrap {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    padding: 14px 16px;
    background: #0b1b3c;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
    z-index: 5;
  }

  .volume-control.open .volume-slider-wrap {
    display: flex;
  }

  #volumeSlider {
    width: 150px;
    height: 6px;
  }

  #volumeSlider::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  #volumeSlider::-moz-range-thumb {
    width: 22px;
    height: 22px;
  }
}

/* iOS: volume is controlled by the phone buttons only, so just the mute button */
.volume-control.no-volume .volume-slider-wrap {
  display: none !important;
}
