/* تعريف المتغيرات بنفس الألوان الأصلية */
:root {
    --primary-color: #0a84ff;
    --secondary-color: #5e5ce6;
    --accent-color: #30d158;
    --accent-purple: #5e5ce6;
    --accent-orange: #ff9f0a;
    --bg-secondary: #1c1c1e;
    --system-gray2: #636366;
    --radius-large: 16px;
}

/* Enhanced 3D Code Effects - الأصلية */
.code-matrix-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(10, 132, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(94, 92, 230, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(48, 209, 88, 0.05) 0%, transparent 50%);
    z-index: -1;
}

/* Binary Stream Effect - الأصلية */
.binary-stream {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    opacity: 0.1;
}

.binary-line {
    position: absolute;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
    animation: binaryFlow 3s linear infinite;
}

@keyframes binaryFlow {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Circuit Board Pattern - الأصلية */
.circuit-board {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(90deg, rgba(10, 132, 255, 0.1) 1px, transparent 1px),
        linear-gradient(180deg, rgba(10, 132, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: circuitMove 20s linear infinite;
    z-index: -1;
}

@keyframes circuitMove {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 50px 50px;
    }
}

/* Hacker Terminal Glow - الأصلية */
.terminal-glow {
    position: relative;
}

.terminal-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    background-size: 400%;
    border-radius: inherit;
    z-index: -1;
    animation: terminalGlow 20s linear infinite;
    filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.terminal-glow:hover::before {
    opacity: 1;
}

@keyframes terminalGlow {
    0% {
        background-position: 0 0;
    }
    50% {
        background-position: 400% 0;
    }
    100% {
        background-position: 0 0;
    }
}

/* Data Flow Animation - الأصلية */
.data-flow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 50px,
            rgba(10, 132, 255, 0.1) 50px,
            rgba(10, 132, 255, 0.1) 51px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 50px,
            rgba(94, 92, 230, 0.1) 50px,
            rgba(94, 92, 230, 0.1) 51px
        );
    animation: dataFlow 30s linear infinite;
    z-index: -1;
}

@keyframes dataFlow {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

/* Three.js Container */
#three-d-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

/* Floating Shapes - الأصلية */
.floating-shapes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    opacity: 0.1;
    animation: float 20s infinite ease-in-out;
    filter: blur(40px);
}

.shape-1 {
    width: 400px;
    height: 400px;
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.shape-2 {
    width: 300px;
    height: 300px;
    top: 60%;
    left: 80%;
    animation-delay: -5s;
}

.shape-3 {
    width: 200px;
    height: 200px;
    top: 80%;
    left: 20%;
    animation-delay: -10s;
}

.shape-4 {
    width: 350px;
    height: 350px;
    top: 30%;
    left: 70%;
    animation-delay: -7s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }
    33% {
        transform: translateY(-30px) rotate(120deg) scale(1.1);
    }
    66% {
        transform: translateY(15px) rotate(240deg) scale(0.9);
    }
}

/* Binary Rain Effect - الأصلية */
.binary-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -1;
    opacity: 0.1;
}

.binary-digit {
    position: absolute;
    color: var(--primary-color);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    animation: fall linear infinite;
}

@keyframes fall {
    to {
        transform: translateY(100vh);
    }
}

/* Hacker Terminal Effect - الأصلية */
.terminal-glitch {
    position: relative;
}

.terminal-glitch::before,
.terminal-glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.terminal-glitch::before {
    animation: glitch-1 0.5s infinite linear alternate-reverse;
    color: #ff00ff;
    z-index: -1;
}

.terminal-glitch::after {
    animation: glitch-2 0.5s infinite linear alternate-reverse;
    color: #00ffff;
    z-index: -2;
}

@keyframes glitch-1 {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(-2px, 2px);
    }
    40% {
        transform: translate(-2px, -2px);
    }
    60% {
        transform: translate(2px, 2px);
    }
    80% {
        transform: translate(2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

@keyframes glitch-2 {
    0% {
        transform: translate(0);
    }
    20% {
        transform: translate(2px, 2px);
    }
    40% {
        transform: translate(2px, -2px);
    }
    60% {
        transform: translate(-2px, 2px);
    }
    80% {
        transform: translate(-2px, -2px);
    }
    100% {
        transform: translate(0);
    }
}

/* Code Syntax Highlighting - الأصلية */
.code-keyword { color: var(--accent-purple); }
.code-function { color: var(--primary-color); }
.code-string { color: var(--accent-orange); }
.code-comment { color: var(--system-gray2); }
.code-number { color: var(--accent-color); }

/* Depth Shadows - الأصلية */
.depth-shadow {
    box-shadow: 
        0 1px 1px rgba(0,0,0,0.12),
        0 2px 2px rgba(0,0,0,0.12),
        0 4px 4px rgba(0,0,0,0.12),
        0 8px 8px rgba(0,0,0,0.12),
        0 16px 16px rgba(0,0,0,0.12);
}

/* Animated Gradient Borders - الأصلية */
.gradient-border {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-large);
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-purple), var(--accent-color));
    border-radius: var(--radius-large);
    z-index: -1;
    animation: rotate-gradient 3s linear infinite;
}

@keyframes rotate-gradient {
    0% {
        filter: hue-rotate(0deg);
    }
    100% {
        filter: hue-rotate(360deg);
    }
}

/* Particle Network */
.particle-network {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: particle-float 6s infinite linear;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* Matrix Digital Rain */
.matrix-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.05;
}

.matrix-column {
    position: absolute;
    top: -100px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 18px;
    color: var(--accent-color);
    animation: matrix-fall linear infinite;
    text-shadow: 0 0 5px currentColor;
}

@keyframes matrix-fall {
    to {
        transform: translateY(100vh);
    }
}

/* Glass Morphism - الأصلية */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Neon Glow Effects - الأصلية */
.neon-glow {
    box-shadow: 
        0 0 5px currentColor,
        0 0 10px currentColor,
        0 0 15px currentColor,
        0 0 20px currentColor;
    animation: neon-pulse 2s infinite alternate;
}

@keyframes neon-pulse {
    from {
        opacity: 0.7;
    }
    to {
        opacity: 1;
    }
}

/* Cyberpunk Grid - الأصلية */
.cyber-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(10, 132, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(10, 132, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: grid-move 20s linear infinite;
    z-index: -1;
}

@keyframes grid-move {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(50px, 50px);
    }
}

/* ============================================= */
/* تحسينات للموبايل مع الحفاظ على التأثيرات */
/* ============================================= */

/* تأثيرات تفاعل الماوس/اللمس الأساسية */
.interactive-element {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

/* للكمبيوتر: تأثير Hover */
@media (hover: hover) {
    .interactive-element:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 30px rgba(10, 132, 255, 0.3);
    }
    
    /* تأثير Hover خاص لـ terminal-glow */
    .terminal-glow.interactive-element:hover::before {
        opacity: 0.7;
        animation-duration: 10s;
    }
    
    /* تأثير Hover للخلفيات */
    .binary-stream:hover {
        opacity: 0.15;
    }
    
    .circuit-board:hover {
        background-image: 
            linear-gradient(90deg, rgba(10, 132, 255, 0.15) 1px, transparent 1px),
            linear-gradient(180deg, rgba(10, 132, 255, 0.15) 1px, transparent 1px);
    }
    
    .floating-shapes:hover .shape {
        opacity: 0.15;
    }
}

/* للموبايل: تأثير الضغط */
@media (hover: none) {
    .interactive-element:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* إظهار terminal-glow على الموبايل عند الضغط */
    .terminal-glow.interactive-element:active::before {
        opacity: 0.5;
        animation-duration: 5s;
        filter: blur(4px);
    }
    
    /* تأثيرات للخلفيات على الموبايل */
    .binary-stream:active {
        opacity: 0.15;
    }
    
    .circuit-board:active {
        animation-duration: 10s;
    }
    
    .floating-shapes:active .shape {
        animation-duration: 10s;
    }
}

/* ============================================= */
/* إظهار كل التأثيرات على الموبايل */
/* ============================================= */

@media (max-width: 768px) {
    .binary-stream,
    .circuit-board,
    .data-flow {
        opacity: 0.05;
    }
    
    .shape {
        display: none;
    }
    
    .binary-rain,
    .matrix-rain {
        opacity: 0.03;
    }
    
    /* تحسينات الـ hover للعمل على الموبايل */
    .hover-3d:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* إخفاء الألوان الخاصة في الحالة العادية على الموبايل */
    .terminal-glow::before {
        opacity: 0; /* كان 0.2 */
        animation-duration: 30s;
        filter: blur(4px);
    }
    
    .gradient-border::before {
        opacity: 0.8;
    }
    
    .neon-glow {
        opacity: 0.8;
        animation-duration: 4s;
    }
    
    /* جعل الأشكال العائمة تظهر على الموبايل */
    .floating-shapes {
        display: block;
    }
    
    .shape {
        display: block;
        opacity: 0.05;
        filter: blur(60px);
        animation-duration: 40s;
    }
    
    .shape-1 {
        width: 200px;
        height: 200px;
    }
    
    .shape-2 {
        width: 150px;
        height: 150px;
    }
    
    .shape-3 {
        width: 100px;
        height: 100px;
    }
    
    .shape-4 {
        width: 175px;
        height: 175px;
    }
}

    
    /* إبطاء جميع الأنيميشن للموبايل */
    .binary-line {
        animation-duration: 5s;
    }
    
    .circuit-board {
        animation-duration: 40s;
    }
    
    .data-flow {
        animation-duration: 60s;
    }
    
    .cyber-grid {
        animation-duration: 40s;
    }
    
    .gradient-border::before {
        animation-duration: 6s;
    }
    
    /* تحسينات للـ glass على الموبايل */
    .glass,
    .glass-dark {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    /* تقليل شدة التأثيرات للبطاريات الضعيفة */
    @media (prefers-reduced-motion: reduce) {
        .binary-stream,
        .circuit-board,
        .data-flow,
        .binary-rain,
        .matrix-rain,
        .cyber-grid {
            opacity: 0.05;
        }
    }
}

/* ============================================= */
/* تحسينات إضافية للشاشات الصغيرة جداً */
/* ============================================= */

@media (max-width: 480px) {
    /* خفف التأثيرات أكثر للشاشات الصغيرة */
    .binary-stream,
    .circuit-board,
    .data-flow,
    .binary-rain,
    .matrix-rain {
        opacity: 0.06;
    }
    
    .terminal-glow::before {
        opacity: 0.2;
        filter: blur(3px);
    }
    
    .shape {
        opacity: 0.06;
        filter: blur(20px);
    }
    
    /* تصغير أكثر للأشكال */
    .shape-1 {
        width: 150px;
        height: 150px;
    }
    
    .shape-2 {
        width: 120px;
        height: 120px;
    }
    
    .shape-3 {
        width: 80px;
        height: 80px;
    }
    
    .shape-4 {
        width: 130px;
        height: 130px;
    }
}

/* ============================================= */
/* تحسينات للأداء والبطارية */
/* ============================================= */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    /* إيقاف الأنيميشن الثقيلة */
    .shape,
    .binary-digit,
    .matrix-column,
    .particle {
        animation: none !important;
    }
    
    .terminal-glitch::before,
    .terminal-glitch::after {
        animation: none !important;
        display: none !important;
    }
}

/* ============================================= */
/* دعم خاص للأجهزة المختلفة */
/* ============================================= */

/* لأجهزة iOS */
@supports (-webkit-touch-callout: none) {
    .glass,
    .glass-dark {
        -webkit-backdrop-filter: blur(20px);
    }
}

/* لأجهزة Android القديمة */
@supports not (backdrop-filter: blur(1px)) {
    .glass {
        background: rgba(255, 255, 255, 0.15);
    }
    
    .glass-dark {
        background: rgba(0, 0, 0, 0.4);
    }
}

/* ============================================= */
/* تأثيرات تفاعلية محسنة */
/* ============================================= */

/* تأثير النبض عند التفاعل */
.pulse-on-interact {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(10, 132, 255, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(10, 132, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(10, 132, 255, 0);
    }
}

/* تأثير موجة عند النقر */
.wave-effect {
    position: relative;
    overflow: hidden;
}

.wave-effect:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.6);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        transform: scale(40, 40);
        opacity: 0;
    }
}

/* تحسينات للأنيميشن على الموبايل */
@media (hover: none) {
    .interactive-element {
        -webkit-tap-highlight-color: rgba(10, 132, 255, 0.1);
    }
    
    /* جعل terminal-glow أكثر وضوحاً عند الضغط */
    .terminal-glow:active {
        animation: terminal-glow-active 0.5s ease;
    }
    
    @keyframes terminal-glow-active {
        0% { transform: scale(1); }
        50% { transform: scale(0.98); }
        100% { transform: scale(1); }
    }
}

/* تحسينات للنصوص على الخلفيات */
.hero-badge,
.glass,
.glass-dark {
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ============================================= */
/* دعم Safe Area للـ iPhone X وما فوق */
/* ============================================= */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav-wrapper {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================= */
/* إصلاحات لتحسين الأداء */
/* ============================================= */

/* استخدام will-change للعناصر المتحركة */
.binary-line,
.shape,
.binary-digit,
.matrix-column,
.particle {
    will-change: transform;
}

/* تقليل paint area للأنيميشن */
.binary-stream,
.circuit-board,
.data-flow,
.cyber-grid {
    isolation: isolate;
}