/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* RTL Support */
body[dir="rtl"] {
    direction: rtl;
}

/* Language Switcher - Fixed position and compact */
.language-switcher {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.25rem;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 0.25rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    direction: ltr !important; /* Force LTR to prevent RTL flip */
}

.lang-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 0.375rem 0.5rem;
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    touch-action: manipulation;
    direction: ltr !important; /* Force LTR for consistency */
}

.lang-btn.active {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.lang-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* RTL Support - Override language switcher positioning */
body[dir="rtl"] .language-switcher {
    right: 1rem !important;
    left: auto !important;
    direction: ltr !important; /* Keep LTR layout regardless of RTL body */
}

body[dir="rtl"] .lang-btn {
    direction: ltr !important; /* Keep LTR button order */
}

/* Matrix Background - Optimized for performance */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: -2;
}

.matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.15;
    will-change: transform;
    display: block; /* Ensure canvas is visible */
    pointer-events: none; /* Allow clicks to pass through */
}

/* Optimize matrix animation for mobile */
@media (max-width: 768px) {
    .matrix-canvas {
        opacity: 0.08;
    }
}

@media (max-width: 480px) {
    .matrix-canvas {
        opacity: 0.05;
    }
}

/* Container */
.container {
    max-width: 400px;
    margin: 0 auto;
    padding: 4rem 1.5rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Profile Section */
.profile-section {
    text-align: center;
    margin-bottom: 2.5rem;
    animation: fadeInUp 0.8s ease-out;
    position: relative;
    z-index: 1;
}

.name {
    font-size: clamp(2rem, 8vw, 2.5rem);
    font-weight: 700;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    animation: glow 2s ease-in-out infinite alternate;
    line-height: 1.2;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px #00ff88, 0 0 20px #00ff88, 0 0 30px #00ff88;
    }
    to {
        text-shadow: 0 0 20px #00ccff, 0 0 30px #00ccff, 0 0 40px #00ccff;
    }
}

.title {
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    font-weight: 300;
    color: #00ff88;
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
    opacity: 0.9;
    line-height: 1.4;
}

.tagline {
    font-size: clamp(0.7rem, 2.2vw, 0.85rem);
    color: #00ccff;
    font-style: italic;
    opacity: 0.8;
}

/* Viewfinder Container */
.viewfinder-container {
    position: relative;
    width: 100%;
    max-width: 280px;
    margin: 0 auto 1.5rem;
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.viewfinder-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    filter: saturate(0.8) contrast(1.1);
}

.viewfinder-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(0.5px);
    transition: filter 0.3s ease;
}

.viewfinder-container:hover .viewfinder-image {
    filter: saturate(1) contrast(1.15) blur(0);
}

/* Viewfinder Overlay */
.viewfinder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 10;
    pointer-events: none;
}

/* HUD Elements */
.hud-top {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

.battery-icon i,
.settings-icon i {
    font-size: 0.875rem;
}

/* Focus Points */
.focus-points {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.focus-square {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.focus-square.top-left {
    top: 15px;
    left: 15px;
    border-right: none;
    border-bottom: none;
}

.focus-square.top-right {
    top: 15px;
    right: 15px;
    border-left: none;
    border-bottom: none;
}

.focus-square.bottom-left {
    bottom: 15px;
    left: 15px;
    border-right: none;
    border-top: none;
}

.focus-square.bottom-right {
    bottom: 15px;
    right: 15px;
    border-left: none;
    border-top: none;
}

/* Center Focus */
.center-focus {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.center-crosshair {
    width: 60px;
    height: 60px;
    position: relative;
}

.center-crosshair::before,
.center-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
}

.center-crosshair::before {
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    transform: translateY(-50%);
}

.center-crosshair::after {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
}

/* REC Indicator */
.rec-indicator {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ff3333;
    font-size: 0.75rem;
    font-weight: bold;
}

.rec-dot {
    width: 8px;
    height: 8px;
    background: #ff3333;
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* HUD Bottom */
.hud-bottom {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
}

/* Grid Lines */
.grid-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.grid-vertical,
.grid-horizontal {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
}

.grid-vertical {
    width: 1px;
    height: 100%;
    top: 0;
}

.grid-vertical:nth-child(1) { left: 33.33%; }
.grid-vertical:nth-child(2) { right: 33.33%; }

.grid-horizontal {
    height: 1px;
    width: 100%;
    left: 0;
}

.grid-horizontal:nth-child(3) { top: 33.33%; }
.grid-horizontal:nth-child(4) { bottom: 33.33%; }

/* Links Section */
.links-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.contact-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #ffffff;
    text-decoration: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    font-size: clamp(0.875rem, 2.5vw, 1rem);
    touch-action: manipulation;
}

.contact-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.contact-btn:hover::before {
    left: 100%;
}

.contact-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.contact-btn svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.contact-btn .x-logo {
    width: 1.125rem;
    height: 1.125rem;
}

.contact-btn i {
    font-size: clamp(1rem, 3vw, 1.25rem);
    width: 1.25rem;
    text-align: center;
    flex-shrink: 0;
}

.contact-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* New Project Card Styles */
.contact-btn.project-card {
    position: relative;
    overflow: hidden;
}

.contact-btn.project-card .project-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    margin-left: 0.75rem;
}

.contact-btn.project-card .project-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #ffffff;
    margin-bottom: 0.125rem;
}

.contact-btn.project-card .project-desc {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 300;
}

/* Hover animations for project cards */
.contact-btn.project-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
    border-color: rgba(0, 255, 136, 0.3);
}

.contact-btn.project-card:hover .project-title {
    color: #00ff88;
}

.contact-btn.project-card:hover .project-desc {
    color: rgba(0, 255, 136, 0.8);
}

/* Icon animations */
.contact-btn.project-card i {
    transition: transform 0.3s ease;
}

.contact-btn.project-card:hover i {
    transform: scale(1.1);
}

/* RTL support for project cards */
body[dir="rtl"] .contact-btn.project-card .project-info {
    margin-left: 0;
    margin-right: 0.75rem;
    align-items: flex-end;
}

/* RTL adjustments */
body[dir="rtl"] .contact-btn {
    flex-direction: row-reverse;
}

body[dir="rtl"] .contact-btn i {
    margin-left: 0.5rem;
}

/* Brand-specific button colors */
.phone-btn:hover {
    border-color: #00b894;
    box-shadow: 0 8px 25px rgba(0, 184, 148, 0.2);
}

.whatsapp-btn:hover {
    border-color: #25d366;
    box-shadow: 0 8px 25px rgba(37, 211, 102, 0.2);
}

.email-btn:hover {
    border-color: #ea4335;
    box-shadow: 0 8px 25px rgba(234, 67, 53, 0.2);
}

.instagram-btn:hover {
    border-color: #e4405f;
    box-shadow: 0 8px 25px rgba(228, 64, 95, 0.2);
}

.snapchat-btn:hover {
    border-color: #fffc00;
    color: #000000;
    background: rgba(255, 252, 0, 0.1);
}

.twitter-btn:hover {
    border-color: #1da1f2;
    box-shadow: 0 8px 25px rgba(29, 161, 242, 0.2);
}

.portfolio-btn:hover {
    border-color: #6366f1;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.2);
}

/* GitHub button color */
.github-btn:hover {
    border-color: #333;
    box-shadow: 0 8px 25px rgba(51, 51, 51, 0.2);
}

/* LinkedIn button color */
.linkedin-btn:hover {
    border-color: #0077b5;
    box-shadow: 0 8px 25px rgba(0, 119, 181, 0.2);
}

/* vCard Section */
.vcard-section {
    text-align: center;
}

.vcard-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50px;
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

.vcard-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* Animations - Optimized for performance */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes kenBurns {
    0% {
        transform: scale(1);
    }
    100% {
        transform: scale(1.05);
    }
}

@keyframes grain {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-1px, 1px); }
    20% { transform: translate(-2px, 0); }
    30% { transform: translate(1px, -1px); }
    40% { transform: translate(-1px, -2px); }
    50% { transform: translate(2px, 1px); }
    60% { transform: translate(-1px, 1px); }
    70% { transform: translate(1px, 2px); }
    80% { transform: translate(-2px, -1px); }
    90% { transform: translate(1px, -1px); }
    100% { transform: translate(0, 0); }
}

/* Responsive Design - Enhanced for mobile */
@media (max-width: 768px) {
    .container {
        padding: 3.5rem 1rem 1.5rem;
        max-width: 100%;
    }
    
    .contact-btn {
        padding: 1rem;
        margin: 0 0.25rem;
        font-size: 0.9rem;
    }
    
    /* Prevent hover effects on touch devices */
    @media (hover: none) {
        .contact-btn:hover {
            transform: none;
            box-shadow: none;
        }
        
        .contact-btn:active {
            transform: scale(0.98);
            background: rgba(255, 255, 255, 0.15);
        }
    }
}

@media (max-width: 480px) {
    .container {
        padding: 3rem 0.5rem 1rem;
    }
    
    .name {
        font-size: clamp(1.75rem, 7vw, 2.25rem);
    }
    
    .title {
        font-size: clamp(0.7rem, 2.2vw, 0.8rem);
    }
    
    .contact-btn {
        padding: 0.875rem 0.75rem;
        font-size: 0.85rem;
    }
}

/* Ensure canvas works on all devices */
body {
    background: #000;
}

/* Safe area support for modern devices */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .language-switcher {
        top: max(1rem, env(safe-area-inset-top));
        right: max(1rem, env(safe-area-inset-right));
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .contact-btn {
        border: 2px solid rgba(255, 255, 255, 0.8);
    }
    
    .contact-btn:hover {
        border-color: #00ff88;
    }
}

/* Focus styles for accessibility */
.contact-btn:focus-visible {
    outline: 2px solid #00ff88;
    outline-offset: 2px;
}

/* Smooth scrolling for iOS */
html {
    -webkit-overflow-scrolling: touch;
}

/* Optimize animations for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .name {
        animation: none;
    }
    
    .contact-btn {
        transition: none;
    }
    
    .matrix-canvas {
        display: none;
    }
}
