/* CRITICAL MOBILE FIXES & ADA COMPLIANCE - v2.0 */

/* ========== ACCESSIBILITY & ADA COMPLIANCE ========== */
/* Skip to main content link for screen readers */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
}

.skip-to-main:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 0;
}

/* Focus indicators for keyboard navigation */
*:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

button:focus,
a:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
}

/* Reduced motion for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========== CRITICAL MOBILE FIXES ========== */

/* Fix navigation overlay and positioning */
@media screen and (max-width: 768px) {
    /* Fix sticky nav that's overlapping content */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        height: 70px;
    }
    
    /* Add padding to body to account for fixed nav */
    body {
        padding-top: 70px;
    }
    
    .nav-container {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 0 1rem;
        height: 70px;
        position: relative;
    }
    
    .logo {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        z-index: 10001;
        flex-grow: 1;
        text-align: center;
    }
    
    .logo img {
        height: 45px !important;
        width: auto !important;
        margin-right: 10px;
    }
    
    .logo span {
        font-size: 1.1rem;
        font-weight: bold;
    }
    
    /* Mobile menu button */
    .mobile-menu-toggle {
        display: block;
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        padding: 10px;
        z-index: 10001;
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Mobile menu - fixed positioning */
    .nav-menu {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: rgba(26, 26, 26, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.3);
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }
    
    .nav-menu.mobile-menu-open {
        display: flex;
    }
    
    .nav-menu li {
        width: 100%;
        margin: 0;
    }
    
    .nav-menu li a {
        display: block;
        padding: 1rem 2rem;
        color: white;
        text-decoration: none;
        font-size: 1.1rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        min-height: 44px;
    }
    
    .nav-menu li a:hover,
    .nav-menu li a:focus {
        background: rgba(255,255,255,0.1);
    }
    
    /* FIX HERO SECTION OVERLAPPING */
    .hero {
        margin-top: 0;
        padding: 1.5rem 1rem;
        min-height: auto;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1e 100%);
    }
    
    .hero-content {
        position: relative;
        z-index: 10;
        padding: 0.5rem;
        text-align: center;
        order: 1;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hero-title {
        font-size: 1.8rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.5rem !important;
        word-wrap: break-word;
        order: 1;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 1rem !important;
        order: 2;
    }
    
    /* Hide hero description and features on mobile to save space */
    .hero-description,
    .hero-features {
        display: none !important;
    }
    
    /* Hero buttons - moved before 3D animation */
    .hero-content .cta-button {
        width: 90%;
        margin: 0.5rem auto;
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        order: 3;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border: none;
        border-radius: 25px;
        cursor: pointer;
        font-weight: 600;
    }
    
    /* Fix 3D animation container - moved after buttons */
    .hero-3d-animation {
        position: relative !important;
        min-height: 150px !important;
        max-height: 180px !important;
        margin: 0.5rem auto !important;
        order: 4;
        z-index: 1;
        width: 100%;
        overflow: hidden;
        padding: 0.5rem;
    }
    
    .logo-3d-container {
        position: relative !important;
        width: 120px !important;
        height: 120px !important;
        margin: 0 auto !important;
        transform: scale(0.8);
    }
    
    .logo-wrapper {
        width: 100px !important;
        height: 100px !important;
        transform-style: preserve-3d;
    }
    
    .logo-image,
    .bearface-logo-bg {
        width: 100px !important;
        height: 100px !important;
        object-fit: contain !important;
    }
    
    /* Hide or minimize 3D elements that cause overlap */
    .grid-lines,
    .printing-bed,
    .printer-animation-wrapper,
    .printer-nozzle,
    .scan-line,
    .particles,
    .progress-container {
        display: none !important;
    }
    
    .print-progress {
        position: absolute;
        bottom: 5px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.75rem;
        padding: 4px 8px;
        background: rgba(0,0,0,0.7);
        border-radius: 5px;
    }
    
    .hero-buttons .cta-button {
        width: 100%;
        padding: 0.8rem;
        font-size: 0.9rem;
        min-height: 44px;
    }
    
    /* CATEGORIES SECTION */
    .categories {
        padding: 2rem 1rem;
    }
    
    .section-title {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
        text-align: center;
    }
    
    .category-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0;
    }
    
    .category-card {
        padding: 1.5rem;
        min-height: auto;
        cursor: pointer;
        transition: transform 0.3s ease;
    }
    
    .category-card:hover,
    .category-card:focus {
        transform: translateY(-5px);
    }
    
    /* PRODUCTS SECTION */
    .products-display {
        padding: 2rem 1rem;
    }
    
    .products-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0;
    }
    
    .product-card {
        width: 100%;
        margin: 0;
        cursor: pointer;
        min-height: auto;
    }
    
    .product-image {
        height: 200px;
        object-fit: cover;
    }
    
    .product-info {
        padding: 1rem;
    }
    
    .add-to-cart-btn {
        width: 100%;
        padding: 0.8rem;
        min-height: 44px;
        font-size: 1rem;
    }
    
    /* MODALS */
    .modal {
        padding: 1rem;
        z-index: 10000;
    }
    
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .close-modal {
        position: absolute;
        right: 10px;
        top: 10px;
        font-size: 2rem;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(0,0,0,0.5);
        border-radius: 50%;
        z-index: 10001;
    }
    
    /* Product Modal */
    .product-modal .modal-content {
        display: flex;
        flex-direction: column;
    }
    
    .product-modal-left,
    .product-modal-right {
        width: 100%;
    }
    
    .product-modal-image {
        height: 250px;
        object-fit: cover;
        border-radius: 10px;
    }
    
    /* Checkout Modal */
    .checkout-content {
        flex-direction: column;
    }
    
    .checkout-form {
        width: 100%;
        order: 2;
    }
    
    .order-summary {
        width: 100%;
        order: 1;
        position: static;
        margin-bottom: 1rem;
        max-height: 200px;
        overflow-y: auto;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 0.8rem;
        font-size: 16px; /* Prevents zoom on iOS */
        border: 2px solid #ddd;
        border-radius: 5px;
        min-height: 44px;
    }
    
    .form-group label {
        display: block;
        margin-bottom: 0.5rem;
        font-weight: 600;
        color: #333;
    }
    
    /* CART */
    .cart-icon {
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: var(--primary-color);
        color: white;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        z-index: 1000;
        cursor: pointer;
    }
    
    .cart-count {
        position: absolute;
        top: -5px;
        right: -5px;
        background: #ff4444;
        color: white;
        border-radius: 50%;
        width: 24px;
        height: 24px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.8rem;
        font-weight: bold;
    }
    
    /* FEATURES SECTION */
    .features {
        padding: 2rem 1rem;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .feature-card {
        padding: 1.5rem;
        text-align: center;
    }
    
    /* CONTACT SECTION */
    .contact {
        padding: 2rem 1rem;
    }
    
    .contact-content {
        flex-direction: column;
        gap: 2rem;
    }
    
    .contact-info,
    .contact-form {
        width: 100%;
    }
    
    /* FOOTER */
    footer {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .footer-section {
        width: 100%;
    }
    
    /* TABLES - Make responsive */
    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Buttons - Ensure all are touch-friendly */
    button,
    .btn,
    .cta-button,
    .submit-btn {
        min-height: 44px;
        min-width: 44px;
        font-size: 16px;
    }
}

/* Small phones (max-width: 375px) */
@media (max-width: 375px) {
    .hero-title {
        font-size: 1.5rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.8rem !important;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
}

/* Landscape orientation fixes */
@media (max-width: 768px) and (orientation: landscape) {
    .navbar {
        height: 50px;
    }
    
    body {
        padding-top: 50px;
    }
    
    .nav-menu {
        top: 50px;
        max-height: calc(100vh - 50px);
    }
    
    .hero {
        min-height: auto;
        padding: 1rem;
    }
    
    .hero-3d-animation {
        min-height: 150px !important;
    }
    
    .logo-3d-container {
        width: 150px !important;
        height: 150px !important;
    }
}

/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .navbar {
        position: sticky;
        top: 0;
    }
    
    body {
        padding-top: 0;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mobile-menu-toggle {
        display: none;
    }
}

/* Hide mobile menu toggle on desktop */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .nav-menu {
        display: flex !important;
        position: static !important;
        flex-direction: row !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
    }
    
    .nav-menu li a {
        border-bottom: none !important;
        padding: 0.5rem 1rem !important;
    }
}

/* ========== ARIA LABELS & SEMANTIC HTML ========== */
/* These styles ensure ARIA elements are properly styled */
[role="button"] {
    cursor: pointer;
}

[aria-hidden="true"] {
    display: none !important;
}

[aria-expanded="false"] + .nav-menu {
    display: none;
}

[aria-expanded="true"] + .nav-menu {
    display: flex;
}

/* Ensure form validation messages are visible */
.error-message {
    color: #d32f2f;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

.success-message {
    color: #388e3c;
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

/* Loading states for better UX */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "...";
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

/* Print styles for accessibility */
@media print {
    .navbar,
    .cart-icon,
    .mobile-menu-toggle,
    .hero-3d-animation,
    button {
        display: none !important;
    }
    
    body {
        padding-top: 0 !important;
    }
    
    * {
        background: white !important;
        color: black !important;
    }
}