/* General reset for responsive layout */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* For iPads (768px and below) */
@media (max-width: 768px) {
    .contact-content {
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .contact-columns {
        display: flex;
        flex-direction: column;
        gap: 2rem;
        padding: 0;
        margin: 0;
    }

    .contact-columns .left-column,
    .contact-columns .right-column {
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .contact-columns .right-column {
        padding: 0;
    }

    .contact-columns .right-column img {
        width: 100%;
        height: auto;
        display: block;
        object-fit: contain;
        max-height: 100vh;
    }
    
    /* Ensure Top link is black on mobile */
    .window-text .top-link {
        color: #443731 !important;
    }
    
    /* Ensure header stays visible when scrolling */
    header {
        background-color: whitesmoke;
        padding: 10px 20px;
        width: 100%;
        margin: 0;
        left: 0;
        right: 0;
        box-sizing: border-box;
    }
}

/* For larger phones and small tablets (600px and below) */
@media (max-width: 600px) {
    /* Adjustments for very small screens */
    .contact-section, .work-section {
        display: flex;
        flex-direction: column;
    }

    .contact-section .left-column, 
    .contact-section .right-column, 
    .work-section .year-content {
        width: 100% !important;
    }
    
    /* Window section improvements for mobile */
    .window {
        width: 100% !important;
        height: auto !important;
        margin: 0;
        padding: 0;
    }
    
    .window-image {
        aspect-ratio: 4/5;
        width: 100%;
        height: 80vh;
    }
    
    .window-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        max-height: none;
    }
    
    /* Reduce font sizes for mobile */
    nav a, .window-text figcaption, .window-text .top-link {
        font-size: 0.78rem !important;
    }
    
    /* Reduce year numbers size by 40% */
    .year-link {
        font-size: 3.6rem !important;
    }
    
    /* Ensure work section stays within viewport */
    .work-section {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Adjust gallery navigation to stay within viewport */
    .gallery-nav.prev {
        left: 0 !important;
    }
    
    .gallery-nav.next {
        right: 0 !important;
    }
    
    /* Ensure images fit within viewport */
    .gallery img {
        max-width: 100%;
        max-height: 70vh;
    }
    
    /* Fix top link positioning and ensure it's not covered by images */
    .window-text {
        position: relative;
        z-index: 10;
        background-color: whitesmoke;
        padding-top: 5px;
    }
    
    /* Position gallery navigation arrows above the image */
    .gallery-nav-buttons {
        position: relative;
        z-index: 5;
        display: flex;
        justify-content: space-between;
        margin-bottom: 5px;
    }
    
    .gallery-nav {
        position: relative !important;
        top: auto !important;
        transform: none !important;
    }
    
    .horizontal-gallery .gallery-nav,
    .single-gallery .gallery-nav {
        position: relative !important;
        top: auto !important;
        transform: none !important;
        margin: 0 5px;
    }
    
    /* Match header margins with window */
    header {
        width: 100%;
        margin: 0;
        left: 0;
        right: 0;
    }
    
    /* Contact page image fix for mobile */
    #contact-section {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: auto;
    }
    
    #contact-section .contact-content {
        height: auto;
        overflow: visible;
    }
    
    #contact-section .right-column img {
        width: 100%;
        height: auto;
        max-height: none;
        object-fit: contain;
    }
}

/* For small phones (480px and below) */
@media (max-width: 480px) {
    .contact-section, .work-section {
        display: flex;
        flex-direction: column;
    }

    .contact-section .left-column, 
    .contact-section .right-column, 
    .work-section .year-content {
        width: 100% !important;
    }

    /* Adjust padding/margin to maximize space on small screens */
    body {
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100vw;
    }
    
    /* Window section improvements for small mobile */
    .window {
        width: 100% !important;
    }
    
    /* Further reduce font sizes */
    h3, p, figcaption {
        font-size: 0.78rem !important;
    }
    
    /* Further reduce year numbers size */
    .year-link {
        font-size: 3rem !important;
    }
    
    /* Ensure gallery navigation is easily tappable but not intrusive */
    .gallery-nav {
        padding: 0.5rem;
        font-size: 1.5rem !important;
    }
    
    /* Add background to header for better visibility when scrolling */
    header {
       	padding: 1rem 1rem;
        width: 100%;
    }
}
