/* Totally Rolled Ice Cream - Mobile-First Responsive Styles */

/* Base styles are mobile-first in styles.css */
/* Here we enhance for larger screens using min-width queries */

/* Performance optimizations for all devices */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Ensure all interactive elements are touch-friendly (minimum 44px) */
button, .cta-button, .nav-menu a, .mobile-menu-toggle {
    min-height: 44px;
    min-width: 44px;
}

/* Prevent horizontal scrolling */
html, body {
    overflow-x: hidden;
    width: 100%;
}

/* Flexible typography that scales with viewport */
html {
    font-size: clamp(14px, 2.5vw, 18px);
}

/* Container improvements for all screen sizes */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Mobile navigation - Center the logo and hamburger menu */
@media (max-width: 767px) {
    .header .nav-container {
        justify-content: center !important;
        align-items: center !important;
        gap: 3rem !important;
        padding: 1rem 2rem !important;
    }
    
    /* Ensure logo and hamburger are visible and centered */
    .logo {
        order: 1;
    }
    
    .mobile-menu-toggle {
        order: 2;
    }
    
    /* Hide desktop nav menu, show mobile dropdown when active */
    nav {
        order: 3;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
    }
    
    /* Center the mobile dropdown menu items */
    .nav-menu {
        text-align: center !important;
        padding: 2rem 1rem !important;
    }
    
    .nav-menu li {
        text-align: center !important;
        padding: 1rem 0 !important;
        border-bottom: 1px solid var(--border-light) !important;
    }
    
    .nav-menu a {
        display: block !important;
        text-align: center !important;
        padding: 1rem 2rem !important;
        font-size: 1.1rem !important;
        width: auto !important;
        margin: 0 auto !important;
        max-width: 300px !important;
    }
}

/* Extra small phones (320px and up) */
@media (min-width: 320px) and (max-width: 359px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .header .nav-container {
        padding: 1rem 1rem !important;
        max-width: calc(100% - 2rem) !important;
    }
    
    .hero h1 {
        font-size: clamp(1.75rem, 8vw, 3rem);
        line-height: 1.2;
    }
    
    .hero p {
        font-size: clamp(1rem, 4vw, 1.25rem);
    }
}

/* Small phones (360px and up) */
@media (min-width: 360px) {
    .container {
        padding: 0 1rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Large phones (414px and up) */
@media (min-width: 414px) {
    .container {
        padding: 0 1.25rem;
    }
    
    .nav-container {
        padding: 1rem 1.25rem;
    }
}

/* Small tablets and larger phones (576px and up) */
@media (min-width: 576px) {
    .container {
        padding: 0 1.5rem;
        max-width: 540px;
    }

    .hero {
        padding: 5rem 1.5rem 4rem;
    }

    .section {
        padding: 4rem 0;
    }

    .stat-card {
        padding: 2.5rem 2rem;
    }

    .nav-container {
        padding: 1rem 1.5rem;
    }

    .logo {
        font-size: 1.5rem;
    }
    
    /* Two-column layout for larger phones */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Tablets (768px and up) */
@media (min-width: 768px) {
    .container {
        padding: 0 2rem;
        max-width: 720px;
    }

    .nav-container {
        padding: 1rem 2rem;
        max-width: 720px;
        margin: 0 auto;
    }

    .logo {
        font-size: 1.75rem;
    }

    /* Desktop navigation - hide mobile menu toggle */
    .mobile-menu-toggle {
        display: none;
    }

    /* Desktop navigation - horizontal layout */
    .nav-menu {
        display: flex;
        flex-direction: row;
        position: static;
        width: auto;
        background: none;
        box-shadow: none;
        padding: 0;
        gap: 2rem;
        align-items: center;
        border: none;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-menu li {
        padding: 0;
        border-bottom: none;
    }

    .nav-menu a {
        padding: 0.5rem 0;
        font-size: 0.95rem;
    }

    /* Hero improvements */
    .hero {
        padding: 6rem 2rem 5rem;
    }

    .section {
        padding: 5rem 0;
    }

    /* Two-column grids */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 2rem;
        margin: 4rem 0;
    }

    .content-grid {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
        margin: 4rem 0;
    }

    .contact-grid {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
    }

    .values-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 2rem;
        margin: 4rem 0;
    }

    /* Forms become more compact */
    .form-container {
        max-width: 600px;
    }

    .cta-button {
        width: auto;
        min-width: 200px;
    }
}

/* Large tablets and small desktops (1024px and up) */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    .nav-container {
        max-width: 960px;
    }

    .hero {
        padding: 8rem 2rem 6rem;
    }

    .section {
        padding: 6rem 0;
    }

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

    .content-grid {
        gap: 4rem;
    }

    .contact-grid {
        gap: 4rem;
    }
    
    /* Better card layouts */
    .cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 2rem;
    }
}

/* Large desktops (1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    .nav-container {
        max-width: 1140px;
    }
}

/* Extra large desktops (1440px and up) */
@media (min-width: 1440px) {
    .container {
        max-width: 1320px;
    }

    .nav-container {
        max-width: 1320px;
    }

    .hero {
        padding: 10rem 2rem 8rem;
    }

    .section {
        padding: 8rem 0;
    }
}

/* Ultra-wide screens (1920px and up) */
@media (min-width: 1920px) {
    .container {
        max-width: 1600px;
    }

    .hero {
        padding: 12rem 2rem 10rem;
    }

    .section {
        padding: 10rem 0;
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    .hero::before {
        background-size: 50px 50px;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
    .card-image {
        height: 200px;
    }
    
    .card-image img {
        object-position: center 30%;
    }
    
    /* Fix hero background for mobile */
    .hero {
        background-attachment: scroll;
    }
}

/* Touch devices - larger touch targets and better interactions */
@media (any-hover: none) {
    .nav-menu a {
        padding: 1rem 0;
        font-size: 1.1rem;
        display: block;
        width: 100%;
    }

    .cta-button {
        padding: 1.25rem 2rem;
        font-size: 1.1rem;
        min-height: 48px;
    }

    .mobile-menu-toggle {
        padding: 1rem;
        font-size: 2rem;
        min-height: 48px;
        min-width: 48px;
    }

    /* Larger scroll to top button for touch */
    .scroll-to-top {
        width: 4rem;
        height: 4rem;
        font-size: 1.5rem;
        bottom: 1.5rem;
        right: 1.5rem;
    }
    
    /* Remove hover effects on touch devices */
    .scroll-to-top:hover {
        background: var(--primary-blue);
        transform: translateY(0);
        box-shadow: var(--shadow-lg);
    }
    
    /* Adjust call button for mobile */
    .call-now-button {
        bottom: 1.5rem;
        left: 1.5rem;
        padding: 1.25rem 1.75rem;
        font-size: 1rem;
    }

    /* Remove hover effects on touch devices */
    .card:hover,
    .stat-card:hover,
    .cta-button:hover,
    .nav-menu a:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }

    /* Larger form inputs for touch */
    .form-group input,
    .form-group textarea,
    .form-group select {
        padding: 1rem;
        font-size: 1rem;
        min-height: 48px;
    }
    
    /* Better mobile menu spacing */
    .nav-menu {
        padding: 1rem 0;
    }
    
    .nav-menu li {
        padding: 0.5rem 0;
    }
    
    /* Prevent zoom on input focus for iOS */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Landscape phone orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding: 3rem 1rem 2rem;
    }

    .section {
        padding: 2rem 0;
    }

    .mobile-menu-toggle {
        padding: 0.5rem;
        font-size: 1.5rem;
    }
}

/* Print styles */
@media print {
    .header,
    .footer,
    .mobile-menu-toggle,
    .cta-button {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    main {
        display: block !important;
    }

    .section {
        padding: 2rem 0;
        break-inside: avoid;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .hero {
        background: none;
        color: black;
        padding: 2rem 0;
    }
}

/* Accessibility and Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .fade-in {
        opacity: 1;
        transform: none;
    }

    .hero::before {
        animation: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-blue: #000080;
        --accent-orange: #ff8800;
        --accent-red: #ff0000;
        --text-dark: #000000;
        --text-medium: #333333;
        --background-light: #ffffff;
        --background-white: #ffffff;
        --card-background: #ffffff;
        --border-light: #000000;
        --border-medium: #000000;
    }

    .card,
    .stat-card,
    .testimonial-card,
    .contact-info {
        border: 2px solid var(--text-dark);
    }

    .nav-menu a:focus,
    .cta-button:focus,
    .mobile-menu-toggle:focus,
    .form-group input:focus,
    .form-group textarea:focus,
    .form-group select:focus {
        outline: 3px solid #ffff00;
        outline-offset: 2px;
    }
}

/* Force dark mode for consistent branding across all systems */
/* Override any system preferences to maintain dark theme */
html {
    color-scheme: dark;
}

:root {
    /* Force dark theme colors */
    --text-dark: #f9fafb !important;
    --text-medium: #e5e7eb !important;
    --text-light: #d1d5db !important;
    --background-light: #111827 !important;
    --background-white: #1f2937 !important;
    --card-background: #374151 !important;
    --border-light: #4b5563 !important;
    --border-medium: #6b7280 !important;
}

body {
    background: var(--background-light) !important;
    color: var(--text-dark) !important;
}

.sprinkle-bg {
    opacity: 0.4 !important;
}

/* Specific device optimizations */

/* iPhone SE and similar small screens */
@media (max-width: 375px) and (max-height: 667px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 0 0.75rem;
    }
    
    .section {
        padding: 2.5rem 0;
    }
}

/* iPhone 12/13/14 and similar */
@media (min-width: 390px) and (max-width: 428px) {
    .hero {
        min-height: 70vh;
    }
    
    .cards-grid {
        gap: 1.25rem;
    }
}

/* iPad and tablet landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .hero {
        padding: 4rem 2rem 3rem;
        min-height: 60vh;
    }
    
    .section {
        padding: 3rem 0;
    }
    
    .content-grid {
        grid-template-columns: 1.2fr 0.8fr;
    }
}

/* iPad Pro and large tablets */
@media (min-width: 1024px) and (max-width: 1366px) {
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 800px;
        margin: 0 auto;
    }
    
    .stats-grid {
        max-width: 900px;
        margin: 0 auto;
    }
}

/* Foldable devices and unusual aspect ratios */
@media (max-aspect-ratio: 1/2) {
    .hero {
        padding: 3rem 1rem 2rem;
    }
    
    .section {
        padding: 2rem 0;
    }
    
    .container {
        padding: 0 1rem;
    }
}

/* Very wide screens (ultra-wide monitors) */
@media (min-aspect-ratio: 3/1) {
    .container {
        max-width: 1200px;
    }
    
    .content-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 3rem;
    }
}