/* om_ts.css
 * O'Mahony's Typesense styling
 * 260209 POM
 */

/* body { background-color: aqua !important;} */
/*#k { background-color: aqua;}*/
#searchSuggestions {background-color: aliceblue; }
/* 1. Reset the form to ensure the search bar and results stay aligned */
#head_search {
    position: relative; 
    display: block;
    width: 100%;
    margin: 0;
}

/* 2. Main Dropdown Window */
#search-container {
    display: none; 
    position: absolute;
    top: 45px; 
    left: 0;
    width: 800px;           
    max-width: 95vw;        
    height: 70vh; /* Fixed height is mandatory for internal scrolling */          
    
    background: #fff;
    z-index: 10000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    border: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    
    /* Forces the scroll to stay inside the children */
    overflow: hidden; 
    box-sizing: border-box; 
    pointer-events: auto; /* Ensures clicks/scrolls are captured here */
}

/* 3. The Body Wrapper */
.search-body {
    display: flex;          
    width: 100%;
    height: 100%; /* Must fill the parent to enable scrolling */          
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* 4. Left Pane: Scrollable Filters (Facets) */
.facets {
    flex: 0 0 220px;        
    padding: 15px;
    border-right: 1px solid #eee;
    background: #fdfdfd;
    box-sizing: border-box;
    
    /* Scroll fix: auto overflow and touch support */
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    height: 100%;
}

/* 5. Right Pane: Scrollable Books (Results) */
.results {
    flex: 1;                
    display: grid;
    grid-template-columns: repeat(3, 180px); 
    gap: 3px;
    padding: 15px;
    justify-content: start;
    box-sizing: border-box;
    
    /* Scroll fix: auto overflow and touch support */
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
    height: 100%;
    overflow-x: hidden;     
}

/* 6. Book Item Styling */
.book-item {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}
.book-item a { text-decoration: none; }

.book-item img {
    max-width: 100%;
    height: 150px;          
    object-fit: contain;
    margin-bottom: 8px;
}

.book-details h4 {
    font-size: 0.85rem;
    line-height: 1.2;
    margin: 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-details p {
    font-size: 0.95rem;
    color: #666;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
    font-weight:bold;
}

/* 7. Scrollbar Visibility Styling (Ensuring they are always visible) */
.facets::-webkit-scrollbar,
.results::-webkit-scrollbar {
    width: 10px; /* Wider for better visibility */
}

.facets::-webkit-scrollbar-thumb,
.results::-webkit-scrollbar-thumb {
    background: #bbb; /* Darker thumb for better contrast */
    border-radius: 10px;
    border: 2px solid #fff; /* Adds padding around the scrollbar */
}

.facets::-webkit-scrollbar-track,
.results::-webkit-scrollbar-track {
    background: #f9f9f9;
}

.binding {
    color:#b4b4df;
    font-size: 10x;
    font-style:italic;
}
@media (max-width: 768px) {
    /* 1. Make the container take up the full screen width */
    #search-container {
        width: 100vw;
        max-width: 100vw;
        left: 0;
        right: 0;
        transform: none;
        height: 85vh; /* Increase height for mobile browsing */
        border-radius: 0;
        top: 50px; /* Ensure it stays below the mobile header */
    }

    /* 2. Stack the filters on top of the results */
    .search-body {
        flex-direction: column;
        overflow-y: auto; /* Allow the body itself to scroll if needed */
    }

    /* 3. Adjust the Filters Sidebar */
    .facets {
        flex: 0 0 auto; /* Stop it from taking up fixed 220px */
        width: 95%;
        max-height: 200px; /* Limit filter height so books are visible */
        border-right: none;
        border-bottom: 1px solid #eee;
        padding: 10px;
    }

    /* 4. Adjust the Book Grid for smaller screens */
    .results {
        width: 95%;
        /* Change from 3 fixed columns to 2 flexible columns */
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px;
        padding: 10px;
        justify-content: center;
    }

    /* 5. Scale the Book Item for 2-column mobile layout */
    .book-item {
        width: 100%;
        padding: 5px;
    }

    .book-item img {
        height: 140px; /* Smaller images for mobile */
    }

    .book-details h4 {
        font-size: 0.8rem;
    }
}

/* Extra small devices (Phones) */
@media (max-width: 480px) {
    .results {
        /* Drop to 1 column if the screen is very narrow */
        grid-template-columns: 1fr; 
    }
    
    .book-item img {
        height: 180px; /* Slightly larger image when in single column */
    }
}

.facet-group h6 {
    color:blue;
    margin:20px 0 2px 0;
}

.facet-item small { /* counts on facet items - right aligned */
    /*float:right;*/

    background: #f8f9fa;
    color: #999;
    font-size: 11px;
    padding: 4px 4px;
    border-radius: 12px;
    border: 1px solid #eee;
    font-weight: 600;    
}

.book-card :hover {
    text-decoration: None;;
}

.book-card .author {
    color:#994222;
}

.book-card .title {
  white-space:inherit;
}

.book-card .img_cont { /* stop sticker messing up content */
    height:inherit;
}

.facet-item {
    cursor: pointer;
}

      .ais-RefinementList-showMore {
        border: 1px solid #888;
        border-radius: 25px;
        font-size: 12px;
        padding:2px 5px;
        background-color: #eee;
        }

      .ais-RefinementList-showMore--disabled {
        display:none;
        }
