/* Mobile Responsive Optimizations for iPhone and Small Screens */

/* Prevent horizontal scroll */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

section {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Base mobile styles */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Prevent iOS zoom on input focus */
    }
    
    input, textarea, select {
        font-size: 16px !important; /* Prevent iOS zoom */
    }
    
    /* Ensure all containers don't overflow */
    .max-w-6xl, .max-w-5xl, .max-w-4xl, .max-w-3xl, .max-w-2xl {
        max-width: 100% !important;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Reduce padding on sections */
    section {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Optimize hero section */
    .hero-section h1 {
        font-size: 2.5rem !important;
        line-height: 1.2;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Prevent text overflow */
    h1, h2, h3, p {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    /* Optimize couple cards */
    .floating {
        width: 9rem !important;
        height: 9rem !important;
    }
    
    /* Optimize event cards */
    .bg-white.rounded-3xl, .rounded-3xl {
        border-radius: 1.5rem !important;
        max-width: 100%;
    }
    
    /* Optimize buttons */
    button, a.inline-block {
        padding: 0.875rem 1.5rem !important;
        font-size: 0.9375rem !important;
        max-width: 100%;
    }
    
    /* Optimize form inputs */
    input[type="text"],
    input[type="tel"],
    select,
    textarea {
        padding: 0.875rem 1rem !important;
        font-size: 1rem !important;
        width: 100%;
        max-width: 100%;
    }
    
    /* Fix grid overflow */
    .grid {
        width: 100%;
        max-width: 100%;
    }
    
    /* Ensure images and decorations don't cause overflow */
    img, svg, .flower-decoration, .butterfly {
        max-width: 100%;
    }
}

/* iPhone 14 Pro Max, 14 Plus, 13 Pro Max, 12 Pro Max (428px) */
@media (max-width: 428px) {
    .hero-section {
        min-height: 100svh;
        padding-top: max(env(safe-area-inset-top), 2rem);
        padding-bottom: max(env(safe-area-inset-bottom), 2rem);
    }
    
    .monogram {
        font-size: 2.25rem !important;
    }
    
    h1.font-great-vibes {
        font-size: 2.25rem !important;
    }
    
    h2.font-great-vibes {
        font-size: 2.5rem !important;
    }
    
    h3.font-great-vibes {
        font-size: 2rem !important;
    }
}

/* iPhone 14 Pro, 13 Pro, 12 Pro (390px) */
@media (max-width: 390px) {
    .monogram {
        font-size: 2rem !important;
    }
    
    h1.font-great-vibes {
        font-size: 2rem !important;
    }
    
    h2.font-great-vibes {
        font-size: 2.25rem !important;
    }
    
    h3.font-great-vibes {
        font-size: 1.75rem !important;
    }
    
    .calendar-day {
        font-size: 0.7rem !important;
        padding: 0.25rem !important;
    }
    
    /* Reduce spacing */
    .space-y-3 > * + * {
        margin-top: 0.5rem !important;
    }
    
    .gap-8 {
        gap: 1.5rem !important;
    }
}

/* iPhone SE, 13 mini, 12 mini (375px and below) */
@media (max-width: 375px) {
    .monogram {
        font-size: 1.75rem !important;
    }
    
    h1.font-great-vibes {
        font-size: 1.875rem !important;
    }
    
    h2.font-great-vibes {
        font-size: 2rem !important;
    }
    
    h3.font-great-vibes {
        font-size: 1.625rem !important;
    }
    
    .floating {
        width: 8rem !important;
        height: 8rem !important;
        font-size: 3rem !important;
    }
    
    .calendar-grid {
        gap: 0.125rem !important;
    }
    
    .calendar-day {
        font-size: 0.65rem !important;
    }
    
    /* Smaller padding */
    .p-8, .p-6 {
        padding: 1rem !important;
    }
    
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-8 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
}

/* Very small screens (320px - old iPhone SE) */
@media (max-width: 320px) {
    .monogram {
        font-size: 1.5rem !important;
    }
    
    h1.font-great-vibes {
        font-size: 1.75rem !important;
    }
    
    h2.font-great-vibes {
        font-size: 1.875rem !important;
    }
    
    h3.font-great-vibes {
        font-size: 1.5rem !important;
    }
    
    .floating {
        width: 7rem !important;
        height: 7rem !important;
        font-size: 2.5rem !important;
    }
    
    .text-xl {
        font-size: 1.125rem !important;
    }
    
    .text-2xl {
        font-size: 1.25rem !important;
    }
    
    .text-3xl {
        font-size: 1.5rem !important;
    }
}

/* Landscape mode optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        min-height: auto;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
    
    .floating {
        width: 6rem !important;
        height: 6rem !important;
    }
    
    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* Touch target improvements */
@media (hover: none) and (pointer: coarse) {
    button, a, input, select, textarea {
        min-height: 44px; /* iOS recommended touch target */
        min-width: 44px;
    }
    
    .calendar-day {
        min-height: 32px;
        min-width: 32px;
    }
}

/* Prevent text size adjustment on orientation change */
@media screen and (orientation: landscape) {
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
}

/* Safe area insets for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: 0;
        padding-right: 0;
    }
    
    .hero-section, section {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    #scrollTop {
        bottom: max(2rem, calc(2rem + env(safe-area-inset-bottom)));
        right: max(2rem, calc(2rem + env(safe-area-inset-right)));
    }
}


/* Additional fixes for horizontal scroll */
@media (max-width: 768px) {
    /* Fix absolute positioned elements */
    .absolute {
        max-width: 100vw;
    }
    
    /* Ensure no element causes overflow */
    .relative {
        max-width: 100%;
        overflow: hidden;
    }
    
    /* Fix divider lines */
    .divider-flower::before,
    .divider-flower::after {
        max-width: 80px !important;
    }
    
    /* Fix calendar */
    .calendar-grid {
        width: 100%;
        max-width: 100%;
    }
    
    /* Fix cards and containers */
    .rounded-2xl, .rounded-3xl {
        margin-left: 0;
        margin-right: 0;
        max-width: 100%;
    }
    
    /* Fix text that might overflow */
    .font-great-vibes {
        max-width: 100%;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    
    /* Ensure padding doesn't cause overflow */
    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix grid gaps that might cause overflow */
    .gap-8 {
        gap: 1.5rem !important;
    }
    
    .gap-12 {
        gap: 2rem !important;
    }
    
    /* Ensure all sections fit */
    .max-w-6xl, .max-w-5xl, .max-w-4xl, .max-w-3xl, .max-w-2xl {
        width: calc(100% - 2rem) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .px-4, .px-6, .px-8 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .max-w-6xl, .max-w-5xl, .max-w-4xl, .max-w-3xl, .max-w-2xl {
        width: calc(100% - 1.5rem) !important;
    }
    
    section {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}
