/*
 * GNB (Global Navigation Bar) styles
 * Extracted from host app to engine for reuse across host apps.
 */

nav {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    font-size: var(--text-1);
    gap: var(--space-1);
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-3);
    background: var(--color-nav-bg);
    color: var(--color-nav-text);
    border-bottom: 1px solid var(--color-border);
    width: 100%;
    box-sizing: border-box;
}

nav a,
nav button {
    min-width: 2em;
    line-height: 1.5;
    font-size: var(--text-1);
    background: transparent;
    color: var(--color-nav-btn-text);
    text-decoration: none;
    padding: var(--space-1);
    border-radius: var(--radius-3);
    border: none;
    transition: background 0.2s var(--ease-out-2), color 0.2s var(--ease-out-2);
}

nav a:hover,
nav button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

nav a:active,
nav button:active {
    background: color-mix(in srgb, var(--surface-hover) 80%, var(--text-primary) 5%);
}

nav #search {
    border-radius: var(--radius-3);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    margin-right: var(--space-1);
}

/* Progress filter button group */
.progress-filter-group {
    display: flex;
    gap: var(--space-1);
}

.progress-filter-btn {
    border-radius: var(--radius-3);
    border: none;
    padding: var(--space-1) var(--space-2);
}

.progress-filter-btn:first-child {
    border-radius: var(--radius-3);
}

.progress-filter-btn:last-child {
    border-radius: var(--radius-3);
}

.progress-filter-btn+.progress-filter-btn {
    border-left: none;
}

.progress-filter-btn.active {
    color: var(--text-primary);
    font-weight: var(--weight-5);
}

/*
 * Nav pills that toggle their selected surface in place
 * -----------------------------------------------------
 * The chat filter and the search trigger flip `.active` on a live page during
 * turbo-frame navigation, so their surface changes where it sits instead of
 * arriving already painted in a fresh document. Animating `background` there
 * re-rasterises the pill's rounded corners on every frame of the transition,
 * and mobile GPU rasterisers have been observed to mis-composite a corner arc
 * under that load: the bottom-left arc is replaced by its own chord and the
 * clipped sliver is drawn back on top, which reads as a folded corner.
 *
 * Put the surface on an overlay pseudo-element and cross-fade it with
 * `opacity`, which the compositor animates without repainting. The rounded
 * rect is rasterised once and only its alpha moves.
 *
 * `z-index: -1` keeps the overlay above the button's own background box and
 * below its text; that needs the button to be a stacking context, hence
 * `position: relative` + `z-index: 0`.
 */
.progress-filter-btn,
.search-popup-trigger {
    position: relative;
    z-index: 0;
    transition: color 0.2s var(--ease-out-2);
}

.progress-filter-btn::before,
.search-popup-trigger::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--surface-hover);
    opacity: 0;
    transition: opacity 0.2s var(--ease-out-2);
    pointer-events: none;
    will-change: opacity;
}

.progress-filter-btn:hover::before,
.progress-filter-btn:active::before,
.progress-filter-btn.active::before,
.search-popup-trigger:hover::before,
.search-popup-trigger:active::before,
.search-popup-trigger.active::before {
    opacity: 1;
}

/*
 * The button itself has to stay transparent in every state, otherwise the
 * `nav a/button` surfaces above would stack on top of the overlay.
 */
.progress-filter-btn,
.progress-filter-btn:hover,
.progress-filter-btn:active,
.progress-filter-btn.active,
.search-popup-trigger,
.search-popup-trigger:hover,
.search-popup-trigger:active,
.search-popup-trigger.active {
    background: transparent;
}

/* ChatGPT-style popup menu overrides */
nav .popup-menu-wrapper .popup-menu {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-3);
    box-shadow: var(--shadow-2);
    padding: var(--space-1);
    background: var(--surface-section);
}

nav .popup-menu-item button,
nav .popup-menu-item a {
    border-radius: var(--radius-2);
    padding: var(--space-1) var(--space-2);
    transition: background 0.15s var(--ease-out-2);
}

nav .popup-menu-item button:hover,
nav .popup-menu-item a:hover {
    background: var(--surface-hover);
}

#inbox-menu-btn {
    position: relative;
}

.badge {
    background: var(--color-badge-bg, red);
    color: var(--color-badge-text, white);
    border-radius: var(--radius-round);
    font-size: var(--text-00);
    font-weight: var(--weight-6);
    line-height: 1;
    margin-left: var(--space-1);
    display: none;
    min-width: var(--space-3);
    height: var(--space-3);
    padding: 0 0.3em;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    vertical-align: middle;
}

/* Responsive visibility helpers */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

@media (max-width: 768px) {
    nav {
        padding: var(--space-3) var(--space-2);
        gap: var(--space-1);
    }

    nav #search {
        width: 8em;
    }

    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: inline-block !important;
    }
}
