/* ================================================
   AmentoJourn — Custom Header CSS
   Academic style, sticky, mobile-first
   ================================================ */

/* ---------- CSS Variables (easy to customise) ---------- */
:root {
    --aj-header-bg:       #1a3a5c;       /* deep academic navy */
    --aj-header-height:   64px;
    --aj-accent:          #2e86ab;       /* teal accent */
    --aj-accent-hover:    #1d6a8a;
    --aj-text-light:      #ffffff;
    --aj-text-muted:      rgba(255,255,255,0.65);
    --aj-border-light:    rgba(255,255,255,0.12);
    --aj-dropdown-bg:     #ffffff;
    --aj-dropdown-shadow: 0 8px 32px rgba(0,0,0,0.18);
    --aj-drawer-width:    300px;
    --aj-transition:      0.25s ease;
    --aj-radius:          6px;
    --aj-font:            'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Preloader ---------- */
.aj-preloader {
    position: fixed;
    inset: 0;
    background: var(--aj-header-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 9999;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.aj-preloader.aj-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.aj-preloader-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--aj-text-light);
    animation: aj-bounce 0.8s infinite alternate;
}
.aj-preloader-dot:nth-child(2) { animation-delay: 0.15s; }
.aj-preloader-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes aj-bounce {
    from { transform: translateY(0); opacity: 0.4; }
    to   { transform: translateY(-12px); opacity: 1; }
}

/* ---------- Header Wrapper ---------- */
.aj-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    background: var(--aj-header-bg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    font-family: var(--aj-font);
    transition: box-shadow var(--aj-transition);
}
.aj-header.aj-scrolled {
    box-shadow: 0 4px 24px rgba(0,0,0,0.28);
}

/* Header inner: single row, flex layout */
.aj-header-inner {
    display: flex;
    align-items: center;
    height: var(--aj-header-height);
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 16px;
}

/* Spacer so page content doesn't hide under fixed header */
.aj-header-spacer {
    height: var(--aj-header-height);
}

/* ---------- Brand (Logo + Name) ---------- */
.aj-brand { flex-shrink: 0; }

.aj-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--aj-text-light);
}
.aj-brand-link:hover { text-decoration: none; color: var(--aj-text-light); }

/* If no logo image, show book icon */
.aj-brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    background: var(--aj-accent);
    border-radius: var(--aj-radius);
    font-size: 18px;
    flex-shrink: 0;
}

/* Custom logo image sizing */
.aj-brand-link .custom-logo {
    height: 38px;
    width: auto;
    border-radius: 4px;
}

.aj-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.aj-brand-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--aj-text-light);
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.aj-brand-sub {
    font-size: 10px;
    color: var(--aj-text-muted);
    letter-spacing: 0.6px;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* ---------- Desktop Navigation ---------- */
.aj-desktop-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.aj-nav-list {
    list-style: none;
    margin: 0; padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.aj-nav-list li { position: relative; }

.aj-nav-list > li > a {
    display: block;
    padding: 8px 14px;
    color: var(--aj-text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--aj-radius);
    transition: color var(--aj-transition), background var(--aj-transition);
    white-space: nowrap;
}
.aj-nav-list > li > a:hover,
.aj-nav-list > li.current-menu-item > a,
.aj-nav-list > li.current-page-ancestor > a {
    color: var(--aj-text-light);
    background: rgba(255,255,255,0.1);
}

/* Dropdown sub-menu */
.aj-nav-list .sub-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 200px;
    background: var(--aj-dropdown-bg);
    border-radius: var(--aj-radius);
    box-shadow: var(--aj-dropdown-shadow);
    list-style: none;
    padding: 6px 0;
    margin: 0;
    z-index: 100;
    animation: aj-fadedown 0.18s ease;
}
.aj-nav-list li:hover > .sub-menu,
.aj-nav-list li:focus-within > .sub-menu { display: block; }

.aj-nav-list .sub-menu li a {
    display: block;
    padding: 9px 18px;
    color: #333;
    font-size: 14px;
    text-decoration: none;
    transition: background var(--aj-transition), color var(--aj-transition);
}
.aj-nav-list .sub-menu li a:hover {
    background: #f4f7fb;
    color: var(--aj-accent);
}

@keyframes aj-fadedown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Header Actions ---------- */
.aj-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Generic icon button */
.aj-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--aj-text-muted);
    font-size: 16px;
    padding: 6px 8px;
    border-radius: var(--aj-radius);
    transition: color var(--aj-transition), background var(--aj-transition);
    line-height: 1;
}
.aj-icon-btn:hover {
    color: var(--aj-text-light);
    background: rgba(255,255,255,0.1);
}

/* Auth Buttons */
.aj-auth-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aj-btn-outline {
    padding: 7px 16px;
    border: 1.5px solid rgba(255,255,255,0.5);
    border-radius: var(--aj-radius);
    color: var(--aj-text-light);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--aj-transition);
    white-space: nowrap;
}
.aj-btn-outline:hover {
    border-color: var(--aj-text-light);
    background: rgba(255,255,255,0.08);
    color: var(--aj-text-light);
    text-decoration: none;
}

.aj-btn-solid {
    padding: 7px 16px;
    background: var(--aj-accent);
    border: 1.5px solid var(--aj-accent);
    border-radius: var(--aj-radius);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--aj-transition);
    white-space: nowrap;
}
.aj-btn-solid:hover {
    background: var(--aj-accent-hover);
    border-color: var(--aj-accent-hover);
    color: #fff;
    text-decoration: none;
}

.aj-btn-outline.aj-full,
.aj-btn-solid.aj-full {
    display: block;
    text-align: center;
    width: 100%;
    margin-bottom: 8px;
}

/* ---------- User Menu Dropdown ---------- */
.aj-user-menu { position: relative; }

.aj-user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid var(--aj-border-light);
    border-radius: 32px;
    padding: 4px 12px 4px 4px;
    cursor: pointer;
    color: var(--aj-text-light);
    font-size: 13px;
    font-weight: 500;
    transition: background var(--aj-transition);
}
.aj-user-btn:hover { background: rgba(255,255,255,0.18); }

.aj-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
}
.aj-avatar-lg {
    width: 42px; height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.aj-user-btn .fa-chevron-down {
    font-size: 10px;
    opacity: 0.7;
    transition: transform var(--aj-transition);
}
.aj-user-menu.aj-open .fa-chevron-down { transform: rotate(180deg); }

.aj-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: var(--aj-dropdown-bg);
    border-radius: var(--aj-radius);
    box-shadow: var(--aj-dropdown-shadow);
    overflow: hidden;
    z-index: 200;
    animation: aj-fadedown 0.18s ease;
}
.aj-user-menu.aj-open .aj-dropdown { display: block; }

.aj-dropdown-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid #eee;
    background: #f8fafc;
}
.aj-dropdown-profile strong {
    display: block;
    font-size: 14px;
    color: #1a1a1a;
    line-height: 1.3;
}
.aj-dropdown-profile span {
    font-size: 12px;
    color: #888;
}

.aj-drop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    color: #333;
    font-size: 14px;
    text-decoration: none;
    transition: background var(--aj-transition), color var(--aj-transition);
}
.aj-drop-item:hover {
    background: #f4f7fb;
    color: var(--aj-accent);
    text-decoration: none;
}
.aj-drop-item i { font-size: 14px; width: 16px; }
.aj-drop-logout:hover { color: #e74c3c; background: #fff5f5; }

/* ---------- Search Bar (slides down) ---------- */
.aj-search-bar {
    background: #122d49;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.aj-search-bar.aj-open { max-height: 80px; }

.aj-search-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 24px;
}
.aj-search-inner form {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--aj-border-light);
    border-radius: var(--aj-radius);
    padding: 0 14px;
}
.aj-search-inner form i {
    color: var(--aj-text-muted);
    font-size: 14px;
    flex-shrink: 0;
}
.aj-search-inner input[type="search"] {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--aj-text-light);
    font-size: 15px;
    padding: 10px 0;
    font-family: var(--aj-font);
}
.aj-search-inner input::placeholder { color: var(--aj-text-muted); }
.aj-search-close {
    background: none;
    border: none;
    color: var(--aj-text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: color var(--aj-transition);
    flex-shrink: 0;
}
.aj-search-close:hover { color: var(--aj-text-light); }

/* ---------- Hamburger (mobile) ---------- */
.aj-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 4px;
    width: 36px;
}
.aj-hamburger span {
    display: block;
    height: 2px;
    background: var(--aj-text-light);
    border-radius: 2px;
    transition: all 0.25s ease;
    transform-origin: center;
}
/* Animate to X when open */
.aj-hamburger.aj-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.aj-hamburger.aj-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.aj-hamburger.aj-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Mobile Drawer ---------- */
.aj-mobile-drawer {
    position: fixed;
    top: 0; right: 0;
    width: var(--aj-drawer-width);
    max-width: 85vw;
    height: 100%;
    background: #fff;
    z-index: 1100;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow-y: auto;
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
}
.aj-mobile-drawer.aj-open {
    transform: translateX(0);
}

.aj-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--aj-header-bg);
    color: var(--aj-text-light);
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.aj-drawer-close {
    background: none;
    border: none;
    color: var(--aj-text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color var(--aj-transition);
}
.aj-drawer-close:hover { color: var(--aj-text-light); }

.aj-drawer-menu {
    list-style: none;
    margin: 0; padding: 8px 0;
    flex: 1;
}
.aj-drawer-menu li a {
    display: block;
    padding: 13px 20px;
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    transition: background var(--aj-transition), color var(--aj-transition);
}
.aj-drawer-menu li a:hover {
    background: #f4f7fb;
    color: var(--aj-accent);
}
.aj-drawer-menu .sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f8fafc;
}
.aj-drawer-menu .sub-menu li a {
    padding-left: 36px;
    font-size: 14px;
    color: #555;
}

.aj-drawer-auth {
    padding: 16px 20px 24px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}
.aj-drawer-auth .aj-btn-outline,
.aj-drawer-auth .aj-btn-solid {
    border-color: var(--aj-accent);
    color: var(--aj-accent);
}
.aj-drawer-auth .aj-btn-outline:hover {
    background: #f0f7fc;
}
.aj-drawer-auth .aj-btn-solid {
    background: var(--aj-accent);
    color: #fff;
    margin-top: 2px;
}

/* Overlay */
.aj-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.aj-overlay.aj-open {
    opacity: 1;
    visibility: visible;
}

/* ---------- Utility ---------- */
.aj-hide-sm { /* hidden on small screens, shown via media query below */ }

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

/* Tablet & Mobile: hide desktop nav, show hamburger */
@media (max-width: 991px) {
    .aj-desktop-nav { display: none; }
    .aj-hamburger { display: flex; }
    .aj-auth-btns { display: none; }
    .aj-user-btn .aj-hide-sm { display: none; }
    .aj-user-btn { padding: 4px; border-radius: 50%; }
    .aj-brand-sub { display: none; }
}

/* Small mobile */
@media (max-width: 480px) {
    .aj-header-inner { padding: 0 14px; gap: 10px; }
    .aj-search-inner { padding: 10px 14px; }
    .aj-brand-title { font-size: 14px; }
}

/* Desktop: hide hamburger */
@media (min-width: 992px) {
    .aj-hamburger { display: none; }
    .aj-hide-sm { display: inline; }
}
