/* Header / Navbar */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    background: var(--primary-bg-color);
    border-bottom: 2px solid var(--tertiary-bg-color);
    display: flex;
    justify-content: center;
}

.header-loading .header-contents {
    min-height: 52px;
}

.header-loading .header-placeholder {
    width: 100%;
    color: var(--primary-color);
    font-size: 2.1rem;
    font-weight: 800;
}

.header-nav-element,
.header-icon-link,
.header-searchbar {
    color: var(--primary-color);
}

.header-contents {
    min-width: min(90vw, 1450px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 10px 0;
}

.header-highlight {
    padding: 0.7rem;
    border-radius: 10px;
}

.header-highlight:hover {
    background-color: var(--tertiary-bg-color);
}

.header-nav-container {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-nav-element {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
}

.header-brand h1 {
    margin: 0;
    font-size: 2.1rem;
    line-height: 1;
    letter-spacing: -0.03em;
}

.header-bag{
    position: relative;
}

.header-brand {
    margin-right: 0.75rem;
}

.header-login {
    margin-left: 0.75rem;
}

.header-searchbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 340px;
    min-width: 240px;
    max-width: 370px;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    border: 2px solid var(--accent-color);
    color: var(--secondary-color);
    cursor: text;
}

.header-searchbar input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
}

.header-searchbar input::placeholder {
    color: var(--secondary-color);
}

.header-searchbar svg {
    flex-shrink: 0;
}

.header-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: none;
    text-decoration: none;
    line-height: 0;
    cursor: pointer;
}

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

/* Hamburger nav menu  */

.menu-dropdown-wrapper {
    order: 4;
    cursor: pointer;
    position: relative; 
    display: inline-flex;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    /* BELOW the button */
    right: 0;
    /* align to right side */
    left: auto;
    /* cancel left: 0 */
    width: max-content;
    /* shrink to content */
    min-width: 180px;

    background: white;
    display: none;
    flex-direction: column;

    border: 1px solid var(--tertiary-color);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 9999;
}

.dropdown-menu a {
    padding: 12px 16px;
    text-decoration: none;
    color: var(--primary-color);
    display: block;
}

.dropdown-menu a:hover {
    background: var(--secondary-bg-color);
}

/* Carousel wrapper */

.book-section {
    padding: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.section-title {
    font-size: 28px;
    color: var(--primary-color);
    font-weight: 600;
}

.view-all-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-weight: 500;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    transition: color 0.2s;
}

.view-all-btn:hover {
    text-decoration: underline;
}

.books-carousel {
    gap: 1rem;
    width: 100%;
    padding: 4px 0 28px 0;
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.books-carousel::-webkit-scrollbar {
    display: none;
}

.books-carousel>.bookcard-frame {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

/* Carousel buttons */

.carousel-nav-btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 42px;
    height: 42px;
    transform: translateY(-50%);
    border: 1px solid var(--accent-color);
    border-radius: 999px;
    background-color: var(--primary-bg-color);
    color: var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.carousel-nav-btn[data-carousel-direction="prev"] {
    left: -3rem;
}

.carousel-nav-btn[data-carousel-direction="next"] {
    right: -3rem;
}

.carousel-nav-btn:hover:not(:disabled) {
    background-color: var(--tertiary-bg-color);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.carousel-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Card for Books */

.bookcard {
    width: 250px;
    font-weight: 500;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: box-shadow 0.3s ease;
}

.bookcard-frame {
    display: inline-block;
}

.featured-carousel-shell {
    position: relative;
}

.bookcard img {
    height: 220px;
}

.bookcard-img-container {
    position: relative;
    display: flex;
    justify-content: center;
    background-color: var(--secondary-bg-color);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 18px 0;
    margin-bottom: 4px;
}

.bookcard-like {
    position: absolute;
    bottom: 12px;
    right: 36px;
    cursor: pointer;
    pointer-events: auto;
}

.bookcard-like path {
    fill: var(--secondary-color);
    transition: fill 0.2s ease;
}

.bookcard-like:hover path {
    fill: var(--like-color) !important;
}

.bookcard-formats {
    background-color: var(--secondary-bg-color);
    padding: 7px 9px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.bookcard-formats span {
    display: flex;
    gap: 3px;
    justify-content: center;
    align-items: center;
}

.bookcard-formats-group {
    display: flex;
    gap: 12px;
}

.bookcard-detail-header {
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    font-weight: 600;
    border-bottom: 2px solid var(--tertiary-bg-color);
}

.bookcard-detail-header-title {
    align-items: center;
    justify-content: center;
    font-size: 18px;
    max-width: 150px;
}

.bookcard-detail-descriptor {
    display: flex;
    justify-content: space-between;
    padding: 4px 9px;
    font-size: 14px;
}

.bookcard-detail-meta {
    display: flex;
    justify-content: space-between;
    padding: 0 9px;
}

.bookcard-detail-meta span{
    max-width: 110px;
}

.bookcard:hover {
    background-color: var(--secondary-bg-color);
    box-shadow:
        0 12px 20px rgba(0, 0, 0, 0.20);
}

.rating-badge {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background-color: var(--raiting-color);
    color: var(--primary-color);
    font-size: 16px;
    font-weight: 700;
}

/* FOOTER */
.footer {
    margin-top: 40px;
    padding: 40px;
    background: var(--tertiary-bg-color);
    color: var(--primary-color);
    font-size: 14px;
}

.footer h3,h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.footer-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.footer-item {
    margin-bottom: 4px;
    list-style-type: none;
}

.footer ul{
    padding-left: 10px;
    margin-bottom: 20px;
}

.footer a {
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.cart-badge{
    position: absolute;
    top: -6px;
    right: -8px;

    display: flex;
    align-items: center;
    justify-content: center;

    min-width: 18px;
    height: 18px;
    padding: 0 4px;

    border-radius: 999px;

    background: var(--accept-bg-color);
    color: var(--primary-bg-color) !important;

    font-size: 12px !important;
    font-weight: 700;
    line-height: 1;
    z-index: 1001;

    pointer-events: none;
}

.cart-is-open {
    overflow: hidden;
}

.cart-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    visibility: hidden;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-overlay.open {
    visibility: visible;
    opacity: 1;
}

.cart-sidebar.open {
    right: 0;
}

.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 8px 24px;
    border-bottom: 1px solid var(--tertiary-color);
}

.cart-header h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 20px;
}

#cart-count-badge {
    color: var(--secondary-color);
    font-size: 14px;
    font-weight: 500;
}

.close-btn,
.remove-cart-item {
    border: 1px solid var(--tertiary-color);
    border-radius: 6px;
    background: white;
    color: var(--primary-color);
    cursor: pointer;
}

.close-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
}

.cart-items-container {
    flex: 1;
    overflow-y: auto;
}

.empty-cart-message {
    margin: 24px;
    color: var(--secondary-color);
}

.cart-item-card {
    display: grid;
    grid-template-columns: 60px minmax(0, 1fr) auto;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--tertiary-color);
}

.cart-item-card img {
    width: 60px;
    height: 84px;
    object-fit: cover;
    border-radius: 4px;
}

.cart-item-info {
    min-width: 0;
}

.cart-item-info h3 {
    margin: 0 0 4px;
    color: var(--primary-color);
    font-size: 14px;
}

.cart-item-author,
.cart-item-meta {
    margin: 0 0 8px;
    color: var(--secondary-color);
    font-size: 12px;
}

.cart-item-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.remove-cart-item {
    padding: 5px 8px;
    color: var(--secondary-color);
    font-size: 12px;
}

.cart-footer {
    display: grid;
    gap: 16px;
    padding: 24px;
    background: var(--secondary-bg-color);
    text-align: center;
}

.product-cart-controls button,
.quantity-stepper button {
    min-width: 40px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
}

.product-cart-controls,
.quantity-stepper {
    display: grid;
    grid-template-columns: 40px minmax(44px, auto) 40px;
    align-items: center;
    overflow: hidden;
    width: fit-content;
    border: 1px solid var(--tertiary-color);
    border-radius: 10px;
    background: var(--primary-bg-color);
}

.product-cart-controls span,
.quantity-stepper span {
    min-width: 44px;
    padding: 6px 10px;
    border-radius: 4px;
    background: var(--secondary-bg-color);
    color: var(--primary-color);
    font-weight: 800;
    text-align: center;
}

.btn-checkout {
    border: 0;
    border-radius: 8px;
    color: var(--primary-bg-color);
    cursor: pointer;
    font-weight: 800;
    background-color: var(--accept-bg-color);
    width: 100%;
    padding: 16px;
}


@media (max-width: 900px) {
    .header {
        padding: 0.65rem 1.25rem 0.8rem;
    }

    .header-contents {
        flex-wrap: wrap;
        margin: 0;
    }

    .header-primary {
        flex: 1 1 auto;
        min-width: 0;
    }

    .header-primary .header-nav-element:not(.header-brand) {
        display: none;
    }

    .header-login {
        order: 1;
        margin-left: 0;
        color: var(--accent-color);
        text-decoration: underline;
        text-underline-offset: 4px;
    }

    .header-login-icon {
        display: none;
    }

    .header-favorite {
        order: 2;
    }

    .header-bag {
        order: 3;
    }

    .header-menu-button {
        display: inline-flex;
    }

    .header-searchbar {
        order: 3;
        flex-basis: 100%;
        max-width: none;
        min-width: 0;
        margin: 0;
    }
}

.two-line-ellipsis {
    display: -webkit-box;
    -webkit-line-clamp: 2;   /* number of lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.one-line-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tooltip {
    position: fixed;
    background: white;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 14px;

    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 99999;

    max-width: 250px;
    white-space: normal;

    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}


/* --- OffCanvas* ---*/

html.offcanvas-open,
body.offcanvas-open {
    overflow: hidden;
    height: 100%;
}

/* Backdrop */
.offcanvas-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;

    z-index: 1000;
}

/* visible */
.offcanvas-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

/* panel */
.offcanvas {
    position: fixed;
    top: 0;
    right: 0;

    width: min(420px, 100vw);
    height: 100vh;

    display: flex;
    flex-direction: column;

    background: var(--primary-bg-color);
    z-index: 1001;

    transform: translateX(100%);
    transition: transform 0.3s ease;

    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
}

.offcanvas.open {
    transform: translateX(0);
}

.offcanvas-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.offcanvas-header{
    border-bottom: 1px solid var(--tertiary-color);
}

.offcanvas-btn-close{
    background-color: var(--primary-bg-color);
    color: var(--primary-color);
    font-size: 18px;
    border: 1px solid var(--tertiary-color);
    border-radius: 6px;
    padding: 1px 6px;
    cursor: pointer;
    width: 32px;
    height:32px;
}

@media (max-width: 900px) {
    .bookcard-frame{
        padding: 0;
    }
    .bookcard{
        width: 210px;
        padding: 10px;
    }
    .bookcard img {
        height: 180px;
    }

}
