/* ==========================================================================
   فريق مداد الثقافي - Medad Cultural Team
   Main Design System & Global Stylesheet
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
  /* Official Brand Palette */
  --primary-dark: #0F5B55;
  --primary-deep: #144E4A;
  --primary-light: #1A6C65;
  --gold-primary: #D4A017;
  --gold-light: #F4C96B;
  --gold-hover: #B8860B;
  
  /* Neutral Light Palette */
  --bg-main: #F4F7F6;
  --bg-surface: #FFFFFF;
  --bg-surface-alt: #EBF2F1;
  --text-primary: #1F2937;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --border-color: #D1D5DB;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(15, 91, 85, 0.08);
  --shadow-lg: 0 10px 25px rgba(15, 91, 85, 0.12);
  --shadow-gold: 0 4px 15px rgba(212, 160, 23, 0.25);

  /* Functional Status Colors */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  /* Typography */
  --font-body: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Amiri', serif;
  
  /* Layout Transitions & Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Palette Overrides */
[data-theme="dark"] {
  --bg-main: #0B1917;
  --bg-surface: #102724;
  --bg-surface-alt: #163430;
  --text-primary: #F3F4F6;
  --text-secondary: #D1D5DB;
  --text-muted: #9CA3AF;
  --border-color: #1F4540;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
  --shadow-gold: 0 4px 20px rgba(244, 201, 107, 0.2);
}

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

html {
  direction: rtl;
  lang: ar;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

main {
  flex: 1;
}

/* Islamic Geometric Pattern Background Utility */
.islamic-pattern-bg {
  background-color: var(--primary-dark);
  background-image: radial-gradient(var(--gold-primary) 0.75px, transparent 0.75px), radial-gradient(var(--gold-primary) 0.75px, var(--primary-dark) 0.75px);
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
  opacity: 0.98;
}

.islamic-pattern-overlay {
  position: relative;
}

.islamic-pattern-overlay::before {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 0L60 30L30 60L0 30Z' fill='none' stroke='%23D4A017' stroke-opacity='0.08' stroke-width='1.5'/%3E%3Cpath d='M30 10L50 30L30 50L10 30Z' fill='none' stroke='%23D4A017' stroke-opacity='0.05' stroke-width='1'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* Typography Rules */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

h1 { font-size: 2.75rem; }
h2 { font-size: 2.25rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.35rem; }
h5 { font-size: 1.15rem; }
h6 { font-size: 1rem; }

p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color var(--transition-fast);
}

[data-theme="dark"] a {
  color: var(--gold-light);
}

a:hover {
  color: var(--gold-primary);
}

ul, ol {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Layout Container & Grid */
.container {
  width: 100%;
  max-width: 1240px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  position: relative;
  z-index: 1;
}

.grid {
  display: grid;
  gap: 1.75rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  html { font-size: 15px; }
  h1 { font-size: 2.1rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.4rem; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .container { padding-left: 1rem; padding-right: 1rem; }
}

/* Section Common Styling */
.section {
  padding: 4.5rem 0;
  position: relative;
}

.section-title-wrap {
  text-align: center;
  margin-bottom: 3.5rem;
  position: relative;
}

.section-subtitle {
  color: var(--gold-primary);
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 0.35rem;
}

.section-title {
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: '';
  display: block;
  width: 70px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
  margin: 0.6rem auto 0;
  border-radius: var(--radius-full);
}

.section-desc {
  max-width: 680px;
  margin: 0.75rem auto 0;
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* Gold Header Ornament */
.header-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--gold-primary);
}

.header-ornament::before, .header-ornament::after {
  content: '';
  width: 40px;
  height: 1px;
  background: var(--gold-primary);
}

/* Utility Animations & Scroll Effects */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-gold { color: var(--gold-primary) !important; }
.text-muted { color: var(--text-muted) !important; }

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-dark);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-primary);
}

/* ═══════════════════════ RESPONSIVE SAFEGUARDS ═══════════════════════ */
body, html {
  max-width: 100%;
  overflow-x: hidden !important;
}

img, video, iframe, canvas, svg, picture {
  max-width: 100%;
  height: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Flex item shrink fix */
.grid > *, .container > *, form > * {
  min-width: 0;
}

@media (max-width: 1024px) {
  .section { padding: 3.5rem 0; }
  .section-title-wrap { margin-bottom: 2.5rem; }
}

@media (max-width: 576px) {
  html { font-size: 14px; }
  .section { padding: 2.5rem 0; }
  .section-title-wrap { margin-bottom: 2rem; }
  .section-subtitle { font-size: 0.85rem; }
  .section-desc { font-size: 1rem; }
  .header-ornament::before, .header-ornament::after { width: 20px; }
  .header-ornament { font-size: 0.85rem; }
}

