/* Container for the masonry grid */
.masonry-grid {
    display: grid;
    width: 100%;
    padding: 1rem 2vw;
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

/* Default layout for smaller screens */
.masonry-grid {
    grid-template-columns: repeat(1, 1fr);
    /* One column by default */
}

/* For medium screens (640px and up) */
@media (min-width: 640px) {
    .masonry-grid {
        grid-template-columns: repeat(2, 1fr);
        /* Two columns */
    }
}

/* For larger screens (1024px and up) */
@media (min-width: 1024px) {
    .masonry-grid {
        grid-template-columns: repeat(3, 1fr);
        /* Three columns */
    }
}

/* Similar adjustments for the .books-masonry-grid */
.books-masonry-grid {
    grid-template-columns: repeat(1, 1fr);
    /* One column by default */
}

@media (min-width: 640px) {
    .books-masonry-grid {
        grid-template-columns: repeat(2, 1fr);
        /* Two columns */
    }
}

@media (min-width: 1024px) {
    .books-masonry-grid {
        grid-template-columns: repeat(3, 1fr);
        /* Three columns */
    }
}

/* Individual masonry items */
.masonry-item {
    break-inside: avoid-column;
    margin: 0.5rem;
    display: block;
    position: relative;
    border-radius: 6px;
    /* Important for the overlay to position correctly */
}

/* Image styling */
.masonry-item img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* Styling for the overlay */
.masonry-overlay {
    position: absolute;
    inset: 0;
    /* This will set top, right, bottom, left to 0 */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 248, 235, 0.85);
    /* Using a similar background */
    opacity: 0;
    /* Start hidden */
    transition: opacity 0.2s ease;
    /* Smooth transition */
}

/* Ensure the overlay shows on hover */
.masonry-item:hover .masonry-overlay {
    opacity: 1;
    /* Show the overlay on hover */
}

.masonry-item:hover img {
    filter: brightness(0.9);
    /* Slightly dim the image on hover */
}

/* Styling for the overlay box */
.masonry-overlay-box {
    width: 75%;
    padding: 2vw 2.25vw;
    background: color-mix(in srgb, var(--light-brown) 50%, transparent);
    color: var(--background);
    border-radius: 6px;
    text-align: center;
    font-size: 1.5vw;
}

.masonry-overlay-box strong {
    display: block;
    margin-bottom: 6px;
}

.no-click {
    cursor: default;
}

.no-click .masonry-overlay {
    pointer-events: none;
}
.books-masonry-section {
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* mobile default: 1 column */
    gap: 1rem; /* space between items */
    width: 100%;
    padding: 1rem 1vw;
    opacity: 1;
    border-radius: 6px;
    transition: opacity 0.5s ease-in-out;
}

@media (min-width: 640px) {
    .books-masonry-section {
        grid-template-columns: repeat(2, 1fr); /* 2 columns for medium screens */
    }
}

@media (min-width: 1024px) {
    .books-masonry-section {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for large screens */
    }
}

/* Normal items */
.books-masonry-item {
    width: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
}

/* Spread / wide items */
.books-masonry-item.spread {
    grid-column: span 2; /* default: span 2 columns */
}

/* Optional: full-width spreads */
.books-masonry-item.full-spread {
    grid-column: 1 / -1; /* span all columns */
}

/* Images */
.books-masonry-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* Overlay (optional) */
.books-masonry-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    color: var(--accent-gold);
}

@media (max-width: 800px) {
    .close {
        cursor: pointer;
        width: 9vw !important;
        height: 9vw !important;
        padding: 1vw;
        background-color: var(--background);
        border-radius: 10px;
        align-items: center;
        justify-content: center;
        top: 2vh;
        /* Position left */
        right: 2vh;
        /* Adjust for left arrow */

    }

    .close span {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 75%;
        height: clamp(3px, 1vw, 6px);
        transform: translate(-50%, -50%);
        background: var(--accent-gold);
        transition: 0.3s ease;
    }

    .close span:nth-child(1) {
        transform: translate(-50%, -50%) rotate(45deg);
    }

    .close span:nth-child(2) {
        opacity: 0;
    }

    .close span:nth-child(3) {
        transform: translate(-50%, -50%) rotate(-45deg);
    }

    .prev,
    .next {
        font-size: 9vw !important;
    }
}

.bg-color-1 {
    background-color: color-mix(in srgb, var(--background) 25%, transparent);
    /* First background color */
}

.bg-color-2 {
    background-color: color-mix(in srgb, var(--light-brown) 25%, transparent);
    /* Second background color */
}


.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    /* Stay in place */
    z-index: 19000;
    /* Sit on top */
    left: 0;
    top: 0;
    width: 100vw;
    /* Full width */
    height: 100vh;
    /* Full height */
    background-color: rgb(0, 0, 0);
    /* Fallback color */
    background-color: color-mix(in srgb, var(--dark-brown) 80%, transparent);
    /* Black w/ opacity */
    align-items: center !important;
    /* Center vertically */
    justify-content: center !important;
    /* Center horizontally */
}

.modal-content {
    margin: auto;
    display: block;
    width: auto;
    /* Adjust as necessary */
    align-items: center !important;
    /* Center vertically */
    max-width: 90vw;
    /* Restrict maximum width */
    max-height: 80vh;
}

#modalImg {
    position: relative;
    border-radius: 6px;
}

#caption {
    margin: auto;
    text-align: center;
    background-color: var(--light-brown);
    color: var(--dark-brown);
    padding: 10px;
    text-decoration: none;
    border-radius: 6px;
    z-index: 19001;
    font-size: 4vw;
    display: none;
}

.close,
.prev,
.next {
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    color: var(--accent-gold);
    font-size: 5vw;
    font-weight: bold;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    cursor: pointer;
    /* Prevent text selection */
}

.prev {
    left: 0;
    /* Position left */
    border-radius: 3px 0 0 3px;
    /* Adjust for left arrow */
}

.next {
    right: 0;
    /* Position right */
    border-radius: 0 3px 3px 0;
    /* Adjust for right arrow */
}

.close {
    cursor: pointer;
    width: 4vw;
    height: 4vw;
    padding: 1vw;
    background-color: var(--background);
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    top: 2vh;
    right: 2vh;
}

.close span {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 75%;
    height: clamp(3px, 1vw, 6px);
    transform: translate(-50%, -50%);
    background: var(--accent-gold);
    transition: 0.3s ease;
}

.close span:nth-child(1) {
    transform: translate(-50%, -50%) rotate(45deg);
}

.close span:nth-child(2) {
    opacity: 0;
}

.close span:nth-child(3) {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.close:hover,
.prev:hover,
.next:hover {
    background-color: rgba(0, 0, 0, 0.8);
    color: var(--light-brown);
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    /* Stack spinner and text */
    position: fixed;
    /* Will keep it in a fixed position */
    top: 50%;
    /* Move it down to the center */
    left: 50%;
    /* Move it to the center */
    min-width: 50vw;
    /* Set a fixed width for the rectangle */
    min-height: 25vh;
    /* Set a fixed height for the rectangle */
    transform: translate(-50%, -50%);
    /* Center the rectangle by offsetting its dimensions */
    background-color: color-mix(in srgb, var(--background) 80%, transparent);
    /* Semi-transparent background */
    z-index: 1000;
    /* Above other content */
    font-size: 1.5rem;
    /* Adjust font size */
    color: var(--dark-brown);
    /* Text color */
}

.spinner {
    border: 8px solid rgba(0, 0, 0, 0.1);
    /* Light color for the spinner */
    border-left-color: var(--light-brown);
    /* Accent color for the left side */
    border-radius: 50%;
    width: 50px;
    /* Size of the spinner */
    height: 50px;
    /* Size of the spinner */
    animation: spin 1s linear infinite;
    /* Spin animation */
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}