/**
 * galatine-nav.css
 *
 * Shared dropdown menu styles for the Services and Products nav menus.
 * Designed to integrate with the existing .nav, .nav-links, .nav-link patterns
 * already defined inline in each page. Uses the same design tokens as the
 * rest of the site (--bg-card, --border, --accent, etc.).
 *
 * Behavior:
 *   - Desktop: dropdown opens on hover OR keyboard focus, closes on mouse leave
 *     or Escape key.
 *   - Mobile: dropdowns expand inline within the existing mobile menu via a
 *     "open" class toggled by JS (see galatine-nav.js).
 */

/* ---------- Dropdown container ---------- */
.nav-dropdown {
    position: relative;
}

/* Top-level trigger button keeps the same look and feel as other nav links */
.nav-dropdown-toggle {
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.3s;
    font-family: inherit;
}
.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible,
.nav-dropdown.open .nav-dropdown-toggle {
    color: var(--text-primary);
    outline: none;
}
.nav-dropdown-toggle .chev {
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
    opacity: 0.7;
}
.nav-dropdown:hover .nav-dropdown-toggle .chev,
.nav-dropdown.open .nav-dropdown-toggle .chev {
    transform: rotate(180deg);
    opacity: 1;
}

/* ---------- Dropdown panel (desktop) ---------- */
.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.85rem);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    min-width: 280px;
    background: rgba(7, 9, 14, 0.97);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    list-style: none;
    margin: 0;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1100;
}
/* Invisible bridge so cursor can travel from trigger to menu without closing it */
.nav-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -0.85rem;
    left: 0;
    right: 0;
    height: 0.85rem;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* ---------- Dropdown items ---------- */
.nav-dropdown-menu li { list-style: none; }
.nav-dropdown-menu a {
    display: block;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
}
.nav-dropdown-menu a:hover,
.nav-dropdown-menu a:focus-visible {
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
}
.nav-dropdown-menu .nd-title {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
    font-size: 0.92rem;
}
.nav-dropdown-menu .nd-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* Indented sub-items grouped under a parent link (e.g. Business Consulting) */
.nav-dropdown-menu a .nd-title.nd-sub {
    padding-left: 0.9rem;
    font-weight: 400;
    font-size: 0.86rem;
    position: relative;
}
.nav-dropdown-menu a .nd-title.nd-sub::before {
    content: '';
    position: absolute;
    left: 0.15rem;
    top: 0.55em;
    width: 0.4rem;
    height: 1px;
    background: var(--border);
}
.nav-dropdown-menu a .nd-desc.nd-sub {
    padding-left: 0.9rem;
}

/* Separator above "View all..." link */
.nav-dropdown-menu .nd-divider {
    height: 1px;
    background: var(--border);
    margin: 0.4rem 0.5rem;
}
.nav-dropdown-menu .nd-all {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 0.6rem 0.9rem;
}
.nav-dropdown-menu .nd-all:hover,
.nav-dropdown-menu .nd-all:focus-visible {
    color: var(--accent);
    background: transparent;
}

/* ---------- Mobile behavior ---------- */
@media (max-width: 768px) {
    .nav-dropdown { width: 100%; }
    .nav-dropdown-toggle {
        width: 100%;
        /* Center the label + chevron together so Services/Products match
           the centered alignment of About, Case Studies, Insights, etc. */
        justify-content: center;
        gap: 0.4rem;
        padding: 0.25rem 0;
    }
    .nav-dropdown-menu {
        position: static;
        transform: none;
        opacity: 1;
        pointer-events: auto;
        background: transparent;
        backdrop-filter: none;
        border: none;
        box-shadow: none;
        padding: 0.25rem 0 0.5rem 0;
        margin: 0.4rem 0 0;
        min-width: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.25s ease;
        /* Center align the dropdown items inside the mobile menu */
        text-align: center;
        list-style: none;
    }
    /* Override desktop hover/open transforms on mobile - keep flat layout.
       Without this, transform: translateX(-50%) from the desktop rule leaks
       through and pushes content sideways, leaving dead space on the right. */
    .nav-dropdown .nav-dropdown-menu,
    .nav-dropdown:hover .nav-dropdown-menu,
    .nav-dropdown:focus-within .nav-dropdown-menu,
    .nav-dropdown.open .nav-dropdown-menu {
        transform: none;
    }
    .nav-dropdown.open .nav-dropdown-menu {
        max-height: 600px;
    }
    .nav-dropdown-menu::before { display: none; }
    .nav-dropdown-menu a { padding: 0.55rem 0.6rem; }
    .nav-dropdown-menu .nd-divider { margin: 0.3rem 0.6rem; }
}

/* ============================================================
   Services mega-menu: 3 categories with right-side flyouts
   ============================================================ */
.nav-mega { min-width: 300px; }
.nav-flyout { position: relative; list-style: none; }

/* Category row (also a link to the overview page) */
.nav-flyout > .nav-flyout-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.nav-flyout > .nav-flyout-toggle:hover,
.nav-flyout > .nav-flyout-toggle:focus-visible,
.nav-flyout:hover > .nav-flyout-toggle,
.nav-flyout:focus-within > .nav-flyout-toggle {
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
}
.nav-flyout .nd-cat { display: block; }
.nav-flyout .nd-caret {
    width: 12px; height: 12px; flex-shrink: 0; opacity: 0.55;
    transition: transform 0.2s, opacity 0.2s;
}
.nav-flyout:hover .nd-caret,
.nav-flyout:focus-within .nd-caret { opacity: 1; transform: translateX(2px); }

/* Flyout submenu panel — pops out to the right of the category */
.nav-flyout-menu {
    position: absolute;
    top: -0.5rem;
    left: 100%;
    margin-left: 0.4rem;
    min-width: 268px;
    background: rgba(7, 9, 14, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem;
    list-style: none;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 1200;
}
/* Invisible bridge across the gap so the cursor can cross without closing */
.nav-flyout-menu::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -0.6rem;
    width: 0.6rem;
}
.nav-flyout.open > .nav-flyout-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}
/* Hover-opening applies ONLY to devices with a real hovering pointer (mouse).
   Touch devices (phones, tablets, touch laptops) report hover:none and open the
   same flyout by tap, via the .open class toggled in galatine-nav.js. Keying off
   pointer capability instead of screen width means a 1024px tablet behaves like a
   phone, not like a desktop that can never open its submenus. */
@media (hover: hover) and (pointer: fine) {
    .nav-flyout:hover > .nav-flyout-menu,
    .nav-flyout:focus-within > .nav-flyout-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }
}
/* Touch devices: mark the open category so the popout reads as attached to it */
@media (hover: none), (pointer: coarse) {
    .nav-flyout.open > .nav-flyout-toggle {
        background: var(--bg-card);
        color: var(--text-primary);
    }
    .nav-flyout.open .nd-caret { opacity: 1; transform: translateX(2px); }
}

/* ---------- Mobile: same interaction as desktop — tap a category and its
   submenu pops out to the right of it as an overlay card ---------- */
@media (max-width: 768px) {
    /* Let the popout card escape the collapsed-menu clipping while open */
    .nav-dropdown.open .nav-dropdown-menu { overflow: visible; }

    .nav-flyout > .nav-flyout-toggle { justify-content: center; gap: 0.5rem; padding: 0.55rem 0.6rem; }
    .nav-flyout > .nav-flyout-toggle .nd-title { font-weight: 600; }
    .nav-flyout .nd-caret { display: inline-block; }
    .nav-flyout.open .nd-caret { opacity: 1; transform: translateX(2px); }

    /* Only the 3 category rows show; descriptions stay compact */
    .nav-mega .nd-desc { display: none; }

    /* Phone popout. Rendered IN-FLOW (not as an overlay) so opening a category
       pushes the items below it down instead of covering them: Case Studies,
       Insights and Get In Touch always stay visible and reachable. The card is
       right-aligned and slides in from the right, so it still reads as popping
       out to the right of the tapped category. */
    .nav-mega { position: relative; left: auto; }
    .nav-flyout { position: static; }
    .nav-flyout.open > .nav-flyout-toggle {
        background: var(--bg-card);
        color: var(--text-primary);
    }
    .nav-flyout-menu {
        display: none;
        position: static;
        width: min(84vw, 320px);
        min-width: 0;
        margin: 0.35rem 0 0.6rem auto;
        text-align: left;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
    }
    .nav-flyout.open > .nav-flyout-menu {
        display: block;
        animation: gtFlyIn 0.22s ease-out;
    }
    @keyframes gtFlyIn {
        from { opacity: 0; transform: translateX(16px); }
        to   { opacity: 1; transform: none; }
    }
    /* The open mobile panel scrolls if it is taller than the screen, so nothing
       is ever cut off on short phones. */
    .nav .nav-links.open {
        max-height: calc(100vh - 86px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-dropdown.open .nav-dropdown-menu { max-height: 900px; }
    .nav-flyout-menu::before { display: none; }
    .nav-flyout-menu a { padding: 0.55rem 0.7rem; }
}


/* ===== SEO components: FAQ accordion + footer navigation ===== */
.faq-section { border-top: 1px solid var(--border); }
.faq-list { display: grid; gap: 0.75rem; margin-top: 2.5rem; }
.faq-item {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
    padding: 0 1.25rem; transition: border-color 0.25s;
}
.faq-item[open] { border-color: var(--border-hover); }
.faq-q {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; padding: 1.05rem 0; font-weight: 600; font-size: 1.02rem; color: var(--text-primary);
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.faq-icon { position: relative; flex: 0 0 22px; height: 22px; border: 1px solid var(--border-hover); border-radius: 50%; }
.faq-icon::before, .faq-icon::after {
    content: ''; position: absolute; left: 50%; top: 50%; background: var(--accent);
    width: 10px; height: 2px; transform: translate(-50%, -50%); transition: transform 0.25s;
}
.faq-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.faq-item[open] .faq-icon::after { transform: translate(-50%, -50%) rotate(0deg); }
.faq-a { padding: 0 0 1.2rem; color: var(--text-secondary); line-height: 1.75; max-width: 70ch; }
.faq-a p { margin: 0; }

.footer-nav { display: flex; gap: 3rem; flex-wrap: wrap; }
.footer-nav-col { display: flex; flex-direction: column; gap: 0.45rem; }
.footer-nav-label {
    font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 0.35rem;
}
.footer-nav a { font-size: 0.85rem; color: var(--text-secondary); transition: color 0.2s; }
.footer-nav a:hover { color: var(--text-primary); }
@media (max-width: 768px) { .footer-nav { gap: 2rem; } }
