/* Samsung Mobile Specific Fixes and Optimizations */

/* Samsung Browser Safe Area Support */
@supports (padding: env(safe-area-inset-top)) {
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
    
    .mobile-menu-toggle {
        margin-right: env(safe-area-inset-right);
    }
    
    .scroll-to-top {
        bottom: calc(2rem + env(safe-area-inset-bottom)) !important;
        right: calc(2rem + env(safe-area-inset-right)) !important;
    }
}

/* Samsung Galaxy S Series Specific (360px - 384px width) */
@media screen and (min-width: 360px) and (max-width: 384px) {
    /* Optimize container padding */
    .container {
        padding: 0 1rem;
    }
    
    /* Hero section adjustments */
    .hero-content {
        padding: 1rem 0;
    }
    
    .hero h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .hero-description {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Button optimizations */
    .btn {
        font-size: 0.875rem;
        padding: 0.875rem 1.25rem;
        min-height: 48px;
        width: 100%;
    }
    
    /* Navigation fixes */
    .nav-menu {
        top: 60px;
        height: calc(100vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-link {
        padding: 1rem;
        font-size: 1.125rem;
        min-height: 48px;
    }
    
    /* Section spacing */
    section {
        padding: 2.5rem 0;
    }
    
    .section-header {
        margin-bottom: 1.5rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    /* Cards and grids */
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .tech-item {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    .project-card {
        padding: 1.25rem;
    }
    
    /* Stats optimization */
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-number {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
}

/* Samsung High DPI Screen Support (3x density) */
@media screen and (-webkit-min-device-pixel-ratio: 3) {
    /* Sharper borders */
    .btn, .nav-link, .card {
        border-width: 0.5px;
    }
    
    /* Thinner lines for high DPI */
    .hamburger-line {
        height: 2.5px;
    }
    
    /* Adjust icon sizes */
    .fas, .fab, .far {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Samsung Fold/Flip Support */
@media screen and (min-width: 280px) and (max-width: 362px) {
    /* Ultra narrow screen optimizations */
    .container {
        padding: 0 0.75rem;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }
    
    .tech-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch and Gesture Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover effects on touch devices */
    .btn:hover,
    .nav-link:hover,
    .social-link:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Active states for touch */
    .btn:active,
    .nav-link:active,
    .social-link:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
    
    /* Larger touch targets */
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text selection on UI elements */
    .btn, .nav-link, .nav-brand {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Samsung Internet Browser Specific Fixes */
@supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) {
    /* Fix position sticky issues */
    .navbar {
        position: -webkit-sticky;
        position: sticky;
    }
    
    /* Fix flexbox issues */
    .hero-content,
    .nav-container {
        display: -webkit-flex;
        display: flex;
    }
    
    /* Fix grid issues */
    .tech-grid,
    .projects-grid {
        display: -ms-grid;
        display: grid;
    }
}

/* Performance Optimizations for Samsung Devices */
@media screen and (max-width: 768px) {
    /* Disable complex animations */
    @keyframes none {
        to { opacity: 1; }
    }
    
    /* Reduce animation complexity */
    .hero *,
    [data-animate] {
        animation-duration: 0.3s !important;
        animation-delay: 0s !important;
    }
    
    /* Optimize transitions */
    * {
        transition-duration: 0.2s !important;
    }
    
    /* Disable parallax on mobile */
    [data-parallax] {
        transform: none !important;
    }
}

/* Landscape Mode Adjustments */
@media screen and (max-width: 926px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 3rem 0;
    }
    
    .navbar {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        min-height: 50px;
    }
    
    .section-header {
        margin-bottom: 1rem;
    }
    
    section {
        padding: 2rem 0;
    }
}

/* Fix for Samsung keyboard pushing content up */
@media screen and (max-height: 500px) {
    .navbar {
        position: absolute;
    }
    
    .hero {
        padding-top: 4rem;
    }
}

/* AMOLED Dark Mode Optimization */
@media (prefers-color-scheme: dark) {
    [data-theme="dark"] {
        --gray-900: #000000; /* True black for AMOLED */
        --gray-50: #000000;
        --white: #0a0a0a;
    }
    
    [data-theme="dark"] body {
        background-color: #000000;
    }
}