/* ============================================================================
   Google Fonts - Loaded via link tag in application.html.erb
   All fonts loaded from Google Fonts CDN for reliability and performance
   ============================================================================ */

/* ============================================================================
   Local Custom Fonts - Al Qalam, Noore Hira, Noore Huda
   Served from public/fonts/ directory (directly by Rails, no asset pipeline)
   This is the industry standard for custom fonts - reliable and fast
   ============================================================================ */

@font-face {
  font-family: 'Al Qalam';
  src: url("/fonts/AlQalam-Regular.ttf") format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Al Qalam';
  src: url("/fonts/AlQalam-Bold.ttf") format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'noorehira';
  src: url("/fonts/NooreHira.ttf") format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'noorehuda';
  src: url("/fonts/NooreHuda.ttf") format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ============================================================================
   Global Font Stack - Following Industry Best Practices
   ============================================================================ */

/* Default: English text uses Arial (Microsoft FrontPage / Google Docs style) */
body {
  font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

/* Trix editor content - default to Arial 11pt (matching Google Docs default) */
/* NOTE: Do NOT use !important on font-family - it will block user selections */
trix-editor {
  font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11pt;
  line-height: 1.6;
}

/* Note: Inline font-family styles from Trix have higher specificity than class selectors */

/* Trix content display - same defaults */
.trix-content {
  font-family: Arial, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11pt;
  line-height: 1.6;
}

/* Arabic/RTL text - Use Al Qalam as default, unless user specifies otherwise */
/* Arabic/RTL text - Global Default */
/* Arabic/RTL text - Use Al Qalam as default, unless user specifies otherwise */
/* Smart Default: Only apply Al Qalam if no inline font-family is present */
*[dir="rtl"]:not([style*="font-family"]),
*[style*="direction: rtl"]:not([style*="font-family"]) {
  font-family: 'Al Qalam', 'Amiri', 'Noto Naskh Arabic', serif;
}

/* Ensure Public Content uses Al Qalam by default, but respects overrides */
.trix-content *[dir="rtl"]:not([style*="font-family"]),
.trix-content *[style*="direction: rtl"]:not([style*="font-family"]) {
  font-family: 'Al Qalam', 'Amiri', 'Noto Naskh Arabic', serif;
}

/* Trix Editor Specific - Smart Default */
trix-editor *[dir="rtl"]:not([style*="font-family"]),
trix-editor *[style*="direction: rtl"]:not([style*="font-family"]) {
  font-family: 'Al Qalam', 'Amiri', 'Noto Naskh Arabic', serif;
}

/* Allow inline styles (from Trix font picker) to ALWAYS win */


/* Ensure English text inside RTL containers keeps Arial font */
/* This prevents Arabic font from cascading to English spans */
.trix-content *[dir="rtl"] span[style*="font-family:Arial"],
.trix-content *[dir="rtl"] span[style*="font-family: Arial"],
trix-editor *[dir="rtl"] span[style*="font-family:Arial"],
trix-editor *[dir="rtl"] span[style*="font-family: Arial"] {
  font-family: Arial, sans-serif !important;
  direction: ltr;
  unicode-bidi: isolate;
}

/* IMPORTANT: Respect user's font choice - inline styles have higher specificity */
/* If user explicitly sets font-family via Trix, it will override the defaults above */