/**
 * Mobile Optimization CSS
 * Responsive design for all screen sizes
 */

/* ===========================================
   1. BASE MOBILE OPTIMIZATIONS
   =========================================== */

/* Prevent text size adjustment */
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Smooth scrolling on mobile */
body {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* Better tap highlighting */
* {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    tap-highlight-color: rgba(0,0,0,0.1);
}

/* Remove default button styles on iOS */
button,
input[type="submit"],
input[type="button"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ===========================================
   2. MOBILE BREAKPOINTS
   =========================================== */

/* Mobile First Approach */

/* Extra Small Devices (phones, 320px and up) */
@media (max-width: 575px) {
    
    /* Typography */
    body {
        font-size: 14px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.75rem; /* 28px */
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
        line-height: 1.4;
    }
    
    /* Container */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Hero Section */
    .hero-section {
        min-height: auto;
        padding: 40px 15px;
    }
    
    .hero-title {
        font-size: 1.75rem;
        margin-bottom: 15px;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }
    
    /* Search Bar */
    .search-wrapper {
        width: 100%;
    }
    
    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 15px;
    }
    
    .search-button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Statistics */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    
    .stat-item {
        padding: 15px;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    .stat-label {
        font-size: 0.75rem;
    }
    
    /* Cards */
    .grid-3-cols {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .grid-2-cols {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    
    .article-card,
    .plant-card,
    .category-card {
        margin-bottom: 20px;
    }
    
    /* Card Content */
    .card-title {
        font-size: 1.1rem;
    }
    
    .card-description {
        font-size: 0.9rem;
        line-height: 1.5;
    }
    
    /* Buttons */
    .btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 15px;
    }
    
    .btn-group {
        flex-direction: column;
        gap: 10px;
    }
    
    /* Navigation */
    .main-nav {
        padding: 10px 15px;
    }
    
    .nav-menu {
        display: none; /* Show mobile menu instead */
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    /* Section Padding */
    section {
        padding: 40px 0;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }
    
    .section-description {
        font-size: 0.9rem;
        margin-bottom: 25px;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
        text-align: center;
    }
    
    .footer-column {
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        padding-bottom: 20px;
    }
    
    .footer-column:last-child {
        border-bottom: none;
    }
    
    /* How-to Cards */
    .howto-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Collection Cards */
    .collection-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Small Devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767px) {
    
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
}

/* Medium Devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991px) {
    
    .container {
        padding-left: 30px;
        padding-right: 30px;
    }
    
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .grid-6-cols {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    section {
        padding: 60px 0;
    }
}

/* Large Devices (desktops, 992px and up) */
@media (min-width: 992px) {
    
    .container {
        max-width: 1400px;
        margin: 0 auto;
    }
    
    /* Show desktop navigation */
    .mobile-menu-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex;
    }
}

/* ===========================================
   3. TOUCH OPTIMIZATIONS
   =========================================== */

/* Larger touch targets (minimum 44x44px) */
@media (max-width: 767px) {
    
    button,
    a.btn,
    input[type="submit"],
    input[type="button"],
    .clickable {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Card links */
    .card-link {
        display: block;
        padding: 15px;
    }
    
    /* Icon buttons */
    .icon-button {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Form inputs */
    input,
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px 15px;
    }
}

/* ===========================================
   4. MOBILE NAVIGATION
   =========================================== */

@media (max-width: 991px) {
    
    /* Hamburger Menu */
    .mobile-menu-toggle {
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        z-index: 1001;
    }
    
    .hamburger-line {
        width: 25px;
        height: 3px;
        background: #2C3E50;
        margin: 3px 0;
        transition: all 0.3s ease;
        border-radius: 3px;
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active .hamburger-line:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }
    
    /* Mobile Menu Overlay */
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 999;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile Menu Drawer */
    .mobile-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 80%;
        max-width: 300px;
        height: 100%;
        background: white;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        padding: 80px 20px 20px;
    }
    
    .mobile-nav.active {
        right: 0;
    }
    
    .mobile-nav-item {
        padding: 15px 20px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 16px;
        color: #2C3E50;
        text-decoration: none;
        display: block;
        transition: background 0.2s ease;
    }
    
    .mobile-nav-item:hover {
        background: #f8f8f8;
    }
}

/* ===========================================
   5. LANDSCAPE OPTIMIZATIONS
   =========================================== */

@media (max-width: 767px) and (orientation: landscape) {
    
    /* Reduce hero height on landscape */
    .hero-section {
        min-height: auto;
        padding: 30px 15px;
    }
    
    /* Adjust font sizes */
    .hero-title {
        font-size: 1.5rem;
    }
    
    /* Stack elements horizontally */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ===========================================
   6. IMAGE OPTIMIZATIONS FOR MOBILE
   =========================================== */

@media (max-width: 767px) {
    
    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }
    
    /* Hero images */
    .hero-image {
        width: 100%;
        height: auto;
        margin-bottom: 20px;
    }
    
    /* Card images */
    .card-image {
        height: 200px;
        object-fit: cover;
    }
}

/* ===========================================
   7. MOBILE-SPECIFIC UTILITIES
   =========================================== */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
}

/* Stack on mobile */
@media (max-width: 767px) {
    .stack-mobile {
        flex-direction: column !important;
    }
    
    .stack-mobile > * {
        width: 100% !important;
        margin-bottom: 15px;
    }
}

/* Center on mobile */
@media (max-width: 767px) {
    .center-mobile {
        text-align: center !important;
    }
}

/* Full width on mobile */
@media (max-width: 767px) {
    .full-width-mobile {
        width: 100% !important;
    }
}

/* ===========================================
   8. MOBILE PERFORMANCE
   =========================================== */

@media (max-width: 767px) {
    
    /* Disable hover effects on mobile */
    .card:hover {
        transform: none;
    }
    
    /* Reduce animations */
    * {
        animation-duration: 0.2s !important;
    }
    
    /* Simplify shadows */
    .box-shadow-heavy {
        box-shadow: 0 2px 10px rgba(0,0,0,0.1) !important;
    }
}

/* ===========================================
   9. SAFE AREA (iPhone X notch)
   =========================================== */

@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    .safe-area-top {
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* ===========================================
   10. MOBILE FORMS
   =========================================== */

@media (max-width: 767px) {
    
    /* Stack form fields */
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 15px;
    }
    
    /* Larger input fields */
    input,
    textarea,
    select {
        width: 100%;
        font-size: 16px;
        padding: 14px;
        border-radius: 8px;
    }
    
    /* Submit buttons */
    input[type="submit"],
    button[type="submit"] {
        width: 100%;
        padding: 16px;
        font-size: 16px;
    }
}
