/* ==========================================================================
   BBT Mega-Menu — portable, theme-agnostic styles.
   All colours/spacing are CSS variables; override them per theme by redefining
   `.bbtm-panel { --bbtm-* }` (or `.bbtm-nav { --bbtm-* }`). Class names are
   namespaced `bbtm-*` so they never collide with a host theme.
   ========================================================================== */

.bbtm-nav {
    /* Palette (neutral defaults — override in your theme) */
    --bbtm-bg:        #ffffff;
    --bbtm-border:    #e6ecec;
    --bbtm-heading:   #1a2a2e;
    --bbtm-text:      #6b7c80;
    --bbtm-link:      #1a2a2e;
    --bbtm-accent:    #177065;
    --bbtm-accent-soft: rgba(23, 112, 101, .08);
    --bbtm-card-bg:   #f4f7f7;
    --bbtm-cta-bg:    #eb5426;
    --bbtm-cta-text:  #ffffff;
    --bbtm-badge-bg:  #eb5426;
    --bbtm-badge-text:#ffffff;

    /* Shape & motion */
    --bbtm-radius:    8px;
    --bbtm-shadow:    0 10px 30px rgba(0, 0, 0, .08);
    --bbtm-gap:       28px;
    --bbtm-panel-max: 1160px;   /* full-width panel cap */
    --bbtm-panel-min: 560px;    /* contained panel min width */
    --bbtm-speed:     .25s;
    --bbtm-z:         999;
}

/* Zero-specificity base layout so it never overrides a theme that styles the bar. */
:where(.bbtm-nav) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ===========================
   Top-level items
   =========================== */
.bbtm-nav > .bbtm-parent {
    position: relative;
}
.bbtm-nav > .bbtm-parent--full {
    position: static; /* lets a full-width panel center on the page */
}
.bbtm-nav > li > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--bbtm-link);
}

/* Caret — a small downward triangle inside the link (shows when item has children) */
.bbtm-caret {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 7px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform var(--bbtm-speed);
    vertical-align: middle;
    position: relative;
    top: -1px;
}
/* Flip the triangle when its menu is open */
.bbtm-open > .bbtm-toggle .bbtm-caret,
.bbtm-open > .bbtm-submenu__link .bbtm-caret {
    transform: rotate(180deg);
}

/* ===========================
   Shared reveal (panels + dropdowns) — CLICK to open (.bbtm-open)
   =========================== */
.bbtm-panel,
.bbtm-submenu {
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--bbtm-speed) ease, transform var(--bbtm-speed) ease, visibility var(--bbtm-speed);
    z-index: var(--bbtm-z);
}
.bbtm-parent.bbtm-open > .bbtm-panel,
.bbtm-has-dropdown.bbtm-open > .bbtm-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ===========================
   Mega panel
   =========================== */
.bbtm-panel {
    position: absolute;
    top: 100%;
    background: var(--bbtm-bg);
    border: 1px solid var(--bbtm-border);
    border-top: 3px solid var(--bbtm-accent);
    border-radius: 0 0 var(--bbtm-radius) var(--bbtm-radius);
    box-shadow: var(--bbtm-shadow);
    padding: 32px 36px;
}
.bbtm-panel--contained {
    left: 0;
    min-width: var(--bbtm-panel-min);
    max-width: calc(100vw - 40px);
}
.bbtm-panel--full {
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: min(var(--bbtm-panel-max), calc(100vw - 40px));
}
.bbtm-parent--full.bbtm-open > .bbtm-panel--full {
    transform: translateX(-50%) translateY(0);
}

.bbtm-grid {
    display: grid;
    grid-auto-columns: 1fr;
    grid-auto-flow: column;
    gap: var(--bbtm-gap);
}

/* Rows mode: columns wrap onto multiple rows instead of a single row.
   Track count comes from --bbtm-cols (default 3). A column whose colspan
   equals the track count fills its own full-width row. Enabled per-panel
   via the "bbtm-rows" CSS class on the top-level menu item. */
.bbtm-grid--rows {
    grid-auto-flow: row;
    grid-template-columns: repeat(var(--bbtm-cols, 3), 1fr);
    align-items: start;
}

/* ===========================
   Columns
   =========================== */
.bbtm-col {
    min-width: 0;
}
.bbtm-col__title {
    margin: 0 0 14px;
    padding-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--bbtm-accent);
    border-bottom: 1px solid var(--bbtm-border);
}
.bbtm-col__title a {
    color: inherit;
    text-decoration: none;
}

/* Links column */
.bbtm-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.bbtm-list__item + .bbtm-list__item {
    margin-top: 2px;
}

/* Nested links sub-groups (depth >= 2) */
.bbtm-list__heading {
    display: block;
    margin: 12px 0 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--bbtm-heading);
}
.bbtm-list__heading a {
    color: inherit;
    text-decoration: none;
}
.bbtm-list--nested {
    margin: 0 0 6px;
    padding-left: 10px;
    border-left: 2px solid var(--bbtm-border);
}
.bbtm-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 10px;
    margin: 0 -10px;
    border-radius: 6px;
    text-decoration: none;
    transition: background var(--bbtm-speed);
}
.bbtm-link:hover {
    background: var(--bbtm-accent-soft);
}
.bbtm-link__icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bbtm-card-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.bbtm-link__icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bbtm-link__text {
    display: flex;
    flex-direction: column;
}
.bbtm-link__title {
    color: var(--bbtm-heading);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}
.bbtm-link:hover .bbtm-link__title {
    color: var(--bbtm-accent);
}
.bbtm-link__desc {
    color: var(--bbtm-text);
    font-size: 12.5px;
    line-height: 1.45;
    margin-top: 2px;
}

/* Card column */
.bbtm-col--card {
    align-self: stretch;
}
.bbtm-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bbtm-card-bg);
    border-radius: var(--bbtm-radius);
    overflow: hidden;
    text-decoration: none;
    transition: transform var(--bbtm-speed), box-shadow var(--bbtm-speed);
}
.bbtm-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bbtm-shadow);
}
.bbtm-card__media img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: cover;
}
.bbtm-card__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px 18px;
}
.bbtm-card__title {
    color: var(--bbtm-heading);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
}
.bbtm-card__desc {
    color: var(--bbtm-text);
    font-size: 13px;
    line-height: 1.5;
}
.bbtm-card__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    margin-top: 6px;
    padding: 9px 16px;
    background: var(--bbtm-cta-bg);
    color: var(--bbtm-cta-text);
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.bbtm-card__cta .bbtm-arrow {
    transition: transform var(--bbtm-speed);
}
.bbtm-card:hover .bbtm-card__cta .bbtm-arrow,
.bbtm-card__cta:hover .bbtm-arrow {
    transform: translateX(3px);
}

/* Image column */
.bbtm-image-wrap {
    display: block;
    border-radius: var(--bbtm-radius);
    overflow: hidden;
}
.bbtm-image-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bbtm-image__caption {
    display: block;
    margin-top: 8px;
    color: var(--bbtm-text);
    font-size: 13px;
    line-height: 1.4;
}

/* A link-level item rendered as image/card sits flush in the list. */
.bbtm-list__item--image,
.bbtm-list__item--card {
    margin: 8px 0;
}
.bbtm-list__item--image .bbtm-image-wrap img {
    height: auto; /* keep aspect ratio inside a narrow column */
}

/* Rich column */
.bbtm-rich__text {
    margin: 0 0 14px;
    color: var(--bbtm-text);
    font-size: 14px;
    line-height: 1.6;
}

/* Badge */
.bbtm-badge {
    display: inline-block;
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    line-height: 1;
    padding: 3px 7px;
    border-radius: 20px;
    background: var(--bbtm-badge-bg);
    color: var(--bbtm-badge-text);
    vertical-align: middle;
}

/* ===========================
   Standard dropdowns (non-mega items)
   =========================== */
.bbtm-submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background: var(--bbtm-bg);
    border: 1px solid var(--bbtm-border);
    border-top: 3px solid var(--bbtm-accent);
    border-radius: 0 0 var(--bbtm-radius) var(--bbtm-radius);
    box-shadow: var(--bbtm-shadow);
}
.bbtm-submenu .bbtm-submenu--lvl1,
.bbtm-submenu .bbtm-submenu {
    top: 0;
    left: 100%;
}
.bbtm-submenu li {
    position: relative;
}
.bbtm-submenu__link {
    display: block;
    padding: 9px 20px;
    color: var(--bbtm-link);
    font-size: 14px;
    text-decoration: none;
    transition: background var(--bbtm-speed), color var(--bbtm-speed), padding var(--bbtm-speed);
}
.bbtm-submenu__link:hover {
    background: var(--bbtm-accent-soft);
    color: var(--bbtm-accent);
    padding-left: 26px;
}

/* ===========================
   Responsive: stacked accordion (< lg)
   =========================== */
@media (max-width: 991.98px) {
    :where(.bbtm-nav) {
        flex-direction: column;
        align-items: stretch;
    }
    .bbtm-nav > .bbtm-parent,
    .bbtm-nav > .bbtm-parent--full {
        position: static;
    }
    .bbtm-nav > li {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        border-bottom: 1px solid var(--bbtm-border);
    }
    /* Top-level toggle fills the row so the caret sits at the right edge. */
    .bbtm-nav > li > .bbtm-toggle {
        flex: 1 1 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .bbtm-caret {
        margin-left: auto;
    }

    /* Collapse panels & dropdowns into in-flow accordions */
    .bbtm-panel,
    .bbtm-submenu {
        position: static;
        flex: 0 0 100%;   /* break to its own full-width row under the toggle */
        width: 100%;
        max-width: none;
        min-width: 0;
        opacity: 1;
        visibility: hidden;
        transform: none;
        box-shadow: none;
        border: 0;
        border-radius: 0;
        padding: 0;
        height: 0;
        overflow: hidden;
    }
    .bbtm-panel--full {
        left: auto;
        transform: none;
    }
    .bbtm-parent.bbtm-open > .bbtm-panel,
    .bbtm-has-dropdown.bbtm-open > .bbtm-submenu {
        visibility: visible;
        height: auto;
        overflow: visible;
        padding: 8px 0 14px;
    }

    .bbtm-grid {
        grid-auto-flow: row;
        grid-template-columns: 1fr;
        gap: 18px;
    }
    .bbtm-col {
        grid-column: auto !important; /* ignore desktop colspan when stacked */
    }
    /* Opt-out: hide heavy blocks on mobile to keep the menu short */
    .bbtm-hide-mobile {
        display: none !important;
    }
}

/* ===========================
   Accessibility
   =========================== */
.bbtm-link:focus-visible,
.bbtm-submenu__link:focus-visible,
.bbtm-card:focus-visible,
.bbtm-nav > li > a:focus-visible {
    outline: 2px solid var(--bbtm-accent);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .bbtm-panel,
    .bbtm-submenu,
    .bbtm-card,
    .bbtm-arrow,
    .bbtm-caret__icon {
        transition: none !important;
    }
}
