/* Large devices (desktops, less than 1200px) */
@media (max-width: 1200px) {
    .plan-options {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* Medium devices (tablets, less than 768px) */
@media (max-width: 768px) {

    html, body {
        overflow-x: hidden;
        max-width: 100%;
        box-sizing: border-box;
        line-height: 100%;
    }

    /* Force all grid containers to respect viewport width */
    section {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Prevent any grid columns from exceeding viewport */
    .about-section,
    .instructors-section,
    .classes-section,
    .schedule-section,
    .form-section,
    .gallery-section,
    .space-section {
        max-width: 100vw;
        overflow-x: hidden;
        box-sizing: border-box;
        padding-top: var(--spacing-xs);
    }

    .container {
        max-width: 100vw;
        padding: 0 var(--spacing-xs);
        margin: 0;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2, p, label, .btn-primary, .btn-secondary {
        font-size: 1rem;
        line-height: 120%;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .language-selector {
        margin-top: var(--spacing-xs);
        justify-content: flex-end;
    }

    .menu-header .language-selector {
        display: none;
    }


    .menu-toggle {
        top: var(--spacing-xs);
        right: var(--spacing-xs);
    }

    .logo {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
    }

    .desktop-logo {
        display: none;
    }

    .logo.desktop-logo.safari-logo {
        display: none;
    }
    
    .mobile-logo {
        display: block;
    }

    .menu-navigation {
        padding: var(--spacing-xs);
    }

    .menu-navigation a {
        font-size: 1.75rem;
        margin-bottom: 0.3rem;
    }

    .overlay-menu {
        display: grid;
        grid-template-rows: auto 1fr auto;
    }

    .menu-header {
        grid-row: 1;
    }

    .menu-logo {
        grid-row: 2;
        justify-self: center;
        align-self: center;
        position: relative;
        left: auto;
        top: auto;
        transform: none;
    }

    .overlay-menu .footer {
        grid-row: 3;
    }

    .close-menu {
        grid-column: 3 / -1;
        padding: var(--spacing-xs);
    }

    .bottom-margin {
        margin-bottom: var(--spacing-xl);
    }

    .about-section .container-is-text:nth-child(1) p {
        grid-column: 1 / -1;
        margin-top: var(--spacing-md);
        margin-bottom: var(--spacing-md);
    }

    .about-section .container-is-text:nth-child(3) p {
        grid-column: 1 / -1;
    }

    .about-section .container-is-text:nth-child(3) p:first-child {
        margin-top: var(--spacing-md);
        margin-bottom: var(--spacing-md);
    }

    .about-section,
    .instructors-section,
    .gallery-section,
    .classes-section,
    .schedule-section,
    .space-section,
    .pricing-section,
    .form-section {
        grid-template-columns: 1fr;
        margin-left: var(--spacing-xs);
        margin-right: var(--spacing-xs);
        gap: 0;
    }

    .about-section .container-is-image,
    .about-section .container-is-text,
    .instructors-section .instructors-title-wrapper, 
    .instructors-section .instructors-content-wrapper,
    .classes-grid .class-wrapper,
    .schedule-section .schedule-day-wrapper,
    .space-section .space-section-grid,
    .pricing-section .pricing-grid,
    .pricing-section .is-title,
    .form-section .contact-form {
        grid-template-columns: 1fr;
        margin-left: 0;
        margin-right: 0;
        grid-column: 1 / -1;
        column-gap: 0;
    }

    .is-title {
        top: 0;
        margin-bottom: var(--spacing-md);
    }

    .about-section .container-is-image img.lg,
    .about-section .container-is-image img.sm {
        grid-column: 1 / -1;
        margin-top: 0;
    } 

    .hero-content h1 {
        margin-bottom: var(--spacing-xs);
    }

    .instructors-section img {
        width: 50%;
        justify-self: center;
    }

    .instructors-content-wrapper h1 {
        justify-self: center;
        margin-top: var(--spacing-xs);
    }

    .instructors-content-wrapper p:nth-child(2),
    .instructors-content-wrapper p:nth-child(3) {
        grid-column: 1 / -1;
    }

    .gallery-section img:nth-child(1) {
        grid-column: 1 / -1;
        margin-bottom: var(--spacing-xs);
    }

    .gallery-section img:nth-child(2) {
        grid-column: 1 / -1;
    }
    
    .classes-grid {
        gap: var(--spacing-md);
    }

    .class-title {
       justify-self: center;
       text-align: center;
    }

    .class-wrapper {
        gap: var(--spacing-sm);
    }

    .classes-section .class-wrapper:nth-child(3) .class-title h1 {
        width: 18ch;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .schedule-day-wrapper .schedule-class:nth-child(1) {
        border-top: 1.5px solid #82381A;
        padding-top: var(--spacing-sm);
    }

    .space-section-grid {
        row-gap: var(--spacing-md);
    }

    .space-section-grid .is-title {
        margin-bottom: 0;
    }

    .space-section .container-is-image {
        width: 100%;
        margin-bottom: var(--spacing-md);
        margin-left: 0;
        margin-right: 0;
    }

    .space-section-grid h1:nth-child(1) {
        grid-column: 1 / -1;
        grid-row: 1;    
    }

    .space-section-grid h1:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;    
    }

    .space-details-wrapper {
        grid-column: 1 / -1;
        grid-row: 3;
    }   

    .space-section-grid img:nth-child(4) {
        grid-column: 1 / -1;  
        grid-row: 4; 
    }

    .space-section-grid img:nth-child(5) {
        grid-column: 1 / -1;  
        grid-row: 5; 
        width: 50%;
        justify-self: center;
        mix-blend-mode: multiply;
    }

    /* Remove rounded corners from form fields on mobile */
    input, 
    textarea, 
    select,
    .form-control {
        border-radius: 0 !important;
        -webkit-border-radius: 0 !important;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    /* Specifically target iOS Safari form styling */
    input[type="text"],
    input[type="email"], 
    input[type="tel"],
    input[type="password"],
    textarea {
        border-radius: 0 !important;
        -webkit-border-radius: 0 !important;
        -webkit-appearance: none;
    }

    .space-img-wrapper {
        grid-column: 1 / -1;  
        grid-row: 6; 
    }

    .form-group {
        margin-bottom: var(--spacing-xs);
    }

    #step-1 div:nth-child(1) {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    
    #step-1 div:nth-child(2) {
        grid-column: 1 / -1;
        grid-row: 2;
    }
    
    #step-1 div:nth-child(3) {
        grid-column: 1 / -1;
        grid-row: 3;
    }
    
    #step-1 div:nth-child(4) {
        grid-column: 1 / -1;
        grid-row: 4;
    }
    
    #step-1 div:nth-child(5) {
        grid-column: 1 / -1;
        grid-row: 5;
    }
    
    #step-1 div:nth-child(6) {
        grid-column: 1 / -1;
        grid-row: 6;
    }
    
    #step-1 div:nth-child(7) {
        grid-column: 1 / -1;
        grid-row: 7;
    }
    
    #step-1 div:nth-child(8) {
        grid-column: 1 / -1;
        grid-row: 8;
    }
    
    #step-1 div:nth-child(9) {
        grid-column: 1 / -1;
        grid-row: 9;
    }
    
    .contact-form button {
        grid-column: 1 / -1;
        grid-row: 10;
    }
    
    /* 2-Step Form Responsive */
    .step-indicator {
        grid-column: 1 / -1;
        gap: var(--spacing-xs);
        margin-bottom: var(--spacing-sm);
    }
    
    .step {
        flex-direction: row;
        padding: 0.5rem;
        gap: calc(var(--spacing-xs) - 0.4rem);
    }
    
    .step-label {
        font-size: 0.75rem;
    }
    
    .form-step {
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: var(--spacing-xs);
    }
    
    .plan-options {
        grid-template-columns: 1fr;
        gap: var(--spacing-xs);
        max-width: 100%;
    }
    
    .form-navigation {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .form-navigation button {
        width: 100%;
    }
    
    .is-left {
        margin-right: 0;
    }
    
    .is-right {
        margin-left: 0;
    }

    .custom-radio-group {
        gap: calc(var(--spacing-xs) - 1rem);
    }

    .footer {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--spacing-sm);
        padding: 0 var(--spacing-xs) var(--spacing-xs) var(--spacing-xs);
        align-items: flex-start;
    }

    
    .footer div:nth-child(1) {
        display: none;
    }
    
    .footer div:nth-child(2) {
        order: 3;
    }
    
    .footer div:nth-child(3) {
        order: 1;
        width: calc(50% - var(--spacing-sm)/2);
        flex-basis: calc(50% - var(--spacing-sm)/2);
        flex-shrink: 0;
    }
    
    .footer div:nth-child(4) {
        order: 2;
        width: calc(50% - var(--spacing-sm)/2);
        flex-basis: calc(50% - var(--spacing-sm)/2);
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        align-self: flex-start;
    }
    
    .footer div:nth-child(5) {
        order: 4;
        flex-grow: 1;
    }

    .newsletter-form {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 100%;
    }
    
    .newsletter-form input[type="text"] {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .footer-section-mobile {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        order: 5;
    }

    .footer-section-mobile h3 {
        text-wrap: nowrap;
        align-self: flex-end;
    }

    /* Ensure proper text wrapping in footer sections */
    .footer .footer-section {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .footer .footer-section h3 {
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Prevent layout shifts during language transitions */
    .footer .footer-section,
    .footer .footer-section * {
        transition: none;
        animation: none;
    }

    .footer-section .footer-logo {
        display: block;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .back-to-top {
        display: none;
    }

    /* Browser-specific logo display */
    .chrome-logo,
    .safari-logo {
        display: none;
    }

}
