/* xemenu1 (30-11-2026, Mortimer: «mejorar los menus y el menu hamburguesa … no está tan optimizada como la de bascdao.com»).
   A layer over header.css (loaded after it, from components/header.html): the ☰ of the bar on phones, a drawer that folds
   by group with the member's card on top, and an icon in front of every destination. header.js is not changed: it still
   opens and closes the drawer (.mobile-active) and marks .active / .parent-active; xemenu.js only folds the groups. */

.xm-open, .xm-top, .xm-chev, .xm-backdrop, .xm-ext { display: none; }
.xm-ico { display: inline-block; flex: none; width: 1.5em; text-align: center; font-style: normal; font-weight: 400; line-height: 1; }
.xm-dot { display: inline-block; flex: none; width: 9px; height: 9px; margin: 0 0.45em 0 0.2em; border-radius: 50%; background: var(--xm-tribe, #f97316);
    box-shadow: 0 0 8px var(--xm-tribe, #f97316); vertical-align: middle; }
.tribe-aether { --xm-tribe: #9370db; }
.tribe-air { --xm-tribe: #87ceeb; }
.tribe-earth { --xm-tribe: #3cb043; }
.tribe-fire { --xm-tribe: #ff6347; }
.tribe-water { --xm-tribe: #4f7dff; }

/* ---------- desktop: the bar as before, the strip under it tidier ---------- */
@media (min-width: 992px) {
    .mobile-edge-tab { display: none !important; }            /* the whole menu is already in the bar */
    .nav-right .xm-sub, .nav-right .nav-link .xm-ico--g { display: none; }
    .desktop-submenu:not(.is-profile) { padding: 8px 12px; width: max-content; max-width: calc(100vw - 48px); border-radius: 14px;
        translate: var(--xm-shift, 0px) 0; }
    .desktop-submenu:not(.is-profile) .submenu-group { gap: 4px; flex-wrap: nowrap; }
    .desktop-submenu:not(.is-profile) .submenu-item,
    .desktop-submenu:not(.is-profile) .submenu-item.tribe-menu-item { display: inline-flex; align-items: center; gap: 2px; padding: 7px 12px !important;
        border-radius: 999px !important; font-size: 0.88rem; font-weight: 600; color: rgba(255, 255, 255, 0.82) !important;
        transition: background 0.18s, color 0.18s; }
    .desktop-submenu:not(.is-profile) .submenu-item:hover,
    .desktop-submenu:not(.is-profile) .submenu-item:focus-visible { background: rgba(255, 255, 255, 0.09) !important; color: #fff !important; }
    .desktop-submenu:not(.is-profile) .submenu-item.active { background: rgba(249, 115, 22, 0.16) !important; color: #fb923c !important; }
    .desktop-submenu:not(.is-profile) .submenu-item.tribe-menu-item:hover,
    .desktop-submenu:not(.is-profile) .submenu-item.tribe-menu-item.active { color: var(--xm-tribe) !important;
        background: color-mix(in srgb, var(--xm-tribe) 16%, transparent) !important; }
    .desktop-submenu .xm-ico { font-size: 0.95em; margin-right: 3px; }
}

/* ---------- phones and tablets: bar + drawer ---------- */
@media (max-width: 991px) {
    /* the bar: logo, name, 🔔 and ☰ always fit */
    .header-nav .nav-container { gap: 8px; }
    .header-nav .nav-brand { font-size: clamp(1rem, 4.6vw, 1.5rem); gap: 0.55rem; letter-spacing: 0.01em; }
    .header-nav .nav-brand img { height: clamp(46px, 13vw, 62px); }
    .header-nav .nav-bell-wrap { order: 2; margin-left: 0; }
    .xm-open { order: 3; display: inline-flex; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
        width: 42px; height: 42px; padding: 0; border-radius: 50%; cursor: pointer; background: rgba(15, 23, 42, 0.55);
        border: 1px solid rgba(249, 115, 22, 0.45); -webkit-tap-highlight-color: transparent; transition: background 0.18s, border-color 0.18s; }
    .xm-open span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #f97316; }
    .xm-open:active { background: rgba(249, 115, 22, 0.2); }
    .xm-open:focus-visible, .xm-close:focus-visible, .nav-right .nav-link:focus-visible { outline: 2px solid #fb923c; outline-offset: 2px; }

    /* the floating ≡ only once the bar has scrolled away, never over the open drawer */
    body:not(.xm-scrolled) .mobile-edge-tab, body.xm-is-open .mobile-edge-tab { display: none !important; }

    .xm-backdrop { position: fixed; inset: 0; z-index: 1049; background: rgba(3, 6, 18, 0.62); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
        opacity: 0; transition: opacity 0.3s ease; }
    body.xm-is-open .xm-backdrop { display: block; opacity: 1; animation: xm-fade 0.3s ease; }

    .header-nav .nav-right { width: min(88vw, 348px); padding: 0 0 28px; gap: 0 !important; align-items: stretch !important;
        background: linear-gradient(180deg, #0f1836 0%, #070b1c 55%, #04060f 100%); border-left: 1px solid rgba(0, 221, 235, 0.22); }
    .header-nav .nav-right.mobile-active { box-shadow: -24px 0 70px rgba(0, 0, 0, 0.7); }

    .xm-top { order: -3; display: flex; align-items: center; justify-content: space-between; flex: none; position: sticky; top: 0; z-index: 3;
        padding: 14px 14px 10px 20px; background: #0f1836; box-shadow: 0 10px 14px -8px rgba(4, 6, 15, 0.9); }
    .xm-top-title { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(255, 255, 255, 0.5); }
    .xm-close { width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1rem; line-height: 1; color: rgba(255, 255, 255, 0.85);
        background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); -webkit-tap-highlight-color: transparent; }
    .xm-close:active { background: rgba(255, 255, 255, 0.14); }

    /* every line of the drawer: no jump to the side on touch (header.css moved the padding on :hover) */
    .header-nav .nav-right .nav-link { width: auto !important; flex: none; gap: 10px; margin: 2px 10px; padding: 12px 12px !important; border-radius: 12px;
        border-bottom: 0 !important; font-size: 1rem !important; text-decoration: none; -webkit-tap-highlight-color: transparent;
        transition: background 0.18s, color 0.18s; }
    .header-nav .nav-right .nav-link::after { content: none !important; }

    /* a group: its title folds and unfolds its lines */
    .header-nav .nav-right .nav-link[data-xm-group] { font-weight: 700; color: #fff !important; background: transparent !important; cursor: pointer; }
    .header-nav .nav-right .nav-link[data-xm-group].parent-active .xm-gtxt { color: #fb923c; }
    .header-nav .nav-right .nav-link[data-xm-group][aria-expanded="true"] { background: rgba(255, 255, 255, 0.045) !important; }
    .xm-ico--g { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; font-size: 1.05rem;
        background: rgba(249, 115, 22, 0.12); border: 1px solid rgba(249, 115, 22, 0.22); }
    .xm-chev { display: block; flex: none; width: 9px; height: 9px; margin: -4px 6px 0 auto; border-right: 2px solid rgba(255, 255, 255, 0.55);
        border-bottom: 2px solid rgba(255, 255, 255, 0.55); transform: rotate(45deg); transition: transform 0.22s ease, margin 0.22s ease; }
    [aria-expanded="true"] > .xm-chev { transform: rotate(-135deg); margin-top: 4px; }
    .header-nav .nav-right .nexus-status-light { position: static; flex: none; margin-left: 2px; }

    .xm-sub { display: none; flex: none; margin: 0 0 6px; padding: 0 0 2px; }
    .xm-sub.is-open { display: block; animation: xm-drop 0.22s ease; }
    .header-nav .nav-right .xm-sub .mobile-sub-item { margin: 1px 10px 1px 22px; padding: 10px 12px !important; font-size: 0.95rem !important; font-weight: 600;
        color: rgba(255, 255, 255, 0.74) !important; background: transparent !important; }
    .header-nav .nav-right .xm-sub .mobile-sub-item:hover { color: #fff !important; background: rgba(255, 255, 255, 0.06) !important; }
    .header-nav .nav-right .xm-sub .mobile-sub-item.active { color: #fb923c !important; background: rgba(249, 115, 22, 0.14) !important;
        box-shadow: inset 3px 0 0 #f97316; }
    .header-nav .nav-right .xm-sub .mobile-sub-item.tribe-menu-item:hover,
    .header-nav .nav-right .xm-sub .mobile-sub-item.tribe-menu-item.active { color: var(--xm-tribe) !important; }
    .header-nav .nav-right .xm-sub .mobile-sub-item.tribe-menu-item.active { background: color-mix(in srgb, var(--xm-tribe) 15%, transparent) !important;
        box-shadow: inset 3px 0 0 var(--xm-tribe); }
    .xm-sub .xm-dot { margin: 0 0.5em 0 0.5em; }
    .xm-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .xm-ext { display: inline; margin-left: auto; font-size: 0.8rem; color: rgba(255, 255, 255, 0.35); }
    .xm-row { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
    .header-nav .nav-right .mobile-notifications-trigger { width: calc(100% - 32px) !important; }

    /* the member's card on top (their group folds under it); a visitor gets the Login button there */
    .header-nav .nav-right .nav-link-profile { order: -2; margin: 10px 12px 6px; padding: 12px 12px !important; gap: 12px; border-radius: 16px;
        background: linear-gradient(135deg, rgba(249, 115, 22, 0.14), rgba(0, 221, 235, 0.07)) !important; border: 1px solid rgba(255, 255, 255, 0.1); }
    .header-nav .nav-right .nav-link-profile .nav-profile-avatar-wrap { width: 42px; height: 42px; box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.6); }
    .header-nav .nav-right .nav-link-profile .nav-link-label { font-size: 1rem; line-height: 1.2; gap: 2px; overflow: hidden; }
    .header-nav .nav-right .nav-link-profile .nav-link-label > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .header-nav .nav-right .nav-link-profile .nav-link-sublabel { font-size: 0.74rem; max-width: 100%; }
    .xm-sub[data-xm-sub="profile"] { order: -1; }
    .xm-sub[data-xm-sub="profile"].is-open { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
    .header-nav .nav-right .xm-login { order: -2; justify-content: center; margin: 4px 14px 10px; font-weight: 800; color: #1a0f05 !important;
        background: linear-gradient(135deg, #f97316, #ffb155) !important; box-shadow: 0 8px 22px rgba(249, 115, 22, 0.3); }
}

@keyframes xm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes xm-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .xm-backdrop, .xm-sub.is-open, .xm-chev, .header-nav .nav-right .nav-link { animation: none !important; transition: none !important; }
}
