/* ========================================
   MOBILE OPTIMIZATION CSS
   Ultimate Mobile Experience for Android & iOS
   ======================================== */

/* ========================================
   BASE MOBILE OPTIMIZATIONS
   ======================================== */

/* Prevent text size adjustment on orientation change */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Mobile-friendly body */
@media (max-width: 768px) {
    body {
        padding: 0.75rem !important;
        overflow-x: hidden;
    }
    
    body.dark-theme,
    body.light-theme {
        padding: 0.75rem !important;
    }
}

/* ========================================
   TOUCH OPTIMIZATIONS
   ======================================== */

/* Disable custom cursor on mobile */
@media (max-width: 768px), (hover: none) {
    .cursor-dot {
        display: none !important;
    }
    
    * {
        cursor: auto !important;
    }
}

/* Touch-friendly tap highlighting */
@media (max-width: 768px) {
    a, button, .nav-link, .social-link, .skill-badge {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    .dark-theme a, 
    .dark-theme button, 
    .dark-theme .nav-link, 
    .dark-theme .social-link {
        -webkit-tap-highlight-color: rgba(34, 211, 238, 0.2);
    }
}

/* ========================================
   PORTFOLIO CARD MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Make portfolio card allow overflow for nav positioning */
    #portfolio-card {
        border-radius: 1rem !important;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
        margin: 0 auto;
        max-width: 100%;
        overflow: visible !important;
        position: relative !important;
    }
    
    /* Canvas header - ensure proper stacking */
    #portfolio-card > div:has(#benedict-canvas) {
        position: relative !important;
        z-index: 1 !important;
    }
    
    /* Navigation - overlay on canvas */
    nav {
        position: absolute !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
        left: auto !important;
        padding: 0.5rem !important;
        width: auto !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 0.5rem !important;
        border: none !important;
        margin: 0 !important;
        z-index: 25 !important;
        border-radius: 1rem !important;
        backdrop-filter: blur(16px) saturate(180%);
        -webkit-backdrop-filter: blur(16px) saturate(180%);
    }
    
    /* Nav background - Liquid Glass Effect */
    .light-theme nav,
    body:not(.dark-theme) nav {
        background: rgba(255, 255, 255, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
    }
    
    .dark-theme nav {
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    }
    
    /* Nav container - make flex row centered */
    nav > div,
    nav > .flex {
        flex-direction: row !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 0 !important;
        width: 100% !important;
        flex: 1 !important;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }
    
    /* Theme toggle - left corner on mobile with liquid glass */
    nav button.theme-toggle,
    nav button[onclick*="toggleTheme"],
    .theme-toggle {
        width: auto !important;
        padding: 0.4rem !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        border-radius: 0.5rem !important;
        flex-shrink: 0 !important;
        order: -1 !important;
        margin-right: auto !important;
        margin-left: -0.5rem !important;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        transition: all 0.3s ease;
    }
    
    .light-theme .theme-toggle,
    body:not(.dark-theme) .theme-toggle {
        background: rgba(255, 255, 255, 0.5);
        border: 1px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 16px rgba(31, 38, 135, 0.1),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.4);
    }
    
    .dark-theme .theme-toggle,
    .dark-theme nav button {
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.15);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
    }
    
    .theme-toggle svg,
    nav button svg {
        width: 1rem !important;
        height: 1rem !important;
    }
    
    /* Navigation links - inline horizontal centered */
    nav ul {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 0.25rem !important;
        padding: 0 !important;
        width: auto !important;
        max-width: none !important;
        background: transparent;
        border-radius: 0;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        box-shadow: none;
        border: none;
        overflow-x: visible !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        margin: 0 !important;
        flex-shrink: 1 !important;
    }
    
    nav ul::-webkit-scrollbar {
        display: none !important;
    }
    
    .light-theme nav ul {
        background: transparent;
        border: none;
    }
    
    .dark-theme nav ul {
        background: transparent;
        border: none;
    }
    
    nav ul li {
        flex: 0 0 auto !important;
        display: inline-flex !important;
    }
    
    nav ul li span {
        display: none !important; /* Hide separators on mobile */
    }
    
    .nav-link {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.7rem !important;
        letter-spacing: 0.01em !important;
        border-radius: 0.375rem !important;
        min-width: auto !important;
        text-align: center !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        display: inline-block !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
    }
    
    .nav-link.active {
        font-weight: 700 !important;
        box-shadow: 0 2px 8px rgba(168, 85, 247, 0.3) !important;
    }
    
    /* Active indicator for mobile */
    .light-theme .nav-link.active {
        background: rgba(59, 130, 246, 0.15) !important;
        color: #2563eb !important;
        box-shadow: 0 2px 6px rgba(59, 130, 246, 0.2) !important;
    }
    
    .dark-theme .nav-link.active {
        background: rgba(34, 211, 238, 0.2) !important;
        color: #22d3ee !important;
        box-shadow: 0 2px 6px rgba(34, 211, 238, 0.25) !important;
    }
    
    /* Hover states for mobile */
    .light-theme .nav-link:not(.active):active {
        background: rgba(59, 130, 246, 0.08) !important;
    }
    
    .dark-theme .nav-link:not(.active):active {
        background: rgba(34, 211, 238, 0.12) !important;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    nav {
        padding: 0.5rem 0.25rem !important; /* Reduced horizontal padding */
    }
    
    .nav-link {
        padding: 0.4rem 0.4rem !important; /* Tighter links */
        font-size: 0.6rem !important;
    }
    
    .theme-toggle {
        padding: 0.4rem !important;
    }
    
    .theme-toggle svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }

    /* Ensure blogs nav is also compact */
    .blogs-nav-container {
        padding: 0.25rem !important;
        top: 4.5rem !important;
        left: 0.25rem !important;
    }

    .blogs-nav-container .nav-link {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.6rem !important;
    }
}

/* ========================================
   CANVAS HEADER MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Canvas header adjustments */
    .relative.h-32,
    #portfolio-card > div:has(#benedict-canvas) {
        height: 5rem !important;
        min-height: 5rem !important;
        margin-top: 0 !important;
        position: relative !important;
        z-index: 1 !important;
    }
    
    #benedict-canvas {
        height: 5rem !important;
    }
    
    .canvas-loading::after {
        font-size: 1rem !important;
    }
    
    /* Ensure proper spacing after nav */
    #portfolio-card > div:first-of-type {
        margin-top: 0 !important;
    }
}

@media (max-width: 480px) {
    .relative.h-32 {
        height: 4rem !important;
        min-height: 4rem !important;
    }
    
    #benedict-canvas {
        height: 4rem !important;
    }
    
    .canvas-loading::after {
        font-size: 0.875rem !important;
    }
}

/* ========================================
   CONTENT AREA MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    #content-area {
        padding: 1.25rem !important;
    }
}

@media (max-width: 480px) {
    #content-area {
        padding: 1rem !important;
    }
}

/* ========================================
   HOME SECTION MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Header adjustments */
    header {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 1rem !important;
    }
    
    header .text-center {
        text-align: center !important;
    }
    
    /* Avatar optimization */
    .avatar-wave {
        width: 5rem !important;
        height: 5rem !important;
    }
    
    /* Disable avatar animations on mobile for performance */
    .avatar-wave::before,
    .avatar-wave::after {
        display: none !important;
    }
    
    /* Typography adjustments */
    h1 {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }
    
    h3 {
        font-size: 1.1rem !important;
    }
    
    p, li {
        font-size: 0.875rem !important;
        line-height: 1.6 !important;
    }
    
    /* Grid adjustments */
    .grid-cols-1.lg\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.25rem !important;
    }
    
    h2 {
        font-size: 1.1rem !important;
    }
    
    p, li {
        font-size: 0.8125rem !important;
    }
    
    .avatar-wave {
        width: 4.5rem !important;
        height: 4.5rem !important;
    }
}

/* ========================================
   SOCIAL LINKS MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    .social-link {
        padding: 0.75rem !important;
        border-radius: 0.875rem !important;
        transition: all 0.2s ease !important;
    }
    
    /* Simplified hover effects for mobile */
    .social-link:hover,
    .social-link:active {
        transform: translateY(-2px) scale(1.02) !important;
    }
    
    .social-icon {
        width: 1.125rem !important;
        height: 1.125rem !important;
    }
    
    .social-link-text {
        font-size: 0.8125rem !important;
    }
    
    /* Disable complex animations on mobile */
    .social-link::before {
        display: none;
    }
    
    .social-icon:hover {
        animation: none !important;
    }
    
    /* Grid adjustments */
    .grid-cols-1.sm\\:grid-cols-2 {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.625rem !important;
    }
}

@media (max-width: 480px) {
    .grid-cols-1.sm\\:grid-cols-2 {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   SKILLS SECTION MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    .skills-container {
        gap: 0.5rem !important;
        justify-content: center;
    }
    
    .skill-badge {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.6875rem !important;
        border-radius: 0.625rem !important;
    }
    
    .skill-icon {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    
    .skill-icon svg {
        width: 0.875rem !important;
        height: 0.875rem !important;
    }
    
    .skill-icon-text {
        font-size: 0.75rem !important;
    }
    
    .skill-name {
        font-size: 0.6875rem !important;
    }
    
    /* Disable entrance animations on mobile */
    .skill-badge {
        animation: none !important;
    }
}

/* ========================================
   EXPERIENCE SECTION MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    .experience-container {
        padding: 1rem !important;
        border-radius: 0.75rem !important;
    }
    
    .experience-switcher {
        padding: 0.25rem !important;
        margin-bottom: 1.25rem !important;
    }
    
    .experience-switcher button {
        padding: 0.625rem !important;
        font-size: 0.8125rem !important;
    }
    
    /* Timeline optimization */
    .timeline-item {
        padding-left: 2rem !important;
        padding-bottom: 2rem !important;
        margin-left: 0.25rem !important;
    }
    
    .timeline-item:hover {
        transform: none !important;
    }
    
    .timeline-icon {
        width: 2rem !important;
        height: 2rem !important;
        left: -1rem !important;
        font-size: 0.625rem !important;
    }
    
    .timeline-icon:hover {
        transform: scale(1.05) !important;
    }
    
    .job-title,
    .company-name {
        font-size: 0.9375rem !important;
    }
    
    .timeline-item ul {
        font-size: 0.8125rem !important;
    }
}

@media (max-width: 480px) {
    .experience-container {
        padding: 0.875rem !important;
    }
    
    .timeline-item {
        padding-left: 1.5rem !important;
    }
    
    .timeline-icon {
        width: 1.75rem !important;
        height: 1.75rem !important;
        left: -0.875rem !important;
        font-size: 0.5625rem !important;
    }
}

/* ========================================
   PROJECTS SECTION MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Force single column layout */
    .projects-grid,
    #content-area .grid,
    div[class*="grid"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .project-card {
        padding: 1.25rem !important;
        border-radius: 0.875rem !important;
        display: block !important;
        width: 100% !important;
        margin-bottom: 0 !important;
    }
    
    .project-card:hover {
        transform: translateY(-2px) !important;
    }
    
    .project-card h3 {
        font-size: 1.125rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    .project-card p {
        font-size: 0.8125rem !important;
        line-height: 1.5 !important;
    }
    
    /* Tag adjustments */
    .project-card .flex-wrap {
        gap: 0.375rem !important;
    }
    
    .project-card span.px-2 {
        padding: 0.375rem 0.625rem !important;
        font-size: 0.6875rem !important;
    }
}

@media (max-width: 480px) {
    .project-card {
        padding: 1rem !important;
    }
    
    .project-card h3 {
        font-size: 1rem !important;
    }
    
    .project-card p {
        font-size: 0.75rem !important;
    }
}

/* ========================================
   CONTACT FORM MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    textarea {
        font-size: 1rem !important; /* Prevent zoom on iOS */
        padding: 0.75rem !important;
        border-radius: 0.625rem !important;
    }
    
    textarea {
        min-height: 8rem !important;
    }
    
    button[type="submit"] {
        padding: 0.875rem 1.5rem !important;
        font-size: 0.9375rem !important;
        border-radius: 0.625rem !important;
        width: 100%;
    }
}

/* ========================================
   POPUP MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    .popup-enter-active .shadow-xl {
        min-width: 85vw !important;
        padding: 1.5rem !important;
    }
    
    .popup-enter-active svg {
        width: 2rem !important;
        height: 2rem !important;
    }
    
    .popup-enter-active .text-lg {
        font-size: 1rem !important;
    }
    
    .popup-enter-active .text-sm {
        font-size: 0.8125rem !important;
    }
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS FOR MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Disable GPU-heavy effects on mobile */
    .card-motion {
        will-change: auto !important;
        backface-visibility: visible !important;
    }
    
    /* Simplify backdrop filters on mobile */
    .social-link,
    .skill-badge {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    /* Disable interactive grid on mobile */
    .interactive-grid {
        display: none !important;
    }
    
    /* Simplify shadows for better performance */
    #portfolio-card {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Disable complex animations */
    .social-icon,
    .theme-toggle,
    .avatar-wave::before {
        animation: none !important;
    }
}

/* ========================================
   ORIENTATION HANDLING
   ======================================== */

@media (max-width: 768px) and (orientation: landscape) {
    .relative.h-32 {
        height: 3.5rem !important;
    }
    
    #benedict-canvas {
        height: 3.5rem !important;
    }
    
    .avatar-wave {
        width: 4rem !important;
        height: 4rem !important;
    }
    
    #content-area {
        padding: 1rem !important;
    }
}

/* ========================================
   SAFE AREA INSETS (for notched devices)
   ======================================== */

@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        body {
            padding-left: max(0.75rem, env(safe-area-inset-left)) !important;
            padding-right: max(0.75rem, env(safe-area-inset-right)) !important;
            padding-top: max(0.75rem, env(safe-area-inset-top)) !important;
            padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
        }
    }
}

/* ========================================
   ANDROID SPECIFIC OPTIMIZATIONS
   ======================================== */

/* Prevent text selection on interactive elements */
@media (max-width: 768px) {
    .nav-link,
    .social-link,
    .skill-badge,
    button,
    .theme-toggle {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* ========================================
   IMPROVED READABILITY ON MOBILE
   ======================================== */

@media (max-width: 768px) {
    /* Better text contrast */
    .light-theme p,
    .light-theme li {
        color: #374151 !important;
    }
    
    .dark-theme p,
    .dark-theme li {
        color: #d1d5db !important;
    }
    
    /* Better spacing */
    section {
        margin-bottom: 2rem !important;
    }
    
    .space-y-8 > * + * {
        margin-top: 1.5rem !important;
    }
    
    .space-y-12 > * + * {
        margin-top: 2rem !important;
    }
}

/* ========================================
   FIXED MOBILE ISSUES
   ======================================== */

@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    body, html, #app, #portfolio-card {
        overflow-x: hidden !important;
        max-width: 100vw;
    }
    
    /* Fix z-index stacking on mobile */
    nav {
        z-index: 30 !important;
    }
    
    #portfolio-card {
        z-index: 10 !important;
    }
    
    .interactive-grid {
        z-index: 1 !important;
    }
}

/* ========================================
   BLOGS NAVIGATION - MOBILE OPTIMIZATION
   ======================================== */

@media (max-width: 768px) {
    /* Blogs nav container - adjust positioning for mobile */
    .blogs-nav-container {
        position: absolute !important;
        top: 3.5rem !important;
        left: 0.5rem !important;
        padding: 0.5rem !important;
        z-index: 35 !important; /* Higher than main nav (30) */
        border-radius: 1rem !important;
        backdrop-filter: blur(16px) saturate(180%);
        -webkit-backdrop-filter: blur(16px) saturate(180%);
    }
    
    /* Match main nav glass effect */
    .light-theme .blogs-nav-container,
    body:not(.dark-theme) .blogs-nav-container {
        background: rgba(255, 255, 255, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.4);
        box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.5);
    }
    
    .dark-theme .blogs-nav-container {
        background: rgba(0, 0, 0, 0.4);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37),
                    inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
    }

    /* Blogs nav link - compact mobile styling */
    .blogs-nav-container .nav-link {
        padding: 0.35rem 0.5rem !important;
        font-size: 0.7rem !important;
        letter-spacing: 0.01em !important;
        border-radius: 0.375rem !important;
        min-width: auto !important;
        text-align: center !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        display: inline-block !important;
        transition: all 0.2s ease !important;
        flex-shrink: 0 !important;
    }
}

/* Extra small mobile screens */
@media (max-width: 480px) {
    .blogs-nav-container .nav-link {
        font-size: 0.65rem !important;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .blogs-nav-container {
        top: 0.25rem !important;
        left: 0.25rem !important;
        padding: 0.25rem !important;
    }
}
