
/* =========================================================
   CODEWORD HEADER CSS
   Navy + White + Electric Blue
   Topbar, Navbar, Dropdowns, Mobile Menu and Tooltips
========================================================= */

:root {
    --cw-navy: #111827;
    --cw-navy-light: #172a48;
    --cw-blue: #2563eb;
    --cw-blue-dark: #1d4ed8;
    --cw-blue-light: #60a5fa;
    --cw-text: #172033;
    --cw-border: #dbe3ed;
}

.cw-topbar *,
.cw-topbar,
header,
header *,
.mobile-menu,
.mobile-menu * {
    box-sizing: border-box;
}

.cw-topbar,
header {
    font-family: "Poppins", "Segoe UI", sans-serif;
}

/* ==================== TOP BAR ==================== */

.cw-topbar {
    position: relative;
    z-index: 1001;
    width: 100%;
    margin: 0;
    padding: 0;
    color: #f8fafc;
    background:
        radial-gradient(circle at 78% -45%, rgba(59,130,246,.2), transparent 40%),
        linear-gradient(110deg, #101827 0%, #131f34 58%, #172a48 100%);
    border-bottom: 1px solid rgba(255,255,255,.1);
    box-shadow: 0 4px 15px rgba(15,23,42,.13);
}

.cw-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    width: 100%;
    max-width: 1500px;
    min-height: 66px;
    margin: 0 auto;
    padding: 10px clamp(16px,2.5vw,36px);
}

.cw-topbar-identity {
    display: flex;
    align-items: center;
    gap: 11px;
    flex: 1 1 auto;
    min-width: 0;
}

.cw-topbar-indicator {
    position: relative;
    display: inline-block;
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--cw-blue-light);
    box-shadow: 0 0 12px rgba(59,130,246,.65);
}

.cw-topbar-indicator::after {
    content: "";
    position: absolute;
    inset: -4px;
    border: 1px solid rgba(96,165,250,.45);
    border-radius: 50%;
    animation: cw-topbar-pulse 2.4s ease-out infinite;
}

.cw-topbar-title {
    display: block;
    color: #f8fafc;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.6;
    letter-spacing: .05px;
    overflow-wrap: anywhere;
}

/* Social icons */

.cw-topbar-social {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    gap: 5px;
}

.cw-topbar-social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    color: #e2e8f0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 16px;
    text-decoration: none;
    transition: color .25s ease, background .25s ease,
        border-color .25s ease, transform .25s ease;
}

.cw-topbar-social a:hover {
    color: #fff;
    background: rgba(59,130,246,.17);
    border-color: rgba(96,165,250,.3);
    transform: translateY(-2px);
}

/* Topbar buttons */

.cw-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 auto;
    gap: 9px;
}

.cw-topbar-actions #user-info,
.cw-topbar-actions #logout-btn {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.cw-topbar-login,
.cw-topbar-logout,
.cw-topbar-hackathon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 39px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
    transition: .25s ease;
}

.cw-topbar-login {
    color: #172033;
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 3px 9px rgba(0,0,0,.09);
}

.cw-topbar-login i {
    color: var(--cw-blue);
    font-size: 12px;
}

.cw-topbar-login:hover {
    color: var(--cw-blue);
    background: #eff6ff;
    border-color: #bfdbfe;
    transform: translateY(-2px);
}

.cw-topbar-logout {
    color: #fecaca;
    background: rgba(220,38,38,.1);
    border-color: rgba(248,113,113,.3);
}

.cw-topbar-logout:hover {
    color: #fff;
    background: #b91c1c;
    border-color: #ef4444;
    transform: translateY(-2px);
}

.cw-topbar-hackathon {
    color: #fff;
    background: linear-gradient(135deg,#2563eb,#1d4ed8);
    border-color: rgba(147,197,253,.22);
    box-shadow: 0 4px 12px rgba(37,99,235,.22);
}

.cw-topbar-hackathon:hover {
    color: #fff;
    background: linear-gradient(135deg,#3b82f6,#1d4ed8);
    transform: translateY(-2px);
    box-shadow: 0 7px 18px rgba(37,99,235,.32);
}

.cw-topbar-hackathon i {
    font-size: 11px;
    transition: transform .25s ease;
}

.cw-topbar-hackathon:hover i {
    transform: translateX(3px);
}

/* ==================== MAIN HEADER ==================== */

header {
    position: relative;
    z-index: 999;
    width: 100%;
    margin: 0;
    background: #fff;
    border-bottom: 1px solid #d7dee8;
    box-shadow: 0 6px 20px rgba(17,24,39,.09);
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    max-width: 1500px;
    min-height: 76px;
    margin: 0 auto;
    padding: 11px clamp(16px,2.2vw,32px);
    background: #fff;
}

/* Logo */

.navbar > a:first-child {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    color: inherit;
    text-decoration: none;
}

.brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    cursor: pointer;
    transition: transform .25s ease;
}

.brand-logo {
    display: block;
    width: 175px;
    height: 60px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
    border: none;
    outline: none;
    box-shadow: none;
    transition: filter .25s ease;
}

.brand:hover {
    transform: translateY(-1px);
}

.brand:hover .brand-logo {
    filter: brightness(1.04);
}

/* ==================== DESKTOP NAVIGATION ==================== */

.menu {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(9px,1.1vw,18px);
    flex: 1 1 auto;
    min-width: 0;
}

.menu > a,
.menu > .dropdown > a {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 12px 0;
    color: #172033;
    font-size: clamp(11px,.88vw,13px);
    font-weight: 600;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
    transition: color .25s ease;
}

.menu > a:hover,
.menu > .dropdown > a:hover,
.menu > .dropdown:focus-within > a {
    color: #1d4ed8;
}

/* Existing underline remains on ::after.
   Tooltips use a separate HTML element. */

.menu > a::after,
.menu > .dropdown > a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 5px;
    width: 0;
    height: 2px;
    border-radius: 3px;
    background: #2563eb;
    transition: width .25s ease;
}

.menu > a:hover::after,
.menu > .dropdown > a:hover::after,
.menu > .dropdown:focus-within > a::after {
    width: 100%;
}

/* ==================== DROPDOWNS ==================== */

.menu > .dropdown {
    position: relative;
    flex: 0 0 auto;
    min-width: 0;
}

.menu > .dropdown > a i {
    font-size: 10px;
    transition: transform .2s ease;
}

.menu > .dropdown:hover > a i,
.menu > .dropdown:focus-within > a i {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    display: none;
    width: 235px;
    max-width: min(280px,calc(100vw - 24px));
    max-height: min(70vh,450px);
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 8px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(17,24,39,.16);
    z-index: 10050;
    animation: cw-header-fade-in .18s ease;
}

.menu > .dropdown:hover > .dropdown-menu,
.menu > .dropdown:focus-within > .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: #334155;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
    transition: color .2s ease, background .2s ease;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
    color: #1d4ed8;
    background: #eff6ff;
}

@keyframes cw-header-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== LOGGED-IN USER ==================== */

#logged-user {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 0 0 auto;
    padding: 8px 10px;
    color: #172033;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

#logged-user i {
    color: #2563eb;
    font-size: 16px;
}

#logged-user[style*="display:none"],
#logged-user[style*="display: none"] {
    display: none !important;
}

/* ==================== ALERTS LINK ==================== */

.menu a.alerts-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 20px;
    background: linear-gradient(135deg,#ff4500,#ff9800,#e91e63);
    color: #fff;
    font-weight: bold;
    text-decoration: none;
    box-shadow: 0 3px 10px rgba(255,69,0,.35);
    animation: alertBlink 1s infinite;
}

.alerts-icon {
    font-size: 18px;
}

.alerts-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
}

@keyframes alertBlink {
    0%,100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .7;
        transform: scale(1.06);
    }
}

/* ==================== HAMBURGER ==================== */

.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    color: #172033;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 21px;
    cursor: pointer;
    transition: color .2s ease, background .2s ease,
        border-color .2s ease;
}

.hamburger:hover {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #93c5fd;
}

/* ==================== MOBILE DRAWER ==================== */

.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    width: min(360px,92vw);
    height: 100vh;
    height: 100dvh;
    padding: 0 18px 24px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    color: #172033;
    background: #fff;
    box-shadow: -12px 0 36px rgba(15,23,42,.2);
    transform: translateX(105%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .32s ease, visibility .32s ease;
}

.mobile-menu.active {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
}

.mobile-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin: 0 -18px 14px;
    padding: 15px 18px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 39px;
    height: 39px;
    color: #172033;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    transition: color .2s ease, background .2s ease;
}

.close-btn:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.mobile-links {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.mobile-links > a,
.mobile-links > .dropdown > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 11px;
    color: #172033;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #edf1f6;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    text-align: left;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: color .2s ease, background .2s ease;
}

.mobile-links > a:hover,
.mobile-links > .dropdown > a:hover {
    color: #1d4ed8;
    background: #eff6ff;
}

.mobile-links .dropdown {
    display: block;
    width: 100%;
    min-width: 0;
}

.mobile-links .dropdown > a i {
    transition: transform .2s ease;
}

.mobile-links .dropdown > a[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.mobile-links .dropdown-menu {
    position: static !important;
    display: none !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    margin: 3px 0 8px !important;
    padding: 6px !important;
    overflow: visible !important;
    background: #f1f5f9 !important;
    border: 0 !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    animation: none !important;
}

.mobile-links .dropdown-menu.mobile-open {
    display: block !important;
}

.mobile-links .dropdown-menu a {
    display: flex;
    width: 100%;
    padding: 10px 11px;
    color: #334155;
    border-bottom: 1px solid #dfe7f0;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1.5;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
}

.mobile-links .dropdown-menu a:last-child {
    border-bottom: 0;
}

.mobile-links .dropdown-menu a:hover {
    color: #1d4ed8;
    background: #dbeafe;
}

/* ==================== TOOLTIP ==================== */

/* Uses a separate element created by JavaScript.
   This prevents conflicts with the navbar underline ::after. */

.cw-nav-tooltip {
    position: fixed;
    z-index: 1000000;
    width: max-content;
    max-width: min(230px,calc(100vw - 16px));
    padding: 9px 12px;
    color: #fff;
    background: #172033;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 8px;
    box-shadow: 0 7px 20px rgba(0,0,0,.2);
    font-family: "Poppins",sans-serif;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.6;
    text-align: center;
    white-space: normal;
    overflow-wrap: break-word;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility .15s ease;
}

.cw-nav-tooltip.is-visible {
    opacity: 1;
    visibility: visible;
}

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

@media (max-width: 1200px) and (min-width: 769px) {
    .navbar {
        gap: 12px;
        padding-right: 18px;
        padding-left: 18px;
    }

    .brand-logo {
        width: 155px;
        height: 52px;
    }

    .menu {
        gap: clamp(6px,.7vw,10px);
    }

    .menu > a,
    .menu > .dropdown > a {
        font-size: 11px;
    }

    .cw-topbar-inner {
        gap: 13px;
    }

    .cw-topbar-title {
        font-size: 11.5px;
    }

    .cw-topbar-social {
        gap: 2px;
    }

    .cw-topbar-social a {
        width: 31px;
        height: 34px;
        font-size: 15px;
    }

    .cw-topbar-actions {
        gap: 7px;
    }

    .cw-topbar-login,
    .cw-topbar-logout,
    .cw-topbar-hackathon {
        padding: 9px 11px;
        font-size: 10.5px;
    }
}

@media (max-width: 768px) {
    .navbar {
        min-height: 67px;
        gap: 12px;
        padding: 10px 16px;
    }

    .brand-logo {
        width: 145px;
        height: 48px;
    }

    .navbar .menu {
        display: none !important;
    }

    .navbar .hamburger {
        display: inline-flex !important;
    }

    .cw-topbar-inner {
        display: grid;
        grid-template-columns: minmax(0,1fr) auto;
        grid-template-areas:
            "identity social"
            "actions actions";
        gap: 11px 8px;
        padding: 12px 15px;
    }

    .cw-topbar-identity {
        grid-area: identity;
    }

    .cw-topbar-title {
        font-size: 11px;
    }

    .cw-topbar-social {
        grid-area: social;
        justify-self: end;
    }

    .cw-topbar-social a {
        width: 29px;
        height: 31px;
        font-size: 13px;
    }

    .cw-topbar-actions {
        grid-area: actions;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .cw-topbar-login,
    .cw-topbar-logout,
    .cw-topbar-hackathon {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 10.5px;
    }
}

@media (max-width: 480px) {
    .brand-logo {
        width: 125px;
        height: 43px;
    }

    .cw-topbar-inner {
        gap: 10px 4px;
        padding: 11px 10px;
    }

    .cw-topbar-title {
        font-size: 10px;
    }

    .cw-topbar-social {
        gap: 0;
    }

    .cw-topbar-social a {
        width: 27px;
        height: 29px;
        font-size: 12px;
    }

    .cw-topbar-actions {
        gap: 6px;
    }

    .cw-topbar-login,
    .cw-topbar-logout,
    .cw-topbar-hackathon {
        gap: 5px;
        min-height: 34px;
        padding: 8px 9px;
        font-size: 10px;
    }

    .navbar {
        padding: 9px 12px;
    }

    .hamburger {
        width: 39px;
        height: 39px;
        font-size: 20px;
    }

    .mobile-menu {
        width: min(360px,94vw);
        padding-right: 15px;
        padding-left: 15px;
    }

    .mobile-header {
        margin-right: -15px;
        margin-left: -15px;
        padding-right: 15px;
        padding-left: 15px;
    }
}

@media (max-width: 350px) {
    .brand-logo {
        width: 112px;
        height: 39px;
    }

    .cw-topbar-title {
        font-size: 9.5px;
    }

    .cw-topbar-social a {
        width: 24px;
    }

    .cw-topbar-login,
    .cw-topbar-logout,
    .cw-topbar-hackathon {
        padding: 7px 8px;
        font-size: 9.5px;
    }

    .hamburger {
        width: 38px;
        height: 38px;
    }
}

/* ==================== OVERFLOW FIX ==================== */

html,
body {
    max-width: 100%;
    overflow-x: clip;
}

header,
.navbar,
.menu {
    overflow: visible;
}

.menu > .dropdown {
    min-width: 0;
}

.dropdown-menu {
    box-sizing: border-box;
}

/* ==================== ACCESSIBILITY ==================== */

.cw-topbar a:focus-visible,
.menu a:focus-visible,
.mobile-links a:focus-visible,
.hamburger:focus-visible,
.close-btn:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 3px;
}

@keyframes cw-topbar-pulse {
    0% {
        transform: scale(.7);
        opacity: .8;
    }

    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

@media (hover: none) {
    .cw-nav-tooltip {
        display: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cw-topbar-indicator::after {
        animation: none !important;
    }

    .cw-topbar *,
    .navbar *,
    .mobile-menu *,
    .brand,
    .menu a,
    .dropdown-menu {
        transition: none !important;
        animation: none !important;
    }
}
