/* =========================================================
   Header navigation — sticky, megamenu, mobile drawer.
   Loaded site-wide via astra-child/header-nav.php.
   ========================================================= */

:root {
    --ti-h-bg: rgba(11, 18, 32, 0.92);
    --ti-h-bg-solid: #0b1220;
    --ti-h-border: rgba(255, 255, 255, 0.08);
    --ti-h-text: #e6edf6;
    --ti-h-muted: #93a3b8;
    --ti-h-blue: #4fc3f7;
    --ti-h-green: #2ecc71;
    --ti-h-height: 64px;
}

.ti-header {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 9999;
    height: var(--ti-h-height);
    background: var(--ti-h-bg);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--ti-h-border);
    color: var(--ti-h-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: box-shadow 0.18s ease, background 0.18s ease;
}
.ti-header[data-scrolled="true"] { box-shadow: 0 8px 28px rgba(0, 0, 0, 0.30); }

.ti-header-inner {
    max-width: 1240px;
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Brand */
.ti-header-brand {
    display: inline-flex; align-items: center; gap: 10px;
    color: var(--ti-h-text); text-decoration: none;
    flex-shrink: 0;
    line-height: 1;
}
.ti-header-brand .ti-brand-mark {
    border-radius: 7px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.06);
}
.ti-header-wordmark {
    font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 700; font-size: 1rem; letter-spacing: -0.01em;
    color: var(--ti-h-text);
    display: inline-flex; align-items: baseline;
}
.ti-header-wordmark-tld {
    font-weight: 500; font-size: 0.82em;
    color: var(--ti-h-muted);
    margin-left: 1px;
}

/* Primary nav */
.ti-header-nav { flex: 1; display: flex; }
.ti-nav {
    list-style: none; margin: 0; padding: 0;
    display: flex; gap: 4px; align-items: center;
    height: 100%;
}
.ti-nav-item { position: relative; height: var(--ti-h-height); display: flex; align-items: center; }
.ti-nav-link {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--ti-h-text);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    height: 36px;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}
.ti-nav-link:hover,
.ti-nav-link:focus-visible { background: rgba(255,255,255,0.06); color: #fff; outline: none; }
.ti-nav-item.is-active > .ti-nav-link { color: var(--ti-h-blue); }
.ti-nav-item.is-active > .ti-nav-link::after {
    content: ""; position: absolute;
    left: 12px; right: 12px; bottom: -2px; height: 2px;
    background: var(--ti-h-blue);
    border-radius: 2px;
}
.ti-nav-caret { font-size: 0.7em; opacity: 0.7; transition: transform 0.15s ease; }
.ti-nav-item[data-open="true"] .ti-nav-caret { transform: rotate(180deg); }

/* Megamenu (Topics) */
.ti-mega {
    position: absolute;
    top: 100%; left: -120px;
    background: var(--ti-h-bg-solid);
    border: 1px solid var(--ti-h-border);
    border-top-color: rgba(79, 195, 247, 0.4);
    border-radius: 0 0 14px 14px;
    box-shadow: 0 30px 60px -10px rgba(0, 0, 0, 0.6);
    padding: 18px;
    width: 720px;
    max-width: calc(100vw - 32px);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    pointer-events: none;
}
.ti-nav-item[data-open="true"] .ti-mega {
    opacity: 1; transform: translateY(0); pointer-events: auto;
}
.ti-mega[hidden] { display: none; }
.ti-nav-item[data-open="true"] .ti-mega[hidden] { display: block; }
.ti-mega-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.ti-mega-card {
    display: block; padding: 12px 14px; border-radius: 8px;
    color: var(--ti-h-text); text-decoration: none;
    transition: background 0.12s ease;
}
.ti-mega-card:hover, .ti-mega-card:focus-visible {
    background: rgba(79, 195, 247, 0.08);
    outline: none;
}
.ti-mega-card-title {
    display: block;
    font-weight: 600; font-size: 0.95rem; color: #fff;
    margin-bottom: 2px;
}
.ti-mega-card-desc {
    display: block;
    font-size: 0.82rem; color: var(--ti-h-muted); line-height: 1.4;
}

/* Dropdown (Roadmaps) */
.ti-dropdown {
    position: absolute;
    top: 100%; left: 0;
    list-style: none; margin: 0; padding: 8px;
    min-width: 220px;
    background: var(--ti-h-bg-solid);
    border: 1px solid var(--ti-h-border);
    border-top-color: rgba(79, 195, 247, 0.4);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 30px 60px -10px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    pointer-events: none;
}
.ti-nav-item[data-open="true"] .ti-dropdown {
    opacity: 1; transform: translateY(0); pointer-events: auto;
}
.ti-dropdown[hidden] { display: none; }
.ti-nav-item[data-open="true"] .ti-dropdown[hidden] { display: block; }
.ti-dropdown li a {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 10px 12px; border-radius: 6px;
    color: var(--ti-h-text); text-decoration: none;
    font-size: 0.92rem;
}
.ti-dropdown li a:hover, .ti-dropdown li a:focus-visible {
    background: rgba(79, 195, 247, 0.08); outline: none;
}
.ti-drop-meta {
    color: var(--ti-h-muted); font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 0.78rem;
}

/* Header tools */
.ti-header-tools {
    display: flex; align-items: center; gap: 6px;
    flex-shrink: 0;
}
.ti-header-search {
    display: flex; align-items: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    height: 36px;
    transition: width 0.22s ease, background 0.16s ease;
    width: 36px;
    overflow: hidden;
}
.ti-header-search[data-state="open"] {
    width: 240px;
    background: rgba(255,255,255,0.08);
}
.ti-search-toggle {
    background: transparent; border: 0; color: var(--ti-h-text);
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.ti-search-toggle:hover { color: #fff; }
.ti-search-input {
    background: transparent; border: 0; outline: none;
    color: var(--ti-h-text);
    font: inherit; font-size: 0.92rem;
    flex: 1;
    padding: 0 12px 0 0;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}
.ti-header-search[data-state="open"] .ti-search-input {
    opacity: 1; pointer-events: auto;
}
.ti-search-input::placeholder { color: var(--ti-h-muted); }

/* Mobile toggle */
.ti-mobile-toggle {
    display: none;
    background: transparent; border: 0;
    width: 40px; height: 40px;
    color: var(--ti-h-text);
    cursor: pointer;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.ti-burger,
.ti-burger::before,
.ti-burger::after {
    display: block;
    width: 22px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    position: relative;
    transition: transform 0.2s ease, top 0.2s ease, bottom 0.2s ease, opacity 0.2s ease;
}
.ti-burger { margin: 0 auto; }
.ti-burger::before, .ti-burger::after {
    content: ""; position: absolute; left: 0;
}
.ti-burger::before { top: -7px; }
.ti-burger::after { top: 7px; }
.ti-header[data-state="open"] .ti-burger { background: transparent; }
.ti-header[data-state="open"] .ti-burger::before { top: 0; transform: rotate(45deg); }
.ti-header[data-state="open"] .ti-burger::after { top: 0; transform: rotate(-45deg); }

/* Mobile drawer */
.ti-mobile-drawer {
    position: fixed;
    top: var(--ti-h-height); right: 0;
    width: min(360px, 92vw);
    height: calc(100vh - var(--ti-h-height));
    background: var(--ti-h-bg-solid);
    border-left: 1px solid var(--ti-h-border);
    overflow-y: auto;
    transform: translateX(110%);
    transition: transform 0.24s ease;
    z-index: 9998;
}
.ti-header[data-state="open"] .ti-mobile-drawer { transform: translateX(0); }
.ti-mobile-drawer-inner { padding: 18px 20px 60px; }
.ti-mobile-search {
    margin-bottom: 16px;
}
.ti-mobile-search-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ti-h-text);
    font: inherit; font-size: 0.95rem;
    outline: none;
}
.ti-mobile-search-input::placeholder { color: var(--ti-h-muted); }
.ti-mobile-drawer details {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 8px 0;
}
.ti-mobile-drawer summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 4px;
    font-weight: 600; font-size: 0.96rem;
    display: flex; justify-content: space-between; align-items: center;
}
.ti-mobile-drawer summary::-webkit-details-marker { display: none; }
.ti-mobile-drawer summary::after {
    content: "+"; color: var(--ti-h-muted); font-weight: 400;
    transition: transform 0.16s ease;
    font-size: 1.4rem; line-height: 1;
}
.ti-mobile-drawer details[open] > summary::after {
    content: "−";
}
.ti-mobile-drawer details ul {
    list-style: none; margin: 0; padding: 0 4px 8px;
}
.ti-mobile-drawer details li a {
    display: block;
    padding: 8px 4px;
    color: var(--ti-h-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 4px;
}
.ti-mobile-drawer details li a:hover,
.ti-mobile-drawer details li a:focus-visible {
    color: var(--ti-h-blue); background: rgba(79,195,247,0.06); outline: none;
}

/* Hide drawer entirely on desktop */
@media (min-width: 1024px) {
    .ti-mobile-drawer { display: none !important; }
    .ti-mobile-toggle { display: none !important; }
}

/* On mobile: hide desktop nav, show hamburger */
@media (max-width: 1023px) {
    :root { --ti-h-height: 60px; }
    .ti-header-nav { display: none; }
    .ti-mobile-toggle { display: inline-flex; }
    .ti-header-search { display: none; }
    .ti-header-inner { gap: 12px; padding: 0 16px; }
}

/* Small phones: shrink wordmark a touch */
@media (max-width: 460px) {
    .ti-header-wordmark { font-size: 0.92rem; }
    .ti-header-wordmark-tld { font-size: 0.78em; }
}

/* When a dark hero is the first content element, let it flow up under the
   translucent fixed header so the body-padding gap is not visible. */
.ti-hero,
.ti-cat-hero {
    margin-top: calc(var(--ti-h-height) * -1);
    padding-top: calc(var(--ti-h-height) + 88px) !important;
}
@media (max-width: 1023px) {
    .ti-hero, .ti-cat-hero {
        padding-top: calc(var(--ti-h-height) + 64px) !important;
    }
}
