/* =================================
   منصة مدارج العلم - ملف الأنماط المخصص
   ================================= */

/* ----- المتغيرات الأساسية ----- */
:root {
    --color-teal: #259390;
    --color-teal-dark: #1a6b68;
    --color-teal-light: #2db5b1;
    --color-gold: #bd9b00;
    --color-gold-dark: #9a7f00;
    --color-cream: #fcfcfb;
    --transition-base: 0.3s ease;
    --transition-smooth: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(37, 147, 144, 0.15);
}

/* ----- إعادة تعيين وإعدادات عامة ----- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    /* لتجنب إخفاء المحتوى خلف الـ navbar */
}

body {
    overflow-x: hidden;
}

/* ----- إخفاء المحتوى قبل تحميل Alpine.js ----- */
[x-cloak] {
    display: none !important;
}

/* ----- تأثيرات الزجاج والشفافية ----- */
.glass-panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ----- تحسين عرض الصور ----- */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* إضافة تأثير على الصور عند التحميل */
img {
    transition: transform 0.3s ease, filter 0.3s ease;
}

img:hover {
    transform: scale(1.02);
}

/* ----- تحسين الروابط ----- */
a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-base);
}

/* ----- النصوص المحدودة (line-clamp fallback للمتصفحات القديمة) ----- */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ----- تحسين الأزرار ----- */
button,
.btn {
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition-base);
    font-family: inherit;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ----- مؤشر التحميل (Loader) ----- */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--color-cream);
    border-bottom-color: var(--color-teal);
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ----- تحسين قسم Hero ----- */
.hero-pattern {
    background-image:
        radial-gradient(circle at 20% 50%, rgba(37, 147, 144, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(189, 155, 0, 0.05) 0%, transparent 50%);
}

/* ----- تحسين البطاقات ----- */
.card-hover {
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), border-color var(--transition-base);
}

.card-hover:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-strong), var(--shadow-glow);
}

/* تأثيرات البطاقات المتقدمة */
.card-shine {
    position: relative;
    overflow: hidden;
}

.card-shine::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.card-shine:hover::before {
    opacity: 1;
    left: 100%;
}

/* ----- تحسين Navbar عند التمرير ----- */
.navbar-scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ----- تحسينات للنوافذ المنبثقة ----- */
.modal-backdrop {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ----- تحسين قوائم HTML في المحتوى الديناميكي ----- */
.prose ul {
    list-style-position: inside;
    margin-right: 1rem;
}

.prose h4 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

/* ----- تحسينات للطباعة ----- */
@media print {

    nav,
    footer,
    .fixed {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ----- تحسينات Accessibility ----- */
.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-teal);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-to-content:focus {
    top: 0;
}

/* ----- تحسين Focus للعناصر التفاعلية ----- */
*:focus-visible {
    outline: 2px solid var(--color-teal);
    outline-offset: 2px;
}

/* ----- تحسينات الأداء للـ Animations ----- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ----- تحسينات للشاشات الصغيرة ----- */
@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ----- تحسين زر الواتساب العائم ----- */
.whatsapp-float {
    animation: float-bounce 2s ease-in-out infinite;
}

@keyframes float-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ----- تحسين التمرير الناعم للأقسام ----- */
section {
    scroll-margin-top: 80px;
}

/* ----- تحسين عرض الكود في حال وجود أمثلة ----- */
code,
pre {
    font-family: 'Courier New', Courier, monospace;
    direction: ltr;
    text-align: left;
}

/* ----- حالة التحميل للصور ----- */
img[data-src] {
    filter: blur(5px);
    transition: filter 0.3s;
}

img[data-src].loaded {
    filter: blur(0);
}

/* ----- تحسين شريط التمرير للمتصفحات الحديثة ----- */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--color-cream);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--color-teal) 0%, var(--color-teal-dark) 100%);
    border-radius: 10px;
    border: 2px solid var(--color-cream);
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--color-gold) 0%, var(--color-gold-dark) 100%);
}

/* ----- تأثيرات إضافية للأزرار ----- */
.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-glow:hover::before {
    width: 300px;
    height: 300px;
}

/* ----- تحسين Typography ----- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    color: #1a202c;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.25rem; }
}

/* ----- تأثير Shimmer للتحميل ----- */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #f8f8f8 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s linear infinite;
}