/* ============================================================
   تقنيات التوحيد — نظام التصميم
   هوية: "الإسطرلاب" — العصر الذهبي الجديد
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Reem+Kufi:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Amiri:wght@400;700&family=Amiri+Quran&display=swap');

:root {
  /* ===== هوية الإسطرلاب — Light (نهار في المخطوطة) ===== */
  --bg: #F4ECD8;              /* عاج مخطوطة */
  --bg-elevated: #FBF7EB;     /* رقّ ناصع */
  --bg-subtle: #EEE3CB;       /* رقّ مظلّل */
  --bg-muted: #E3D5B6;        /* حافة الرقّ */
  --bg-deep: #0E1B2C;         /* حبر مغربي */

  --text: #1A1410;            /* حبر كحلي بنّي */
  --text-secondary: #4A3F33;
  --text-muted: #826F58;
  --text-on-accent: #FBF7EB;
  --text-on-deep: #F4ECD8;

  --border: #D4C4A0;          /* حواف رقّ */
  --border-strong: #B8A47E;
  --border-deep: #1F2D44;

  /* ألوان مميزة */
  --accent: #B87333;          /* نحاس مؤكسد (الإسطرلاب) */
  --accent-hover: #9B5F25;
  --accent-soft: #F0E1C7;     /* خلفية نحاسية فاتحة */

  --turquoise: #2A9D8F;       /* فيروز سامرّاء */
  --turquoise-soft: #D7EBE7;

  --crimson: #8B2635;         /* أحمر مدمن قاني (للتحذيرات) */
  --gold: #C49B41;            /* ذهب مذهّب */
  --gold-soft: #F2E5BB;

  --danger: #8B2635;
  --success: #2A9D8F;
  --warning: #C49B41;

  /* تظليلات حبر */
  --shadow-xs: 0 1px 2px rgba(14,27,44,0.05);
  --shadow-sm: 0 2px 4px rgba(14,27,44,0.07);
  --shadow-md: 0 4px 12px rgba(14,27,44,0.09);
  --shadow-lg: 0 12px 32px rgba(14,27,44,0.13);
  --shadow-glow: 0 0 40px rgba(184,115,51,0.18);
  --shadow-ink: 0 6px 16px rgba(14,27,44,0.1);

  /* أحجام */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 22px;
  --radius-full: 999px;
  --radius-mihrab: 50% 50% 8px 8px / 50% 50% 8px 8px;  /* قوس محراب */

  /* خطوط */
  --font-display: 'Reem Kufi', 'IBM Plex Sans Arabic', sans-serif;
  --font-sans: 'IBM Plex Sans Arabic', system-ui, -apple-system, sans-serif;
  --font-serif: 'Amiri', Georgia, serif;
  --font-quran: 'Amiri Quran', 'Amiri', serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', monospace;

  /* مقاسات النص */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  /* مساحات */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;
  --space-10: 4rem;
  --space-12: 6rem;

  /* انتقالات */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* حاويات */
  --container: 1200px;
  --container-narrow: 720px;
  --container-mushaf: 580px;
}

/* ===== Dark Mode — ليل المرصد ===== */
[data-theme="dark"] {
  --bg: #0E1B2C;              /* حبر مغربي */
  --bg-elevated: #15263C;
  --bg-subtle: #1B2E48;
  --bg-muted: #233856;
  --bg-deep: #08111B;

  --text: #F4ECD8;            /* عاج على ليل */
  --text-secondary: #D4C4A0;
  --text-muted: #9B8E73;
  --text-on-accent: #0E1B2C;
  --text-on-deep: #F4ECD8;

  --border: #2A3F5C;
  --border-strong: #3D5778;
  --border-deep: #08111B;

  --accent: #D8954A;          /* نحاس متوهج */
  --accent-hover: #E8A85C;
  --accent-soft: #1F2D44;

  --turquoise: #4FBFB0;
  --turquoise-soft: #1B3A36;

  --gold: #E0B855;
  --gold-soft: #2D2818;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 50px rgba(216,149,74,0.2);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.7;
  direction: rtl;
  text-align: right;
  font-feature-settings: 'kern', 'liga', 'calt';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-base), color var(--transition-base);
  min-height: 100vh;
  position: relative;
}

/* خلفية بنقش هندسي خفيف على كامل الموقع */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23B87333' fill-opacity='0.04'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40 Z M40 20 L60 40 L40 60 L20 40 Z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: -1;
  opacity: 0.7;
}

[data-theme="dark"] body::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23D8954A' fill-opacity='0.05'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40 Z M40 20 L60 40 L40 60 L20 40 Z'/%3E%3C/g%3E%3C/svg%3E");
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); }

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  letter-spacing: 0;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p { color: var(--text-secondary); }

@media (max-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-2xl); }
}

/* ===== Container ===== */
.tq-container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.tq-container-narrow {
  width: 100%;
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ===== Buttons ===== */
.tq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
  font-family: var(--font-display);
  transition: all var(--transition-fast);
  text-decoration: none;
  border: 1.5px solid transparent;
  white-space: nowrap;
  position: relative;
  letter-spacing: 0.01em;
}

.tq-btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 4px 14px rgba(184,115,51,0.25);
}
.tq-btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(184,115,51,0.35);
  color: var(--text-on-accent);
}

.tq-btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.tq-btn-ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

.tq-btn-danger {
  background: var(--danger);
  color: white;
}
.tq-btn-danger:hover { filter: brightness(0.92); color: white; }

.tq-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}
.tq-btn-icon:hover {
  background: var(--bg-muted);
  color: var(--accent);
  border-color: var(--accent);
}

.tq-btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }
.tq-btn-lg { padding: var(--space-4) var(--space-6); font-size: var(--text-lg); }

/* ===== Form ===== */
.tq-input,
.tq-textarea,
.tq-select {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

.tq-input:focus,
.tq-textarea:focus,
.tq-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.tq-textarea { min-height: 120px; resize: vertical; line-height: 1.7; }

.tq-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-2);
  font-family: var(--font-display);
}

.tq-field { margin-bottom: var(--space-5); }

.tq-helper {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* ===== Card ===== */
.tq-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.tq-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
}

/* ===== Tag / Badge ===== */
.tq-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-full);
  letter-spacing: 0.02em;
  font-family: var(--font-display);
}

.tq-tag-muted { background: var(--bg-muted); color: var(--text-muted); }
.tq-tag-religious { background: var(--turquoise-soft); color: var(--turquoise); }
.tq-tag-tech { background: var(--accent-soft); color: var(--accent); }

/* ===== Header ===== */
.tq-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(244, 236, 216, 0.88);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .tq-header {
  background: rgba(14, 27, 44, 0.88);
}

.tq-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  gap: var(--space-6);
}

.tq-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
}

.tq-logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

/* الإسطرلاب — رمز مصغّر */
.tq-logo-mark svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

[data-theme="dark"] .tq-logo-mark {
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
}

.tq-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.tq-logo-text strong {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}

.tq-logo-text small {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

.tq-nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
}

.tq-nav-links a {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--text-sm);
  position: relative;
  padding: var(--space-2) 0;
  font-family: var(--font-display);
}

.tq-nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  transition: width var(--transition-base);
}

.tq-nav-links a:hover { color: var(--text); }
.tq-nav-links a:hover::after { width: 100%; }

.tq-nav-actions { display: flex; align-items: center; gap: var(--space-3); }

.tq-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 28px;
  height: 28px;
  justify-content: center;
}

.tq-menu-toggle span {
  width: 100%;
  height: 2px;
  background: var(--text);
  transition: transform var(--transition-base);
}

@media (max-width: 768px) {
  .tq-nav-links {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    flex-direction: column;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: var(--space-5);
    gap: var(--space-4);
  }
  .tq-nav-links.is-open { display: flex; }
  .tq-menu-toggle { display: flex; }
}

/* ===== Prayer Times Strip ===== */
.tq-prayer-strip {
  background: var(--bg-deep);
  color: var(--text-on-deep);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  font-family: var(--font-display);
  border-bottom: 1px solid var(--border-deep);
}

.tq-prayer-strip .strip-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.tq-prayer-now {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--gold);
  font-weight: 600;
}

.tq-prayer-now .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.4); }
}

.tq-prayer-list {
  display: flex;
  gap: var(--space-5);
  list-style: none;
  color: var(--text-secondary);
  opacity: 0.85;
  flex-wrap: wrap;
}

.tq-prayer-list li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: rgba(244, 236, 216, 0.8);
}

.tq-prayer-list li.is-next {
  color: var(--gold);
  font-weight: 600;
}

.tq-prayer-list li strong {
  color: inherit;
  font-weight: 600;
}

/* ===== Footer ===== */
.tq-footer {
  background: var(--bg-deep);
  color: var(--text-on-deep);
  padding: var(--space-10) 0 var(--space-6);
  margin-top: var(--space-12);
  position: relative;
  overflow: hidden;
}

.tq-footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cg fill='%23B87333' fill-opacity='0.06'%3E%3Cpath d='M40 0 L80 40 L40 80 L0 40 Z M40 20 L60 40 L40 60 L20 40 Z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.tq-footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
  margin-bottom: var(--space-8);
  position: relative;
}

.tq-footer-col h4 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: var(--space-4);
  font-family: var(--font-display);
}

.tq-footer-col a {
  display: block;
  color: rgba(244, 236, 216, 0.7);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}

.tq-footer-col a:hover { color: var(--accent); }

.tq-footer-bottom {
  padding-top: var(--space-6);
  border-top: 1px solid rgba(244, 236, 216, 0.15);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: rgba(244, 236, 216, 0.6);
  position: relative;
}

@media (max-width: 768px) {
  .tq-footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== Theme Toggle ===== */
.tq-theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.tq-theme-toggle:hover {
  background: var(--bg-muted);
  transform: rotate(20deg);
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== Mihrab divider (signature) ===== */
.tq-mihrab-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: var(--space-8) 0;
  position: relative;
}

.tq-mihrab-divider::before,
.tq-mihrab-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.tq-mihrab-divider svg {
  width: 60px;
  height: 30px;
  color: var(--accent);
  margin: 0 var(--space-4);
}

/* ===== Utility ===== */
.tq-flex { display: flex; }
.tq-flex-col { display: flex; flex-direction: column; }
.tq-items-center { align-items: center; }
.tq-justify-between { justify-content: space-between; }
.tq-justify-center { justify-content: center; }
.tq-gap-2 { gap: var(--space-2); }
.tq-gap-3 { gap: var(--space-3); }
.tq-gap-4 { gap: var(--space-4); }
.tq-gap-6 { gap: var(--space-6); }

.tq-text-center { text-align: center; }
.tq-mt-4 { margin-top: var(--space-4); }
.tq-mt-6 { margin-top: var(--space-6); }
.tq-mt-8 { margin-top: var(--space-8); }
.tq-mb-4 { margin-bottom: var(--space-4); }
.tq-mb-6 { margin-bottom: var(--space-6); }
.tq-mb-8 { margin-bottom: var(--space-8); }
.tq-py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.tq-py-10 { padding-top: var(--space-10); padding-bottom: var(--space-10); }
.tq-py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }

.tq-hidden { display: none !important; }

/* ===== Skeleton ===== */
.tq-skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 0%, var(--bg-subtle) 50%, var(--bg-muted) 100%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Animations ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.tq-fade-in { animation: fadeIn 0.6s ease forwards; }
.tq-fade-up { animation: fadeInUp 0.6s ease forwards; }

/* ===== Toast ===== */
.tq-toast {
  position: fixed;
  top: var(--space-6);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-deep);
  color: var(--text-on-deep);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--accent);
  z-index: 1000;
  font-weight: 500;
  font-family: var(--font-display);
  animation: fadeInUp 0.3s ease;
}

.tq-toast-success { border-right: 4px solid var(--turquoise); }
.tq-toast-error { border-right: 4px solid var(--danger); }
.tq-toast-warning { border-right: 4px solid var(--gold); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-subtle); }
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: var(--radius-full);
  border: 3px solid var(--bg-subtle);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-hover); }

::selection {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* ===== VPN Warning Banner ===== */
.vpn-banner {
  background: linear-gradient(90deg, var(--crimson), #6B1D28);
  color: white;
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  text-align: center;
  font-family: var(--font-display);
  position: relative;
  z-index: 99;
}

.vpn-banner i { margin-left: var(--space-2); }
