/* HLM Book Layout Styles */

/* --- General Section Styling --- */
.hlm-section {
  width: 100%;
  max-width: 1200px; /* Consistent max width */
  margin: 30px auto; /* Spacing between sections */
  padding: 0 20px; /* Horizontal padding */
  box-sizing: border-box;
  position: relative; /* For potential absolute elements inside */
}

.hlm-section-title {
  font-size: 24px;
  font-weight: normal;
  color: #333;
  margin-bottom: 20px;
  text-align: center;
}

.hlm-random-books-carousel .swiper {
  width: 100%;
  padding-top: 10px; /* Space for potential overflow */
  padding-bottom: 50px; /* Increased space for pagination and reflection */
}

.hlm-random-books-carousel .swiper-slide {
  text-align: center;
  font-size: 18px;
  background: transparent; /* Make slide background transparent */

  /* Align items to the start for top alignment */
  display: flex;
  justify-content: center;
  align-items: flex-start; /* Align to top */
  height: auto; /* Adjust height based on content */
  overflow: visible; /* Allow reflection to show */
  box-sizing: border-box;
}

.hlm-random-books-carousel .swiper-slide .hlm-carousel-slide-link {
  display: flex; /* Use flexbox for link content */
  flex-direction: column; /* Stack image and title vertically */
  align-items: center; /* Center items horizontally */
  text-decoration: none;
  color: inherit;
  width: 100%;
  position: relative; /* For reflection positioning relative to link */
  padding-bottom: 5px; /* Reduce bottom padding on link itself */
}

.hlm-random-books-carousel .swiper-slide .hlm-carousel-image-container {
  width: 100%;
  max-width: 130px; /* Control max width of the container */
  margin: 0 auto 8px auto; /* Center container and add bottom margin */
  aspect-ratio: 2 / 3; /* Enforce aspect ratio (adjust if needed) */
  background-color: #f0f0f0; /* Light background for empty space */
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); /* Lighter shadow for container */
  position: relative; /* For positioning image and reflection */
  display: flex; /* Center image inside */
  align-items: center;
  justify-content: center;
  overflow: hidden; /* Hide potential image overflow if needed */
  padding-bottom: 35px; /* Add space below container for reflection */
  box-sizing: border-box; /* Include padding in height calculation */
}

/* --- NEW: Book Title Styles --- */
.hlm-carousel-book-title {
  font-size: 13px;
  color: #333;
  text-align: center;
  line-height: 1.3;
  margin-top: 5px; /* Space between image and title */
  padding: 0 5px; /* Horizontal padding */
  width: 100%; /* Take full width for centering */
  box-sizing: border-box;
  /* Limit text to 2 lines with ellipsis */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 34px; /* Reserve space for approx 2 lines */
}

.hlm-random-books-carousel
  .swiper-slide
  .hlm-carousel-slide-link:hover
  .hlm-carousel-image-container {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.hlm-random-books-carousel
  .swiper-slide
  .hlm-carousel-slide-link:hover
  .hlm-carousel-book-image {
  transform: scale(1.05);
}

/* --- UPDATED: Reflection Effect - Apply to image CONTAINER pseudo-element --- */
.hlm-carousel-image-container::after {
  content: "";
  display: block;
  position: absolute;
  bottom: 0px; /* Position at the bottom of the container's padding */
  left: 10%;
  right: 10%;
  width: 80%;
  height: 30px;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.15) 0%,
    rgba(0, 0, 0, 0) 100%
  );
  z-index: 0; /* Behind the image, but above container background */
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  filter: blur(2px);
  opacity: 0.6;
}

/* Swiper Navigation Buttons */
.hlm-random-books-carousel .swiper-button-next,
.hlm-random-books-carousel .swiper-button-prev {
  color: #555; /* Arrow color */
  width: 30px;
  height: 30px;
  /* background-color: rgba(255, 255, 255, 0.7); */ /* Optional background */
  /* border-radius: 50%; */
  top: 40%; /* Adjust vertical position relative to slide height */
  transform: translateY(-50%); /* Center vertically */
  transition: color 0.2s ease;
}
.hlm-random-books-carousel .swiper-button-next:hover,
.hlm-random-books-carousel .swiper-button-prev:hover {
  color: #000;
}

.hlm-random-books-carousel .swiper-button-next:after,
.hlm-random-books-carousel .swiper-button-prev:after {
  font-size: 16px; /* Arrow size */
  font-weight: bold;
}

/* Swiper Pagination */
.hlm-random-books-carousel .swiper-pagination {
  bottom: 10px; /* Position pagination lower */
}
.hlm-random-books-carousel .swiper-pagination-bullet {
  background-color: #aaa;
  opacity: 0.7;
  transition: background-color 0.2s ease, opacity 0.2s ease;
}

.hlm-random-books-carousel .swiper-pagination-bullet-active {
  background-color: #333;
  opacity: 1;
}

/* --- Featured Categories Styles --- */
/* Use the .hlm-section base styles */
.hlm-featured-categories-container {
  background-color: #f8f8f8; /* Keep the light grey background */
  padding-top: 20px; /* Add padding specific to this section */
  padding-bottom: 20px;
  margin-top: 0; /* Remove top margin if carousel is directly above */
}

.hlm-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 0 10px; /* Keep padding within the section */
}

.hlm-main-title {
  font-size: 28px;
  font-weight: normal;
  color: #333;
  margin: 0;
  white-space: nowrap; /* Attempt to fix title wrapping */
}

.hlm-view-all {
  color: #666;
  text-decoration: none;
  font-size: 14px;
  display: flex;
  align-items: center;
}

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

.hlm-view-all::after {
  content: "→";
  margin-left: 5px;
}

.hlm-categories-row {
  display: flex;
  flex-wrap: wrap;
  gap: 25px;
  /* Removed margin-bottom, spacing handled by section margin */
  justify-content: flex-start;
}

.hlm-book-card {
  flex: 0 0 auto;
  width: calc(18% - 17px); /* Default 3 columns */
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  min-height: 250px;
  display: flex;
}

.hlm-book-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.hlm-card-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.hlm-card-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}

.hlm-book-card:hover .hlm-card-background {
  transform: scale(1.05);
}

.hlm-card-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0.1) 50%,
    rgba(0, 0, 0, 0) 100%
  );
  z-index: 1;
  transition: background-color 0.3s ease;
}

.hlm-card-content {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 15px 20px;
  z-index: 2;
  box-sizing: border-box;
  color: #ffffff;
}

.hlm-card-category {
  font-size: 16px;
  font-weight: bold;
  color: rgba(255, 255, 255, 0.95);
  display: block;
  line-height: 1.4;
}

/* --- Updated image styles to fit container --- */
.hlm-random-books-carousel .swiper-slide .hlm-carousel-book-image {
  display: block;
  /* Let the browser calculate width/height based on container and object-fit */
  max-width: 100%; /* Ensure image doesn't exceed container width */
  max-height: 100%; /* Ensure image doesn't exceed container height */
  object-fit: contain; /* Scale image down to fit, preserving aspect ratio */
  /* Remove individual margin, shadow, border-radius, padding - handled by container */
  transition: transform 0.3s ease;
  position: relative; /* Keep relative */
  z-index: 1; /* Keep image above reflection */
  /* Removed width: 100%, height: 100%, max-height: none */
}

/* --- Responsive Styles --- */

/* Medium devices (tablets, less than 992px) */
@media (max-width: 991.98px) {
  .hlm-book-card {
    width: calc(50% - 13px); /* 2 columns */
  }
  .hlm-main-title {
    font-size: 24px;
  }
  /* Adjust carousel nav button position */
  .hlm-random-books-carousel .swiper-button-next,
  .hlm-random-books-carousel .swiper-button-prev {
    top: 38%; /* Adjust based on potentially shorter slides */
  }
}

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
  .hlm-section {
    padding: 0 15px; /* Reduce padding on smaller screens */
  }
  .hlm-section-title {
    font-size: 22px;
  }
  .hlm-book-card {
    width: calc(50% - 10px); /* Still 2 columns, adjust gap */
    min-height: 220px;
  }
  .hlm-main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .hlm-categories-row {
    gap: 20px;
  }
  /* Hide nav buttons on smaller screens, rely on touch swipe */
  .hlm-random-books-carousel .swiper-button-next,
  .hlm-random-books-carousel .swiper-button-prev {
    display: none;
  }
  .hlm-random-books-carousel .swiper {
    padding-bottom: 40px; /* Space for pagination */
  }
  .hlm-random-books-carousel .swiper-slide .hlm-carousel-image-container {
    max-width: 110px; /* Smaller container on tablets */
    padding-bottom: 30px; /* Adjust reflection space */
  }
  .hlm-random-books-carousel
    .swiper-slide
    .hlm-carousel-image-container::after {
    height: 25px;
  }
  .hlm-carousel-book-title {
    font-size: 12px;
    min-height: 32px; /* Adjust min height */
  }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
  .hlm-section-title {
    font-size: 20px;
  }
  .hlm-book-card {
    width: 100%; /* 1 column */
    min-height: 200px;
  }
  .hlm-card-category {
    font-size: 14px;
  }
  .hlm-categories-row {
    gap: 15px;
  }
  .hlm-card-content {
    padding: 12px 15px;
  }
  .hlm-random-books-carousel .swiper-slide .hlm-carousel-image-container {
    max-width: 100px; /* Even smaller container on phones */
    padding-bottom: 25px; /* Adjust reflection space */
  }
  .hlm-random-books-carousel
    .swiper-slide
    .hlm-carousel-image-container::after {
    height: 20px;
    left: 5%;
    right: 5%;
    width: 90%;
  }
  .hlm-random-books-carousel .swiper-pagination {
    bottom: 5px;
  }
}

/* Helper class for no image (remains the same) */
.no-thumbnail {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #eee;
  color: #999;
  font-size: 14px;
}
