/**
 * BlogThree mobile layout styles (consolidated).
 *
 * Merged from: global-mobile.css, mobile-centering-fix.css, mobile-menu-safe.css,
 * and the inline <style> block previously in header.php.
 *
 * Loaded via wp_enqueue_style with media="screen and (max-width: 768px)"
 * (see functions.php). Mobile performance overrides for touch feedback and
 * animation reduction live separately in mobile-performance.css because they
 * key off JS-added body classes (.touch-active, .is-mobile-device) and apply
 * to touch devices regardless of viewport width.
 */

/* ============================================================
 * Section 1: Global mobile foundation
 * Source: global-mobile.css
 * ============================================================ */
/**
 * Global Mobile Responsiveness Fixes
 * Comprehensive mobile-first optimizations for all BlogThree pages
 * 
 * @package BlogThree
 * @version 1.0.0
 */

/* ===================================
   Mobile Detection Classes
   =================================== */
.is-mobile-device,
.touch-device {
    /* Disable hover effects on touch devices */
    -webkit-tap-highlight-color: rgba(139, 92, 246, 0.2);
    -webkit-touch-callout: none;
}

/* ===================================
   Global Mobile Reset (320px and up)
   =================================== */
@media (max-width: 768px) {

    /* Prevent horizontal scroll globally */
    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    /* Container padding standardization */
    .container,
    .container-custom {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
    }

    /* Remove min-height screen on mobile for better scrolling */
    .min-h-screen {
        min-height: 100svh !important;
        /* Small viewport height for mobile browsers */
    }
}

/* ===================================
   Typography - Mobile First
   =================================== */
@media (max-width: 768px) {

    /* Fluid typography with clamp() */
    h1,
    .text-hero-xl,
    .text-hero-lg {
        font-size: clamp(2rem, 6vw, 3rem) !important;
        line-height: 1.1 !important;
    }

    h2,
    .text-4xl,
    .text-5xl {
        font-size: clamp(1.75rem, 5vw, 2.5rem) !important;
        line-height: 1.2 !important;
    }

    h3,
    .text-3xl,
    .text-2xl {
        font-size: clamp(1.5rem, 4vw, 2rem) !important;
        line-height: 1.3 !important;
    }

    h4,
    .text-xl,
    .text-lg {
        font-size: clamp(1.125rem, 3vw, 1.5rem) !important;
        line-height: 1.4 !important;
    }

    p,
    .text-base {
        font-size: 1rem !important;
        line-height: 1.6 !important;
    }

    .text-sm {
        font-size: 0.875rem !important;
    }

    .text-xs {
        font-size: 0.75rem !important;
    }

    /* Prevent text overflow */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    p {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
}

/* ===================================
   Touch Targets - WCAG Compliance
   =================================== */
@media (max-width: 768px) {

    /* Minimum 44px touch targets */
    button,
    a,
    input[type="submit"],
    input[type="button"],
    input[type="reset"],
    .btn,
    .button,
    [role="button"] {
        min-height: 44px !important;
        min-width: 44px !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Form inputs need larger touch areas */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        min-height: 48px !important;
        padding: 0.75rem 1rem !important;
        font-size: 16px !important;
        /* Prevents iOS zoom */
    }

    /* Larger checkboxes and radios */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px !important;
        height: 24px !important;
        cursor: pointer;
    }

    /* Clickable labels */
    label {
        display: block;
        padding: 0.5rem 0;
        cursor: pointer;
    }
}

/* ===================================
   Navigation Mobile Fixes
   =================================== */
@media (max-width: 768px) {

    /* Mobile menu button always visible */
    .mobile-menu-button {
        display: flex !important;
    }

    /* Desktop menu hidden */
    .desktop-menu {
        display: none !important;
    }

    /* Mobile dropdown styling */
    .mobile-dropdown {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(10, 10, 10, 0.98) !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Convert hover dropdowns to click */
    .hover\:block:hover {
        display: none !important;
    }

    .mobile-dropdown-trigger.active+.dropdown-menu {
        display: block !important;
    }
}

/* ===================================
   Hero Section Mobile
   =================================== */
@media (max-width: 768px) {

    /* Hero content spacing */
    .hero-section,
    section.relative.min-h-screen {
        padding: 3rem 0 !important;
        min-height: auto !important;
    }

    /* Hero badges */
    .inline-flex.items-center.gap-2 {
        font-size: 0.75rem !important;
        padding: 0.5rem 1rem !important;
    }

    /* Long badge text wrap */
    .tracking-wider.uppercase {
        display: block !important;
        text-align: center !important;
        line-height: 1.4 !important;
    }

    /* CTA buttons stack */
    .flex.flex-col.sm\:flex-row {
        flex-direction: column !important;
        width: 100% !important;
        padding: 0 1rem !important;
    }

    .flex.flex-col.sm\:flex-row>* {
        width: 100% !important;
        margin: 0.5rem 0 !important;
    }

    /* Footer responsiveness */
    .site-footer .container .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    .footer-widget {
        text-align: center !important;
        margin-bottom: 2rem !important;
    }

    .footer-widget h4 {
        justify-content: center !important;
    }

    .footer-widget ul {
        align-items: center !important;
    }

    .social-links {
        justify-content: center !important;
    }
}

/* ===================================
   Blog/Article Pages Mobile
   =================================== */
@media (max-width: 768px) {

    /* Single column layout */
    .grid.grid-cols-1.lg\:grid-cols-3 {
        grid-template-columns: 1fr !important;
    }

    /* Prose content padding */
    .prose {
        padding: 0 !important;
        font-size: 1rem !important;
    }

    .prose img {
        margin-left: -1rem !important;
        margin-right: -1rem !important;
        max-width: calc(100% + 2rem) !important;
        width: calc(100% + 2rem) !important;
    }

    /* Meta information stack */
    .flex.items-center.text-gray-400.space-x-6 {
        flex-wrap: wrap !important;
        gap: 0.75rem !important;
    }

    /* Share buttons responsive */
    #social-share-buttons {
        display: grid !important;
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)) !important;
        gap: 0.5rem !important;
    }

    .share-button {
        width: 100% !important;
        height: 60px !important;
        padding: 0 !important;
    }
}

/* ===================================
   Forms & Inputs Mobile
   =================================== */
@media (max-width: 768px) {

    /* Form container spacing */
    form {
        padding: 1.5rem !important;
    }

    /* Input groups stack */
    .flex.gap-4>input,
    .flex.space-x-4>input {
        width: 100% !important;
        margin: 0.5rem 0 !important;
    }

    /* Error messages */
    .error-message,
    .success-message {
        font-size: 0.875rem !important;
        padding: 0.75rem !important;
    }

    /* Submit buttons full width */
    button[type="submit"],
    input[type="submit"] {
        width: 100% !important;
        padding: 1rem !important;
        font-size: 1rem !important;
        font-weight: 600 !important;
    }

    /* Consent checkboxes */
    .consent-group {
        display: flex !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
    }

    .consent-group input[type="checkbox"] {
        margin-top: 0.125rem !important;
        flex-shrink: 0 !important;
    }
}

/* ===================================
   Dashboard/Tables Mobile
   =================================== */
@media (max-width: 768px) {

    /* Dashboard header responsive */
    .dashboard-header {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .dashboard-header>div {
        width: 100% !important;
        text-align: center !important;
    }

    .dashboard-header button,
    .dashboard-header a {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Stats cards larger */
    .stats-card {
        padding: 1.5rem !important;
    }

    .stats-card .text-3xl {
        font-size: 2rem !important;
    }

    .stats-card .text-sm {
        font-size: 0.875rem !important;
        margin-top: 0.5rem !important;
    }

    /* Responsive tables */
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    table {
        min-width: 600px !important;
    }

    /* Table actions */
    td button,
    td a {
        padding: 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

/* ===================================
   Performance Optimizations
   =================================== */
/* Disable complex animations ONLY if user prefers reduced motion */
@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;
    }

    .animate-float,
    .animate-float-slow,
    .animate-float-medium,
    .animate-float-gentle,
    .animate-particle-float,
    .animate-mesh-move,
    .animate-cyber-glow,
    .animate-neon-pulse,
    .animate-aurora-shift,
    .animate-shimmer-neon {
        animation: none !important;
    }
}

/* Optimize heavy effects for mobile without disabling them completely */
.cyber-mesh,
.cyber-grid,
.bg-cyber-mesh,
.bg-aurora {
    opacity: 0.5;
    /* Reduce intensity for performance */
}

/* Optimize backdrop filters */
.backdrop-blur-xl {
    backdrop-filter: blur(12px);
    /* Slightly reduced from desktop */
}

/* No-hover touch adjustments are handled by media(hover: none) block */

/* ===================================
   Touch Interactions
   =================================== */
@media (hover: none) and (pointer: coarse) {

    /* Touch feedback */
    button:active,
    a:active,
    [role="button"]:active {
        transform: scale(0.98) !important;
        opacity: 0.9 !important;
    }

    /* Remove hover-only effects */
    .group:hover .group-hover\:opacity-100 {
        opacity: 1 !important;
        /* Always show on mobile */
    }

    /* Touch-friendly spacing */
    a+a,
    button+button {
        margin-left: 0.5rem !important;
    }

    /* Disable user selection on buttons */
    button,
    a,
    [role="button"] {
        -webkit-user-select: none !important;
        user-select: none !important;
    }
}

/* ===================================
   Utility Classes
   =================================== */
@media (max-width: 768px) {

    /* Hide desktop only elements */
    .desktop-only,
    .hidden-mobile {
        display: none !important;
    }

    /* Show mobile only elements */
    .mobile-only,
    .show-mobile {
        display: block !important;
    }

    /* Full width on mobile */
    .mobile\:w-full {
        width: 100% !important;
    }

    /* Stack flex items */
    .mobile\:flex-col {
        flex-direction: column !important;
    }

    /* Reset margins */
    .mobile\:m-0 {
        margin: 0 !important;
    }

    /* Common spacing */
    .mobile\:p-4 {
        padding: 1rem !important;
    }

    .mobile\:px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .mobile\:py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* ===================================
   Landscape Mobile Adjustments
   =================================== */
@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce vertical spacing */
    .py-8 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }

    .my-8 {
        margin-top: 2rem !important;
        margin-bottom: 2rem !important;
    }

    /* Compact headers */
    h1 {
        font-size: 1.75rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    /* Two column grids in landscape */
    .grid-cols-1 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===================================
   iOS Specific Fixes
   =================================== */
@supports (-webkit-touch-callout: none) {

    /* Prevent input zoom on iOS */
    input,
    select,
    textarea {
        font-size: 16px !important;
    }

    /* Fix position fixed issues */
    .fixed {
        position: -webkit-sticky !important;
        position: sticky !important;
    }

    /* Smooth scrolling */
    .overflow-auto,
    .overflow-y-auto {
        -webkit-overflow-scrolling: touch !important;
    }
}

/* ===================================
   Android Specific Fixes
   =================================== */
@media screen and (-webkit-min-device-pixel-ratio: 0) {

    /* Tap highlight color */
    * {
        -webkit-tap-highlight-color: rgba(139, 92, 246, 0.1) !important;
    }

    /* Fix select dropdowns */
    select {
        background-image: url("data:image/svg+xml,...") !important;
        background-position: right 0.5rem center !important;
        background-size: 1.5rem !important;
        padding-right: 2.5rem !important;
    }
}

/* ===================================
   Accessibility Improvements
   =================================== */
@media (max-width: 768px) {

    /* Focus states more visible */
    *:focus {
        outline: 3px solid #8b5cf6 !important;
        outline-offset: 2px !important;
    }

    /* Skip links */
    .skip-link {
        position: absolute !important;
        top: -40px !important;
        left: 0 !important;
        background: #8b5cf6 !important;
        color: white !important;
        padding: 8px !important;
        text-decoration: none !important;
        z-index: 100 !important;
    }

    .skip-link:focus {
        top: 0 !important;
    }

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

        button,
        a {
            text-decoration: underline !important;
        }
    }
}

/* ===================================
   Print Styles
   =================================== */
@media print {

    /* Hide navigation and decorative elements */
    header,
    footer,
    nav,
    .no-print,
    .animate-*,
    .bg-gradient-*,
    .shadow-* {
        display: none !important;
    }

    /* Reset colors for print */
    * {
        color: #000 !important;
        background: #fff !important;
    }

    /* Ensure content fits page */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* ===================================
   Loading States
   =================================== */
@media (max-width: 768px) {

    /* Skeleton loaders */
    .skeleton {
        background: linear-gradient(90deg, #1a1a1a 0%, #2a2a2a 50%, #1a1a1a 100%) !important;
        background-size: 200% 100% !important;
        animation: skeleton-loading 1.5s ease-in-out infinite !important;
    }

    @keyframes skeleton-loading {
        0% {
            background-position: 200% 0;
        }

        100% {
            background-position: -200% 0;
        }
    }

    /* Loading spinner */
    .loading-spinner {
        width: 40px !important;
        height: 40px !important;
    }
}
/* ============================================================
 * Section 2: Mobile centering fixes
 * Source: mobile-centering-fix.css
 * ============================================================ */
/**
 * Mobile Centering Fix
 * Fixes off-center content on mobile devices
 * Created: July 31, 2025
 */

/* Global centering fixes for mobile */
@media (max-width: 768px) {
    /* Fix container alignment */
    .container,
    .container-custom {
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Fix content wrapper alignment */
    .content-wrapper,
    .page-wrapper,
    main,
    .main-content {
        margin-left: auto !important;
        margin-right: auto !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    
    /* Fix text alignment issues */
    .text-center {
        text-align: center !important;
    }
    
    /* Fix flex container centering */
    .flex,
    .flex-col {
        align-items: center !important;
    }
    
    .flex.justify-between {
        justify-content: space-between !important;
    }
    
    .flex.justify-center {
        justify-content: center !important;
    }
    
    /* Fix grid centering */
    .grid {
        justify-items: center !important;
        justify-content: center !important;
    }
    
    /* Fix margin auto issues */
    .mx-auto {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Fix common off-center elements */
    header,
    nav,
    footer {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix hero sections */
    .hero,
    .hero-section,
    [class*="hero-"] {
        width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        text-align: center !important;
    }
    
    /* Fix card layouts */
    .card,
    .bg-glass-dark,
    .bg-glass-light,
    [class*="bg-glass"] {
        margin-left: auto !important;
        margin-right: auto !important;
        width: calc(100% - 2rem) !important;
        max-width: 100% !important;
    }
    
    /* Fix button alignment */
    .btn,
    button,
    [type="button"],
    [type="submit"] {
        margin-left: auto !important;
        margin-right: auto !important;
        display: block !important;
        width: auto !important;
        max-width: 100% !important;
    }
    
    .btn-group,
    .button-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.5rem !important;
        width: 100% !important;
    }
    
    /* Fix form elements */
    form,
    .form-group,
    input,
    textarea,
    select {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Fix modal centering */
    .modal,
    .modal-content,
    [class*="modal"] {
        margin: 1rem auto !important;
        width: calc(100% - 2rem) !important;
        max-width: calc(100vw - 2rem) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    /* Fix image centering */
    img,
    picture,
    figure {
        display: block !important;
        margin-left: auto !important;
        margin-right: auto !important;
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Fix navigation menu centering */
    .mobile-menu,
    .nav-menu,
    [class*="menu"] {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 1rem !important;
    }
    
    /* Fix specific page sections */
    #hero-section,
    #features-section,
    #trending-section,
    #activity-section {
        width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        margin: 0 !important;
    }
    
    /* Fix dashboard layouts */
    .dashboard-container,
    .creator-dashboard,
    .dashboard-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 1rem !important;
    }
    
    /* Fix sidebar on mobile */
    .sidebar,
    aside {
        width: 100% !important;
        margin: 0 !important;
        padding: 1rem !important;
    }
    
    /* Prevent horizontal overflow */
    * {
        max-width: 100vw !important;
    }
    
    /* Fix specific BlogThree components */
    .nft-grid,
    .blog-grid,
    .trending-grid {
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 1rem !important;
    }
    
    .nft-card,
    .blog-card,
    .trending-card {
        width: 100% !important;
        margin: 0 auto 1rem !important;
    }
    
    /* Fix table responsiveness */
    table {
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
    }
    
    /* Fix absolute positioned elements */
    .absolute {
        position: relative !important;
        width: 100% !important;
        margin: 0 !important;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    /* Even tighter padding on very small screens */
    .container,
    .container-custom,
    .content-wrapper {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Stack all flex items vertically */
    .flex:not(.flex-col) {
        flex-direction: column !important;
    }
    
    /* Full width buttons on very small screens */
    .btn,
    button {
        width: 100% !important;
    }
}

/* Fix for specific iOS Safari issues */
@supports (-webkit-touch-callout: none) {
    /* iOS specific fixes */
    body {
        -webkit-text-size-adjust: 100%;
    }
    
    .container,
    .container-custom {
        padding-left: env(safe-area-inset-left, 1rem) !important;
        padding-right: env(safe-area-inset-right, 1rem) !important;
    }
}

/* Fix landscape orientation issues */
@media (max-height: 500px) and (orientation: landscape) {
    .hero,
    .hero-section {
        min-height: auto !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}
/* ============================================================
 * Section 3: Mobile menu solid background (anti-glass)
 * Source: mobile-menu-safe.css
 * ============================================================ */
/**
 * Safe Mobile Menu Styles
 * Provides solid background for mobile dropdown visibility without heavy effects
 */

/* Mobile menu with solid dark background */
.mobile-menu-solid {
    /* Solid dark background with 95% opacity */
    background-color: rgba(15, 23, 42, 0.95) !important;
    
    /* Simple shadow for depth */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
    
    /* Ensure it appears above content */
    z-index: 50 !important;
    
    /* Remove any transparency effects */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

/* Ensure menu items are visible */
.mobile-menu-solid a,
.mobile-menu-solid button {
    /* Ensure text is visible against dark background */
    color: rgba(255, 255, 255, 0.9) !important;
    
    /* Add padding for better touch targets */
    padding: 0.75rem 1rem;
    
    /* Ensure readable text */
    position: relative;
    z-index: 10;
}

/* Simple hover states */
.mobile-menu-solid a:hover,
.mobile-menu-solid button:hover {
    /* Light background on hover */
    background-color: rgba(139, 92, 246, 0.15) !important;
    
    /* Ensure text stays visible */
    color: #ffffff !important;
}

/* Fix for Alpine.js controlled menu */
[x-show="mobileMenuOpen"] {
    /* Ensure solid background when visible */
    background-color: rgba(15, 23, 42, 0.95) !important;
}

/* Override glass-dark transparency */
.bg-glass-dark.mobile-menu-solid {
    /* Force solid background */
    background-color: rgba(15, 23, 42, 0.95) !important;
    backdrop-filter: none !important;
}
/* ============================================================
 * Section 4: Mobile menu layout + dropdown toggle states
 * Source: previously inline in header.php <style>
 * Note: scoped to max-width:1023px to cover tablets, even though the
 * sheet itself is loaded only up to 768px. The 1023px range above
 * the file's gate is dead, but the rules are kept here for clarity
 * — the menu only renders below lg: (1024px) anyway.
 * ============================================================ */
@media (max-width: 1023px) {
    #mobile-menu {
        position: fixed;
        top: 64px;
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(59, 130, 246, 0.3);
        z-index: 9999;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .has-dropdown .dropdown-menu {
        display: none;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease-in-out;
    }

    .has-dropdown.mobile-open .dropdown-menu {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
}
