/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */

:root {
  /* Colors - Material Design 3 */
  --color-primary: #4a90e2;
  --color-primary-variant: #357abd;
  --color-secondary: #8e44ad;
  --color-surface: #ffffff;
  --color-background: #f8f8f8;
  --color-error: #b00020;
  --color-on-primary: #ffffff;
  --color-on-surface: #1a1a1a;
  --color-on-background: #1a1a1a;
  --color-on-error: #ffffff;
  --color-outline: #e0e0e0;
  --color-outline-variant: #f5f5f5;
  
  /* Text Colors */
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #666666;
  --color-text-disabled: #999999;
  
  /* Spacing Scale (Material Design) */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-2xl: 32px;
  --spacing-3xl: 48px;
  
  /* Base Font Size - Can be overridden by user settings */
  --base-font-size: 16px;
  
  /* Typography Scale */
  --font-size-xs: 10px;      /* 10sp */
  --font-size-sm: 12px;       /* 12sp */
  --font-size-base: 14px;     /* 14sp */
  --font-size-md: 16px;       /* 16sp */
  --font-size-lg: 18px;       /* 18sp */
  --font-size-xl: 20px;       /* 20sp */
  --font-size-2xl: 24px;      /* 24sp */
  --font-size-3xl: 32px;      /* 32sp */
  --font-size-4xl: 48px;      /* 48sp */
  
  /* Quran Text Sizes - Scale relative to --base-font-size */
  --quran-arabic-size: calc(var(--base-font-size) * 1.5);      /* Arabic text: 1.5x base */
  --quran-translation-size: calc(var(--base-font-size) * 1);   /* Translation: 1x base */
  --quran-transliteration-size: calc(var(--base-font-size) * 0.875); /* Transliteration: 0.875x base */
  --quran-tafsir-size: calc(var(--base-font-size) * 1);        /* Tafsir: 1x base */
  
  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.8;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Elevation (Material Design Shadows) */
  --elevation-0: none;
  --elevation-1: 0px 1px 3px rgba(0, 0, 0, 0.12), 0px 1px 2px rgba(0, 0, 0, 0.24);
  --elevation-2: 0px 3px 6px rgba(0, 0, 0, 0.16), 0px 3px 6px rgba(0, 0, 0, 0.23);
  --elevation-4: 0px 10px 20px rgba(0, 0, 0, 0.19), 0px 6px 6px rgba(0, 0, 0, 0.23);
  --elevation-8: 0px 15px 25px rgba(0, 0, 0, 0.15), 0px 5px 10px rgba(0, 0, 0, 0.05);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
  --transition-slower: 400ms ease;
  
  /* Z-Index Scale */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ============================================
   Theme Definitions
   ============================================ */

/* New Light Theme (default) - Равшан */
:root,
[data-theme="newLight"] {
  --color-primary: #2c3e50;
  --color-primary-variant: #34495e;
  --color-secondary: #8e44ad;
  --color-surface: #FFFFFF;
  --color-surface-variant: #f8f9fa;
  --color-background: #f8f9fa;
  --color-error: #E63946;
  --color-on-primary: #FFFFFF;
  --color-on-surface: #1a1a1a;
  --color-on-background: #1a1a1a;
  --color-on-error: #FFFFFF;
  --color-outline: #e0e0e0;
  --color-outline-variant: #e0e0e0;
  --color-text-primary: #1a1a1a;
  --color-text-secondary: #666666;
  --color-text-disabled: #999999;
  --color-primary-container: #2c3e50;
  --color-primary-container-low-opacity: rgba(44, 62, 80, 0.1);
  --color-primary-low-opacity: rgba(44, 62, 80, 0.3);
  --color-word-highlight: #0066cc; /* Bright blue for word highlighting in light mode */
  --color-word-hover: #0052a3; /* Slightly darker blue for hover in light mode */
  --surah-svg-filter: none; /* No filter for light theme - SVGs are dark */
}

/* New Dark Theme - Торик (Golden Glint) */
[data-theme="newDark"] {
  --color-primary: #D4AF37;
  --color-primary-variant: #B8941F;
  --color-secondary: #C9A961;
  --color-surface: #1E1E1E;
  --color-surface-variant: #2A2A2A;
  --color-background: #141414;
  --color-error: #D32F2F;
  --color-on-primary: #1A1A1A;
  --color-on-surface: #FAF8F3;
  --color-on-background: #FAF8F3;
  --color-on-error: #FAFAFA;
  --color-outline: #3A3A3A;
  --color-outline-variant: #2F2F2F;
  --color-text-primary: #FAF8F3;
  --color-text-secondary: #C9A961;
  --color-text-disabled: #6B6B6B;
  --color-primary-container: #D4AF37;
  --color-primary-container-low-opacity: rgba(212, 175, 55, 0.15);
  --color-primary-low-opacity: rgba(212, 175, 55, 0.3);
  --surah-svg-filter: invert(1) brightness(1.2); /* Invert for dark theme to make SVGs visible */
}

/* Classic Light Theme */
[data-theme="light"] {
  --color-primary: #16697A;
  --color-primary-variant: #0F4F5F;
  --color-secondary: #698F3F;
  --color-surface: #FFFFFF;
  --color-surface-variant: #F5F5F5;
  --color-background: #DBDBDB;
  --color-error: #D32F2F;
  --color-on-primary: #FFFFFF;
  --color-on-surface: #6F5E5C;
  --color-on-background: #6F5E5C;
  --color-on-error: #FFFFFF;
  --color-outline: #E0E0E0;
  --color-outline-variant: #F5F5F5;
  --color-text-primary: #6F5E5C;
  --color-text-secondary: #8A7A78;
  --color-text-disabled: #BDBDBD;
  --color-primary-container: #16697A;
  --color-primary-container-low-opacity: rgba(22, 105, 122, 0.1);
  --color-primary-low-opacity: rgba(22, 105, 122, 0.3);
  --color-word-highlight: #0066cc; /* Bright blue for word highlighting in classic light mode */
  --color-word-hover: #0052a3; /* Slightly darker blue for hover in classic light mode */
}

/* Classic Dark Theme */
[data-theme="dark"] {
  --color-primary: #5ee0ff;
  --color-primary-variant: #041020;
  --color-secondary: #9fb0d4;
  --color-surface: #0d1a2b;
  --color-surface-variant: #041020;
  --color-background: #071029;
  --color-error: #D32F2F;
  --color-on-primary: #021524;
  --color-on-surface: #e6f0ff;
  --color-on-background: #e6f0ff;
  --color-on-error: #FFFFFF;
  --color-outline: #29292A;
  --color-outline-variant: #29292A;
  --color-text-primary: #e6f0ff;
  --color-text-secondary: #9fb0d4;
  --color-text-disabled: #666666;
  --color-primary-container: #5ee0ff;
  --color-primary-container-low-opacity: rgba(94, 224, 255, 0.1);
  --color-primary-low-opacity: rgba(94, 224, 255, 0.3);
  --surah-svg-filter: invert(1) brightness(1.2);
}

/* Soft Beige Theme */
[data-theme="softBeige"] {
  --color-primary: #8D6E63;
  --color-primary-variant: #6D4C41;
  --color-secondary: #A1887F;
  --color-surface: #F5F0E1;
  --color-surface-variant: #F5F0E1;
  --color-background: #F5F0E1;
  --color-error: #D32F2F;
  --color-on-primary: #FFFFFF;
  --color-on-surface: #5A4D3F;
  --color-on-background: #5A4D3F;
  --color-on-error: #FFFFFF;
  --color-outline: #E0E0E0;
  --color-outline-variant: #F5F5F5;
  --color-text-primary: #5A4D3F;
  --color-text-secondary: #8A7A78;
  --color-text-disabled: #BDBDBD;
  --color-primary-container: #8D6E63;
  --color-primary-container-low-opacity: rgba(141, 110, 99, 0.1);
  --color-primary-low-opacity: rgba(141, 110, 99, 0.3);
  --color-word-highlight: #0066cc; /* Bright blue for word highlighting in soft beige theme */
  --color-word-hover: #0052a3; /* Slightly darker blue for hover in soft beige theme */
  --surah-svg-filter: none;
}

/* Elegant Marble Theme */
[data-theme="elegantMarble"] {
  --color-primary: #6D4C41;
  --color-primary-variant: #5D4037;
  --color-secondary: #8D6E63;
  --color-surface: #F8F4F0;
  --color-surface-variant: #F8F4F0;
  --color-background: #F8F4F0;
  --color-error: #D32F2F;
  --color-on-primary: #FFFFFF;
  --color-on-surface: #5A4033;
  --color-on-background: #5A4033;
  --color-on-error: #FFFFFF;
  --color-outline: #E0E0E0;
  --color-outline-variant: #F5F5F5;
  --color-text-primary: #5A4033;
  --color-text-secondary: #8A7A78;
  --color-text-disabled: #BDBDBD;
  --color-primary-container: #6D4C41;
  --color-primary-container-low-opacity: rgba(109, 76, 65, 0.1);
  --color-primary-low-opacity: rgba(109, 76, 65, 0.3);
  --color-word-highlight: #0066cc; /* Bright blue for word highlighting in elegant marble theme */
  --color-word-hover: #0052a3; /* Slightly darker blue for hover in elegant marble theme */
  --surah-svg-filter: none;
}

/* Night Sky Theme (dark) */
[data-theme="nightSky"] {
  --color-primary: #F5F3E7;
  --color-primary-variant: #1B2836;
  --color-secondary: #B0AFA6;
  --color-surface: #2C3E50;
  --color-surface-variant: #1B2836;
  --color-background: #2C3E50;
  --color-error: #D32F2F;
  --color-on-primary: #000000;
  --color-on-surface: #F5F3E7;
  --color-on-background: #F5F3E7;
  --color-on-error: #FFFFFF;
  --color-outline: #29292A;
  --color-outline-variant: #29292A;
  --color-text-primary: #F5F3E7;
  --color-text-secondary: #B0AFA6;
  --color-text-disabled: #666666;
  --color-primary-container: #F5F3E7;
  --color-primary-container-low-opacity: rgba(245, 243, 231, 0.1);
  --color-primary-low-opacity: rgba(245, 243, 231, 0.3);
  --surah-svg-filter: invert(1) brightness(1.2);
}

/* Silver Light Theme */
[data-theme="silverLight"] {
  --color-primary: #455A64;
  --color-primary-variant: #37474F;
  --color-secondary: #90A4AE;
  --color-surface: #C0C0C0;
  --color-surface-variant: #C0C0C0;
  --color-background: #C0C0C0;
  --color-error: #D32F2F;
  --color-on-primary: #FFFFFF;
  --color-on-surface: #333333;
  --color-on-background: #333333;
  --color-on-error: #FFFFFF;
  --color-outline: #E0E0E0;
  --color-outline-variant: #F5F5F5;
  --color-text-primary: #333333;
  --color-text-secondary: #666666;
  --color-text-disabled: #999999;
  --color-primary-container: #455A64;
  --color-primary-container-low-opacity: rgba(69, 90, 100, 0.1);
  --color-primary-low-opacity: rgba(69, 90, 100, 0.3);
  --color-word-highlight: #0066cc; /* Bright blue for word highlighting in silver light theme */
  --color-word-hover: #0052a3; /* Slightly darker blue for hover in silver light theme */
  --surah-svg-filter: none;
}

/* ============================================
   Base Styles
   ============================================ */

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

/* Surahs Grid */
.surahs-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 8px;
  padding: 0;
  margin-top: 0;
}

@media (min-width: 768px) {
  .surahs-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Lightweight surah list link – CSS-only hover, composited transitions */
.surahs-grid-link {
  display: block;
  padding: 16px;
  border: 1px solid var(--color-outline);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  background-color: var(--color-surface);
  box-shadow: var(--elevation-1);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.surahs-grid-link:hover {
  transform: translateY(-4px);
  box-shadow: var(--elevation-4);
  border-color: var(--color-primary);
  background-color: var(--color-surface-variant);
}

/* Theme-aware SVG filter for surah names */
.surah-name-svg {
  filter: var(--surah-svg-filter, none);
}

html {
  scroll-behavior: smooth;
  scrollbar-gutter: auto; /* Prevents space reservation for scrollbar */
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  direction: ltr; /* Default LTR for Tajik/English content */
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  scrollbar-gutter: auto; /* Prevents space reservation for scrollbar */
}

body {
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ============================================
   Typography System
   ============================================ */

/* Display Styles */
.display-large {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-tight);
  letter-spacing: -0.5px;
}

.display-medium {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-tight);
  letter-spacing: 0;
}

.display-small {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-tight);
  letter-spacing: 0;
}

/* Headline Styles */
.headline-large {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: 0.15px;
}

.headline-medium {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: 0.15px;
}

.headline-small {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  letter-spacing: 0.15px;
}

/* Title Styles */
.title-large {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.15px;
}

.title-medium {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.1px;
}

.title-small {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.1px;
}

/* Body Styles */
.body-large {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
  letter-spacing: 0.5px;
}

.body-medium {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-relaxed);
  letter-spacing: 0.25px;
}

.body-small {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  letter-spacing: 0.4px;
}

/* Label Styles */
.label-large {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.1px;
}

.label-medium {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.5px;
}

.label-small {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  letter-spacing: 0.5px;
}

/* ============================================
   Arabic Text Styling
   ============================================ */

.arabic-text,
[dir="rtl"],
.rtl {
  font-family: 'Amiri', 'Noto Naskh Arabic', 'Arabic Typesetting', serif;
  direction: rtl;
  text-align: right;
}

/* Quran-specific text sizing - uses scaled variables */
.quran-arabic-text {
  font-size: var(--quran-arabic-size);
}

/* Mushaf V4 Tajweed font for page 1 (prototype).
   The project already ships woff2/p1.woff2 (QCF4001_COLOR). */
@font-face {
  font-family: 'p1-v4';
  src: url('/woff2/p1.woff2') format('woff2');
  font-display: swap;
}

.quran-translation-text {
  font-size: var(--quran-translation-size);
}

.quran-transliteration-text {
  font-size: var(--quran-transliteration-size);
}

.quran-tafsir-text {
  font-size: var(--quran-tafsir-size);
}

/* Font Size Slider Styling */
.quran-font-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease;
}

.quran-font-size-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s ease;
}

.quran-font-size-slider:active::-webkit-slider-thumb {
  transform: scale(1.1);
}

.quran-font-size-slider:active::-moz-range-thumb {
  transform: scale(1.1);
}

/* Tajik/English text - LTR */
[dir="ltr"],
.ltr {
  direction: ltr;
  text-align: left;
}

/* Mixed content containers */
.verse-container {
  direction: ltr; /* Container is LTR */
}

.verse-container .arabic-text {
  direction: rtl; /* Arabic inside is RTL */
}

/* ============================================
   Component Styles
   ============================================ */

/* AppBar – animate transform (composited) instead of top */
.app-bar {
  background-color: var(--color-background);
  border-bottom: 1px solid var(--color-outline);
  box-shadow: var(--elevation-0);
  position: fixed;
  top: 56px; /* Directly below global TopBar with no gap */
  left: 0;
  right: 0;
  z-index: 1019; /* Below drawers (1001-1002) but above content */
  height: 56px; /* Material Design AppBar height */
  margin: 0; /* Ensure no gap */
  padding: 0;
  transition: transform 0.3s ease-in-out;
  transform: translateY(0);
}

/* AppBar when TopBar is hidden – moves up to take its place */
.app-bar.top-bar-hidden {
  transform: translateY(-56px);
}

.app-bar-content {
  display: flex;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
}

.app-bar-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cards */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-2);
  padding: var(--spacing-lg);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--elevation-4);
}

.card-elevation-1 {
  box-shadow: var(--elevation-1);
}

.card-elevation-2 {
  box-shadow: var(--elevation-2);
}

.card-elevation-4 {
  box-shadow: var(--elevation-4);
}

.card-elevation-8 {
  box-shadow: var(--elevation-8);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
  text-decoration: none;
  min-height: 40px; /* Material Design button min height */
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--elevation-2);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--elevation-4);
  background-color: var(--color-primary-variant);
}

.btn-primary:active:not(:disabled) {
  box-shadow: var(--elevation-1);
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--color-primary-container-low-opacity);
}

.btn-text {
  background-color: transparent;
  color: var(--color-primary);
  padding: var(--spacing-sm);
}

.btn-text:hover:not(:disabled) {
  background-color: var(--color-primary-container-low-opacity);
}

.btn-icon {
  background-color: transparent;
  color: var(--color-primary);
  padding: var(--spacing-sm);
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  min-height: 40px;
}

.btn-icon:hover:not(:disabled) {
  background-color: var(--color-primary-container-low-opacity);
}

/* Verse Container */
.verse-container {
  margin: var(--spacing-xl) 0;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-outline);
}

.verse-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  line-height: 1;
  text-align: center;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  margin-left: var(--spacing-sm);
}

.translation {
  margin-top: var(--spacing-md);
  line-height: var(--line-height-relaxed);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-normal);
}

/* Surah card hover effects */
.surah-card {
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.surah-card:hover {
  border-color: var(--color-primary) !important;
  box-shadow: var(--elevation-2);
}

/* ============================================
   Scrollbar Styling
   ============================================ */

/* Global scrollbars - visible on hover/focus (same as home page horizontal sections) */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent; /* Hidden by default */
  transition: scrollbar-color var(--transition-slow);
}

*:hover,
*:focus-within {
  scrollbar-color: var(--color-outline) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background: transparent;
}

*::-webkit-scrollbar-track {
  background: transparent;
  box-shadow: none;
  border: none;
  margin: 0;
  padding: 0;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  border: none;
  box-shadow: none;
  transition: background var(--transition-slow);
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

*:hover::-webkit-scrollbar-thumb,
*:focus-within::-webkit-scrollbar-thumb {
  background: var(--color-outline);
  opacity: 0.5;
}

*:hover::-webkit-scrollbar-thumb:hover,
*:focus-within::-webkit-scrollbar-thumb:hover {
  background: var(--color-outline);
  opacity: 0.7;
}

/* Body/html scrollbars - same on-demand behavior as sidebar */
html,
body {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent; /* Hidden by default */
  transition: scrollbar-color var(--transition-slow);
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 6px;
  background: transparent;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: transparent;
  border: none;
  margin: 0;
  padding: 0;
  box-shadow: none;
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 3px;
  border: none;
  box-shadow: none;
  transition: background var(--transition-slow);
  -webkit-background-clip: padding-box;
  background-clip: padding-box;
}

/* Show scrollbar on hover/focus - matching sidebar behavior */
html:hover::-webkit-scrollbar-thumb,
html:focus-within::-webkit-scrollbar-thumb,
body:hover::-webkit-scrollbar-thumb,
body:focus-within::-webkit-scrollbar-thumb {
  background: var(--color-outline);
  opacity: 0.5;
}

html:hover::-webkit-scrollbar-thumb:hover,
html:focus-within::-webkit-scrollbar-thumb:hover,
body:hover::-webkit-scrollbar-thumb:hover,
body:focus-within::-webkit-scrollbar-thumb:hover {
  background: var(--color-outline);
  opacity: 0.7;
}

html:hover,
html:focus-within,
body:hover,
body:focus-within {
  scrollbar-color: var(--color-outline) transparent;
}

/* ============================================
   Animations
   ============================================ */

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

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

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

.fade-in {
  animation: fadeIn var(--transition-slow) ease;
}

.slide-up {
  animation: slideUp var(--transition-slow) ease;
}

/* ============================================
   Utility Classes
   ============================================ */

/* Spacing Utilities */
.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }
.p-2xl { padding: var(--spacing-2xl); }

.m-xs { margin: var(--spacing-xs); }
.m-sm { margin: var(--spacing-sm); }
.m-md { margin: var(--spacing-md); }
.m-lg { margin: var(--spacing-lg); }
.m-xl { margin: var(--spacing-xl); }
.m-2xl { margin: var(--spacing-2xl); }

.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

/* Text Utilities */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-disabled { color: var(--color-text-disabled); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

/* Display Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* ============================================
   Responsive Design
   ============================================ */

/* Mobile First Approach */
@media (max-width: 599px) {
  /* Mobile styles */
  .app-bar-content {
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .app-bar-title {
    font-size: var(--font-size-lg);
  }
  
  .card {
    padding: var(--spacing-md);
  }
  
  body {
    font-size: var(--font-size-sm);
  }
}

/* Tablet */
@media (min-width: 600px) and (max-width: 959px) {
  /* Tablet styles */
  .app-bar-content {
    padding: var(--spacing-sm) var(--spacing-lg);
  }
}

/* Desktop */
@media (min-width: 960px) {
  /* Desktop styles */
  .app-bar-content {
    padding: var(--spacing-sm) var(--spacing-xl);
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  /* Large desktop styles */
  .app-bar-content {
    max-width: 1200px;
  }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Mobile/touch device styles */
  .btn {
    min-height: 48px; /* Larger touch targets for mobile */
  }
  
  .btn-icon {
    width: 48px;
    height: 48px;
    min-height: 48px;
  }
  
  .card:hover {
    box-shadow: var(--elevation-2); /* Less pronounced hover on touch */
  }
  
  /* Ensure all interactive elements have adequate touch targets */
  button, a, input, select, textarea {
    min-height: 44px; /* iOS recommended minimum */
  }
  
  /* Prevent text size adjustment on iOS */
  input, select, textarea, button {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* Hero Section - Dark Mode Overlay */
[data-theme="newDark"] .hero-overlay,
[data-theme="dark"] .hero-overlay,
[data-theme="nightSky"] .hero-overlay {
  opacity: 0.5 !important; /* Lower opacity in dark themes to show gold SVG */
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-variant) 100%) !important;
}

/* Hero Section - Dark Mode Gold Tint for SVG Background */
[data-theme="newDark"] .hero-section::before,
[data-theme="dark"] .hero-section::before,
[data-theme="nightSky"] .hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.3) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="newDark"] .hero-section::before {
  /* Enhanced gold tint for newDark theme */
  background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.4) 0%, rgba(184, 148, 31, 0.2) 50%, transparent 80%);
}

/* Home Page Content Background with Islamic Pattern */
.home-content-background {
  position: relative;
  width: 100%;
  margin-top: 0;
}

.home-content-background::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background-image: url('/islamic-pattern.svg');
  background-size: 400px 400px;
  background-position: center;
  background-repeat: repeat;
  background-attachment: scroll;
  z-index: 0;
  pointer-events: none;
}

.home-content-background::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background-color: var(--color-background);
  opacity: 0.15;
  z-index: 1;
  pointer-events: none;
}

/* Dark Mode - Very low overlay to show pattern clearly */
[data-theme="newDark"] .home-content-background::before,
[data-theme="dark"] .home-content-background::before,
[data-theme="nightSky"] .home-content-background::before {
  opacity: 0.3; /* Increased to better hide the pattern in dark mode */
}

/* Light Mode - Very low opacity to show pattern clearly */
[data-theme="newLight"] .home-content-background::before,
[data-theme="light"] .home-content-background::before,
[data-theme="softBeige"] .home-content-background::before,
[data-theme="elegantMarble"] .home-content-background::before,
[data-theme="silverLight"] .home-content-background::before {
  opacity: 0.05;
}

/* Apply color filter to pattern based on theme - using ::after */
[data-theme="newDark"] .home-content-background::after {
  filter: brightness(0.8) sepia(0.3) saturate(1.2) hue-rotate(10deg);
  opacity: 0.15; /* Reduced from 0.6 for less visibility in dark mode */
}

[data-theme="dark"] .home-content-background::after,
[data-theme="nightSky"] .home-content-background::after {
  filter: brightness(0.7);
  opacity: 0.12; /* Reduced from 0.5 for less visibility in dark mode */
}

[data-theme="newLight"] .home-content-background::after,
[data-theme="light"] .home-content-background::after,
[data-theme="softBeige"] .home-content-background::after,
[data-theme="elegantMarble"] .home-content-background::after,
[data-theme="silverLight"] .home-content-background::after {
  opacity: 0.5;
}

/* Additional Mobile Optimizations */
@media (max-width: 599px) {
  /* Ensure images don't overflow */
  img {
    max-width: 100%;
    height: auto;
  }
  
  /* Prevent horizontal scrolling */
  * {
    max-width: 100%;
  }
  
  /* Better spacing on mobile */
  h1 {
    font-size: clamp(24px, 6vw, 32px) !important;
  }

  /* Surah app bar title should stay small on mobile */
  .app-bar-title {
    font-size: var(--font-size-sm) !important;
  }
  
  h2 {
    font-size: clamp(20px, 5vw, 28px) !important;
  }
  
  h3 {
    font-size: clamp(18px, 4vw, 24px) !important;
  }
  
  /* Improve readability */
  p, div, span {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  /* Hide Google Play badge on very small screens if needed */
  @media (max-width: 360px) {
    /* Keep badge but make it smaller */
    header a[href*="play.google.com"] img {
      height: 24px !important;
    }
  }
}

/* ============================================
   404 Not Found Page Styles
   ============================================ */

.not-found-overlay-link {
  position: absolute;
  left: 25.84%;
  bottom: 16.54%;
  width: 20.85%;
  height: 7.86%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.not-found-svg {
  filter: var(--not-found-svg-filter, none);
}

/* Light themes - invert SVG to make white text visible on light background */
:root,
[data-theme="newLight"],
[data-theme="light"] {
  --not-found-svg-filter: invert(1);
}

/* Dark themes - no filter needed, SVG is already visible */
[data-theme="newDark"],
[data-theme="dark"] {
  --not-found-svg-filter: none;
}

/* ============================================
   Mobile Optimizations for Home Page
   ============================================ */

@media (max-width: 768px) {
  /* Reduce section padding on mobile */
  .home-page-wrapper .hero-section {
    padding: clamp(16px, 4vw, 24px) clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px) !important;
    margin-bottom: 24px !important;
  }

  .home-page-wrapper [style*="padding: clamp(16px, 4vw, 24px)"] {
    padding: 12px 12px !important;
  }

  /* Reduce section headings on mobile */
  .home-page-wrapper h2 {
    font-size: 1.25rem !important;
    margin-bottom: 12px !important;
  }

  /* Reduce gaps between cards in scrollable containers */
  .scrollable-container {
    gap: 12px !important;
    padding: 6px 8px !important;
  }

  /* Reduce card sizes on mobile */
  .surah-card,
  .card {
    min-width: 140px !important;
    height: 100px !important;
  }

  .surah-card img,
  .surah-name-svg {
    width: 140px !important;
    height: 100px !important;
  }

  /* Reduce HoverableCard sizes */
  .home-page-wrapper a[style*="minWidth"] {
    min-width: min(240px, 100%) !important;
    max-width: min(240px, 100%) !important;
    padding: 12px 16px !important;
    max-height: 180px !important;
  }

  /* Reduce font sizes in cards */
  .home-page-wrapper .scrollable-container div[style*="fontSize: '1.125rem'"] {
    font-size: 1rem !important;
    line-height: 1.4 !important;
  }

  .home-page-wrapper .scrollable-container div[style*="fontSize: '0.875rem'"] {
    font-size: 0.8rem !important;
  }

  /* Reduce emoji size in duas cards */
  .home-page-wrapper .scrollable-container div[style*="fontSize: '32px'"] {
    font-size: 24px !important;
    margin-bottom: 6px !important;
  }

  /* Reduce section margins on mobile */
  .home-page-wrapper > div > div > div[style*="marginBottom"] {
    margin-bottom: 16px !important;
  }

  /* Reduce side padding on mobile */
  .home-content-background > div {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  
  /* Reduce section inner padding on mobile */
  .home-page-wrapper [style*="padding: clamp(12px, 3vw, 24px)"] {
    padding: 12px 8px !important;
  }
  
  /* Reduce hero section side padding on mobile */
  .hero-section {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }

  /* Reduce hero section title */
  .hero-section h1 {
    font-size: clamp(20px, 5vw, 28px) !important;
    margin-bottom: clamp(12px, 3vw, 20px) !important;
  }

  /* Make search placeholder smaller on mobile */
  .hero-section > div > div {
    max-width: 100% !important;
  }

  /* Prevent content overlapping on mobile */
  /* MainContentWrapper already adds marginTop: 56px for top bar visibility */
  /* Pages should NOT include 56px in their paddingTop - they should only account for their own fixed elements */
  
  /* Ensure fixed elements don't overlap content */
  main {
    position: relative;
    z-index: 0;
  }

  /* Ensure proper spacing for pages with fixed tabs/bars */
  main > div[style*="position: fixed"] {
    z-index: 1019;
  }

  /* Fix qaida lesson page card overlapping on mobile */
  main > div[style*="minHeight: '100vh'"] {
    position: relative;
    z-index: 1;
  }

  /* Ensure qaida cards don't overlap */
  main .card,
  main [style*="backgroundColor: 'var(--color-surface-variant)'"] {
    position: relative;
    z-index: 1;
  }

  /* Prevent text from appearing above cards */
  main h4,
  main h3 {
    position: relative;
    z-index: 2;
  }

  /* Ensure flex containers handle overflow properly */
  main [style*="display: 'flex'"],
  main [style*='display: flex'] {
    position: relative;
    z-index: 1;
  }
}

/* ============================================
   Dark Mode Hero Section Overlay Fix
   ============================================ */

/* Increase overlay opacity in dark mode to hide background SVG better */
[data-theme="newDark"] .hero-overlay,
[data-theme="dark"] .hero-overlay {
  opacity: 0.95 !important;
}

/* ============================================
   Card Hover Effects (CSS-only, no JS)
   ============================================ */

/* Generic hoverable card - lifts up on hover */
.hoverable-card {
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  will-change: transform;
}

.hoverable-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--elevation-4);
  border-color: var(--color-primary);
}

/* Surah card hover effect - with dynamic border color support */
.surah-card-hoverable {
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  will-change: transform;
}

.surah-card-hoverable:hover {
  transform: translateY(-4px);
  box-shadow: var(--elevation-4);
  border-color: var(--card-border-hover) !important;
}

/* Prophet card hover effect - with dynamic border color support */
.prophet-card-hoverable {
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  will-change: transform;
}

.prophet-card-hoverable:hover {
  transform: translateY(-4px);
  box-shadow: var(--elevation-4);
  border-color: var(--card-border-hover) !important;
}

/* Quran page surah list card hover effect */
.quran-surah-card {
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base), background-color var(--transition-base);
  will-change: transform;
}

.quran-surah-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--elevation-4);
  border-color: var(--color-primary);
  background-color: var(--color-surface-variant);
}

/* Button hover effect - background color change */
.button-hoverable {
  transition: background-color var(--transition-base);
}

.button-hoverable:hover {
  background-color: var(--color-surface-variant);
}

/* Section link hover effect - opacity change */
.section-link {
  transition: opacity var(--transition-base);
}

.section-link:hover {
  opacity: 0.8;
}

/* Touch device - disable hover effects */
@media (hover: none) and (pointer: coarse) {
  .hoverable-card:hover,
  .surah-card-hoverable:hover,
  .prophet-card-hoverable:hover,
  .quran-surah-card:hover {
    transform: translateY(0);
    box-shadow: var(--elevation-1);
  }
  
  .button-hoverable:hover {
    background-color: transparent;
  }
}
