/*
 * MissionPilot — Global Header / Navigation
 * --------------------------------------------------------------------------
 * SINGLE SOURCE OF TRUTH for header + nav + mega-menu styling.
 * Markup lives in components/header-universal.html (injected by
 * header-loader.js); colors come from prism-tokens.css (PRISM root).
 *
 * Guiding principle: change the header here once and every page follows.
 * This file is linked AFTER each page's inline <style> so it always wins
 * over any stale per-page header rules.
 */

/* The sticky bar itself is transparent — only the navy pill inside it is visible.
   pointer-events:none lets clicks pass through the transparent gutters to the
   page; the pill re-enables them. */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: transparent;
    border: none;            /* clear any border-bottom inherited from page/main.css */
    box-shadow: none;
    padding: 16px 24px 0;
    pointer-events: none;
}

/* The floating navy "pill" — a rounded square that holds the logo + nav */
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;         /* the section bar wraps onto a 2nd row inside the pill */
    row-gap: 0;
    background: var(--prism-navy);
    border: 2px solid var(--prism-canvas);   /* cream ring: invisible on the page,
                                                separates the bar from any box that
                                                scrolls under the fixed header */
    border-radius: 16px;
    box-shadow: none;   /* no shadow — it darkened the page around the pill, making
                           the cream border read as a bright ring */
    pointer-events: auto;
    position: relative;
}

.logo {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: #FFFFFF;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-tagline {
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.72);   /* ivory-ish on navy */
    border-left: 1px solid rgba(255, 255, 255, 0.22);
    padding-left: 12px;
}

nav {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
    z-index: 2;              /* keep the primary nav above the section bar so it always receives hover */
}

/* ---- Section sub-nav: a lighter bar NESTED INSIDE the navy pill on /pta/,
   /hoa/. The navy pill grows to hold it; the lighter bar visually connects up
   to its parent primary item (same colour, merged). The primary row (logo,
   tagline, nav) never changes between pages. Lives only in this file. ---- */

/* shared lighter tone for the inner bar + its connected parent item */
:root { --section-fill: color-mix(in srgb, var(--prism-navy) 80%, #FFFFFF); }

/* Full-width second row. The pill is positioned by the loader: its left edge
   sits under the parent item and it grows right, shifting left only if it would
   overflow. justify-content is the fallback before the loader measures. */
.section-inner {
    flex-basis: 100%;
    display: flex;
    justify-content: flex-start;
    margin-top: 8px;
    position: relative;
    z-index: 1;              /* below the primary nav (which is z-index 2) */
}

/* The lighter fill — hugs its content, but never narrower than min-width */
.section-pillbox {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-wrap: nowrap;          /* always one line — never wrap */
    white-space: nowrap;
    width: max-content;         /* hug content so it stays connected to the parent */
    background: var(--section-fill);
    border-radius: 12px;
    padding: 9px 16px;          /* a little larger both ways */
}
.section-pillbox .section-link { white-space: nowrap; }

/* The parent primary item the section drops out of — same fill, squared bottom,
   bled downward so it merges into the inner bar below it. */
.nav-link.nav-parent-active {
    background: var(--section-fill);
    color: #FFFFFF;
    border-radius: 10px 10px 0 0;
    margin-bottom: -8px;         /* reach down to the inner bar (which is 8px below) */
    padding-bottom: 18px;
    box-shadow: none;
    position: relative;
}

/* Concave fillets that round the inside 90° corners where the tab meets the bar */
.nav-link.nav-parent-active::before,
.nav-link.nav-parent-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 8px;
    background: var(--section-fill);
}
.nav-link.nav-parent-active::before {
    left: -8px;
    -webkit-mask: radial-gradient(circle at top left, transparent 8px, #000 8.5px);
            mask: radial-gradient(circle at top left, transparent 8px, #000 8.5px);
}
.nav-link.nav-parent-active::after {
    right: -8px;
    -webkit-mask: radial-gradient(circle at top right, transparent 8px, #000 8.5px);
            mask: radial-gradient(circle at top right, transparent 8px, #000 8.5px);
}

.section-label {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--prism-navy);          /* inverted: blue text */
    background: #FFFFFF;               /* on white */
    border: none;
    border-radius: 9999px;
    padding: 3px 8px;
    margin-right: 2px;
    white-space: nowrap;
}

.section-inner .section-link {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;           /* ~25% smaller than the primary nav */
    padding: 5px 11px;
    border-radius: 9999px;
}

/* Inverted hover: light fill + navy text (opposite of the primary's light-on-navy) */
.section-inner .section-link:hover {
    background: #FFFFFF;
    color: var(--prism-navy);
    box-shadow: none;
}

/* Selected = outline, matching the primary title bar's active style */
.section-inner .section-link.active {
    color: #FFFFFF;
    background: transparent;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

/* Join Beta takes the same shape/look as the sub-menu hover (white pill, navy text).
   Selector is extra-specific to beat `header .btn.btn-primary`. */
.section-inner .section-cta.btn-primary {
    background: #FFFFFF;
    color: var(--prism-navy);
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 5px 12px;
    border: none;
    box-shadow: none;
    margin-left: 2px;
}
.section-inner .section-cta.btn-primary:hover {
    background: #FFFFFF;
    color: var(--prism-navy);
}

.nav-item {
    position: relative;
}

.nav-link {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-weight: 500;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
}

.nav-link.active {
    color: #FFFFFF;
    /* outlined pill matching the hover shape — inset shadow follows the radius
       and adds no layout shift */
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

/* Invisible hover bridge between a nav item and its mega menu */
.nav-item::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    display: none;
}

.nav-item:hover::after {
    display: block;
}

/* Mega Menu */
.mega-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--border-hairline);
    border-radius: 16px;
    padding: 32px;
    min-width: 500px;
    box-shadow: var(--shadow-popover);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    pointer-events: none;
    z-index: 100;            /* dropdowns stay above the nav + section bar */
}

.nav-item:hover .mega-menu,
.mega-menu:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* Single-column mega menus (e.g. Mac Apps) read better narrower */
.mega-menu.mega-menu--single {
    min-width: 320px;
}
.mega-menu.mega-menu--single .mega-menu-grid {
    grid-template-columns: 1fr;
}

.mega-menu-section h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
    font-weight: 700;
}

.mega-menu-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mega-menu-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.mega-menu-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mega-menu-icon {
    width: 40px;
    height: 40px;
    background: var(--prism-navy);
    color: var(--fg-on-dark);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mega-menu-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--fg-on-dark);
}

/* App-logo variant: the image fills the dark chip (logo is on black per brand) */
.mega-menu-icon--logo {
    background: #000000;
    padding: 0;
    overflow: hidden;
}
.mega-menu-icon--logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

.mega-menu-content {
    flex: 1;
}

.mega-menu-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.mega-menu-desc {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.mega-menu-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 8px;
}

/* Beta = PRISM success tint; "soon"/future = muted */
.badge-beta {
    background: var(--prism-success-tint);
    color: var(--prism-success);
}

.badge-soon {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

/* CTA buttons living inside the navy pill (e.g. PTA "Join Beta") need contrast
   against navy — flip them to the tangerine accent. Overrides main.css/pta.css. */
header .btn-primary,
header .btn.btn-primary {
    background: var(--prism-tangerine);
    color: #FFFFFF;
    border: none;
}
header .btn-primary:hover,
header .btn.btn-primary:hover {
    background: var(--prism-tangerine-deep);
}

/* Right-most primary dropdown anchors to its right edge so it never runs off
   the viewport (it would otherwise center under the trigger and overflow). */
nav > .nav-item:last-child .mega-menu {
    left: auto;
    right: 0;
    transform: none;
}

/* Responsive */
@media (max-width: 1240px) {
    /* drop the tagline first to make room for the section nav */
    .logo-tagline { display: none; }
}

@media (max-width: 1024px) {
    .mega-menu {
        left: 0;
        transform: none;
    }
}

@media (max-width: 768px) {
    .logo-tagline { display: none; }
    nav { display: none; }   /* desktop nav hidden; mobile-nav.css takes over */
}
