/* ========================================
   MOBILE FIXES - CyberGrantsAlliance.org
   ======================================== */

/* Mobile Breakpoints */
@media (max-width: 1024px) {
    /* Tablet adjustments */
    body {
        font-size: 16px !important;
    }
}

@media (max-width: 767px) {
    /* ========================================
       MOBILE MENU FIXES
       ======================================== */
    
    /* Show hamburger menu toggle on mobile */
    .elementor-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 10px;
        background: transparent;
        border: none;
        color: var(--text-primary, #16163f);
        position: relative !important;
        width: 48px !important;
        height: 48px !important;
    }
    
    /* Stack icons on top of each other */
    .elementor-menu-toggle svg {
        width: 28px !important;
        height: 28px !important;
        fill: currentColor !important;
        position: absolute !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        transition: opacity 0.2s ease !important;
    }
    
    /* Show hamburger (open) icon by default, hide close icon */
    .elementor-menu-toggle svg.elementor-menu-toggle__icon--open,
    .elementor-menu-toggle svg.e-eicon-menu-bar {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        z-index: 2 !important;
    }
    
    .elementor-menu-toggle svg.elementor-menu-toggle__icon--close,
    .elementor-menu-toggle svg.e-eicon-close {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: 1 !important;
    }
    
    /* When menu is active, hide hamburger and show close icon */
    .elementor-menu-toggle[aria-expanded="true"] svg.elementor-menu-toggle__icon--open,
    .elementor-menu-toggle[aria-expanded="true"] svg.e-eicon-menu-bar {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: 1 !important;
    }
    
    .elementor-menu-toggle[aria-expanded="true"] svg.elementor-menu-toggle__icon--close,
    .elementor-menu-toggle[aria-expanded="true"] svg.e-eicon-close {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        z-index: 2 !important;
    }
    
    /* Hide legacy Elementor mobile dropdown on mobile - we use custom drawer */
    nav.elementor-nav-menu--dropdown {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Hide duplicate hamburger/nav inside Elementor's sticky spacer clone.
       Elementor sticky creates a hidden clone to maintain layout; ensure
       nothing in the spacer ever becomes visible on mobile. */
    .elementor-sticky__spacer,
    .elementor-sticky__spacer * {
        visibility: hidden !important;
    }
    .elementor-sticky__spacer .elementor-menu-toggle,
    .elementor-sticky__spacer .elementor-widget-nav-menu {
        display: none !important;
    }
    
    /* ========================================
       MOBILE LAYOUT ADJUSTMENTS
       ======================================== */
    
    /* Make containers full-width on mobile */
    .elementor-container {
        max-width: 100% !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Stack columns vertically on mobile */
    .elementor-column {
        width: 100% !important;
        margin-bottom: 20px !important;
    }
    
    /* ========================================
       TYPOGRAPHY ADJUSTMENTS
       ======================================== */
    
    /* Larger headings on mobile */
    h1, .elementor-heading-title.elementor-size-default {
        font-size: 28px !important;
        line-height: 1.3 !important;
    }
    
    h2 {
        font-size: 24px !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 20px !important;
        line-height: 1.4 !important;
    }
    
    h4, h5, h6 {
        font-size: 18px !important;
        line-height: 1.4 !important;
    }
    
    /* Body text */
    body, p, .elementor-widget-text-editor {
        font-size: 16px !important;
        line-height: 1.6 !important;
    }
    
    /* ========================================
       TAP TARGET SIZES
       ======================================== */
    
    /* Ensure all clickable elements are at least 48x48px */
    a, button, .elementor-button, .elementor-icon-list-item {
        min-height: 48px !important;
        min-width: 48px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Buttons */
    .elementor-button {
        padding: 14px 24px !important;
        font-size: 16px !important;
    }
    
    /* ========================================
       IMAGES & MEDIA
       ======================================== */
    
    /* Responsive images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Prevent horizontal scroll */
    .elementor-section {
        overflow-x: hidden !important;
    }
    
    /* ========================================
       FORMS
       ======================================== */
    
    /* Make form inputs larger for mobile */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 14px !important;
        min-height: 48px !important;
    }
    
    /* Form labels */
    label {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }
    
    /* ========================================
       SPACING ADJUSTMENTS
       ======================================== */
    
    /* Reduce padding/margins on mobile */
    .elementor-section {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }
    
    .elementor-widget-wrap {
        padding: 15px !important;
    }
}

@media (max-width: 480px) {
    /* Extra small devices */
    
    h1, .elementor-heading-title.elementor-size-default {
        font-size: 24px !important;
    }
    
    h2 {
        font-size: 20px !important;
    }
    
    h3 {
        font-size: 18px !important;
    }
    
    .elementor-section {
        padding-top: 30px !important;
        padding-bottom: 30px !important;
    }
}

/* ========================================
   TOUCH-FRIENDLY IMPROVEMENTS
   ======================================== */

/* Remove hover states on touch devices */
@media (hover: none) and (pointer: coarse) {
    .elementor-nav-menu li:hover > ul.sub-menu,
    .elementor-nav-menu li:hover > .elementor-nav-menu--dropdown {
        display: none !important;
    }
    
    /* Use click/tap instead of hover */
    .elementor-nav-menu .menu-item-has-children.elementor-active > ul.sub-menu,
    .elementor-nav-menu .menu-item-has-children.elementor-active > .elementor-nav-menu--dropdown {
        display: block !important;
    }
}

/* ========================================
   FIX: Prevent text size adjustment
   ======================================== */
   
html {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

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

/* Focus visible for keyboard navigation */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #165DFB !important;
    outline-offset: 2px !important;
}

/* Skip to content link */
.skip-to-content {
    position: absolute !important;
    top: -100px !important;
    left: 0 !important;
    background: #165DFB !important;
    color: white !important;
    padding: 10px 20px !important;
    z-index: 10000 !important;
}

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

/* ========================================
   CGA ENTERPRISE MOBILE DRAWER
   Custom slide-in mobile navigation
   ======================================== */

:root {
    --cga-drawer-bg: #ffffff;
    --cga-drawer-width: min(360px, 85vw);
    --cga-brand: #165DFB;
    --cga-brand-dark: #0f47d4;
    --cga-text: #16163f;
    --cga-text-muted: #64748b;
    --cga-border: #e5e7eb;
    --cga-bg-soft: #f8fafc;
    --cga-shadow: 0 20px 60px rgba(16, 24, 40, 0.18);
}

/* Backdrop */
.cga-mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(16, 16, 30, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.28s ease, visibility 0s linear 0.28s;
    z-index: 99998;
    pointer-events: none;
}

.cga-mobile-backdrop.cga-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.28s ease, visibility 0s linear 0s;
    pointer-events: auto;
}

/* Drawer shell - hidden by default, only visible when JS opens it */
.cga-mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--cga-drawer-width);
    max-width: 100vw;
    background: var(--cga-drawer-bg);
    box-shadow: var(--cga-shadow);
    z-index: 99999;
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    visibility: hidden;
    overflow: hidden;
}

.cga-mobile-drawer.cga-open {
    transform: translateX(0);
    visibility: visible;
}

/* Hide drawer + backdrop on desktop (>= 768px) */
@media (min-width: 768px) {
    .cga-mobile-drawer,
    .cga-mobile-backdrop { display: none !important; }
}

/* Body scroll lock */
body.cga-drawer-open {
    overflow: hidden !important;
    touch-action: none;
}

/* Drawer header */
.cga-mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--cga-border);
    flex-shrink: 0;
}

.cga-mobile-drawer-logo {
    display: flex;
    align-items: center;
    max-width: 200px;
}

.cga-mobile-drawer-logo img {
    max-height: 44px;
    width: auto;
    display: block;
}

.cga-mobile-close {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    color: var(--cga-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

.cga-mobile-close:hover,
.cga-mobile-close:focus-visible {
    background: var(--cga-bg-soft);
    color: var(--cga-brand);
    outline: none;
}

.cga-mobile-close svg {
    width: 22px;
    height: 22px;
}

/* Nav area */
.cga-mobile-drawer-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.cga-mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cga-mobile-item {
    border-bottom: 1px solid var(--cga-border);
    position: relative;
}

.cga-mobile-item:last-child {
    border-bottom: none;
}

/* Top-level link / parent button */
.cga-mobile-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 22px;
    color: var(--cga-text);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1.3;
    min-height: 52px;
    font-family: inherit;
    border-left: 4px solid transparent;
}

.cga-mobile-link:hover,
.cga-mobile-link:focus-visible {
    background: var(--cga-bg-soft);
    color: var(--cga-brand);
    outline: none;
}

.cga-mobile-link.cga-active {
    color: var(--cga-brand);
    border-left-color: var(--cga-brand);
    background: rgba(22, 93, 251, 0.06);
}

.cga-mobile-link-text {
    flex: 1;
}

/* Chevron */
.cga-mobile-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: var(--cga-text-muted);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
    flex-shrink: 0;
    margin-left: 12px;
}

.cga-mobile-chevron svg {
    width: 18px;
    height: 18px;
}

.cga-mobile-item.cga-expanded .cga-mobile-chevron {
    transform: rotate(180deg);
    color: var(--cga-brand);
}

.cga-mobile-item.cga-expanded > .cga-mobile-parent {
    color: var(--cga-brand);
}

/* Submenu (accordion) */
.cga-mobile-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--cga-bg-soft);
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.cga-mobile-submenu > li {
    border-top: 1px solid var(--cga-border);
}

.cga-mobile-sublink {
    display: block;
    padding: 14px 22px 14px 46px;
    color: var(--cga-text);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.35;
    border-left: 4px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.cga-mobile-sublink:hover,
.cga-mobile-sublink:focus-visible {
    background: #eef2ff;
    color: var(--cga-brand);
    outline: none;
}

.cga-mobile-sublink.cga-active {
    color: var(--cga-brand);
    border-left-color: var(--cga-brand);
    font-weight: 600;
    background: #eef2ff;
}

/* Footer (CTA + contact + social) */
.cga-mobile-drawer-footer {
    flex-shrink: 0;
    padding: 16px 20px 22px;
    border-top: 1px solid var(--cga-border);
    background: #ffffff;
}

.cga-mobile-cta {
    display: block;
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--cga-brand) 0%, var(--cga-brand-dark) 100%);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(22, 93, 251, 0.28);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    letter-spacing: 0.01em;
}

.cga-mobile-cta:hover,
.cga-mobile-cta:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(22, 93, 251, 0.35);
    color: #ffffff;
    outline: none;
}

.cga-mobile-cta:active {
    transform: translateY(0);
}

.cga-mobile-contact {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cga-mobile-contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--cga-text-muted);
    font-size: 14px;
    text-decoration: none;
    padding: 6px 2px;
    line-height: 1.3;
    word-break: break-all;
}

.cga-mobile-contact-item:hover,
.cga-mobile-contact-item:focus-visible {
    color: var(--cga-brand);
    outline: none;
}

.cga-mobile-contact-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.cga-mobile-contact-icon svg {
    width: 16px;
    height: 16px;
}

.cga-mobile-social {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--cga-border);
}

.cga-mobile-social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cga-bg-soft);
    color: var(--cga-text);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.cga-mobile-social-link:hover,
.cga-mobile-social-link:focus-visible {
    background: var(--cga-brand);
    color: #ffffff;
    transform: translateY(-1px);
    outline: none;
}

.cga-mobile-social-link svg {
    width: 18px;
    height: 18px;
}

/* Reset global min-height rule for drawer internals (override mobile.css line ~236) */
.cga-mobile-drawer a,
.cga-mobile-drawer button,
.cga-mobile-drawer .cga-mobile-contact-item {
    min-width: 0 !important;
    justify-content: flex-start !important;
}

.cga-mobile-drawer .cga-mobile-close,
.cga-mobile-drawer .cga-mobile-cta,
.cga-mobile-drawer .cga-mobile-social-link {
    justify-content: center !important;
}

.cga-mobile-drawer .cga-mobile-link,
.cga-mobile-drawer .cga-mobile-sublink {
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
}

.cga-mobile-drawer .cga-mobile-sublink {
    display: block !important;
}

