/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* Fix for iOS Safari */
    body {
        -webkit-text-size-adjust: 100%;
    }
    
    input, textarea, select {
        font-size: 16px; /* Prevents iOS zoom on input focus */
    }
}

/* Tablet and smaller desktop styles */
@media screen and (max-width: 1400px) {
    section {
        margin: 0 5rem;
    }

    .skills-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 1rem;
    }
}

@media screen and (max-width: 1200px) {
    #desktop-nav {
        display: none;
    }
    
    #hamburger-nav {
        display: flex;
    }

    section {
        margin: 0 3rem;
    }

    .profile-left, .profile-right {
        flex: 1;
    }

    .section__text h1 {
        font-size: 2.5rem;
    }

    #typed-name {
        font-size: 2.5rem;
    }

    .experience-container {
        flex-direction: column;
    }

    .experience-box {
        width: 100%;
    }

    .projects-grid {
        gap: 2rem;
    }

    .project-card {
        flex-direction: column;
        gap: 1.5rem;
    }

    .project-image-carousel {
        width: 100%;
        max-width: 500px;
        height: 250px;
    }

    .project-image {
        width: 100%;
        max-width: 500px;
        height: 250px;
    }

    .skills-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }

    .leadership-container {
        flex-direction: column;
    }

    .leadership-box {
        width: 100%;
    }
}

/* Tablet styles */
@media screen and (max-width: 900px) {
    section {
        margin: 0 2rem;
        margin-bottom: 4rem;
    }

    nav {
        height: 15vh;
    }

    .logo {
        font-size: 1.5rem;
    }

    #profile {
        flex-direction: column;
        padding-top: 2vh;
    }

    .profile-left, .profile-right {
        width: 100%;
    }

    .section__pic-container {
        width: 250px;
        height: 250px;
        margin: 0 auto;
    }

    .intro-block {
        padding-left: 2rem;
        padding-right: 2rem;
        padding-top: 2rem;
    }

    .intro-text {
        text-align: center;
        max-width: 100%;
        font-size: 1.1rem;
    }

    .section__text {
        text-align: center;
    }

    .section__text h1 {
        font-size: 2rem;
    }

    #typed-name {
        font-size: 2rem;
    }

    .btn-container {
        justify-content: center;
    }

    .socials-container {
        justify-content: center;
    }

    .experience-header h1 {
        font-size: 2rem;
    }

    .experience-box h2 {
        font-size: 1.3rem;
    }

    .experience-box p {
        font-size: 0.9rem;
    }

    .projects-header h1 {
        font-size: 2rem;
    }

    .project-toggle-btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }

    .project-card {
        padding: 1.5rem;
    }

    .project-title {
        font-size: 1.2rem;
    }

    .project-description {
        font-size: 0.75rem;
    }

    .tech-tag {
        font-size: 0.55rem;
        padding: 0.3rem 0.6rem;
    }

    .skills-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .skill-card {
        padding: 1rem;
        min-height: 120px;
    }

    .skill-icon img {
        width: 35px;
        height: 35px;
    }

    .skill-name {
        font-size: 0.9rem;
    }

    .skill-level {
        font-size: 0.7rem;
    }

    .leadership-header h1 {
        font-size: 2rem;
    }

    .leadership-title {
        font-size: 1.3rem;
    }

    .contact-header h1 {
        font-size: 2rem;
    }

    .contact-info-container {
        flex-direction: column;
        gap: 2rem;
        padding: 2rem;
    }

    .contact-info-left {
        width: 100%;
        align-items: center;
    }
    
    .contact-info-right {
        width: 100%;
        justify-content: center;
    }

    footer {
        padding: 1.5rem 1rem;
    }

    .footer-links {
        gap: 1.5rem;
    }
}

/* Mobile styles */
@media screen and (max-width: 600px) {
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
        width: 100%;
    }
    
    section {
        margin: 0 1rem;
        margin-bottom: 3rem;
        padding-top: 3vh;
        padding-bottom: 3vh;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    nav {
        height: 12vh;
        width: 100%;
    }

    .logo {
        font-size: 1.2rem;
    }

    .hamburger-menu {
        transform: scale(0.9);
        min-width: 44px; /* Apple's recommended touch target size */
        min-height: 44px;
    }

    .menu-links {
        min-width: 180px;
    }

    .menu-links a {
        font-size: 1rem;
        padding: 0.8rem 1rem;
    }

    #profile {
        padding-top: 5vh;
    }

    .section__pic-container {
        width: 200px;
        height: 200px;
    }

    .section__text h1 {
        font-size: 1.5rem;
    }

    #typed-name {
        font-size: 1.5rem;
    }

    .section__text__p2 {
        font-size: 1rem;
    }

    .intro-block {
        padding-left: 1rem;
        padding-right: 1rem;
        padding-top: 1rem;
    }

    .intro-text {
        font-size: 0.95rem;
        padding: 0.8rem;
        margin-top: 1.5rem;
    }

    .intro-text p {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .btn {
        padding: 0.8rem;
        font-size: 0.9rem;
        width: 130px;
        min-height: 44px; /* iOS touch target */
        touch-action: manipulation;
    }

    .btn-container {
        gap: 0.8rem;
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
    }

    .icon {
        width: 35px;
        height: 35px;
        min-width: 44px; /* Better touch target */
        min-height: 44px;
    }

    .experience-header h1,
    .projects-header h1,
    .skills-header h1,
    .leadership-header h1,
    .contact-header h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    .experience-box {
        padding: 1.5rem;
    }

    .experience-box h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    .experience-box p {
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .project-toggle-container {
        flex-wrap: wrap;
        gap: 0.8rem;
    }

    .project-toggle-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
        flex: 1;
        min-width: 150px;
        min-height: 44px; /* iOS touch target */
        touch-action: manipulation;
    }

    .project-card {
        padding: 1.2rem;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .project-content {
        width: 100%;
        max-width: 100%;
    }

    .project-title {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
        word-wrap: break-word;
    }

    .project-tech-tags {
        gap: 0.4rem;
        flex-wrap: wrap;
        width: 100%;
    }

    .tech-tag {
        font-size: 0.5rem;
        padding: 0.25rem 0.5rem;
    }

    .project-description {
        font-size: 0.7rem;
        line-height: 1.4;
        word-wrap: break-word;
    }

    .project-link {
        font-size: 0.8rem;
        min-height: 44px; /* iOS touch target */
        display: inline-flex;
        align-items: center;
        touch-action: manipulation;
    }

    .project-image-carousel {
        width: 100%;
        max-width: 100%;
        height: 200px;
        overflow: hidden;
    }

    .project-image {
        width: 100%;
        max-width: 100%;
        height: 200px;
    }

    .project-image img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .carousel-btn {
        width: 44px; /* iOS touch target */
        height: 44px;
        font-size: 1.2rem;
        padding: 0.3rem;
        touch-action: manipulation;
        flex-shrink: 0;
    }

    .skills-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .skill-card {
        padding: 0.8rem;
        min-height: 100px;
    }

    .skill-icon img {
        width: 30px;
        height: 30px;
    }

    .skill-name {
        font-size: 0.8rem;
    }

    .skill-level {
        font-size: 0.65rem;
    }

    .leadership-box {
        padding: 1.5rem;
    }

    .leadership-title {
        font-size: 1.1rem;
    }

    .leadership-description {
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .contact-header h2 {
        font-size: 1.2rem;
    }

    .contact-label {
        font-size: 0.9rem;
    }

    .contact-info-container {
        padding: 1.5rem 1rem;
        overflow: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .contact-info-left,
    .contact-info-right {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .contact-email {
        font-size: 0.85rem;
        text-align: center;
        word-break: break-all;
        overflow-wrap: anywhere;
        hyphens: auto;
        max-width: 100%;
        display: block;
        min-height: 44px; /* iOS touch target */
        line-height: 44px;
    }

    .linkedin-icon {
        width: 3rem;
        height: 3rem;
        min-width: 44px; /* iOS touch target */
        min-height: 44px;
    }

    footer {
        padding: 1rem 0.5rem;
    }

    .footer-links {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    .footer-links a {
        font-size: 0.85rem;
    }

    .copyright {
        font-size: 0.75rem;
    }

    /* Fix skill centering on mobile */
    .skills-container .skill-card:nth-child(19) {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Extra small mobile devices */
@media screen and (max-width: 400px) {
    body {
        overflow-x: hidden;
    }

    section {
        margin: 0 0.5rem;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .logo {
        font-size: 1rem;
    }

    .section__text h1 {
        font-size: 1.3rem;
    }

    #typed-name {
        font-size: 1.3rem;
    }

    .section__pic-container {
        width: 180px;
        height: 180px;
        margin: 0 auto;
    }

    .btn {
        padding: 0.7rem;
        font-size: 0.85rem;
        width: 120px;
        min-height: 44px;
    }

    .experience-header h1,
    .projects-header h1,
    .skills-header h1,
    .leadership-header h1,
    .contact-header h1 {
        font-size: 1.5rem;
    }

    .project-card {
        padding: 1rem;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .project-image-carousel {
        height: 180px;
        width: 100%;
        max-width: 100%;
    }

    .project-image {
        height: 180px;
        width: 100%;
        max-width: 100%;
    }

    .carousel-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }

    .skills-container {
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 0.6rem;
    }

    .skill-card {
        padding: 0.6rem;
        min-height: 90px;
        width: 100%;
    }

    .skill-icon img {
        width: 25px;
        height: 25px;
    }

    .contact-email {
        font-size: 0.75rem;
        word-break: break-all;
    }

    .contact-info-container {
        padding: 1rem 0.5rem;
    }
}

/* iPhone X and newer - notch support */
@media only screen 
    and (device-width: 375px) 
    and (device-height: 812px) 
    and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    nav {
        padding-top: env(safe-area-inset-top);
    }
}

/* iPhone 12, 13, 14 Pro */
@media only screen 
    and (device-width: 390px) 
    and (device-height: 844px) 
    and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    nav {
        padding-top: env(safe-area-inset-top);
    }
}

/* iPhone 14 Pro Max, 15 Pro Max */
@media only screen 
    and (device-width: 430px) 
    and (device-height: 932px) 
    and (-webkit-device-pixel-ratio: 3) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    nav {
        padding-top: env(safe-area-inset-top);
    }
}

/* Landscape mode optimizations for iPhone */
@media screen and (max-height: 450px) and (orientation: landscape) {
    nav {
        height: 10vh;
    }
    
    section {
        padding-top: 2vh;
        padding-bottom: 2vh;
    }
    
    .section__pic-container {
        width: 150px;
        height: 150px;
    }
    
    #profile {
        flex-direction: row;
        align-items: center;
    }
}