/**
 * Mobile-Specific Enhancements
 * Touch interactions, performance, and mobile UI optimizations
 *
 * @package EarphonesShop
 */

/* =========================
   MOBILE TOUCH INTERACTIONS
   ========================= */

/* Touch device optimization */
.touch-device * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

/* Active touch state */
.active-touch {
    opacity: 0.7;
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* Larger tap targets for mobile */
@media (max-width: 768px) {

    a,
    button,
    .btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* =========================
   IOS-SPECIFIC FIXES
   ========================= */

/* iOS Safari viewport height fix */
.ios-device {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

/* Prevent iOS text size adjustment */
@media (max-width: 768px) {
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
}

/* Smooth scrolling on iOS */
.mobile-menu,
.modal-content,
.scrollable-content {
    -webkit-overflow-scrolling: touch;
}

/* =========================
   MOBILE HEADER OPTIMIZATIONS
   ========================= */

@media (max-width: 768px) {

    /* Hide header on scroll down */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        transition: transform 0.3s ease;
    }

    .header-hidden {
        transform: translateY(-100%);
    }

    /* Compact header on mobile */
    .site-header {
        padding: 12px 0;
    }

    .site-branding {
        font-size: 18px;
    }
}

/* =========================
   MOBILE MENU ENHANCEMENTS
   ========================= */

@media (max-width: 768px) {

    /* Full screen mobile menu */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        background: var(--color-white);
        z-index: 9999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu.active {
        transform: translateX(0);
    }

    /* Overlay when menu is open */
    .mobile-menu.active::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Mobile menu items */
    .mobile-menu li {
        border-bottom: 1px solid var(--color-border-light);
    }

    .mobile-menu a {
        display: block;
        padding: 16px 20px;
        font-size: 16px;
        color: var(--color-text);
        transition: background 0.2s;
    }

    .mobile-menu a:active {
        background: var(--color-neutral-light);
    }
}

/* =========================
   MOBILE CARD OPTIMIZATIONS
   ========================= */

@media (max-width: 768px) {

    /* Reduce hover effects on mobile */
    .review-card:hover,
    .guide-card:hover,
    .post-card:hover {
        transform: translateY(-4px);
        /* Less lift */
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        /* Lighter shadow */
    }

    /* Disable image zoom on mobile for performance */
    .card-image img,
    .review-image img,
    .post-thumbnail img {
        transform: none !important;
    }

    /* Stack card content vertically */
    .review-card,
    .guide-card,
    .post-card {
        display: flex;
        flex-direction: column;
    }

    .card-image {
        width: 100%;
        aspect-ratio: 16/9;
    }
}

/* =========================
   MOBILE FORM OPTIMIZATIONS
   ========================= */

@media (max-width: 768px) {

    /* Larger inputs for easier touch */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    input[type="tel"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px;
        /* Prevent iOS zoom */
        min-height: 44px;
        padding: 12px 16px;
    }

    /* Full-width buttons on mobile */
    .btn,
    .button,
    button[type="submit"] {
        width: 100%;
        padding: 14px 24px;
        font-size: 16px;
    }

    /* Stack form rows */
    .form-row {
        flex-direction: column;
    }

    .form-row>* {
        width: 100%;
        margin-bottom: 16px;
    }
}

/* =========================
   MOBILE TYPOGRAPHY
   ========================= */

@media (max-width: 768px) {

    /* Reduce font sizes for readability */
    h1,
    .h1 {
        font-size: 28px;
        line-height: 1.2;
    }

    h2,
    .h2 {
        font-size: 24px;
        line-height: 1.3;
    }

    h3,
    .h3 {
        font-size: 20px;
        line-height: 1.4;
    }

    body {
        font-size: 15px;
        line-height: 1.6;
    }

    /* Readable paragraph width */
    p {
        max-width: 100%;
    }
}

/* =========================
   MOBILE GRID LAYOUTS
   ========================= */

@media (max-width: 768px) {

    /* Single column on mobile */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Flex containers stack */
    .flex-row {
        flex-direction: column;
    }

    /* Full-width containers */
    .container {
        padding: 0 16px;
        max-width: 100%;
    }
}

/* =========================
   MOBILE SPACING
   ========================= */

@media (max-width: 768px) {

    /* Reduce spacing for mobile */
    .section {
        padding: 40px 0;
    }

    .spacing-lg {
        margin-bottom: 32px;
    }

    .spacing-md {
        margin-bottom: 20px;
    }

    .spacing-sm {
        margin-bottom: 12px;
    }

    /* Compact padding */
    .card-content {
        padding: 16px;
    }
}

/* =========================
   MOBILE MODALS & OVERLAYS
   ========================= */

@media (max-width: 768px) {

    /* Full-screen modals on mobile */
    .modal-content {
        width: 100%;
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }

    /* Bottom sheet style for drawers */
    .drawer,
    .bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 80vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .drawer.active,
    .bottom-sheet.active {
        transform: translateY(0);
    }
}

/* =========================
   MOBILE SEARCH
   ========================= */

@media (max-width: 768px) {

    /* Full-width search on mobile */
    .search-form {
        width: 100%;
    }

    .search-input {
        width: 100%;
        font-size: 16px;
    }

    /* Search results dropdown */
    .search-results-dropdown {
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =========================
   MOBILE TOAST NOTIFICATIONS
   ========================= */

@media (max-width: 768px) {
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        transform: translateX(0) translateY(200%);
        min-width: auto;
        max-width: none;
    }

    .toast.show {
        transform: translateX(0) translateY(0);
    }
}

/* =========================
   MOBILE TABLES
   ========================= */

@media (max-width: 768px) {

    /* Scrollable tables */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Or stack table cells */
    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        display: flex;
        flex-direction: column;
        margin-bottom: 16px;
        border: 1px solid var(--color-border);
        border-radius: 8px;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 12px;
        border-bottom: 1px solid var(--color-border-light);
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 12px;
    }
}

/* =========================
   MOBILE IMAGES
   ========================= */

@media (max-width: 768px) {

    /* Responsive images */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Lazy load placeholder */
    img[data-src] {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }
}

/* =========================
   PERFORMANCE OPTIMIZATIONS
   ========================= */

/* Reduce animations on low-end devices */
.low-end-device * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
}

.low-end-device .card-image img {
    transform: none !important;
}

/* Disable parallax on mobile */
@media (max-width: 768px) {
    .parallax-bg {
        background-attachment: scroll !important;
        transform: none !important;
    }
}

/* =========================
   MOBILE HERO SECTION
   ========================= */

@media (max-width: 768px) {

    .hero-section,
    .hero-section-v2 {
        min-height: auto;
        padding: 60px 0 40px;
    }

    .hero-headline {
        font-size: 32px;
        line-height: 1.2;
    }

    .hero-subheadline {
        font-size: 16px;
    }

    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 16px;
    }
}

/* =========================
   MOBILE FOOTER
   ========================= */

@media (max-width: 768px) {
    .footer-widgets {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
}

/* =========================
   MOBILE BACK-TO-TOP
   ========================= */

@media (max-width: 768px) {
    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
    }
}

/* =========================
   MOBILE HORIZONTAL SCROLL
   ========================= */

@media (max-width: 768px) {

    /* Horizontal scroll containers */
    .scroll-container {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 16px;
        padding: 0 16px;
    }

    .scroll-container>* {
        flex-shrink: 0;
        scroll-snap-align: start;
    }

    /* Hide scrollbar but keep functionality */
    .scroll-container::-webkit-scrollbar {
        display: none;
    }

    .scroll-container {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* =========================
   MOBILE UTILITIES
   ========================= */

/* Hide on mobile */
.hide-mobile {
    display: none !important;
}

/* Show only on mobile */
@media (min-width: 769px) {
    .show-mobile-only {
        display: none !important;
    }
}

/* Text alignment mobile */
.text-center-mobile {
    text-align: center;
}

/* Full width on mobile */
.full-width-mobile {
    width: 100% !important;
}