/* ==========================================
   MOBILE OPTIMIZATION ENHANCEMENTS
   Additional mobile-specific fixes
   ========================================== */

/* Prevent horizontal scroll on mobile */
html,
body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari bottom bar */
    .hero {
        min-height: -webkit-fill-available;
    }
    
    /* Prevent rubber band scrolling */
    body {
        overscroll-behavior-y: none;
    }
}

/* Touch optimization */
* {
    -webkit-tap-highlight-color: rgba(0, 212, 255, 0.15);
    -webkit-touch-callout: none;
}

/* Smooth scrolling on mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Mobile-specific text selection */
::selection {
    background: rgba(0, 212, 255, 0.3);
    color: white;
}

::-moz-selection {
    background: rgba(0, 212, 255, 0.3);
    color: white;
}

/* Mobile font smoothing */
@media screen and (max-width: 768px) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
}

/* Hide cursor effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .cursor-dot,
    .cursor-outline {
        display: none !important;
    }
}

/* Mobile image optimization */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* Prevent image dragging on mobile */
    img {
        -webkit-user-drag: none;
        user-select: none;
    }
}

/* Mobile video optimization */
@media (max-width: 768px) {
    video {
        max-width: 100%;
        height: auto;
    }
}

/* Improve mobile button interactions */
@media (max-width: 768px) {
    button,
    .btn,
    a.btn {
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
    }
    
    /* Larger touch targets */
    button,
    .btn {
        min-height: 48px;
    }
    
    .nav-link {
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Mobile form inputs */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        /* Prevent zoom on iOS */
        font-size: 16px !important;
        
        /* Better mobile appearance */
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        
        /* Better tap targets */
        min-height: 48px;
    }
    
    /* Style native select on mobile */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2300d4ff' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 1rem center;
        background-size: 12px;
        padding-right: 3rem;
    }
}

/* Mobile modal improvements */
@media (max-width: 768px) {
    .modal {
        padding: 0;
    }
    
    .modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}

/* Mobile grid optimizations */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
    }
    
    /* Add padding to body to account for fixed navbar */
    body {
        padding-top: 70px;
    }
    
    .nav-menu {
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Mobile hero section */
@media (max-width: 768px) {
    .hero {
        padding: 100px 1.5rem 2rem !important;
        min-height: auto;
    }
    
    .hero-content {
        width: 100%;
        text-align: center;
    }
    
    .hero h1 {
        line-height: 1.3;
        margin-bottom: 1rem;
        font-size: 2rem;
    }
    
    .hero p {
        margin-bottom: 1.5rem;
    }
    
    /* Improved section spacing on mobile */
    .core-identity,
    .about,
    .experience,
    .skills {
        padding: 40px 1.5rem !important;
    }
    
    .core-identity h2,
    .section-title {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 80px 1rem 1.5rem !important;
    }
    
    .core-identity,
    .about,
    .experience,
    .skills {
        padding: 30px 1rem !important;
    }
}

/* Mobile card improvements */
@media (max-width: 768px) {
    .card {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
}

/* Mobile project cards */
@media (max-width: 768px) {
    .project-card {
        overflow: hidden;
    }
    
    .project-overlay {
        position: static;
        opacity: 1;
        background: transparent;
    }
    
    .project-links {
        position: static;
        transform: none;
        display: flex;
        gap: 0.75rem;
        margin-top: 1rem;
    }
    
    .project-link {
        position: static;
        transform: none;
        flex: 1;
        text-align: center;
        padding: 0.75rem;
        background: rgba(0, 212, 255, 0.1);
        border: 1px solid rgba(0, 212, 255, 0.3);
        border-radius: 8px;
    }
}

/* Mobile footer */
@media (max-width: 768px) {
    .footer {
        text-align: center;
    }
    
    .footer-social {
        justify-content: center;
    }
    
    .social-link {
        width: 40px;
        height: 40px;
    }
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
    /* Reduce animations on mobile for performance */
    * {
        animation-duration: 0.3s !important;
    }
    
    /* Simplify shadows on mobile */
    .card,
    .project-card {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    /* Reduce blur effects on mobile */
    .hero-background,
    .cyber-grid {
        filter: none;
    }
}

/* Enhanced Mobile Button Styling */
@media (max-width: 768px) {
    .btn,
    button.btn,
    a.btn {
        width: 100%;
        max-width: 100%;
        padding: 14px 24px !important;
        font-size: 16px !important;
        border-radius: 24px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: all 0.3s ease;
        font-weight: 600;
        letter-spacing: 0.5px;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
    
    .btn-text {
        white-space: normal;
        word-break: break-word;
    }
    
    /* Hero button container - stack vertically on mobile */
    .hero-buttons {
        display: flex;
        flex-direction: column;
        gap: 12px !important;
        margin-top: 2rem;
        width: 100%;
    }
    
    .btn-primary {
        background: var(--gradient-primary) !important;
        color: white !important;
        border: none !important;
        box-shadow: 0 8px 24px rgba(204, 103, 65, 0.25) !important;
    }
    
    .btn-primary:hover,
    .btn-primary:active {
        box-shadow: 0 12px 32px rgba(204, 103, 65, 0.35) !important;
    }
    
    .btn-secondary {
        background: transparent !important;
        color: var(--primary-color) !important;
        border: 2px solid var(--primary-color) !important;
    }
    
    .btn-secondary:hover,
    .btn-secondary:active {
        background: rgba(204, 103, 65, 0.08) !important;
    }
}

/* Enhanced Mobile Hero Section */
@media (max-width: 768px) {
    .hero {
        padding: 100px 1.5rem 3rem !important;
        min-height: auto;
    }
    
    .hero-container {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        align-items: center;
    }
    
    .hero-content {
        width: 100%;
        text-align: center;
        padding: 0;
    }
    
    .hero-image {
        width: 100%;
        max-width: 300px;
        margin: 1rem 0;
    }
    
    .hero-title {
        font-size: 2rem !important;
        line-height: 1.3 !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-subtitle {
        font-size: 1.1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .hero-description {
        font-size: 0.95rem !important;
        line-height: 1.7 !important;
        margin-bottom: 2rem !important;
        color: var(--text-secondary) !important;
    }
}

/* Enhanced Mobile Status Indicator */
@media (max-width: 768px) {
    .status-indicator {
        display: inline-flex;
        margin: 0 auto 1.5rem;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 0.85rem;
        font-weight: 600;
        letter-spacing: 1px;
    }
}

/* Enhanced Mobile Social Links */
@media (max-width: 768px) {
    .social-links {
        display: flex;
        justify-content: center;
        gap: 1rem;
        margin-top: 2rem;
    }
    
    .social-link {
        width: 48px !important;
        height: 48px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: rgba(204, 103, 65, 0.1);
        border: 1px solid rgba(204, 103, 65, 0.2);
        transition: all 0.3s ease;
        font-size: 1.2rem;
    }
    
    .social-link:active {
        transform: scale(0.92);
        background: rgba(204, 103, 65, 0.2);
    }
}

/* Mobile landscape mode */

/* Mobile hero avatar optimization */
@media (max-width: 768px) {
    .hero-avatar {
        width: 100%;
        max-width: 280px;
        margin: 1.5rem auto;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .hero-avatar img {
        width: 100%;
        height: auto;
        border-radius: 16px;
        display: block;
    }
}

/* Mobile scroll indicator */
@media (max-width: 768px) {
    .scroll-indicator {
        display: none !important;
    }
}

/* Improved mobile form styling */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px !important;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        min-height: 48px;
        padding: 12px 16px;
        border-radius: 8px;
        border: 1px solid rgba(204, 103, 65, 0.3);
        background: var(--bg-card);
        color: var(--text-primary);
        width: 100%;
    }
    
    input:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(204, 103, 65, 0.1);
    }
    
    textarea {
        resize: vertical;
        min-height: 120px;
    }
}

/* Mobile spacing improvements */
@media (max-width: 768px) {
    .container {
        padding: 0 1.5rem !important;
    }

    /* Reduce vertical whitespace between sections across all pages */
    section {
        padding: 2.2rem 0 !important;
    }

    /* Also tighten generic section wrapper used in some pages */
    .section {
        padding: 2.2rem 0 !important;
    }

    /* Prevent extra header whitespace on mobile */
    .section-header {
        margin-bottom: 3rem !important;
    }

    /* Tighten common headings and paragraphs a bit to feel less spaced */
    h2,
    h3 {
        margin-top: 0 !important;
        margin-bottom: 0.9rem !important;
    }

    p {
        margin-bottom: 0.9rem !important;
    }
}



/* Mobile text optimization */
@media (max-width: 768px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.8rem;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.2rem;
        line-height: 1.4;
    }
    
    p {
        font-size: 0.95rem;
        line-height: 1.7;
    }
    
    small {
        font-size: 0.85rem;
    }
}

/* Mobile touch-friendly elements */
@media (max-width: 768px) {
    a,
    button,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    button {
        padding: 12px 24px;
    }
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
    .navbar {
        height: auto;
        padding: 1rem 1.5rem;
    }
    
    .nav-logo a {
        font-size: 1.2rem;
    }
    
    .hamburger {
        display: flex;
    }
}

/* Hide non-essential mobile elements */
@media (max-width: 480px) {
    .scroll-indicator,
    .floating-elements,
    .cyber-grid,
    .glitch {
        display: none !important;
    }
}

/* Extra small mobile optimization (phones under 400px width) */
@media (max-width: 400px) {
    .hero-title {
        font-size: 1.6rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    .btn {
        font-size: 14px !important;
        padding: 12px 20px !important;
    }
}
@media (max-width: 896px) and (orientation: landscape) {
    .hero {
        padding: 1.5rem 0;
    }
    
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero-stats {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    section {
        padding: 2rem 0 !important;
    }
}

/* Tablet optimization */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Fix for notched devices (iPhone X and later) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    
    .navbar {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Accessibility improvements for mobile */
@media (max-width: 768px) {
    /* Better focus indicators on mobile */
    a:focus,
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Skip to content link for mobile */
    .skip-to-content {
        position: absolute;
        top: -40px;
        left: 0;
        background: var(--primary-color);
        color: white;
        padding: 8px;
        text-decoration: none;
        z-index: 10000;
    }
    
    .skip-to-content:focus {
        top: 0;
    }
}

/* Loading optimization for mobile */
@media (max-width: 768px) {
    /* Lazy load images */
    img[loading="lazy"] {
        background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(139, 92, 246, 0.1));
    }
    
    /* Skeleton loading for cards */
    .card.loading {
        background: linear-gradient(
            90deg,
            rgba(255, 255, 255, 0.05) 0%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 100%
        );
        background-size: 200% 100%;
        animation: skeleton-loading 1.5s ease-in-out infinite;
    }
    
    @keyframes skeleton-loading {
        0% {
            background-position: 200% 0;
        }
        100% {
            background-position: -200% 0;
        }
    }
}

/* Mobile debug helper (remove in production) */
@media (max-width: 768px) {
    /* Uncomment to see mobile breakpoint indicator
    body::before {
        content: 'Mobile View';
        position: fixed;
        top: 70px;
        right: 10px;
        background: rgba(0, 212, 255, 0.9);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 12px;
        z-index: 9999;
        pointer-events: none;
    }
    */
}

    /* Custom Fixes for Mobile Layout (Hero & Core Identity) */
    @media (max-width: 768px) {

    /* Make hero container single column */
    .hero-container {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Improve global tappable/clickable fit */
    .nav-link {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }

    /* Make section titles not overflow */
    .section-title {
        word-break: break-word;
        line-height: 1.15;
    }

    /* Put hero CTA buttons in a horizontal row (2 buttons per row feel better on mobile) */
    .hero-buttons {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.9rem !important;
        width: 100%;
        justify-content: center;
    }

    .hero-buttons .btn {
        width: auto;
        /* keep desktop-ish button sizing while still fitting two per row */
        flex: 0 0 auto;
        max-width: 100%;
        justify-content: center;
    }

    /* Center social icons under hero/buttons on mobile */
    .social-links {
        justify-content: center !important;
        width: 100% !important;
    }



    /* Core Identity grid adjust for small phones */
    .core-identity > .container > div {
        grid-template-columns: 1fr !important;
    }
}


@media (max-width: 480px) {
    .hero-title {
        font-size: 2.2rem !important;
    }
    .hero-subtitle {
        font-size: 1.2rem !important;
    }
}

/* Global Section Padding Reduction for Mobile */
@media (max-width: 768px) {
    .section, section, .about {
        padding: 4rem 0 !important;
    }
    .section-title {
        font-size: 2.2rem !important;
        margin-bottom: 2rem !important;
    }
    
    /* Optimize internal tabs (Skills, Experience, Projects) */
    .cyber-tabs, .cyber-tabs-container, .experience-tabs, .project-filters {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        padding-bottom: 10px !important;
        -webkit-overflow-scrolling: touch;
        gap: 0.75rem !important;
        max-width: 100%;
    }
    
    /* Hide scrollbar but keep functionality */
    .cyber-tabs::-webkit-scrollbar,
    .cyber-tabs-container::-webkit-scrollbar,
    .experience-tabs::-webkit-scrollbar,
    .project-filters::-webkit-scrollbar {
        height: 4px;
        display: none;
    }
    
    .cyber-tab, .filter-btn {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        padding: 0.6rem 1.2rem !important;
        font-size: 0.9rem !important;
    }
}
