/* YOUR EXISTING HOBBIES CSS - PRESERVED EXACTLY */

/* Books Grid Layout - EXACTLY 2 COLUMNS */
.books-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* Override any other grid styles that might be interfering */
.gallery.books-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
}

/* Individual Book Item */
.book-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    background: #1B1B1B; /* Changed to dark */
    border: none; /* No border */
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    padding: 2rem 2rem 1.5rem 1.5rem; /* Increased top and right padding */
    gap: 1.5rem;
    position: relative;
    overflow: visible;
    box-sizing: border-box;
}

.book-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

/* Yellow Bookmark - Default */
.book-item::before {
    content: '';
    position: absolute;
    top: -8px;
    right: 5%;
    width: 20px;
    height: 40px;
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    clip-path: polygon(0 0, 100% 0, 100% 85%, 50% 70%, 0 85%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
    transition: all 0.3s ease;
}

/* Favorite Star Bookmark */
.book-item.favourite::before {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    content: '★';
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    clip-path: none;
    border-radius: 4px;
}

/* Alternative: Different colored bookmark for favorites */
.book-item.favourite-bookmark::before {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.book-item:hover::before {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

/* Book Image Section */
.book-image {
    flex-shrink: 0;
    width: 150px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    background: transparent;
}

.book-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
    margin-bottom: 0.5rem;
    aspect-ratio: auto;
    max-height: none;
}

.book-item:hover .book-image img {
    transform: scale(1.02);
}

/* Book Purchase Links */
.book-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
    margin-top: 0.5rem;
}

.book-links a {
    color: #EDCB52; /* Golden color for links */
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0;
    transition: opacity 0.2s ease;
    text-align: center;
}

.book-links a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* Book Details Section */
.book-details {
    flex: 1;
    min-width: 0;
}

.book-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #6E6E6E; /* Grey text color */
}

/* Book Title - Large and prominent */
.book-text h1,
.book-text h2,
.book-text h3 {
    margin: 0.5rem 0 0.5rem 0; /* Added top margin to clear the bookmark */
    color: #FFFFFF; /* White title */
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
}

/* Author - Dark grey, smaller than title */
.book-text p.author,
.book-text p:first-of-type:not(.description) {
    margin: 0 0 1rem 0;
    color: #FFFFFF; /* White author */
    font-size: 1rem;
    font-weight: 500;
}

/* Key Ideas heading */
.book-text p strong,
.book-text strong {
    color: #EDCB52; /* Golden color for "Key Ideas" */
}

/* Description and other text - White for legibility */
.book-text p.description,
.book-text p:not(.author):not(:first-of-type) {
    margin: 0.5rem 0;
    color: #FFFFFF; /* White text for legibility */
    font-size: 0.9rem;
    line-height: 1.6;
}

/* List items - White for legibility */
.book-text li {
    margin: 0.25rem 0;
    color: #FFFFFF; /* White list items */
}

.book-text h4 {
    margin: 1rem 0 0.5rem 0;
    color: #34495e;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.25rem;
}

.book-text ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.book-text li {
    margin: 0.25rem 0;
}

.book-text blockquote {
    background: #2A2A2A; /* Darker background for quotes */
    border-left: 4px solid #EDCB52; /* Golden border */
    margin: 1rem 0;
    padding: 1rem;
    font-style: italic;
    color: #6E6E6E; /* Grey text */
}

.book-text.no-details {
    color: #6E6E6E; /* Grey for no details */
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

/* SURGICAL OVERRIDE - Only fix the grid columns at 992px */
@media screen and (max-width: 992px) {
    .gallery.books-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
        padding: 0.5rem;
    }
    
    .book-item {
        flex-direction: row;
        align-items: flex-start;
        padding: 1.5rem;
        gap: 1.5rem;
    }
    
    .book-item::before {
        right: 5%;
        top: -8px;
    }
    
    .book-image {
        width: 120px;
    }
    
    .book-image img {
        aspect-ratio: auto;
        object-fit: contain;
    }
}

/* Mobile phones: Side-by-side but optimized */
@media (max-width: 600px) {
    .book-item {
        flex-direction: row !important;
        align-items: flex-start !important;
        padding: 1rem !important;
        gap: 1rem !important;
        margin: 1rem 2rem !important; /* top/bottom: 1rem, left/right: 2rem */
    }
    
    .book-item::before {
        right: 5% !important;
        top: -8px !important;
    }
    
    /* Book image - maintain aspect ratio, no clipping */
    .book-image {
        width: 100px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
    }
    
    .book-image img {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        aspect-ratio: auto !important;
        max-width: 100px !important;
        max-height: none !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Purchase links under image */
    .book-links {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.2rem !important;
        align-items: center !important;
        margin-top: 0.25rem !important;
    }
    
    .book-links a {
        font-size: 0.65rem !important;
        padding: 0.1rem 0 !important;
    }
    
    /* Text content - flexible width */
    .book-details {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .book-text {
        text-align: left !important;
    }
    
    .book-text h1,
    .book-text h2,
    .book-text h3 {
        font-size: 1.1rem !important;
        margin: 0 0 0.5rem 0 !important;
        line-height: 1.2 !important;
        color: #FFFFFF !important; /* White title on mobile */
    }
    
    .book-text p.author,
    .book-text p:first-of-type:not(.description) {
        font-size: 0.85rem !important;
        margin: 0 0 0.75rem 0 !important;
        color: #FFFFFF !important; /* White author on mobile */
    }
    
    .book-text p strong {
        font-size: 0.8rem !important;
        color: #EDCB52 !important; /* Golden "Key Ideas" on mobile */
    }
    
    .book-text ul {
        margin: 0.5rem 0 !important;
        padding-left: 1.2rem !important;
    }
    
    .book-text li {
        font-size: 0.75rem !important;
        margin: 0.2rem 0 !important;
        line-height: 1.3 !important;
        color: #FFFFFF !important; /* White bullets on mobile */
    }
    
    .book-text p.description,
    .book-text p:not(.author):not(:first-of-type) {
        font-size: 0.75rem !important;
        margin: 0.5rem 0 !important;
        line-height: 1.4 !important;
        color: #FFFFFF !important; /* White description on mobile */
    }
}

/* ========================================= */
/* LAZY LOADING ADDITIONS - NON-DESTRUCTIVE */
/* ========================================= */

/* Core lazy loading image styles */
.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    background-color: #333;
    display: block;
    position: relative;
    overflow: hidden;
}

.lazy-image.loaded {
    opacity: 1;
}

.lazy-image.error {
    opacity: 0.7;
    background-color: #404040;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23888" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21,15 16,10 5,21"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 48px;
}

/* Subtle loading shimmer animation */
.lazy-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shimmer 2.5s infinite;
    pointer-events: none;
    z-index: 1;
}

.lazy-image.loaded::before,
.lazy-image.error::before {
    display: none;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Specific min-heights for different gallery types */
.books-grid .book-image .lazy-image {
    min-height: 200px; /* For book covers */
}

.gallery:not(.books-grid) .lazy-image {
    min-height: 250px; /* For brooches and yacht images */
}

#Yachts .gallery .lazy-image {
    min-height: 200px; /* Yacht specific sizing */
}

/* With preloader, only load the very first image immediately for each section */
.gallery img:first-child,
.books-grid .book-item:first-child img {
    opacity: 1 !important;
    background: none !important;
}

/* Remove shimmer animation on first loaded images */
.gallery img:first-child::before,
.books-grid .book-item:first-child img::before {
    display: none !important;
}

/* Preloader integration - ensure lazy images start hidden */
.loader + * .lazy-image {
    opacity: 0;
    visibility: hidden;
}

/* Show lazy images after preloader is done */
body:not(.loading) .lazy-image {
    visibility: visible;
}

/* Ensure gallery images maintain their layout - don't override existing book styles */
.gallery:not(.books-grid) img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Override any existing lazy loading prevention */
.gallery img.lazy-image {
    opacity: 0;
    visibility: visible !important;
    display: block !important;
}

.gallery img.loaded {
    opacity: 1;
    visibility: visible !important;
    display: block !important;
}

/* Ensure book images in the grid don't get disrupted by lazy loading */
.books-grid .book-image img.lazy-image {
    /* Inherit all the existing book image styles - DO NOT OVERRIDE */
    transition: opacity 0.4s ease-in-out, transform 0.3s ease;
}

.books-grid .book-image img.loaded {
    /* Maintain the hover effect from existing CSS */
    transition: opacity 0.4s ease-in-out, transform 0.3s ease;
}

/* Ensure lazy loading doesn't interfere with book item hover effects */
.book-item:hover .book-image img.lazy-image,
.book-item:hover .book-image img.loaded {
    transform: scale(1.02); /* Preserve existing hover effect */
}

/* Mobile compatibility - ensure lazy loading works with existing responsive design */
@media (max-width: 600px) {
    .books-grid .book-image .lazy-image {
        min-height: 120px; /* Smaller min-height for mobile */
    }
}


/* Limit the height to viewport minus some padding */
.vocab-scroll-container {
  max-height: calc(100vh - 150px); /* Adjust 150px based on header/footer or other elements */
  overflow-y: auto;
  padding-right: 15px; /* prevent scrollbar overlap on content */
  -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: #666 transparent; /* Firefox */
}

/* Optional: WebKit scrollbar styling */
.vocab-scroll-container::-webkit-scrollbar {
  width: 8px;
}
.vocab-scroll-container::-webkit-scrollbar-thumb {
  background-color: #666;
  border-radius: 4px;
}
.vocab-scroll-container::-webkit-scrollbar-track {
  background: transparent;
}



