/**
 * Mobile Responsive CSS Improvements
 * Enhanced mobile experience for Dondo theme
 * 
 * @package Dondo
 * @version 1.0.0
 */

/* ==========================================================================
   BASE MOBILE IMPROVEMENTS
   ========================================================================== */

/* Ensure proper viewport behavior */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/* Improve touch targets - excluding menu icons and special elements */
input[type="submit"], 
.button:not(.menu-icon):not(.toggle-topbar),
button:not(.menu-icon):not(.toggle-topbar):not([class*="menu"]) {
    min-height: 44px;
}

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

/* Prevent horizontal scroll */
body {
    overflow-x: hidden;
    width: 100%;
}

/* ==========================================================================
   TYPOGRAPHY - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    html {
        font-size: 14px;
    }
    
    h1, .h1 {
        font-size: 1.75rem !important;
        line-height: 1.2;
    }
    
    h2, .h2 {
        font-size: 1.5rem !important;
        line-height: 1.25;
    }
    
    h3, .h3 {
        font-size: 1.25rem !important;
    }
    
    h4, .h4, h5, .h5, h6, .h6 {
        font-size: 1rem !important;
    }
    
    p, li, td, th {
        font-size: 0.9375rem;
        line-height: 1.6;
    }
    
    .entry-title {
        font-size: 1.5rem !important;
        word-wrap: break-word;
        hyphens: auto;
    }
    
    .page-title {
        font-size: 1.5rem !important;
        padding-top: 60px !important;
    }
}

/* ==========================================================================
   HEADER - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .site-header {
        min-height: 60px;
    }
    
    .header-wrap {
        height: 60px;
        padding: 0 10px;
    }
    
    .header-wrap .theme-logo img {
        max-height: 40px;
        width: auto;
    }
    
    .header-wrap .theme-logo .name h1,
    .header-wrap .theme-logo .name h2,
    .header-wrap .theme-logo .name a {
        font-size: 1.125rem;
        line-height: 60px;
    }
    
    #main-nav {
        padding: 5px 10px;
    }
    
    /* Mobile menu icon - preserve original styling */
    .menu-icon {
        min-height: auto !important;
        min-width: auto !important;
        height: auto !important;
        width: auto !important;
    }
    
    .menu-icon span,
    .menu-icon span::before,
    .menu-icon span::after {
        background-color: inherit;
    }
    
    .toggle-topbar {
        min-height: auto !important;
        min-width: auto !important;
    }
    
    /* Fixed header spacing for admin bar */
    .admin-bar .site-header.fixed {
        margin-top: 46px;
    }
    
    @media screen and (max-width: 782px) {
        .admin-bar .site-header.fixed {
            margin-top: 46px;
        }
    }
}

/* ==========================================================================
   NAVIGATION - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .navigation-overlay {
        width: 100% !important;
        max-width: 100vw;
    }
    
    .top-bar-section ul li > a {
        padding: 15px 20px;
        font-size: 1rem;
    }
    
    .top-bar-section .dropdown li > a {
        padding: 12px 25px;
    }
    
    /* Better mobile menu spacing */
    .offcanvas-overlap-right .inner-wrap,
    .offcanvas-overlap-menu .inner-wrap {
        transform: translateX(-280px);
    }
}

/* ==========================================================================
   CONTENT LAYOUT - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    /* Full width content on mobile */
    .page .site-content .row #primary,
    .single-post .site-content .row #primary,
    .search .site-content .row #primary {
        padding: 0 15px !important;
        margin: 0;
        width: 100%;
    }
    
    /* Remove sidebar push/pull on mobile */
    .medium-push-3, .medium-push-4,
    .medium-pull-8, .medium-pull-9 {
        left: 0;
        right: auto;
    }
    
    /* Stack columns */
    .column, .columns {
        width: 100%;
        float: none;
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Sidebar full width on mobile */
    #secondary {
        padding: 20px 15px;
        width: 100%;
    }
    
    /* Content area padding */
    .entry-content {
        padding: 0 5px;
    }
    
    /* Page header adjustments */
    .page-header {
        margin-top: 30px;
        margin-bottom: 30px;
        padding: 0 15px;
    }
    
    .page-header > .page-title-container > .page-title {
        padding-top: 60px;
    }
    
    /* Entry header */
    .single .entry-header {
        padding: 0 10px;
    }
    
    .single .entry-header.unique-page-header .entry-title {
        margin: 60px 0 0 0;
    }
}

/* ==========================================================================
   IMAGES & MEDIA - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    img {
        max-width: 100%;
        height: auto;
    }
    
    .post-thumbnail {
        margin: 0 -15px;
        width: calc(100% + 30px);
    }
    
    .single .site-content .post-thumbnail,
    .page .site-content .post-thumbnail {
        border-width: 10px;
    }
    
    /* Featured media */
    .tdf-featured-media {
        min-height: 200px !important;
        max-height: 300px !important;
    }
    
    .inner-wrap > #page > .tdf-featured-media .imgLiquidFill {
        height: 300px !important;
        margin-top: 0;
    }
    
    /* Gallery columns on mobile */
    .gallery-columns-2 .gallery-item,
    .gallery-columns-3 .gallery-item,
    .gallery-columns-4 .gallery-item,
    .gallery-columns-5 .gallery-item {
        max-width: 50%;
    }
    
    .gallery-columns-6 .gallery-item,
    .gallery-columns-7 .gallery-item,
    .gallery-columns-8 .gallery-item,
    .gallery-columns-9 .gallery-item,
    .gallery-columns-10 .gallery-item {
        max-width: 33.33%;
    }
    
    /* Flexslider mobile */
    .flex-direction-nav a {
        width: 30px;
        height: 50px;
    }
    
    .flex-direction-nav a:before {
        font-size: 16px !important;
        padding: 5px 8px;
    }
    
    /* WooCommerce product gallery */
    .woocommerce-product-gallery__image.flex-active-slide {
        margin-left: 0;
    }
}

/* ==========================================================================
   PORTFOLIO - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .tdf.page-template-portfolio .site-content .blocks.shuffle {
        margin: 10px 5px;
    }
    
    .tdf.page-template-portfolio .site-content .blocks.shuffle .type-tdf-portfolio {
        width: 100% !important;
        margin-bottom: 10px;
    }
    
    .site-content .content-excerpts .type-tdf-portfolio .portfolio-info {
        position: relative;
        opacity: 1;
        padding: 15px;
    }
    
    /* Portfolio modal */
    .tdf.page-template-portfolio #portfolioContent {
        padding: 0;
    }
    
    .tdf.page-template-portfolio #portfolioContent #featuredContent,
    .tdf.page-template-portfolio #portfolioContent #featuredMedia {
        max-height: none;
        height: auto;
    }
    
    .tdf.page-template-portfolio #portfolioContent .close-reveal-modal {
        top: 10px;
        right: 10px;
        z-index: 10001;
    }
}

/* ==========================================================================
   BLOCKS & ARCHIVE - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .blocks {
        margin: 15px 0;
    }
    
    .blocks .medium-five,
    .blocks .medium-six {
        width: 100%;
    }
    
    .site-content .content-excerpts .hentry {
        margin-bottom: 15px;
        padding: 0;
    }
    
    .site-content .content-excerpts .hentry .item-wrap {
        padding: 15px;
    }
    
    /* Related posts */
    .related-items .related-posts .related-post {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .related-items .title {
        margin-bottom: 20px;
    }
}

/* ==========================================================================
   SIDEBAR & WIDGETS - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .widget {
        margin-bottom: 30px;
    }
    
    .widget-area {
        margin-top: 30px;
        padding: 0 15px;
    }
    
    .footer-widget-area {
        padding: 30px 15px;
    }
    
    .footer-widget-area .column,
    .footer-widget-area .columns {
        margin-bottom: 30px !important;
    }
}

/* ==========================================================================
   FORMS - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    input[type="search"],
    textarea,
    select {
        width: 100%;
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px;
    }
    
    .button, button, input[type="submit"] {
        width: 100%;
        padding: 15px 20px;
        font-size: 1rem;
    }
    
    /* Search form */
    .search-form {
        display: flex;
        flex-wrap: wrap;
    }
    
    .search-form .search-field {
        flex: 1;
        min-width: 0;
    }
    
    .search-form .search-submit {
        width: auto;
        flex-shrink: 0;
    }
    
    /* Comment form */
    .comment-form input,
    .comment-form textarea {
        width: 100%;
    }
    
    .comment-respond .form-submit .submit {
        float: none;
        width: 100%;
    }
}

/* ==========================================================================
   COMMENTS - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .comments-area .author-avatar,
    .comments-area .author-comment {
        padding: 10px;
    }
    
    .comments-area .author-avatar {
        width: 60px;
        float: left;
    }
    
    .comments-area .author-comment {
        margin-left: 70px;
    }
    
    .comment-list .children {
        margin-left: 15px;
    }
}

/* ==========================================================================
   FOOTER - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .site-footer {
        padding: 20px 0;
    }
    
    .site-footer .row {
        padding: 0 15px;
    }
    
    .site-footer .column,
    .site-footer .columns {
        text-align: center;
        margin-top: 15px !important;
        margin-bottom: 15px !important;
    }
    
    .footer-menu .menu {
        display: block;
    }
    
    .footer-menu .menu li {
        display: block;
        margin: 10px 0;
    }
    
    .social-links {
        text-align: center;
    }
    
    .social-links li {
        padding: 5px;
    }
    
    .scroll-top {
        min-width: 40px;
        padding: 8px;
    }
}

/* ==========================================================================
   TABLES - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table thead,
    table tbody,
    table tr,
    table td,
    table th {
        display: block;
    }
    
    table tr {
        margin-bottom: 15px;
        border-bottom: 2px solid #ddd;
    }
    
    table td,
    table th {
        text-align: left;
        padding: 8px 10px;
        border: none;
        border-bottom: 1px solid #eee;
    }
    
    table td:before {
        content: attr(data-label);
        font-weight: bold;
        display: block;
        margin-bottom: 5px;
    }
}

/* ==========================================================================
   WOOCOMMERCE - MOBILE
   ========================================================================== */

@media only screen and (max-width: 640px) {
    .woocommerce ul.products li.product {
        width: 100% !important;
        margin: 0 0 20px 0 !important;
    }
    
    .woocommerce .woocommerce-ordering,
    .woocommerce .woocommerce-result-count {
        float: none;
        width: 100%;
        text-align: center;
        margin-bottom: 15px;
    }
    
    .woocommerce-cart .site-content .row #primary {
        padding: 0 15px !important;
    }
    
    .woocommerce table.cart {
        display: block;
    }
    
    .woocommerce table.cart td {
        display: block;
        text-align: center;
    }
    
    .woocommerce table.cart .product-thumbnail {
        width: 100%;
    }
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #ef4523;
    outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    z-index: 100000;
}

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

/* Reduced motion for users who prefer it */
@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;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .site-header,
    .site-footer,
    .navigation-overlay,
    .scroll-top,
    .related-items,
    #secondary,
    .comment-respond,
    .nav-links {
        display: none !important;
    }
    
    .site-content .row #primary {
        width: 100% !important;
        padding: 0 !important;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode support
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .site-header,
    .site-footer {
        background-color: #2d2d2d;
    }
    
    a {
        color: #ff7f5f;
    }
    */
}

