/* Brand cluster: LIBRARY mark stays primary; parent-site exit is quieter (university-masthead pattern).
   Header min-height mirrors the English wrapped-nav masthead so BG/EN share the same vertical band. */
.header .header-main {
    display: flex;
    align-items: center;
    gap: 1rem 1.25rem;
    min-height: 104px;
}

.header .brand-cluster {
    flex: 0 0 auto;
    margin-left: -8px;
    margin-right: 0.85rem;
    max-width: 40%;
    position: relative;
    z-index: 2;
}

.header .logo-bar {
    display: flex;
    align-items: center;
    gap: 1.85rem;
    min-width: 0;
}

.header .logo {
    flex: 0 0 auto;
    position: relative;
}

.header .logo::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -0.95rem;
    width: 1px;
    height: 1.35rem;
    background: rgba(70, 80, 95, 0.18);
    transform: translateY(-50%);
}

.header .logo-link {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.header .logo img {
    max-width: 176px;
    max-height: 50px;
    width: auto;
    height: auto;
    display: block;
    filter: contrast(1.08) saturate(1.05);
}

/* Quiet masthead exit — plain utility link, not a pill/chip */
.header .helis-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex: 0 0 auto;
    min-width: 0;
    max-width: none;
    padding: 0.2rem 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #3d4654;
    font-family: Montserrat, Poppins, sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    line-height: 1.2;
    text-decoration: none;
    text-transform: none;
    white-space: nowrap;
    text-align: left;
    transition: color 0.18s ease;
}

.header .helis-back-link__chevron {
    flex: 0 0 auto;
    width: 0.42rem;
    height: 0.42rem;
    margin-top: -0.05rem;
    border-left: 1.75px solid currentColor;
    border-bottom: 1.75px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.18s ease;
}

.header .helis-back-link__label {
    position: relative;
    padding-bottom: 0.1rem;
}

.header .helis-back-link__label::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: currentColor;
    opacity: 0.28;
    transform: scaleX(1);
    transform-origin: left center;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.header .helis-back-link:hover,
.header .helis-back-link:focus {
    color: #1a2330;
    background: transparent;
    border: 0;
    text-decoration: none;
    outline: none;
}

.header .helis-back-link:hover .helis-back-link__chevron,
.header .helis-back-link:focus .helis-back-link__chevron {
    transform: rotate(45deg) translate(-1.5px, 1.5px);
}

.header .helis-back-link:hover .helis-back-link__label::after,
.header .helis-back-link:focus .helis-back-link__label::after {
    opacity: 0.7;
    transform: scaleX(1);
}

.header .helis-back-link:focus-visible {
    outline: 1px solid rgba(36, 48, 65, 0.35);
    outline-offset: 3px;
}

.header .header-nav {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0;
    margin-right: 0.5rem;
    justify-content: center;
    position: relative;
    z-index: 1;
    overflow: hidden;
}

.header .header-nav .navbar-collapse,
.header .header-nav .primary-menu {
    min-width: 0;
}

/* Keep search / login / language in their own slot so they never sit on top of the nav. */
.header .header-utils {
    flex: 0 0 auto;
    margin-left: auto;
    margin-right: 0;
    padding-left: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    z-index: 3;
}

.header .header-utils .menu-icons {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.header .header-utils .menu-icons > div {
    flex: 0 0 auto;
}

.header .header-utils .menu-icons a {
    padding: 0.65rem 0.45rem;
}

.header .menu-toggler {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    flex: 0 0 22px;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-left: 0.85rem;
    align-self: center;
    z-index: 4;
}

.header .menu-toggler .bar {
    top: 50%;
    transform: translateY(-50%);
}

/* Header controls are not text fields. A tap was leaving a blinking caret. */
.header {
    caret-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

.header .search-input {
    caret-color: auto;
    -webkit-user-select: text;
    user-select: text;
}

.header .menu-toggler:focus,
.header .menu-toggler:focus-visible {
    outline: none;
}

.theme-dark .header .logo::after,
body.dark .header .logo::after {
    background: rgba(255, 255, 255, 0.2);
}

.theme-dark .header .helis-back-link,
body.dark .header .helis-back-link {
    color: rgba(255, 255, 255, 0.78);
    border: 0;
    background: transparent;
}

.theme-dark .header .helis-back-link:hover,
.theme-dark .header .helis-back-link:focus,
body.dark .header .helis-back-link:hover,
body.dark .header .helis-back-link:focus {
    color: #ffffff;
    border: 0;
    background: transparent;
}

.theme-dark .header .helis-back-link:focus-visible,
body.dark .header .helis-back-link:focus-visible {
    outline-color: rgba(242, 245, 248, 0.45);
}

/*
 * Phones and tablet portrait use the hamburger, placed to the right of
 * the search / login / language icons.
 */
@media (max-width: 1023.98px) {
    /* Sticky plugin often freezes a too-tall spacer after the header wraps. */
    .sticky-wrapper {
        height: auto !important;
    }

    .header {
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .header .menu-toggler {
        display: block;
        height: 22px;
        margin-left: 0.45rem;
    }

    .header .navbar-expand-xl .navbar-collapse {
        display: none !important;
        flex-basis: 100%;
        flex-grow: 1;
    }

    .header .navbar-expand-xl .navbar-collapse.show {
        display: block !important;
    }

    .header .header-main {
        flex-wrap: wrap;
        min-height: 56px;
        gap: 0.4rem 0.65rem;
        align-items: center;
    }

    .header .brand-cluster {
        margin-left: -4px;
        margin-right: 0;
        max-width: calc(100% - 110px);
    }

    .header .header-nav {
        order: 3;
        flex: 1 0 100%;
        margin-right: 0;
        overflow: visible;
        min-height: 0;
    }

    .header .header-utils {
        margin-right: 0;
        margin-left: auto;
        padding-left: 0;
        gap: 0.2rem;
    }

    .header .header-utils .menu-icons {
        gap: 0.05rem;
    }

    .header .header-utils .menu-icons a {
        padding: 0.55rem 0.35rem;
    }

    .header .logo-bar {
        gap: 0.85rem;
    }

    .header .logo::after {
        right: -0.45rem;
        height: 1.05rem;
    }

    .header .logo img {
        max-width: 148px;
        max-height: 42px;
    }

    .header .helis-back-link {
        font-size: 0.72rem;
        gap: 0.4rem;
    }

    /* Page sections and their first title carry the white band under the header. */
    .single-book,
    .page,
    .blog-posts,
    .authors-listing,
    .home-book-list,
    .books-listing,
    .error-page,
    .single-author,
    .single-publisher,
    .single-post {
        margin-top: 0;
    }

    .page .container > .row > div > h1:first-child,
    .error-page h1,
    .single-book h1,
    .single-author h1,
    .single-publisher h1,
    .single-post h1,
    .blog-posts h1:first-of-type,
    .authors-listing h1:first-of-type,
    .books-listing h1:first-of-type,
    .books-listing .book-filter h2,
    .home-book-list > .container > .section-title:first-child,
    .section-title:first-child h2 {
        margin-top: 8px;
    }
}

/* iPad landscape (1024) through just under the desktop container: one row of tabs. */
@media (min-width: 1024px) and (max-width: 1199.98px) {
    .header .navbar-expand-xl .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }

    .header .navbar-expand-xl .navbar-nav {
        flex-direction: row;
    }

    .header .menu-toggler {
        display: none;
    }

    .header .header-main {
        flex-wrap: nowrap;
        min-height: 84px;
        gap: 0.35rem;
    }

    .header .header-nav {
        order: 0;
        flex: 1 1 auto;
        overflow: visible;
        margin-right: 0.2rem;
    }

    .header .brand-cluster {
        max-width: none;
        margin-left: 0;
        margin-right: 0.2rem;
    }

    .header .logo-bar {
        gap: 0.55rem;
    }

    .header .logo img {
        max-width: 112px;
        max-height: 34px;
    }

    .header .helis-back-link {
        font-size: 0.6rem;
        gap: 0.28rem;
    }

    .header .primary-menu > li > a {
        padding: 0.85rem 0.45rem;
        font-size: 0.64rem;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .header .header-utils {
        padding-left: 0.15rem;
    }

    .header .header-utils .menu-icons a {
        padding: 0.4rem 0.22rem;
    }
}

@media (min-width: 1200px) {
    .header .navbar-expand-xl .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }

    .header .menu-toggler {
        display: none;
    }

    .header .header-nav {
        overflow: visible;
        margin-right: 0.65rem;
    }

    .header .brand-cluster {
        max-width: 28%;
    }

    .header .primary-menu > li > a {
        padding-left: 0.45rem;
        padding-right: 0.45rem;
        font-size: 0.78rem;
        white-space: nowrap;
    }

    .header .header-utils .menu-icons a {
        padding: 0.65rem 0.35rem;
    }
}

/* Nest Hub Max (1280x800): the six tabs do not reliably fit beside the icons.
   Use the burger instead of clipping the last labels off the right edge. */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .sticky-wrapper {
        height: auto !important;
        max-width: 100%;
    }

    .header .menu-toggler {
        display: block;
        flex: 0 0 22px;
        width: 22px;
        height: 22px;
        margin-left: 0.65rem;
    }

    .header .navbar-expand-xl .navbar-collapse {
        display: none !important;
        flex-basis: 100%;
        flex-grow: 1;
    }

    .header .navbar-expand-xl .navbar-collapse.show {
        display: block !important;
    }

    .header .header-main {
        flex-wrap: wrap;
        align-items: center;
        min-width: 0;
        max-width: 100%;
        gap: 0.4rem 0.75rem;
    }

    .header .header-nav {
        order: 3;
        flex: 1 0 100%;
        min-width: 0;
        margin-right: 0;
        overflow: visible;
    }

    .header .brand-cluster {
        flex: 1 1 auto;
        max-width: calc(100% - 150px);
        min-width: 0;
        overflow: hidden;
    }

    .header .logo-bar {
        gap: 0.75rem;
        min-width: 0;
    }

    .header .logo img {
        max-width: 150px;
        max-height: 44px;
    }

    .header .helis-back-link {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 0.75rem;
        overflow: hidden;
    }

    .header .helis-back-link__label {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header .header-utils {
        flex: 0 0 auto;
        margin-left: auto;
        z-index: 6;
        background: transparent;
    }

    .header .primary-menu > li > a {
        white-space: normal;
    }
}

.theme-dark .header .header-utils,
body.dark .header .header-utils {
    background: transparent;
}

@media (max-width: 1399.98px) {
    .books-listing .book-grid .book .book-title,
    .books-listing .book-grid .book .book-title a,
    .books-listing .book-list .book .book-title,
    .books-listing .book-list .book .book-title a,
    .books-listing .book-mini-list .book .book-title,
    .books-listing .book-mini-list .book .book-title a {
        overflow: visible;
        text-overflow: unset;
        white-space: normal;
        height: auto;
    }
}

@media (max-width: 575.98px) {
    .header {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .header .header-main {
        gap: 0.35rem 0.5rem;
        min-height: 52px;
    }

    .header .brand-cluster {
        margin-left: 0;
        max-width: calc(100% - 132px);
    }

    .header .logo-bar {
        gap: 0.55rem;
    }

    .header .logo::after {
        display: none;
    }

    .header .logo img {
        max-width: 128px;
        max-height: 36px;
    }

    .header .brand-cluster {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .header .logo-bar {
        width: 100%;
        min-width: 0;
    }

    .header .helis-back-link {
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
        font-size: 0.68rem;
        gap: 0.35rem;
        white-space: nowrap;
        line-height: 1.2;
        overflow: hidden;
    }

    .header .helis-back-link__label {
        display: block;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header .header-utils {
        flex: 0 0 auto;
        flex-shrink: 0;
    }

    .header .header-main {
        max-width: 100%;
    }

    .header .helis-back-link__chevron {
        align-self: center;
        margin-top: 0;
    }

    .header .menu-toggler {
        height: 22px;
        flex-basis: 20px;
        width: 20px;
        margin-left: 0.3rem;
    }

    .header .header-utils .menu-icons a {
        padding: 0.45rem 0.28rem;
    }
}

/* Search panel: sit under the magnifier on the right, about 1/3 width. */
.header {
    overflow: visible;
}

.header > .container {
    position: relative;
}

.header .search-header {
    width: 33.333vw;
    max-width: 28rem;
    min-width: 16rem;
    top: 100%;
    right: 0;
    left: auto;
    margin-top: 0.4rem;
    z-index: 40;
    box-shadow: 0 10px 28px rgba(18, 25, 33, 0.14);
    border-radius: 8px;
    overflow: hidden;
}

.header .search-header form {
    position: relative;
    margin: 0;
}

.header .search-header .search-input {
    border-radius: 8px;
    border-color: #e4e7ec;
    font-size: 0.95rem;
    padding: 0.7rem 2.75rem 0.7rem 2.75rem;
}

.header .search-header button[type=submit] {
    top: 50%;
    transform: translateY(-50%);
    left: 0.35rem;
}

.header .search-header .search-close {
    top: 50%;
    transform: translateY(-50%);
    right: 0.75rem;
}

html[dir=rtl] .header .search-header {
    right: auto;
    left: 0;
}

html[dir=rtl] .header .search-header button[type=submit] {
    left: auto;
    right: 0.35rem;
}

html[dir=rtl] .header .search-header .search-close {
    right: auto;
    left: 0.75rem;
}

@media (max-width: 1199.98px) {
    .header .search-header {
        width: 40vw;
        min-width: 15rem;
    }
}

@media (max-width: 991.98px) {
    .header .search-header {
        width: 52vw;
        min-width: 14rem;
        max-width: none;
    }
}

@media (max-width: 767.98px) {
    .header .search-header {
        width: 70vw;
        min-width: 12.5rem;
    }
}

/* A long word in a title was widening the column past the screen.
   The body hides horizontal overflow, so the right edge was clipped. */
.row > [class*="col-"] {
    min-width: 0;
}

h1,
h2,
h3,
h4,
.book-title,
.book-title a,
.book-short-description,
.page-content,
.index-page-content,
.single-book,
.books-listing,
.single-post,
.blog-posts {
    overflow-wrap: break-word;
}

@media (max-width: 767.98px) {
    .single-book h1,
    .page h1,
    .blog-posts h1,
    .single-post h1,
    .single-author h1,
    .authors-listing h1,
    .books-listing h1 {
        font-size: 1.55rem;
        line-height: 1.3;
    }
}

@media (max-width: 575.98px) {
    .header .search-header {
        width: 100%;
        min-width: 0;
        max-width: none;
        right: 0;
        margin-top: 0.25rem;
    }

    html[dir=rtl] .header .search-header {
        left: 0;
        right: auto;
    }
}
