/* Header mega menus — Authors & Books */

.nav-mega {
    position: relative;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.nav-mega__trigger {
    gap: 0.35rem;
}

.nav-mega__caret {
    font-size: 0.6rem;
    opacity: 0.65;
    transition: transform 0.2s ease;
}

.nav-mega.is-open .nav-mega__caret {
    transform: rotate(180deg);
}

.nav-mega__panel {
    position: absolute;
    top: 100%;
    left: 0;
    width: min(920px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.14);
    opacity: 0;
    pointer-events: none;
    transition: none;
    z-index: 1060;
    overflow: visible;
    /* Keep visibility:visible so decoded images stay warm after first open */
}

.nav-mega__inner {
    display: grid;
    grid-template-columns: 210px 1fr;
    min-height: 280px;
    overflow: hidden;
    border-radius: 1.25rem;
}

/* Keep hover alive across the short gap under the navbar */
.nav-mega__panel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 14px;
}

.nav-mega.is-open .nav-mega__panel {
    opacity: 1;
    pointer-events: auto;
}

.nav-mega__intro {
    padding: 1.5rem 1.25rem;
    background:
        radial-gradient(circle at top left, rgba(236, 53, 47, 0.18), transparent 55%),
        linear-gradient(160deg, #121C39 0%, #253A73 55%, #7D1C19 140%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.nav-mega__intro--books {
    background:
        radial-gradient(circle at top left, rgba(245, 158, 11, 0.22), transparent 55%),
        linear-gradient(160deg, #0B1124 0%, #253A73 50%, #7D1C19 140%);
}

.nav-mega__eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.75;
    margin-bottom: 0.5rem;
}

.nav-mega__title {
    font-family: var(--font-heading), "Playfair Display", serif;
    font-size: 1.55rem !important;
    font-weight: 700;
    color: #fff !important;
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

.nav-mega__copy {
    font-size: 0.82rem;
    line-height: 1.5;
    opacity: 0.85;
    margin-bottom: 1.1rem;
}

.nav-mega__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35);
    padding-bottom: 0.15rem;
    width: fit-content;
    transition: opacity 0.2s ease;
}

.nav-mega__cta:hover {
    color: #fff;
    opacity: 0.85;
}

.nav-mega__grid {
    padding: 1.1rem 1.15rem 1.25rem;
    max-height: min(420px, 60vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

.nav-mega__grid--authors {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem 0.75rem;
    align-content: start;
}

.nav-mega__grid--books {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    align-content: start;
}

/* Faster paint for long lists (100+) */
.mega-author,
.mega-book {
    content-visibility: auto;
    contain-intrinsic-size: 56px;
}

.nav-mega__empty {
    grid-column: 1 / -1;
    color: #6b7280;
    font-size: 0.875rem;
    margin: 1rem 0;
}

/* Author cards */
.mega-author {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.9rem;
    text-decoration: none;
    color: #111827;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.mega-author:hover {
    background: #FEF0EF;
    color: var(--color-primary);
    transform: translateY(-1px);
}

.mega-author__avatar {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0.35rem;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.mega-author__avatar img,
.mega-author__fallback {
    width: 100%;
    height: 100%;
    border-radius: 0.35rem;
    object-fit: cover;
}

.mega-author__avatar img.mega-lazy:not([src]) {
    opacity: 0;
}

.mega-author__avatar img.is-loaded {
    opacity: 1;
}

.mega-author__fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #FEF0EF, #e8eef8);
    color: #9ca3af;
}

.mega-author__name {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.25;
}

/* Book cards */
.mega-book {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem;
    border-radius: 0.85rem;
    text-decoration: none;
    color: #111827;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.mega-book:hover {
    background: #f8fafc;
    border-color: #e5e7eb;
    color: var(--color-secondary);
    transform: translateY(-1px);
}

.mega-book__cover {
    position: relative;
    width: 42px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 0.35rem;
    overflow: hidden;
    background: #f3f4f6;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.12);
}

.mega-book__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mega-book__cover img.mega-lazy:not([src]) {
    opacity: 0;
}

.mega-book__cover img.is-loaded {
    opacity: 1;
}

.mega-book__fallback {
    width: 100%;
    height: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #a1a1aa;
    background: linear-gradient(160deg, #f3f4f6, #e5e7eb);
}

.mega-book__meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.mega-book__title {
    font-size: 0.8rem;
    font-weight: 650;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile accordion lists */
.mobile-mega {
    width: 100%;
}

.mobile-mega__summary {
    list-style: none;
    cursor: pointer;
    width: 100%;
}

.mobile-mega__summary::-webkit-details-marker {
    display: none;
}

.mobile-mega__list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem 0.75rem;
    max-height: min(320px, 50vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.mobile-mega__item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 0.55rem;
    border-radius: 0.75rem;
    color: #374151;
    text-decoration: none;
}

.mobile-mega__item:hover {
    background: #f9fafb;
    color: var(--color-primary);
}

.mobile-mega__item img {
    width: 36px;
    height: 36px;
    border-radius: 0.35rem;
    object-fit: cover;
}

.mobile-mega__item--book img {
    width: 30px;
    height: 42px;
    border-radius: 0.25rem;
}

.mobile-mega__item span {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.mobile-mega__item strong {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.25;
}

.mobile-mega__item small {
    color: #6b7280;
    font-size: 0.72rem;
}

.mobile-mega__icon {
    width: 36px;
    height: 36px;
    border-radius: 0.35rem;
    background: #f3f4f6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.mobile-mega__all {
    display: block;
    padding: 0.5rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}

@media (max-width: 1100px) {
    .nav-mega__panel {
        width: min(820px, calc(100vw - 2rem));
    }

    .nav-mega__grid--authors,
    .nav-mega__grid--books {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .nav-mega__panel {
        display: none;
    }
}

/* Prevent page horizontal scroll from crowded laptop nav */
html,
body {
    overflow-x: clip;
}

.bpa-nav {
    flex-wrap: nowrap;
    max-width: 100%;
    min-width: 0;
}

.bpa-nav .header-link {
    white-space: nowrap;
}

.nav-label-short {
    display: none;
}

@media (max-width: 1399.98px) {
    .bpa-header-inner {
        min-height: 100px;
    }

    header .logo {
        --logo-height: 120px;
        --header-h: 100px;
        margin: 0 4px;
    }

    /* .bpa-nav {
        gap: 0 !important;
    } */

    .bpa-nav .header-link {
        padding: 0.4rem 0.45rem;
        font-size: 0.78rem;
    }
}

@media (max-width: 1199.98px) {
    .bpa-header-inner {
        min-height: 96px;
    }

    header .logo {
        --logo-height: 108px;
        --header-h: 96px;
        margin: 0 2px;
    }

    .bpa-nav .header-link {
        padding: 0.35rem 0.28rem;
        font-size: 0.72rem;
    }

    .nav-label-full {
        display: none;
    }

    .nav-label-short {
        display: inline;
    }
}
