/* --- MAIN CONTAINER --- */
.container { max-width: 1200px; margin: 0 auto; padding: 5rem 1.5rem 3rem 1.5rem; }
@media (min-width: 768px) { .container { padding-top: 3rem; } }
h1 { text-align: center; margin-bottom: 2.5rem; font-weight: 700; font-size: 2.2rem; }

/* --- CONTROLS --- */
.controls { display: flex; gap: 12px; justify-content: center; margin-bottom: 3rem; align-items: center; min-height: 48px; }

.search-input { 
    width: 220px; /* Always expanded width */
    height: 44px; 
    padding: 0 16px 0 40px; /* Padding accommodates icon on the left */
    border: none; 
    border-radius: 22px; 
    outline: none !important;
    background-color: #f5f5f7;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3ccircle cx='11' cy='11' r='8'/%3e%3cline x1='21' y1='21' x2='16.65' y2='16.65'/%3e%3c/svg%3e");
    background-repeat: no-repeat; 
    background-position: 14px center; /* Keep icon positioned to the left */
    font-size: 16px; 
    color: #1d1d1f; 
    cursor: text; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    box-sizing: border-box;
}

/* Subtle background darkening on focus */
.search-input:focus { 
    background-color: #e8e8ed;
}

/* Keep placeholder visible at all times */
.search-input::placeholder { 
    color: #86868b; 
}

.sort-select { 
    width: 44px; height: 44px; min-width: 44px; flex-shrink: 0; padding: 0; border: none; border-radius: 22px; outline: none !important;
    background-color: #f5f5f7;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%231d1d1f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M7 15l5 5 5-5M7 9l5-5 5 5'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: center; color: transparent; cursor: pointer; transition: 0.2s; appearance: none; -webkit-appearance: none; box-sizing: border-box;
}

/* --- GRID & CARDS --- */
.bookshelf { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
@media (min-width: 768px) { .bookshelf { grid-template-columns: repeat(3, 1fr); gap: 2rem; } }
@media (min-width: 1024px) { .bookshelf { grid-template-columns: repeat(4, 1fr); gap: 2rem; } }

.book-card { border: none !important; outline: none !important; box-shadow: none; border-radius: 12px; transition: transform 0.3s ease; display: flex; flex-direction: column; background: transparent; overflow: hidden; height: 100%; cursor: pointer; } 
.book-card:hover, .book-card.is-active { transform: translateY(-4px); }

.empty-state { grid-column: 1 / -1; text-align: center; color: #86868b; padding: 3rem 1rem; font-size: 1.1rem; }

.img-container { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: linear-gradient(90deg, #f8f9fa 0%, #e9ecef 50%, #f8f9fa 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite linear; border-radius: 8px; }
.img-container.stop-shimmer { animation: none; background: transparent; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.cover-img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.6s ease; position: absolute; top: 0; left: 0; z-index: 3; }
.cover-img.loaded { opacity: 1; }

.card-body { padding: 1rem 0; display: flex; flex-direction: column; flex-grow: 1; }
.book-title { font-size: 1rem; font-weight: 600; margin: 0 0 0.25rem 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.book-author { font-size: 0.85rem; color: #666; margin: 0 0 1rem 0; }
.btn-amazon { background-color: #f5f5f7; color: #1d1d1f; border: none; border-radius: 8px; outline: none; padding: 10px 16px; font-size: 0.85rem; font-weight: 600; text-decoration: none; transition: 0.2s; display: block; text-align: center; margin-top: auto; }
.btn-amazon:hover { background-color: #e8e8ed; }

/* --- SUMMARY OVERLAY & AI LINK --- */
.summary-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; display: flex; flex-direction: column; border-radius: 8px; }
.book-card.is-active .summary-overlay { opacity: 1; pointer-events: auto; }
.summary-content { flex-grow: 1; padding: 1.5rem 1.5rem 3.5rem 1.5rem; overflow-y: auto; text-align: center; display: flex; flex-direction: column; }
.summary-text { margin: auto 0; font-size: 0.95rem; line-height: 1.6; color: #1d1d1f; }

.ai-link { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); display: inline-flex; align-items: center; z-index: 25; text-decoration: none; background-color: rgba(255, 255, 255, 0.85); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(0, 0, 0, 0.1); color: #1d1d1f; padding: 6px 14px; border-radius: 50px; font-size: 0.75rem; font-weight: 500; pointer-events: none; opacity: 0; transition: all 0.3s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.06); white-space: nowrap; }
.book-card.is-active .ai-link { pointer-events: auto; opacity: 1; }
.ai-link:hover { background-color: #ffffff; box-shadow: 0 6px 14px rgba(0,0,0,0.1); }
.ai-sparkle { width: 14px; height: 14px; margin-right: 6px; fill: #1d1d1f; }

@media (max-width: 480px) {
    .search-input { width: 180px; } /* Update mobile width selector to target the base class */
    
    .ai-link { padding: 4px 10px; font-size: 0.65rem; max-width: 90%; box-sizing: border-box; justify-content: center; overflow: hidden; text-overflow: ellipsis; }
    .ai-sparkle { width: 12px; height: 12px; margin-right: 4px; flex-shrink: 0; }
}