/**
 * Mobile Layout Fixes
 * Education Canine IDF — ecimedia theme
 * Rewritten: 2026-04-02 — clean cascade, no unnecessary !important
 *
 * Loaded AFTER style.css — same selectors override naturally.
 * !important only where strictly needed (inline styles, JS toggles).
 */

/* ===================== Global overflow guard ===================== */
html {
    overflow-x: hidden !important; /* prevent horizontal scroll at all costs */
    -webkit-overflow-scrolling: touch;
}
body {
    overflow-x: hidden !important;
    width: 100%;
    min-width: 0;
}

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

    /* -- Containment -- */
    .container,
    .container-narrow {
        max-width: 100%;
        padding-left: 16px;
        padding-right: 16px;
        box-sizing: border-box;
    }

    /* -- Hero -- */
    .eci-hero {
        padding: 2.5rem 0;
        overflow: hidden;
    }

    .eci-hero-split {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    .eci-hero h1 {
        font-size: 1.5rem;
        line-height: 1.25;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .eci-hero p {
        font-size: 1rem;
    }

    .eci-hero-visual {
        order: -1;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .eci-hero-visual img {
        max-width: 220px;
        width: 60vw;
        height: auto;
        margin: 0 auto;
    }

    .eci-hero-cta {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .eci-hero-cta .btn {
        font-size: 0.875rem;
        padding: 0.75rem 1.25rem;
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    /* -- Trust grid -- */
    .eci-trust-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    /* -- Section headers -- */
    .eci-section {
        padding: 2rem 0;
        overflow: hidden;
    }

    .eci-section h2,
    .eci-section-header h2 {
        font-size: 1.35rem;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .eci-section-header-row {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
        align-items: stretch;
    }

    .eci-eyebrow {
        text-align: center;
    }

    /* -- Grids: single column -- */
    .eci-categories-grid,
    .eci-services-grid,
    .eci-articles-grid,
    .eci-guides-grid,
    .eci-tools-grid,
    .eci-testimonials-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .eci-reeducation-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    /* -- Cards -- */
    .eci-category-card,
    .eci-service-card,
    .eci-article-card,
    .eci-guide-card,
    .eci-tool-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .eci-category-card {
        padding: 1.25rem;
    }

    .eci-category-card h3 {
        font-size: 1.1rem;
    }

    .eci-reeduc-card {
        padding: 0.75rem;
    }

    .eci-reeduc-card h4 {
        font-size: 0.85rem;
    }

    /* -- Newsletter -- */
    .eci-newsletter-inner {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .eci-form-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .eci-form-row input[type="email"],
    .eci-form-row .btn {
        width: 100%;
    }

    /* -- Footer -- */
    .eci-footer-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    /* -- Inner hero (single/archive) -- */
    .eci-inner-hero {
        padding: 2rem 0;
        overflow: hidden;
    }

    .eci-inner-hero-title {
        font-size: 1.4rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .eci-inner-hero-meta {
        justify-content: center;
    }

    .eci-inner-hero::before,
    .eci-inner-hero::after {
        display: none;
    }

    /* -- Post nav -- */
    .eci-post-nav-inner {
        grid-template-columns: 1fr;
    }

    /* -- Content containment -- */
    .entry-content,
    .post-content,
    .page-content,
    .eci-article-content {
        max-width: 100%;
        padding: 0 16px;
        box-sizing: border-box;
        overflow-x: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .entry-content img,
    .entry-content table,
    .entry-content iframe,
    .entry-content pre,
    .entry-content video {
        max-width: 100%;
        height: auto;
    }

    .entry-content table {
        display: block;
        overflow-x: auto;
    }

    pre, code {
        white-space: pre-wrap;
        word-break: break-word;
        max-width: 100%;
    }

    /* -- Media -- */
    img, video, iframe, embed, object, svg {
        max-width: 100%;
        height: auto;
    }

    /* -- CTA box -- */
    .eci-page-cta-box {
        padding: 2rem 1rem;
    }

    .eci-page-cta-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .eci-page-cta-actions .btn {
        text-align: center;
        justify-content: center;
    }
}

/* ===================== Small screens < 400px ===================== */
@media (max-width: 400px) {

    .container,
    .container-narrow {
        padding-left: 12px;
        padding-right: 12px;
    }

    .eci-hero h1 {
        font-size: 1.3rem;
    }

    .eci-hero-visual img {
        max-width: 180px;
    }

    .eci-category-card {
        padding: 1rem;
    }

    .eci-category-card h3 {
        font-size: 1rem;
    }

    .eci-trust-grid,
    .eci-reeducation-grid {
        grid-template-columns: 1fr;
    }
}

/* ===================== Burger menu < 900px ===================== */
@media (max-width: 900px) {

    .eci-menu-toggle {
        display: block !important; /* overrides display:none from desktop */
        position: relative;
        z-index: 10002;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        pointer-events: auto;
    }

    .eci-main-nav.is-open {
        display: flex !important;  /* JS toggle — must override display:none */
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.menu-open {
        overflow: hidden !important; /* lock scroll when menu open */
        position: fixed;
        width: 100%;
    }
}

/* ===================== Safety net (all viewports) ===================== */
.site-header:not(.eci-site-header) { display: none !important; }
.site-footer:not(.eci-site-footer) { display: none !important; }

.site-header .container,
.site-header,
header {
    max-width: 100vw;
    overflow-x: hidden;
}
