/* =========================================================
   Al-Qur'an Desktop Widget — Visual Stylesheet
   Quran.com Pristine Light & Dark Theme + Animated Particles + Tajweed Color System
   Audited & Crafted by @personas/4-webdesigner.json & @personas/5-user-genz.json
   Purity: 100% Zero-Taswir • WCAG AAA • Ultra Smooth 120Hz
   ========================================================= */

/* --- Particle Canvas --- */
#particlesCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
}

/* --- Pulse Animations --- */
@keyframes pulseGold {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.25);
    border-color: rgba(217, 119, 6, 0.7);
  }
  50% {
    box-shadow: 0 0 18px 4px rgba(245, 158, 11, 0.45);
    border-color: rgba(217, 119, 6, 1);
  }
}

@keyframes pulseEmerald {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.7);
  }
  50% {
    box-shadow: 0 0 18px 4px rgba(16, 185, 129, 0.45);
    border-color: rgba(5, 150, 105, 1);
  }
}

/* --- LIGHT THEME (Default Quran.com Clean White Look) --- */
body.theme-light {
  background-color: #f8fafc;
  color: #0f172a;
}

body.theme-light header {
  background-color: rgba(255, 255, 255, 0.95);
  border-bottom-color: #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

body.theme-light .widget-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
}

body.theme-light .widget-card:hover {
  border-color: #cbd5e1;
}

body.theme-light .ayah-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

body.theme-light .ayah-card:hover {
  border-color: #94a3b8;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

body.theme-light .ayah-card.last-read-active {
  animation: pulseGold 2.5s infinite ease-in-out;
  border-color: #d97706 !important;
  background-color: #fffbeb !important;
}

body.theme-light .ayah-card.audio-playing {
  animation: pulseEmerald 2.2s infinite ease-in-out;
  border-color: #059669 !important;
  background-color: #ecfdf5 !important;
}

body.theme-light .view-mode-btn.active {
  background-color: #0f172a;
  color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.15);
}

body.theme-light .view-mode-btn:not(.active) {
  color: #64748b;
}

body.theme-light .view-mode-btn:not(.active):hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

body.theme-light .quran-arabic-text {
  color: #0f172a;
}

body.theme-light .translation-text {
  color: #334155;
}

/* --- DARK THEME (OLED Sanctuary) --- */
body.theme-dark {
  background-color: #030608;
  color: #f8fafc;
}

body.theme-dark header {
  background-color: rgba(11, 17, 28, 0.94);
  border-bottom-color: #1e293b;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
}

body.theme-dark .widget-card,
body.theme-dark .ayah-card {
  background-color: #0b111c;
  border-color: #1e293b;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

body.theme-dark .ayah-card:hover {
  border-color: rgba(212, 175, 55, 0.45);
}

body.theme-dark .ayah-card.last-read-active {
  animation: pulseGold 2.5s infinite ease-in-out;
  border-color: #d4af37 !important;
  background-color: rgba(212, 175, 55, 0.08) !important;
}

body.theme-dark .ayah-card.audio-playing {
  animation: pulseEmerald 2.2s infinite ease-in-out;
  border-color: #10b981 !important;
  background-color: rgba(16, 185, 129, 0.09) !important;
}

body.theme-dark .view-mode-btn.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(16, 185, 129, 0.2));
  color: #fdfbf7;
  border: 1px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 0 14px -2px rgba(212, 175, 55, 0.3);
}

body.theme-dark .view-mode-btn:not(.active) {
  color: #94a3b8;
}

body.theme-dark .view-mode-btn:not(.active):hover {
  background-color: #1e293b;
  color: #ffffff;
}

body.theme-dark .quran-arabic-text {
  color: #ffffff;
}

body.theme-dark .translation-text {
  color: #cbd5e1;
}

/* --- Card Transitions --- */
.ayah-card {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Arabic Typography Enhancements --- */
.quran-arabic-text {
  font-family: 'Amiri', 'Scheherazade New', 'Traditional Arabic', serif;
  direction: rtl;
  text-align: right;
  line-height: 2.3;
  word-spacing: 3px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* End of Ayah Symbol */
.ayah-end-symbol {
  font-family: 'Amiri', 'Scheherazade New', serif;
  font-size: 0.9em;
  color: #d97706;
  margin: 0 0.35rem;
  display: inline-block;
  user-select: none;
}

body.theme-dark .ayah-end-symbol {
  color: #fbbf24;
}

/* =========================================================
   OFFICIAL QURAN.COM TAJWEED COLOR SYSTEM
   ========================================================= */

/* Default / Tajweed ON (Light Theme) */
body.tajweed-on tajweed.madda_necessary,
body.tajweed-on tajweed.madda_obligatory {
  color: #dc2626 !important; /* Crimson / Merah - Mad Lazim / Wajib (6 harakat) */
  font-weight: 700;
}

body.tajweed-on tajweed.madda_permissible {
  color: #ea580c !important; /* Coral / Oranye Merah - Mad Jaiz Munfashil (2, 4, 6 harakat) */
  font-weight: 600;
}

body.tajweed-on tajweed.madda_normal {
  color: #d97706 !important; /* Amber / Emas - Mad Thabi'i (2 harakat) */
}

body.tajweed-on tajweed.ghunnah,
body.tajweed-on tajweed.idgham_ghunnah,
body.tajweed-on tajweed.idgham_shafawi {
  color: #059669 !important; /* Emerald - Dengung / Ghunnah (2 harakat) */
  font-weight: 700;
}

body.tajweed-on tajweed.ikhafa,
body.tajweed-on tajweed.ikhafa_shafawi {
  color: #b45309 !important; /* Warm Amber - Ikhfa' (Samar-samar) */
}

body.tajweed-on tajweed.qalaqah {
  color: #0284c7 !important; /* Sky Blue - Qalqalah (Memantul) */
  font-weight: 700;
}

body.tajweed-on tajweed.iqlab {
  color: #2563eb !important; /* Royal Blue - Iqlab (Tukar ke Mim) */
  font-weight: 700;
}

body.tajweed-on tajweed.idgham_wo_ghunnah {
  color: #64748b !important; /* Slate - Idgham Bilaghunnah */
}

body.tajweed-on tajweed.ham_wasl,
body.tajweed-on tajweed.laam_shamsiyah,
body.tajweed-on tajweed.slnt {
  color: #94a3b8 !important; /* Muted Gray - Tidak dibaca */
}

/* Tajweed ON (Dark Theme / OLED) */
body.theme-dark.tajweed-on tajweed.madda_necessary,
body.theme-dark.tajweed-on tajweed.madda_obligatory {
  color: #f87171 !important;
  font-weight: 700;
}

body.theme-dark.tajweed-on tajweed.madda_permissible {
  color: #fb923c !important;
}

body.theme-dark.tajweed-on tajweed.madda_normal {
  color: #facc15 !important;
}

body.theme-dark.tajweed-on tajweed.ghunnah,
body.theme-dark.tajweed-on tajweed.idgham_ghunnah,
body.theme-dark.tajweed-on tajweed.idgham_shafawi {
  color: #34d399 !important;
  font-weight: 700;
}

body.theme-dark.tajweed-on tajweed.ikhafa,
body.theme-dark.tajweed-on tajweed.ikhafa_shafawi {
  color: #fbbf24 !important;
}

body.theme-dark.tajweed-on tajweed.qalaqah {
  color: #38bdf8 !important;
  font-weight: 700;
}

body.theme-dark.tajweed-on tajweed.iqlab {
  color: #60a5fa !important;
  font-weight: 700;
}

body.theme-dark.tajweed-on tajweed.idgham_wo_ghunnah {
  color: #94a3b8 !important;
}

body.theme-dark.tajweed-on tajweed.ham_wasl,
body.theme-dark.tajweed-on tajweed.laam_shamsiyah,
body.theme-dark.tajweed-on tajweed.slnt {
  color: #64748b !important;
}

/* Hide Quran.com embedded end spans to prevent duplicate numbering */
tajweed .end,
tajweed span.end,
span.end {
  display: none !important;
}

/* Tajweed OFF: Plain Monochrome Arabic */
body.tajweed-off tajweed {
  color: inherit !important;
  font-weight: inherit !important;
}

/* --- VIEW MODES --- */

/* MODE: ARAB (Continuous Mushaf Flow) */
body.mode-mushaf #versesContainer,
body.mode-mushaf #focusSlideContainer,
body.mode-mushaf #translationFlowContainer {
  display: none !important;
}
body.mode-mushaf #mushafContainer {
  display: block !important;
}

/* MODE: TERJEMAHAN (Continuous Translation Flow) */
body.mode-transflow #versesContainer,
body.mode-transflow #focusSlideContainer,
body.mode-transflow #mushafContainer {
  display: none !important;
}
body.mode-transflow #translationFlowContainer {
  display: block !important;
}

/* MODE: FOKUS (Single Ayah Carousel) */
body.mode-focus-slide #versesContainer,
body.mode-focus-slide #mushafContainer,
body.mode-focus-slide #translationFlowContainer,
body.mode-focus-slide #bismillahCard,
body.mode-focus-slide #surahIntroCard,
body.mode-focus-slide .bottom-nav-bar {
  display: none !important;
}
body.mode-focus-slide #focusSlideContainer {
  display: block !important;
  margin-top: 1.5rem;
}

/* --- ADAPTIVE FLUID & MAXIMIZE SCREEN WIDTH --- */
.content-container {
  width: 100% !important;
  max-width: 96% !important;
  margin-left: auto !important;
  margin-right: auto !important;
  transition: max-width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 1600px) {
  .content-container {
    max-width: 94% !important;
  }
}

@media (min-width: 2000px) {
  .content-container {
    max-width: 92% !important;
  }
}

/* Boxed Mode Toggle */
body.layout-boxed .content-container {
  max-width: 1100px !important;
}

/* Mushaf Centered Fluid Flow with Wide Breath */
#mushafTextFlow {
  text-align: center;
  direction: rtl;
  line-height: 2.7;
  word-spacing: 6px;
  padding: 1.5rem 1rem;
}

/* --- FULLSCREEN SANCTUARY OVERRIDES --- */
:fullscreen {
  overflow-y: auto !important;
}

body.theme-light:fullscreen {
  background-color: #f8fafc !important;
}

body.theme-dark:fullscreen {
  background-color: #030608 !important;
}

:fullscreen main {
  max-width: 96% !important;
  width: 96% !important;
  padding: 2.5rem 1.5rem !important;
}

:fullscreen .ayah-card {
  padding: 1.75rem !important;
}

/* --- Font Size Button Active Indicator --- */
.font-size-btn.active {
  background-color: #ffffff;
  color: #d97706;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  font-weight: 800;
}
body.theme-dark .font-size-btn.active {
  background-color: #1e293b;
  color: #fbbf24;
}

/* --- Word-by-Word Interactive Hover & Selection --- */
.quran-word {
  display: inline-block;
  padding: 0 0.15rem;
  border-radius: 0.375rem;
  transition: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.quran-word:hover,
.quran-word.word-hovered {
  color: #2563eb !important;
  background-color: rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

body.theme-dark .quran-word:hover,
body.theme-dark .quran-word.word-hovered {
  color: #60a5fa !important;
  background-color: rgba(59, 130, 246, 0.2);
}

.quran-word.word-modal-active {
  color: #2563eb !important;
  font-weight: 800;
  background-color: rgba(37, 99, 235, 0.12);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.35);
  border-radius: 6px;
  padding: 0 0.25rem;
}

body.theme-dark .quran-word.word-modal-active {
  color: #60a5fa !important;
  background-color: rgba(59, 130, 246, 0.25);
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.45);
}

/* Tooltip & Context Menu Animations */
#wordTooltip, #wordContextMenu {
  animation: tooltipFadeIn 0.15s ease-out;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

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

/* Modal Animation */
#wordDetailModal {
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Clickable Latin, Translation & Mushaf Ayah Symbols --- */
.ayah-latin-text {
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: text;
}
.ayah-latin-text:hover {
  color: #059669 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.translation-text {
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: text;
}
.translation-text:hover {
  color: #b45309 !important;
}

.ayah-symbol-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-family: inherit;
  font-size: 0.85em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  vertical-align: middle;
  user-select: none;
}
.ayah-symbol-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  background: #f59e0b !important;
  color: #ffffff !important;
  border-color: #d97706 !important;
}

.ayah-symbol-btn.is-active-last-read {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  color: #ffffff !important;
  border-color: #b45309 !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
  animation: pulseGold 2.5s infinite;
}

/* Last Read Active Ayah Highlights */
.last-read-active-card {
  border: 2px solid #f59e0b !important;
  box-shadow: 0 10px 25px -5px rgba(245, 158, 11, 0.2), 0 8px 10px -6px rgba(245, 158, 11, 0.15) !important;
  background-color: rgba(245, 158, 11, 0.04) !important;
  position: relative;
}

.mushaf-ayah-span {
  transition: background-color 0.2s ease;
  border-radius: 6px;
  padding: 2px 4px;
}
.mushaf-ayah-span.mushaf-last-read {
  background: rgba(245, 158, 11, 0.12) !important;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.4);
}

/* Ayah Quick Action Popover */
#ayahQuickActionMenu {
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.3), 0 0 15px rgba(245, 158, 11, 0.35);
  transform-origin: center bottom;
  animation: quickMenuPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes quickMenuPop {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

#authModal {
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Slim Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
body.theme-light ::-webkit-scrollbar-track {
  background: #f1f5f9;
}
body.theme-light ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
body.theme-light ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

body.theme-dark ::-webkit-scrollbar-track {
  background: #030608;
}
body.theme-dark ::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 9999px;
}
body.theme-dark ::-webkit-scrollbar-thumb:hover {
  background: #d4af37;
}

/* =========================================================
   Feature Expansions (Gen-Z & Gen-Alpha Suite):
   1. Halal Natural Soundscape 4-Track Ambient Synthesizer
   2. DeepWork Pomodoro Tilawah Timer
   3. 1-Tap Aesthetic Social Media Poster Generator
   4. Khatam Tracker 30 Juz & Safar Progress
   5. Personal Tadabbur Journal
   ========================================================= */

/* --- Soundscape Mixer Drawer & Sliders --- */
#soundscapeMixerDrawer input[type="range"] {
  accent-color: #3b82f6;
  cursor: pointer;
}
body.theme-dark #soundscapeMixerDrawer input[type="range"] {
  accent-color: #60a5fa;
}

/* --- Pomodoro Dock Bar --- */
#pomodoroDockBar {
  animation: slideDownBar 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideDownBar {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Social Media Poster Generator --- */
#posterModalBackdrop {
  animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
#posterModal {
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
}
@keyframes modalScaleIn {
  from {
    transform: scale(0.93);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
.poster-ratio-btn.active {
  background-color: #4f46e5 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 10px -2px rgba(79, 70, 229, 0.4);
}
.poster-theme-dot.active {
  ring: 3px solid #4f46e5;
  box-shadow: 0 0 0 2px #ffffff, 0 0 10px rgba(79, 70, 229, 0.5);
  transform: scale(1.15);
}
#posterCanvas {
  max-width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

/* --- Khatam Tracker 30 Juz Grid --- */
.khatam-juz-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
body.theme-dark .khatam-juz-item {
  border-color: #334155;
  background: #0f172a;
}
.khatam-juz-item:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
  box-shadow: 0 4px 12px -2px rgba(245, 158, 11, 0.2);
}
.khatam-juz-item.completed {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.25)) !important;
  border-color: #10b981 !important;
  color: #047857 !important;
  box-shadow: 0 2px 6px -1px rgba(16, 185, 129, 0.2);
}
body.theme-dark .khatam-juz-item.completed {
  color: #34d399 !important;
  border-color: #059669 !important;
}

/* --- Tadabbur Modal --- */
#tadabburModal {
  animation: modalScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Pilihan Suasana Mood & Vibe Syahdu (from https://tauhidlife.my.id/relax) --- */
.mood-vibe-card {
  min-height: 88px;
  padding: 11px 13px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: #ffffff;
}
body.theme-dark .mood-vibe-card {
  border-color: rgba(30, 41, 59, 0.8);
  background: rgba(15, 23, 42, 0.6);
}
.mood-vibe-card:hover {
  transform: translateY(-2px);
  border-color: #10b981;
  box-shadow: 0 6px 16px -2px rgba(16, 185, 129, 0.15);
}
body.theme-dark .mood-vibe-card:hover {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(30, 41, 59, 0.8);
}
.mood-vibe-card.active {
  border-color: #10b981 !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3), 0 8px 20px -4px rgba(16, 185, 129, 0.25) !important;
  background: rgba(16, 185, 129, 0.05) !important;
  transform: scale(1.02);
}
body.theme-dark .mood-vibe-card.active {
  background: rgba(15, 23, 42, 0.95) !important;
  border-color: #34d399 !important;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.4), 0 0 20px rgba(16, 185, 129, 0.3) !important;
}
.mood-vibe-card .vibe-top-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

