/* ====== HEADER STYLES ====== */
#header {
    position: sticky;
    top: 0;
    width: 100%;
    background: linear-gradient(135deg, #040b14 0%, #1a1f2e 100%);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
    z-index: 999;
    transition: all 0.3s ease;
}

/* Hide navbar while a quiz session is in progress (body class set by MicroQuiz) */
body.quiz-active #header {
    display: none;
}

/* On dense course content routes, hide the sticky header so the lesson area can use the full viewport. */
#header.hide-desktop-on-course-content {
    display: none;
}

#header.hide-on-blog {
    display: none;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 30px;
    height: 70px;
}

.header-wordmark {
    display: inline-flex;
    flex: 0 0 auto;
    min-height: 44px;
    align-items: center;
    gap: 8px;
    color: #e8f6ff;
    font-family: "Open Sans", sans-serif;
    text-decoration: none;
    white-space: nowrap;
}

.header-wordmark__icon {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid rgba(125, 229, 255, 0.34);
    border-radius: 8px;
    background: rgba(103, 220, 255, 0.12);
    color: #9defff;
}

.header-wordmark__text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.1;
}

.header-wordmark__kicker {
    color: #b6ecf9;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.045em;
    line-height: 1.15;
    text-transform: uppercase;
}

.header-wordmark__name {
    color: #f3fbff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.15;
}

.header-wordmark:hover {
    color: #9eecff;
}

.header-wordmark:focus-visible {
    outline: 2px solid #8ce9ff;
    outline-offset: 3px;
}

/* Desktop Navigation Menu */
.desktop-nav {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-width: 0;
    margin: 0 14px;
}

.desktop-nav ul {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 5px;
}

.desktop-nav .nav-link {
    display: block;
    padding: 8px 18px;
    color: #a8a9b4;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    font-family: "Open Sans", sans-serif;
    transition: all 0.3s ease;
    border-radius: 4px;
    position: relative;
}

.desktop-nav .nav-link:hover {
    color: #fff;
    background: rgba(20, 157, 221, 0.1);
}

.desktop-nav .nav-link.active {
    color: #149ddd;
    background: rgba(20, 157, 221, 0.15);
    border-bottom: 2px solid #149ddd;
}

.desktop-nav .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: #149ddd;
    transform: translateX(-50%);
    transition: width 0.3s ease;
}

.desktop-nav .nav-link:hover::after {
    width: 70%;
}

.desktop-nav .nav-link.active::after {
    width: 70%;
}

/* Header Social Links */
.header-socials {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header-socials a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    border-radius: 50%;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 18px;
}

.header-socials a:hover {
    background: #149ddd;
    color: #fff;
    transform: translateY(-3px);
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #149ddd;
    font-size: 28px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
    color: #37b3ed;
}

/* Mobile Navigation Menu */
.mobile-nav {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: #1a1f2e;
    border-top: 1px solid rgba(20, 157, 221, 0.2);
    max-height: calc(100vh - 70px);
    overflow-y: auto;
}

.mobile-nav ul {
    list-style: none;
    padding: 15px 0;
    margin: 0;
}

.mobile-nav li {
    padding: 0;
}

.mobile-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 25px;
    color: #a8a9b4;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.mobile-nav .nav-link i {
    font-size: 18px;
    color: #149ddd;
}

.mobile-nav .nav-link:hover {
    background: rgba(20, 157, 221, 0.1);
    color: #fff;
    padding-left: 35px;
}

.mobile-nav .nav-link.active {
    background: rgba(20, 157, 221, 0.15);
    color: #149ddd;
    border-left: 3px solid #149ddd;
    padding-left: 32px;
}

/* ====== RESPONSIVE DESIGN ====== */

/* Tablet and below */
@media (max-width: 1024px) {
    .header-container {
        padding: 0 20px;
    }

    .desktop-nav {
        margin: 0 12px;
    }

    .desktop-nav .nav-link {
        padding: 8px 14px;
        font-size: 13px;
    }

    .header-socials {
        gap: 8px;
    }

    .header-socials a {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

/* Mobile screens */
@media (max-width: 768px) {
    .header-container {
        height: 60px;
        padding: 0 15px;
        justify-content: space-between;
    }

    /* Hide desktop nav on mobile */
    .desktop-nav {
        display: none;
    }

    /* Show mobile toggle */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Show mobile nav when active */
    #header.mobile-menu-active .mobile-nav {
        display: block;
    }

    .header-socials {
        display: none;
    }

    .desktop-nav {
        margin: 0;
    }

    .header-wordmark__kicker {
        font-size: 9px;
    }

    .header-wordmark__name {
        font-size: 13px;
    }
}

/* Small screens */
@media (max-width: 480px) {
    .header-container {
        height: 55px;
        padding: 0 12px;
    }

    .mobile-menu-toggle {
        font-size: 24px;
    }

    .mobile-nav {
        top: 55px;
    }

    .mobile-nav .nav-link {
        padding: 12px 20px;
        font-size: 14px;
    }

    .mobile-nav .nav-link:hover {
        padding-left: 30px;
    }

    .mobile-nav .nav-link.active {
        padding-left: 27px;
    }
}

/* Smooth transitions */
* {
    -webkit-tap-highlight-color: transparent;
}

header button {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* AI Theme Header Overrides */
#header {
    background:
        linear-gradient(135deg, rgba(8, 30, 50, 0.96) 0%, rgba(14, 46, 67, 0.95) 50%, rgba(20, 61, 85, 0.95) 100%),
        radial-gradient(circle at 15% 20%, rgba(86, 225, 255, 0.24), transparent 40%);
    border-bottom: 1px solid rgba(121, 215, 255, 0.28);
    box-shadow: 0 14px 24px rgba(6, 24, 39, 0.32);
    backdrop-filter: blur(10px);
}

#header::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(35, 213, 255, 0) 0%, rgba(110, 230, 255, 0.85) 50%, rgba(35, 213, 255, 0) 100%);
    opacity: 0.85;
}

.desktop-nav .nav-link {
    color: #d8efff !important;
    border: 1px solid transparent;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.desktop-nav .nav-link:hover {
    color: #ffffff !important;
    background: rgba(111, 221, 255, 0.14);
    border-color: rgba(128, 227, 255, 0.38);
}

.desktop-nav .nav-link.active {
    color: #9defff !important;
    border-color: rgba(135, 233, 255, 0.52);
    background: linear-gradient(135deg, rgba(14, 80, 108, 0.48) 0%, rgba(22, 111, 134, 0.42) 100%);
    border-bottom: 1px solid rgba(135, 233, 255, 0.52);
    box-shadow: inset 0 0 0 1px rgba(77, 174, 209, 0.25);
}

.desktop-nav .nav-link::after {
    display: none;
}

.header-socials a {
    background: rgba(103, 220, 255, 0.14);
    border: 1px solid rgba(125, 229, 255, 0.34);
    color: #e8f8ff !important;
}

.header-socials a:hover {
    background: rgba(89, 216, 255, 0.28);
    border-color: rgba(151, 236, 255, 0.6);
    box-shadow: 0 8px 14px rgba(2, 27, 43, 0.35), 0 0 18px rgba(92, 220, 255, 0.34);
}

.mobile-menu-toggle {
    color: #84e8ff;
    border-radius: 10px;
}

.mobile-menu-toggle:hover {
    color: #e2f9ff;
    background: rgba(115, 221, 252, 0.12);
}

.mobile-nav {
    background: linear-gradient(180deg, rgba(11, 35, 56, 0.98) 0%, rgba(15, 45, 66, 0.98) 100%);
    border-top-color: rgba(130, 225, 255, 0.35);
}

.mobile-nav .nav-link {
    color: #d8efff !important;
}

.mobile-nav .nav-link i {
    color: #88e9ff;
}

.mobile-nav .nav-link:hover {
    background: rgba(111, 221, 255, 0.16);
    color: #ffffff !important;
}

.mobile-nav .nav-link.active {
    background: rgba(111, 221, 255, 0.19);
    color: #9deeff !important;
    border-left-color: #89ebff;
}

/* ── Learn Dropdown ── */

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ── Mobile nav section label ── */
/* Search and keyboard navigation; seven primary destinations are direct links. */
.header-search-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.45rem;
    border: 1px solid transparent;
    border-radius: 999px;
    color: #d8efff;
    text-decoration: none;
}
.header-search-link:hover {
    color: #fff;
    border-color: rgba(135, 233, 255, 0.5);
    background: rgba(111, 221, 255, 0.15);
}
.header-search-link:focus-visible,
.mobile-menu-toggle:focus-visible,
.desktop-nav .nav-link:focus-visible {
    outline: 3px solid #8ce9ff;
    outline-offset: 3px;
}
.mobile-menu-toggle { min-width: 44px; min-height: 44px; }
/* Keep seven direct destinations comfortably spaced, without forcing the
   wordmark or social actions to compete for room at intermediate widths. */
@media (min-width: 1025px) {
    .header-container {
        max-width: 1480px;
        padding-inline: clamp(20px, 2vw, 32px);
        gap: clamp(12px, 1.4vw, 24px);
    }

    .desktop-nav {
        flex: 1 1 auto;
        justify-content: center;
        gap: clamp(14px, 1.5vw, 24px);
        margin: 0;
    }

    .desktop-nav ul {
        flex: 0 1 auto;
        min-width: 0;
        justify-content: center;
        gap: clamp(14px, 1.6vw, 28px);
    }

    .desktop-nav .nav-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 44px;
        padding: 0 clamp(9px, 0.85vw, 14px);
        font-size: clamp(14px, 0.95vw, 15px);
        line-height: 1.25;
        white-space: nowrap;
    }

    .header-search-link {
        width: 44px;
        height: 44px;
        min-width: 44px;
        flex: 0 0 44px;
        padding: 0;
    }

    .header-socials { flex: 0 0 auto; gap: 8px; }
    .header-socials a { width: 44px; height: 44px; }
}

/* Prioritize primary destinations instead of crowding them with social icons. */
@media (min-width: 1025px) and (max-width: 1359px) {
    .header-socials { display: none; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .header-container { height: 70px; }
    .desktop-nav, .header-socials { display: none; }
    .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    #header.mobile-menu-active .mobile-nav { display: block; }
}

/* A consistent dropdown anchor across 55px, 60px and 70px header heights. */
.mobile-menu-toggle { flex: 0 0 44px; min-width: 44px; min-height: 44px; }
.mobile-nav {
    top: 100%;
    max-height: calc(100dvh - var(--header-row-height, 70px));
    --mobile-item-inset: clamp(20px, 4vw, 26px);
}
.mobile-nav .nav-link {
    min-height: 48px;
    padding: 12px var(--mobile-item-inset);
}
.mobile-nav .nav-link:hover { padding-left: var(--mobile-item-inset); }
.mobile-nav .nav-link.active { padding-left: calc(var(--mobile-item-inset) - 3px); }

@media (max-width: 768px) {
    #header { --header-row-height: 60px; }
}
@media (max-width: 480px) {
    #header { --header-row-height: 55px; }
}
