/* ============================================================
   FF Mega Menu — Frontend Styles

   Color theming uses CSS custom properties. Defaults are the
   var() fallback values. Override them by saving colors in the
   FF Mega Menu → Colors admin settings, which outputs a
   <style id="ff-mega-colors"> block in <head>.

   Variables:
     --ffm-primary        Main brand color (borders, links, hovers)
     --ffm-primary-dark   Darker shade (headings, deep hover text)
     --ffm-primary-light  Light tint (hover backgrounds)
     --ffm-accent         CTA / button fill color
     --ffm-panel-bg       Desktop panel background
     --ffm-mobile-bg      Mobile accordion background
   ============================================================ */

/* ── Trigger item ──────────────────────────────────────────── */

.ff-mega-trigger {
    position: relative !important;
}

/* Hide any accidental WordPress sub-menu on a trigger item */
.ff-mega-trigger > .sub-menu {
    display: none !important;
}

/* Arrow indicator on the trigger link */
.ff-mega-trigger > a::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    margin-left: 6px;
    vertical-align: middle;
    transition: transform 0.2s;
    opacity: 0.7;
}
.ff-mega-trigger.is-open > a::after {
    transform: rotate(180deg);
}

/* ── Panel shell ───────────────────────────────────────────── */

.ff-mega-panel {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    width: 100vw;
    background: var(--ffm-panel-bg, #ffffff);
    border-top: 3px solid var(--ffm-primary, #1a6b5e);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    /* top/width/left set by JS on load */
}

/* ── Desktop: CSS :hover handles show/hide ─────────────────────
   :hover propagates up the DOM tree even for position:fixed children,
   so the panel staying open while mousing over it is browser-native —
   no JS timers, no gap issues, no blink.
──────────────────────────────────────────────────────────────── */
@media (min-width: 1025px) {
    .ff-mega-trigger:hover > .ff-mega-panel,
    .ff-mega-trigger:focus-within > .ff-mega-panel {
        display: block;
    }

    /* ── Gap bridge ──────────────────────────────────────────────
       Invisible extension below the <li> — only as wide as the
       trigger item, not the full nav bar. Keeps :hover alive as
       the cursor moves from the nav item down into the panel.
    ──────────────────────────────────────────────────────────────── */
    .ff-mega-trigger::after {
        content: '';
        position: absolute;
        bottom: -50px;
        left: 0;
        right: 0;
        height: 50px;
        display: block;
    }
}

/* ── Mobile: JS class handles show/hide ───────────────────────── */
.ff-mega-trigger.is-open > .ff-mega-panel {
    display: block;
}


/* ── Inner layout ──────────────────────────────────────────── */

.ff-mega-panel-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 40px 36px;
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.ff-mega-columns {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ff-mega-col {
    flex: 1;
    min-width: 0;
}

/* ── Column title ──────────────────────────────────────────── */

.ff-mega-col-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.10em;
    color: #9ca3af;
    margin: 0 0 10px;
    padding: 0 12px 10px;
    border-bottom: 1px solid #f0f0f0;
}

/* ── Card item ─────────────────────────────────────────────── */

.ff-mega-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ff-mega-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none !important;
    color: inherit !important;
    background: var(--ffm-card-bg, #f0fdf9);
    border: 1px solid var(--ffm-card-border, #d1fae5);
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    cursor: pointer;
}

.ff-mega-card:hover,
.ff-mega-card:focus {
    background: var(--ffm-primary-light, #d1fae5);
    border-color: var(--ffm-primary, #1a6b5e);
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    transform: translateX(2px);
    outline: none;
}

.ff-mega-card:focus-visible {
    outline: 2px solid var(--ffm-primary, #1a6b5e);
    outline-offset: 2px;
}

.ff-mega-card-icon {
    font-size: 22px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
    width: 28px;
    text-align: center;
}

.ff-mega-card-body {
    flex: 1;
    min-width: 0;
}

.ff-mega-card-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    margin-bottom: 2px;
}

.ff-mega-card-desc {
    display: block;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.ff-mega-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    color: #ffffff;
    white-space: nowrap;
    align-self: flex-start;
    margin-top: 3px;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

/* ── Button item ───────────────────────────────────────────── */

.ff-mega-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none !important;
    transition: opacity 0.15s, transform 0.1s;
    margin: 6px 12px;
    cursor: pointer;
}

.ff-mega-button:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.ff-mega-button--primary {
    background: var(--ffm-accent, #16a34a);
    color: #ffffff !important;
}

.ff-mega-button--secondary {
    background: var(--ffm-primary-light, #ecfdf5);
    color: var(--ffm-primary-dark, #065f46) !important;
    border: 1px solid var(--ffm-primary-light, #6ee7b7);
}

.ff-mega-button--outline {
    background: transparent;
    color: var(--ffm-primary, #1a6b5e) !important;
    border: 2px solid var(--ffm-primary, #1a6b5e);
}

/* ── HTML block item ───────────────────────────────────────── */

.ff-mega-html-item {
    padding: 4px 12px;
}

/* ── Divider ───────────────────────────────────────────────── */

.ff-mega-divider {
    border: none;
    border-top: 1px solid #f0f0f0;
    margin: 8px 12px;
}

/* ── WP Menu item ──────────────────────────────────────────── */

.ff-mega-wp-menu {
    padding: 4px 0;
}

.ff-mega-wp-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ff-mega-wp-menu-list li {
    margin: 0;
    padding: 0;
}

.ff-mega-wp-menu-list a {
    display: block;
    padding: 7px 12px;
    color: var(--ffm-primary, #1a6b5e) !important;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none !important;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}

.ff-mega-wp-menu-list a:hover {
    background: var(--ffm-primary-light, #ecfdf5);
    color: var(--ffm-primary-dark, #065f46) !important;
}

/* Sub-menus (depth 2) */
.ff-mega-wp-menu-list .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0 0 4px 16px;
}

.ff-mega-wp-menu-list .sub-menu a {
    font-size: 12.5px;
    font-weight: 400;
    color: #4b5563 !important;
    padding: 5px 10px;
}

.ff-mega-wp-menu-list .sub-menu a:hover {
    background: var(--ffm-primary-light, #f0fdf4);
    color: var(--ffm-primary, #1a6b5e) !important;
}

/* ── Recent Posts item ─────────────────────────────────────── */

.ff-mega-posts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
}

.ff-mega-posts--grid {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.ff-mega-post-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none !important;
    color: inherit;
    transition: background 0.15s;
}

.ff-mega-posts--grid .ff-mega-post-card {
    flex-direction: column;
    width: calc(50% - 4px);
    padding: 8px;
    gap: 6px;
}

.ff-mega-post-card:hover {
    background: var(--ffm-primary-light, #ecfdf5);
}

.ff-mega-post-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 42px;
    border-radius: 5px;
    overflow: hidden;
}

.ff-mega-posts--grid .ff-mega-post-thumb {
    width: 100%;
    height: 80px;
}

.ff-mega-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ff-mega-post-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.ff-mega-post-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ffm-primary-dark, #0d4a40);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ff-mega-post-excerpt {
    font-size: 11.5px;
    color: #6b7280;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Featured sidebar ──────────────────────────────────────── */

.ff-mega-featured {
    width: 280px;
    flex-shrink: 0;
    padding-left: 28px;
    border-left: 1px solid #e5e7eb;
}


/* ============================================================
   Mobile — panel becomes an inline accordion
   ============================================================ */

@media (max-width: 1024px) {

    .ff-mega-trigger {
        position: relative !important;
    }

    .ff-mega-panel {
        position: static !important;
        display: none;
        width: 100% !important;
        box-shadow: none !important;
        border-top: none !important;
        border-left: 3px solid var(--ffm-primary, #1a6b5e);
        background: var(--ffm-mobile-bg, #f8fafc) !important;
        margin: 4px 0 4px 16px;
        border-radius: 0 8px 8px 0;
    }

    .ff-mega-trigger.is-open > .ff-mega-panel {
        display: block;
    }

    .ff-mega-panel-inner {
        flex-direction: column;
        padding: 16px 16px 20px;
        gap: 16px;
        max-width: 100%;
    }

    .ff-mega-columns {
        flex-direction: column;
        gap: 12px;
    }

    .ff-mega-col-title {
        font-size: 10px;
        padding: 0 0 8px;
    }

    .ff-mega-featured {
        width: 100%;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #e5e7eb;
        padding-top: 16px;
    }

    .ff-mega-card {
        padding: 8px 6px;
    }

    .ff-mega-card-icon {
        font-size: 18px;
    }

    .ff-mega-backdrop {
        display: none !important;
    }

    /* Hide the CSS arrow — the JS toggle button takes its place */
    .ff-mega-trigger > a::after {
        display: none;
    }

    /* Make room for the absolutely-positioned toggle button */
    .ff-mega-trigger > a {
        padding-right: 50px !important;
    }

    /* ── Mobile toggle button ──────────────────────────────────────
       Absolute-positioned flush right, matching Kadence's pattern
       for its own sub-menu toggle buttons.
    ──────────────────────────────────────────────────────────────── */
    .ff-mega-mobile-toggle {
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        height: 50px !important;
        width: 50px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
        border: none !important;
        border-left: 1px solid rgba(255,255,255,0.1) !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        cursor: pointer;
        color: inherit !important;
        line-height: 1 !important;
        font-size: inherit !important;
        text-transform: none !important;
        letter-spacing: 0 !important;
    }

    .ff-mega-mobile-toggle:hover,
    .ff-mega-mobile-toggle:focus {
        background: rgba(255,255,255,0.08) !important;
        outline: none !important;
        box-shadow: none !important;
    }

    .ff-mega-toggle-icon {
        display: block;
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;
        border-top: 6px solid currentColor;
        transition: transform 0.2s;
        pointer-events: none;
    }

    .ff-mega-trigger.is-open .ff-mega-toggle-icon {
        transform: rotate(180deg);
    }

    /* Panel takes full width below the link+button row */
    .ff-mega-panel {
        flex: 0 0 100%;
    }
}

/* Desktop: keep the toggle button out of the way */
@media (min-width: 1025px) {
    .ff-mega-mobile-toggle {
        display: none;
    }
}
