/* ==================================================
   MOBILE RESPONSIVE FIXES FOR ALL PAGES
   Add this to any page: <link rel="stylesheet" href="mobile-fixes.css">
   ================================================== */

/* ====================
   HOME PAGE MOBILE
   ==================== */

@media (max-width: 768px) {
    /* Info popup mobile fix - ensure it displays properly */
    .info-popup {
        position: fixed !important;
        top: 4rem !important;
        right: 1rem !important;
        left: auto !important;
        transform: none !important;
        max-width: calc(100vw - 2rem) !important;
        white-space: normal !important;
        z-index: 1000 !important;
    }
    
    /* Enter Store button mobile sizing */
    .enter-store-button {
        padding: 0.5rem 0 !important;
        font-size: 0.95rem !important;
        margin-top: 2.5rem !important;
        text-decoration-thickness: 2px !important;
    }
    
    .enter-store-button span {
        display: inline-block !important;
    }
}

@media (max-width: 600px) {
    /* Smaller Enter Store button on small mobile */
    .enter-store-button {
        padding: 0.5rem 0 !important;
        font-size: 0.9rem !important;
        max-width: 180px !important;
        margin-top: 2rem !important;
    }
    
    .enter-store-button span {
        display: inline-block !important;
    }
    
    /* Info button positioning */
    .info-button-container {
        right: 1rem !important;
    }
}

/* ====================
   STORE PAGE MOBILE
   ==================== */

@media (max-width: 768px) {
    /* Enable full page scrolling on mobile */
    html, body {
        overflow: auto !important;
        overflow-x: hidden !important;
        height: auto !important;
        min-height: 100vh !important;
    }
    
    /* Cart icon at bottom - preserve desktop styling with worm bubble */
    .cart-icon {
        position: fixed !important;
        right: 30px !important;
        bottom: 30px !important;
        top: auto !important;
        font-size: 20px !important;
        z-index: 9999 !important;
        color: white !important;
        padding: 15px !important;
        cursor: pointer !important;
        border: 2px solid transparent !important;
        border-radius: 50% !important;
        width: 50px !important;
        height: 50px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        pointer-events: auto !important;
    }
    
    .cart-icon svg {
        width: 20px !important;
        height: 20px !important;
        stroke: white !important;
    }
    
    /* Keep cart worm bubble visible */
    .cart-worm-bubble {
        pointer-events: none !important;
        display: block !important;
    }
    
    /* Product grid - 2 columns on tablet, proper padding for whole page scroll */
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
        padding: 140px 1.5rem 6rem 1.5rem !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        overflow: visible !important;
    }
    
    /* Product items - proper sizing */
    .product-item {
        padding: 1.25rem !important;
        width: 100% !important;
    }
    
    .product-image {
        height: 150px !important;
    }
    
    .product-title {
        font-size: 0.9rem !important;
        margin-top: 0.75rem !important;
    }
    
    /* Product cards */
    .product-card {
        padding: 0.75rem !important;
    }
    
    .product-card img {
        height: 180px !important;
    }
    
    .product-title {
        font-size: 0.9rem !important;
    }
    
    .product-price {
        font-size: 1rem !important;
    }
    
    /* Cart overlay - fullscreen standalone on mobile */
    .cart-overlay {
        background: black !important;
        justify-content: center !important;
        padding: 0 !important;
    }
    
    /* Cart sidebar full width on mobile */
    .cart-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        border-left: none !important;
    }
    
    /* Cart header mobile - better alignment */
    .cart-header {
        padding: 1.5rem 1.25rem !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .cart-header h2 {
        font-size: 1.25rem !important;
        margin: 0 !important;
        flex: 1 !important;
        text-align: left !important;
    }
    
    .cart-close {
        font-size: 2rem !important;
        padding: 0 !important;
        line-height: 1 !important;
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Cart items mobile */
    .cart-item {
        padding: 1rem !important;
        gap: 0.75rem !important;
    }
    
    .cart-item-image {
        width: 60px !important;
        height: 60px !important;
    }
    
    .cart-item-controls {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-top: 0.5rem !important;
    }
    
    .remove-item {
        font-size: 1.25rem !important;
        padding: 0.25rem !important;
        width: 28px !important;
        height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }
    
    .cart-item-name {
        font-size: 0.95rem !important;
    }
    
    .cart-item-size,
    .cart-item-price {
        font-size: 0.85rem !important;
    }
    
    /* Cart footer mobile */
    .cart-footer {
        padding: 1.25rem !important;
    }
    
    .cart-total-line {
        font-size: 0.95rem !important;
    }
    
    .cart-total-line.final {
        font-size: 1.1rem !important;
    }
    
    /* Checkout button */
    .checkout-btn {
        padding: 1rem !important;
        font-size: 1rem !important;
        min-height: 48px !important;
    }
    
    /* Product modal mobile */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        margin: 1rem !important;
    }
    
    .modal-top {
        flex-direction: column !important;
    }
    
    .modal-left {
        width: 100% !important;
    }
    
    .product-detail-image {
        height: 300px !important;
    }
    
    .modal-bottom {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .product-info-left,
    .product-info-right {
        width: 100% !important;
    }
    
    .product-name {
        font-size: 1.25rem !important;
    }
    
    .add-to-cart-btn {
        width: 100% !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        min-height: 48px !important;
    }
}

@media (max-width: 600px) {
    /* Single column on mobile with better spacing */
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        padding: 120px 0 5rem 0 !important;
        max-width: 70% !important;
        margin: 0 auto 0 10% !important;
    }
    
    /* Product items - smaller mobile, 30% narrower */
    .product-item {
        padding: 1.5rem !important;
        width: 100% !important;
        margin: 0 auto !important;
    }
    
    .product-image {
        height: 200px !important;
    }
    
    .product-title {
        font-size: 1rem !important;
    }
    
    .product-card img {
        height: 220px !important;
    }
    
    /* Cart overlay - fullscreen standalone on small mobile */
    .cart-overlay {
        background: black !important;
        justify-content: center !important;
        padding: 0 !important;
    }
    
    .cart-sidebar {
        width: 100vw !important;
        border-left: none !important;
    }
    
    /* Smaller cart items on small mobile - better alignment */
    .cart-header {
        padding: 1.25rem 1rem !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .cart-header h2 {
        font-size: 1.1rem !important;
        margin: 0 !important;
        flex: 1 !important;
        text-align: left !important;
    }
    
    .cart-close {
        font-size: 1.75rem !important;
        padding: 0 !important;
        line-height: 1 !important;
        width: 28px !important;
        height: 28px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .cart-item {
        padding: 0.85rem !important;
    }
    
    .cart-item-image {
        width: 50px !important;
        height: 50px !important;
    }
    
    .cart-item-controls {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-top: 0.5rem !important;
    }
    
    .remove-item {
        font-size: 1.1rem !important;
        padding: 0.25rem !important;
        width: 26px !important;
        height: 26px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }
    
    .cart-footer {
        padding: 1rem !important;
    }
    
    /* Product modal on small mobile */
    .product-detail-image {
        height: 250px !important;
    }
    
    .product-name {
        font-size: 1.1rem !important;
    }
    
    .product-thumbnails {
        gap: 0.5rem !important;
    }
    
    .thumbnail {
        width: 50px !important;
        height: 50px !important;
    }
    
    /* Size selector buttons */
    .size-btn {
        padding: 0.5rem 1rem !important;
        font-size: 0.85rem !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }
    
    /* Cart icon at bottom - preserve desktop styling with worm bubble */
    .cart-icon {
        position: fixed !important;
        right: 20px !important;
        bottom: 20px !important;
        top: auto !important;
        font-size: 18px !important;
        z-index: 9999 !important;
        color: white !important;
        padding: 12px !important;
        cursor: pointer !important;
        border: 2px solid transparent !important;
        border-radius: 50% !important;
        width: 45px !important;
        height: 45px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        pointer-events: auto !important;
    }
    
    .cart-icon svg {
        width: 18px !important;
        height: 18px !important;
        stroke: white !important;
    }
}

/* ====================
   WORK PAGE MOBILE
   ==================== */

@media (max-width: 768px) {
    /* Project boxes stack */
    .single-box {
        flex-direction: column !important;
        height: auto !important;
    }
    
    .pane {
        height: 200px !important;
        border-right: none !important;
        border-bottom: 2px solid #000 !important;
    }
    
    /* Modal adjustments */
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: 1rem !important;
        margin: 1rem auto !important;
    }
    
    .modal-images {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }
    
    .modal-image {
        max-height: 60vh !important;
    }
    
    /* View All button */
    .view-all-button {
        font-size: 1rem !important;
        padding: 0.75rem 1.25rem !important;
    }
}

@media (max-width: 600px) {
    .pane {
        height: 150px !important;
    }
    
    .project-title {
        font-size: 1.2rem !important;
    }
    
    .modal-close {
        width: 44px !important;
        height: 44px !important;
        font-size: 2rem !important;
    }
}

/* ====================
   CONTACT PAGE MOBILE
   ==================== */

@media (max-width: 768px) {
    /* Fix scrolling on contact page */
    body.contact-page,
    html:has(.contact-container) {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .contact-container {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
        padding-bottom: 3rem !important;
    }
    
    .contact-card {
        width: 95% !important;
        max-width: 600px !important;
        padding: 1.5rem !important;
        margin: 1rem auto !important;
    }
    
    .contact-form input,
    .contact-form select,
    .contact-form textarea {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 0.75rem !important;
        min-height: 44px !important;
    }
    
    .contact-form textarea {
        min-height: 120px !important;
    }
    
    .submit-btn {
        padding: 1rem !important;
        font-size: 0.9rem !important;
        min-height: 48px !important;
    }
    
    /* Email and IG side by side */
    .contact-info {
        flex-direction: row !important;
        gap: 1rem !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
    }
    
    .contact-info-item {
        font-size: 0.8rem !important;
    }
    
    /* Reduce overall text sizes */
    .contact-card h2,
    .contact-form h2 {
        font-size: 1.3rem !important;
    }
    
    .contact-card p,
    .contact-form p {
        font-size: 0.85rem !important;
    }
}

@media (max-width: 600px) {
    /* Ensure scrolling works on smaller mobile devices */
    body {
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative !important;
    }
    
    .contact-card {
        padding: 1rem !important;
    }
    
    .contact-form h2 {
        font-size: 1.2rem !important;
    }
    
    .contact-form label {
        font-size: 0.85rem !important;
    }
    
    /* Keep Email and IG side by side */
    .contact-info {
        flex-direction: row !important;
        gap: 0.75rem !important;
    }
    
    .contact-info-item {
        font-size: 0.75rem !important;
    }
    
    /* Reduce input text size */
    .contact-form input,
    .contact-form select,
    .contact-form textarea {
        font-size: 14px !important;
    }
    
    /* Success/error messages */
    .success-msg,
    .error-msg {
        font-size: 0.85rem !important;
    }
}

/* ====================
   ADMIN PAGE MOBILE
   ==================== */

@media (max-width: 768px) {
    .wrap {
        padding: 1rem !important;
        margin: 1rem auto !important;
    }
    
    h1 {
        font-size: 1.5rem !important;
    }
    
    /* Search and buttons */
    .bar {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    input[type="search"] {
        width: 100% !important;
        min-width: 100% !important;
        font-size: 16px !important;
    }
    
    button {
        width: 100% !important;
        padding: 0.75rem !important;
        min-height: 48px !important;
    }
    
    /* Table scroll on mobile */
    table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }
    
    th, td {
        padding: 0.5rem !important;
        font-size: 0.85rem !important;
    }
    
    .pill {
        font-size: 0.75rem !important;
        padding: 2px 6px !important;
    }
    
    /* Login panel */
    .panel {
        width: 90vw !important;
        padding: 1.5rem !important;
    }
    
    .panel h2 {
        font-size: 1.25rem !important;
    }
}

/* ====================
   ABOUT PAGE MOBILE
   ==================== */

@media (max-width: 900px) {
    .about-content {
        padding: 2rem !important;
        margin: 1rem !important;
    }
    
    .about-content h1 {
        font-size: 2rem !important;
    }
    
    .about-content h2 {
        font-size: 1.5rem !important;
    }
    
    .about-text {
        font-size: 1rem !important;
    }
}

@media (max-width: 600px) {
    .about-container {
        padding: 1rem !important;
    }
    
    .about-content {
        padding: 1.5rem !important;
    }
    
    .about-content h1 {
        font-size: 1.8rem !important;
        margin-bottom: 1.5rem !important;
    }
}

/* ====================
   CANVAS EFFECTS MOBILE OPTIMIZATION
   ==================== */

@media (max-width: 768px) {
    /* Reduce canvas complexity on mobile */
    canvas {
        image-rendering: auto !important;
    }
    
    /* Ensure canvas scales properly */
    #worm-canvas,
    #admin-bg {
        width: 100vw !important;
        height: 100vh !important;
        display: block !important;
    }
}

/* ====================
   GLOBAL MOBILE IMPROVEMENTS
   ==================== */

@media (max-width: 768px) {
    /* Better touch targets */
    button,
    a,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100% !important;
        -ms-text-size-adjust: 100% !important;
    }
    
    /* Improve tap highlight */
    * {
        -webkit-tap-highlight-color: rgba(249, 102, 250, 0.2) !important;
    }
    
    /* Smooth scrolling on mobile */
    html {
        scroll-behavior: smooth !important;
    }
    
    body {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ====================
   BACKDROP FILTER MOBILE FALLBACK
   ==================== */

/* For older mobile browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(1px)) {
    .calm-plate,
    .calm-pill,
    .view-all-button {
        background: rgba(255, 255, 255, 0.9) !important;
    }
    
    .aa-ghost {
        text-shadow: 0 0 8px rgba(0, 0, 0, 0.8), 0 0 4px rgba(255, 255, 255, 0.6) !important;
    }
}

/* ====================
   LANDSCAPE MOBILE OPTIMIZATIONS
   ==================== */

@media (max-height: 500px) and (orientation: landscape) {
    /* Compact header spacing */
    .logo-menu-container {
        top: 50% !important;
    }
    
    .logo-nav {
        width: 150px !important;
    }
    
    .dropdown-menu {
        top: -120px !important;
        padding: 0.75rem !important;
    }
    
    .menu-links li {
        margin: 0.4rem 0 !important;
    }
    
    .menu-links a {
        font-size: 0.9rem !important;
    }
}
