/**
 * Smart House - Ultra Mobile-Friendly Responsive Stylesheet
 *
 * Comprehensive mobile optimizations for:
 * - Fluid layouts across all screen widths (320px to 1200px+)
 * - 44px minimum touch targets for comfortable mobile tapping
 * - iOS Safari auto-zoom prevention (16px input fonts)
 * - Swipeable horizontal category pills
 * - Interactive mobile Table of Contents (TOC)
 * - Stacked high-impact hero and featured article layouts
 * - High legibility typography and spacing
 *
 * @package Smart_House
 */

/* ==========================================================================
   1. Global Mobile Hygiene
   ========================================================================== */
html, body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   2. Tablet Landscape & Portrait (1024px and below)
   ========================================================================== */
@media (max-width: 1024px) {
    .container {
        width: min(100% - 32px, 1560px);
    }

    .hero-copy {
        width: 65%;
    }

    .hero h1 {
        font-size: 40px;
    }

    .featured,
    .featured-content {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }

    .article-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 22px;
    }

    .newsletter,
    .newsletter-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* ==========================================================================
   3. Tablet Portrait & Mobile Landscape (768px and below)
   ========================================================================== */
@media (max-width: 768px) {
    .container {
        width: min(100% - 24px, 1560px);
    }

    /* Header Compact */
    .site-header {
        height: 64px;
    }

    .header-inner {
        height: 64px;
    }

    /* Logo Mobile */
    .site-header-logo {
        height: 38px !important;
        max-height: 42px !important;
        max-width: 175px !important;
    }

    .brand a,
    .brand .brand-link {
        gap: 9px;
    }

    .brand-square-box {
        width: 38px;
        height: 38px;
        border-radius: 9px;
    }

    .brand-square-box svg.square-logo-svg {
        width: 19px;
        height: 19px;
    }

    .brand-side-title {
        font-size: 17px;
        letter-spacing: -0.02em;
    }

    .brand-side-tagline {
        font-size: 7px;
        letter-spacing: 0.12em;
    }

    .header-actions {
        gap: 8px;
    }

    .icon-btn {
        width: 40px;
        height: 40px;
    }

    .mobile-menu-btn {
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    /* Mobile Navigation Drawer */
    .mobile-nav.open {
        top: 64px;
        padding: 16px;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 16px 36px rgba(16, 36, 67, 0.12);
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .mobile-nav ul li {
        position: relative;
        margin-bottom: 3px;
    }

    .mobile-nav ul li a {
        padding: 12px 14px;
        font-size: 15.5px;
        font-weight: 600;
        color: #102443;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-decoration: none;
        transition: all 0.2s ease;
    }

    .mobile-nav ul li a:hover,
    .mobile-nav ul li a:active {
        background: #f1f7ff;
        color: var(--primary);
    }

    .mobile-nav ul li.current-menu-item > a {
        background: #eaf6ff;
        color: var(--primary);
    }

    /* Accordion Toggle Arrow for Parent Menu Items (e.g. Category) */
    .mobile-nav .dropdown-arrow,
    .mobile-nav .mobile-dropdown-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        border-radius: 8px;
        background: #eff6ff;
        color: var(--primary);
        font-size: 15px;
        font-weight: 800;
        line-height: 1;
        transition: transform 0.25s ease, background 0.2s ease, color 0.2s ease;
        margin-left: 8px;
        flex-shrink: 0;
    }

    .mobile-nav ul li.menu-item-has-children.sub-menu-open > a .dropdown-arrow,
    .mobile-nav ul li.menu-item-has-children.sub-menu-open > a .mobile-dropdown-toggle {
        transform: rotate(180deg);
        background: var(--primary);
        color: #ffffff;
    }

    /* Sub-menu (Categories dropdown) in Mobile Drawer - clearly distinct & nested */
    .mobile-nav ul li ul.sub-menu {
        display: none;
        margin: 4px 0 10px 10px;
        padding: 8px 6px 8px 14px;
        background: #f7faff;
        border-left: 3.5px solid var(--primary);
        border-radius: 0 12px 12px 0;
        box-shadow: inset 0 1px 3px rgba(8, 120, 232, 0.04);
    }

    .mobile-nav ul li.sub-menu-open > ul.sub-menu {
        display: block;
        animation: mobileSubMenuSlide 0.22s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
    }

    @keyframes mobileSubMenuSlide {
        from {
            opacity: 0;
            transform: translateY(-8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .mobile-nav ul li ul.sub-menu li {
        margin-bottom: 2px;
    }

    .mobile-nav ul li ul.sub-menu li a {
        padding: 9px 12px;
        font-size: 14px;
        font-weight: 500;
        color: #475569;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
    }

    .mobile-nav ul li ul.sub-menu li a::before {
        content: "•";
        color: var(--primary);
        font-size: 17px;
        line-height: 1;
    }

    .mobile-nav ul li ul.sub-menu li a:hover,
    .mobile-nav ul li ul.sub-menu li.current-menu-item > a {
        background: #eaf4fe;
        color: var(--primary);
        font-weight: 600;
        padding-left: 16px;
    }

    .mobile-nav-cta {
        margin-top: 14px;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .mobile-nav-cta .btn {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 13px;
        font-size: 15px;
        font-weight: 700;
    }

    /* Hero Section Mobile – Premium Editorial Design */
    .hero {
        position: relative;
        min-height: auto !important;
        padding: 46px 0 38px !important;
        background: #0f1f38 !important;
        overflow: hidden;
    }

    .hero-image {
        position: absolute;
        inset: 0;
        background-size: cover !important;
        background-position: center center !important;
        opacity: 0.88;
    }

    .hero-overlay {
        position: absolute;
        inset: 0;
        background: linear-gradient(180deg,
            rgba(12, 26, 48, 0.78) 0%,
            rgba(12, 26, 48, 0.70) 50%,
            rgba(12, 26, 48, 0.90) 100%) !important;
    }

    .hero-content {
        position: relative;
        z-index: 2;
        min-height: auto !important;
        display: flex !important;
        justify-content: center !important;
    }

    .hero-copy {
        width: 100% !important;
        max-width: 520px;
        margin: 0 auto;
        padding: 0 !important;
        text-align: center;
    }

    .hero .eyebrow {
        display: inline-flex;
        margin: 0 auto 14px;
        background: rgba(255, 255, 255, 0.18);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.28);
        color: #ffffff;
        font-size: 11.5px;
        padding: 6px 14px;
        border-radius: 20px;
        gap: 6px;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    }

    .hero .eyebrow svg {
        stroke: #ffffff;
    }

    .hero h1 {
        font-size: clamp(25px, 6.8vw, 33px) !important;
        color: #ffffff !important;
        line-height: 1.22 !important;
        letter-spacing: -0.025em;
        margin: 0 auto 12px !important;
        max-width: 100%;
        font-weight: 800;
        text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    }

    .hero h1 br {
        display: none !important;
    }

    .hero h1 span {
        background: linear-gradient(135deg, #60b5ff 0%, #a5d8ff 100%) !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        display: inline !important;
    }

    .hero-copy p {
        color: rgba(255, 255, 255, 0.92) !important;
        font-size: 14px !important;
        line-height: 1.55 !important;
        margin: 0 auto 20px !important;
        max-width: 440px;
        text-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
    }

    .hero-feature-card {
        display: none !important;
    }

    /* Mobile Pill Search Bar */
    .search-box {
        height: 50px !important;
        background: #ffffff !important;
        border-radius: 999px !important;
        border: 0 !important;
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28) !important;
        max-width: 440px !important;
        margin: 0 auto !important;
        padding: 4px 5px 4px 16px !important;
        display: flex;
        align-items: center;
    }

    .search-box .search-icon {
        color: #0878e8;
    }

    .search-box input[type="search"] {
        font-size: 15px !important;
        color: #102443 !important;
        padding-left: 8px;
    }

    .search-box input[type="search"]::placeholder {
        color: #7a8b9e;
    }

    .search-box button[type="submit"] {
        height: 42px !important;
        padding: 0 22px !important;
        border-radius: 999px !important;
        font-size: 13.5px !important;
        font-weight: 700;
        background: linear-gradient(135deg, #0878e8 0%, #0284c7 100%) !important;
        color: #ffffff !important;
        border: 0 !important;
        box-shadow: 0 4px 14px rgba(8, 120, 232, 0.35);
    }

    /* Popular Searches Pills */
    .popular-searches {
        margin: 16px auto 0 !important;
        justify-content: center;
        gap: 6px 8px;
        max-width: 460px;
    }

    .popular-searches span {
        color: rgba(255, 255, 255, 0.85) !important;
        font-size: 11.5px !important;
        font-weight: 600;
        width: 100%;
        text-align: center;
        margin-bottom: 3px;
    }

    .popular-searches a {
        background: rgba(255, 255, 255, 0.16) !important;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.24) !important;
        color: #ffffff !important;
        font-size: 11.5px !important;
        padding: 5px 12px !important;
        border-radius: 18px !important;
        transition: all 0.2s ease;
    }

    .popular-searches a:hover,
    .popular-searches a:active {
        background: #ffffff !important;
        color: var(--primary) !important;
    }

    /* Compact Glass Stats Bar */
    .hero-stats {
        display: flex !important;
        justify-content: space-around !important;
        align-items: center;
        gap: 4px !important;
        margin: 22px auto 0 !important;
        max-width: 460px !important;
        width: 100% !important;
        background: rgba(255, 255, 255, 0.14) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.22) !important;
        border-radius: 14px !important;
        padding: 12px 6px !important;
        box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2) !important;
    }

    .hero-stats > div {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 2px 4px !important;
        text-align: center;
        flex: 1;
    }

    .hero-stats > div:not(:last-child) {
        border-right: 1px solid rgba(255, 255, 255, 0.18) !important;
    }

    .hero-stats strong {
        font-size: 16px !important;
        color: #ffffff !important;
        display: block;
        line-height: 1.1;
    }

    .hero-stats small {
        font-size: 10px !important;
        color: rgba(255, 255, 255, 0.8) !important;
        display: block;
        margin-top: 3px;
        letter-spacing: 0.02em;
    }

    /* Category Strip (Horizontal Touch Swipe) */
    .category-strip {
        padding: 14px 0;
        position: relative;
    }

    .category-scroll {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 2px 2px 6px;
    }

    .category-scroll::-webkit-scrollbar {
        display: none;
    }

    .category-pill {
        white-space: nowrap;
        padding: 8px 15px;
        font-size: 13px;
        flex-shrink: 0;
        border-radius: 20px;
    }

    /* Featured Article Section Stacked */
    .featured,
    .featured-content {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
        border-radius: 16px;
        overflow: hidden;
    }

    .featured-image,
    .featured-image-wrapper {
        min-height: 210px;
        height: 210px;
        order: -1;
    }

    .featured-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .featured-copy {
        padding: 22px 18px;
    }

    .featured-copy h2 {
        font-size: 20px;
        line-height: 1.3;
        margin: 10px 0 10px;
    }

    .featured-copy p {
        font-size: 13.5px;
        line-height: 1.5;
        margin-bottom: 16px;
    }

    .featured-copy .btn {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 18px;
        font-size: 14px;
    }

    /* Section Headings */
    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 22px;
    }

    .section-heading h2 {
        font-size: 22px;
        letter-spacing: -0.02em;
    }

    .section-heading p {
        font-size: 13.5px;
    }

    .section-heading .sort {
        width: 100%;
        justify-content: space-between;
    }

    .section-heading select {
        flex: 1;
        max-width: 220px;
        padding: 7px 12px;
        font-size: 13px;
    }

    /* Article Cards Mobile */
    .article-grid {
        grid-template-columns: 1fr !important;
        gap: 18px;
    }

    .article-card {
        border-radius: 14px;
        overflow: hidden;
    }

    .article-card .card-image {
        aspect-ratio: 16/9;
        height: auto;
    }

    .card-body {
        padding: 16px;
    }

    .card-body h3 {
        font-size: 17px;
        line-height: 1.35;
        margin-bottom: 8px;
    }

    .card-body .meta {
        font-size: 11.5px;
        gap: 12px;
        margin-bottom: 10px;
    }

    .card-body > p {
        font-size: 13.5px;
        line-height: 1.55;
        color: var(--muted);
        margin-bottom: 14px;
    }

    .card-body .read-more {
        display: inline-block;
        padding: 6px 0;
        font-size: 13.5px;
        font-weight: 700;
    }

    /* Benefits Section */
    .benefits-section {
        padding: 30px 0;
    }

    .benefits,
    .benefits-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .benefit {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .benefit b {
        font-size: 14.5px;
    }

    .benefit small {
        font-size: 12.5px;
    }

    /* Newsletter Section */
    .newsletter-section {
        padding: 32px 0;
    }

    .newsletter,
    .newsletter-container {
        grid-template-columns: 1fr !important;
        border-radius: 16px;
        overflow: hidden;
    }

    .newsletter-image {
        height: 170px !important;
        min-height: 170px !important;
    }

    .newsletter-copy {
        padding: 24px 18px;
    }

    .newsletter-copy h2 {
        font-size: 21px;
        line-height: 1.25;
        margin: 10px 0;
    }

    .newsletter-copy p {
        font-size: 13.5px;
        line-height: 1.5;
        margin-bottom: 16px;
    }

    .newsletter-form {
        flex-direction: column;
        gap: 10px;
    }

    .newsletter-form input {
        width: 100%;
        height: 48px;
        font-size: 16px; /* Prevents iOS auto-zoom */
        border-radius: 10px;
    }

    .newsletter-form button {
        width: 100%;
        height: 46px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Single Post Layout on Mobile */
    .single-post-container {
        padding: 20px 0 40px;
    }

    .single-category-wrapper {
        margin: 10px 0 12px;
    }

    .single-category-badge {
        font-size: 12px !important;
        padding: 6px 14px !important;
    }

    .single-post-title {
        font-size: clamp(24px, 6vw, 30px) !important;
        line-height: 1.25 !important;
    }

    .single-post-excerpt {
        font-size: 15px !important;
        line-height: 1.6 !important;
    }

    .single-post-meta {
        font-size: 12px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .single-post-featured-image {
        margin: 16px 0 24px;
        border-radius: 12px;
        overflow: hidden;
    }

    .single-content-layout {
        display: block !important;
    }

    .single-post-sidebar {
        display: none !important;
    }

    /* Mobile Table of Contents (Hidden) */
    .mobile-toc-box {
        display: none !important;
    }

    .mobile-toc-box .toc-header {
        padding: 13px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        font-size: 14px;
        font-weight: 700;
        background: #f0f7ff;
        user-select: none;
    }

    .mobile-toc-box .toc-nav-mobile {
        padding: 12px 14px;
        max-height: 280px;
        overflow-y: auto;
    }

    .mobile-toc-box .toc-list {
        border-left: 2.5px solid #0878e8;
        padding-left: 10px;
        margin-left: 4px;
    }

    .mobile-toc-box .toc-num {
        font-weight: 800;
        color: #0878e8;
        font-size: 12px;
        min-width: 18px;
        flex-shrink: 0;
        display: inline-block;
    }

    .mobile-toc-box .toc-link {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 6px 8px;
        font-size: 13px;
        color: var(--text);
        text-decoration: none;
        border-radius: 6px;
        border-left: none;
        margin-left: 0;
    }

    .mobile-toc-box .toc-link:hover,
    .mobile-toc-box .toc-link.active {
        color: #0878e8;
        background: #eff6ff;
        font-weight: 700;
    }

    /* Single Post Body Typography */
    .single-entry-content {
        font-size: 16px;
        line-height: 1.75;
    }

    .single-entry-content h2 {
        font-size: 22px;
        margin: 28px 0 12px;
    }

    .single-entry-content h3 {
        font-size: 18px;
        margin: 24px 0 10px;
    }

    .single-entry-content img {
        border-radius: 10px;
        max-width: 100%;
        height: auto;
    }

    .single-entry-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    .single-author-card {
        padding: 18px;
        flex-direction: column;
        text-align: center;
        align-items: center;
        gap: 12px;
    }

    .single-author-card .author-avatar img {
        width: 64px;
        height: 64px;
    }

    .author-header-line {
        justify-content: center;
    }

    /* Contact Page Mobile */
    .contact-page-wrapper {
        padding: 24px 0 40px;
    }

    .contact-layout {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .contact-info-panel .contact-card,
    .contact-form-panel .contact-form-card {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .contact-card h3,
    .contact-form-card h2 {
        font-size: 20px;
    }

    .smart-house-contact-form input,
    .smart-house-contact-form textarea,
    .wpcf7-form-control-wrap input,
    .wpcf7-form-control-wrap textarea {
        font-size: 16px !important; /* Prevents iOS auto-zoom */
        padding: 12px 14px;
        border-radius: 10px;
    }

    .smart-house-contact-form .btn-submit,
    .wpcf7-submit {
        width: 100%;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 15px;
        font-weight: 700;
        border-radius: 10px;
    }

    /* Footer Mobile */
    .site-footer {
        padding: 40px 0 20px;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    .footer-brand {
        text-align: left;
    }

    .footer-brand .socials {
        justify-content: flex-start;
        gap: 10px;
    }

    .footer-brand .socials a {
        width: 38px;
        height: 38px;
    }

    .footer-bottom {
        text-align: center;
        justify-content: center;
        margin-top: 30px;
        padding-top: 20px;
    }
}

/* ==========================================================================
   4. Small Mobile (320px to 480px - iPhone SE, small Androids)
   ========================================================================== */
@media (max-width: 480px) {
    .container {
        width: min(100% - 20px, 1560px);
    }

    .hero h1 {
        font-size: 27px;
    }

    .hero-stats strong {
        font-size: 17px;
    }

    .hero-stats small {
        font-size: 11px;
    }

    .card-body h3 {
        font-size: 16px;
    }

    .card-body > p {
        font-size: 13px;
    }

    .back-top {
        width: 40px;
        height: 40px;
        bottom: 16px;
        right: 16px;
    }
}
