/* Portrait/Ebook cover aspect ratio for carousel images */
.portrait-container {
  position: relative;
  width: 180px;
  aspect-ratio: 2/3;
  background: #f3f3f3;
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: border 0.5s;
  display: block;
  max-width: 100%;
  max-height: 100%;
}

/* Carousel caption text wrapping */
.carousel-caption {
  width: 100%;
  max-width: 250px;
  margin: 0 auto;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: none; /* Prevent hyphenation for better readability */
  word-break: keep-all; /* Keep words intact */
  white-space: normal;
  line-height: 1.4;
  text-align: center;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  
  /* Ensure proper display containment */
  contain: layout style;
  display: block;
  box-sizing: border-box;
  
  /* Responsive height handling */
  min-height: auto;
  height: auto;
  max-height: none;
}

/* Carousel overlay effect */
.carousel-slide {
  transition: transform 0.7s cubic-bezier(0.4,0,0.2,1), opacity 0.7s, z-index 0.3s;
  will-change: transform, opacity, z-index;
  /* Performance optimizations for mobile */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

/* Add subtle animation to carousel track for touch feedback */
#carousel-track {
  transition: transform 0.1s ease-out;
}

#carousel-track.swiping {
  transition: none;
}

/* Loading state for carousel */
.carousel-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 300px;
  color: rgba(255, 255, 255, 0.6);
}

/* Comprehensive tablet responsive design */
/* Large tablets (901px - 1024px) */
@media (max-width: 1024px) and (min-width: 901px) {
  .portrait-container {
    width: 165px;
    aspect-ratio: 2/3;
  }
  
  .carousel-caption {
    max-width: 220px;
    font-size: 0.85rem;
    line-height: 1.35;
    margin-top: 0.5rem;
  }
}

/* Medium tablets (769px - 900px) */
@media (max-width: 900px) and (min-width: 769px) {
  .portrait-container {
    width: 155px;
    aspect-ratio: 2/3;
  }
  
  .carousel-caption {
    max-width: 210px;
    font-size: 0.8rem;
    line-height: 1.3;
    margin-top: 0.45rem;
  }
}

/* Small tablets (641px - 768px) */
@media (max-width: 768px) and (min-width: 641px) {
  .portrait-container {
    width: 145px;
    aspect-ratio: 2/3;
  }
  
  .carousel-caption {
    max-width: 200px;
    font-size: 0.775rem;
    line-height: 1.25;
    margin-top: 0.4rem;
  }
}

/* Mobile devices (up to 640px) */
@media (max-width: 640px) {
  .portrait-container {
    width: 90vw;
    max-width: 260px;
    min-width: 120px;
    height: auto;
    aspect-ratio: 2/3;
  }
  
  .carousel-caption {
    max-width: 250px;
    font-size: 0.75rem;
    line-height: 1.2;
    margin-top: 0.35rem;
  }
  
  /* Mobile carousel navigation - position buttons on sides */
  .carousel-nav-mobile {
    display: none; /* Hide mobile nav wrapper, we'll position buttons on sides */
  }
  
  .carousel-slide {
    height: auto !important;
  }
  
  /* Responsive carousel indicators - smaller and fit on one line */
  #carousel-indicators {
    flex-wrap: nowrap; /* Force single line */
    padding: 0 8px;
    justify-content: center;
    max-width: 100%;
    overflow-x: auto; /* Allow horizontal scroll if needed */
    gap: 1px; /* Minimal gap */
    scrollbar-width: none; /* Hide scrollbar in Firefox */
    -ms-overflow-style: none; /* Hide scrollbar in IE/Edge */
  }
  
  #carousel-indicators::-webkit-scrollbar {
    display: none; /* Hide scrollbar in webkit browsers */
  }
  
  #carousel-indicators button {
    width: 6px;
    height: 6px;
    margin: 1px;
    min-width: 6px;
    flex-shrink: 0; /* Prevent shrinking */
  }
  
  /* Position carousel buttons on the sides */
  .carousel-btn {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 30 !important;
    width: 40px !important;
    height: 40px !important;
  }
  
  #carousel-left {
    left: 8px !important;
  }
  
  #carousel-right {
    right: 8px !important;
  }
  
  /* When there are too many indicators on mobile, scale them down */
  #carousel-indicators.many-indicators {
    gap: 0.5px;
    padding: 0 4px;
  }
  
  #carousel-indicators.many-indicators button {
    width: 4px;
    height: 4px;
    margin: 0.5px;
    min-width: 4px;
  }
}

@media (max-width: 400px) {
  .portrait-container {
    max-width: 180px;
  }
  
  /* Adjust base size for very small screens */
  #carousel-indicators {
    padding: 0 8px;
    gap: 1px;
  }
  
  #carousel-indicators button {
    width: 6px;
    height: 6px;
    margin: 0.5px;
    min-width: 6px;
  }
  
  #carousel-indicators.size-small button {
    width: 5px;
    height: 5px;
    margin: 0.5px;
    min-width: 5px;
  }
  
  #carousel-indicators.size-tiny button {
    width: 3px;
    height: 3px;
    margin: 0.25px;
    min-width: 3px;
  }
  
  #carousel-indicators.size-micro button {
    width: 2px;
    height: 2px;
    margin: 0.25px;
    min-width: 2px;
  }
  
  /* Smaller carousel buttons for very small screens */
  .carousel-btn {
    width: 36px !important;
    height: 36px !important;
  }
  
  #carousel-left {
    left: 4px !important;
  }
  
  #carousel-right {
    right: 4px !important;
  }
}

/* Banner Carousel Styles */
.banner-carousel-section {
  position: relative;
}

.banner-carousel-btn {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 50%;
  padding: 12px;
  transition: all 0.3s ease;
  z-index: 10;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.banner-carousel-btn:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

#banner-carousel-container {
  height: 200px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.banner-slide {
  min-width: 100%;
  height: 200px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-bg {
  position: absolute;
  top: 0;
  left: 0;  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(2px) brightness(0.3);
  transform: scale(1.1);
  z-index: 1;
  opacity: 1;
}


.banner-slide img {
  width: auto;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  object-position: center;
  transition: transform 0.7s ease;
  position: relative;
  z-index: 2;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 20%, black 80%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 20%, black 80%, transparent 100%);
  background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 1) 20%, rgba(255, 255, 255, 1) 80%, transparent 100%);
}

.banner-slide:hover img {
  transform: scale(1.05);
}

#banner-carousel-indicators {
  margin-top: 12px;
}

#banner-carousel-indicators button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: transparent;
  transition: all 0.3s ease;
  cursor: pointer;
}

#banner-carousel-indicators button.active {
  background: white;
  border-color: white;
}

#banner-carousel-indicators button:hover {
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(1.2);
}

@media (max-width: 768px) {
  #banner-carousel-container {
    height: 150px;
  }
  
  .banner-slide {
    height: 150px;
  }
  
  .banner-bg {
    height: 150px;
  }
  
  .banner-carousel-btn {
    padding: 8px;
    min-width: 40px;
    min-height: 40px;
  }
  
  #banner-carousel-left {
    left: 6px;
  }
  
  #banner-carousel-right {
    right: 6px;
  }
  
  .banner-carousel-btn svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  #banner-carousel-container {
    height: 120px;
  }
  
  .banner-slide {
    height: 120px;
  }
  
  .banner-bg {
    height: 120px;
  }
  
  .banner-carousel-btn {
    padding: 6px;
    min-width: 36px;
    min-height: 36px;
  }
  
  #banner-carousel-left {
    left: 8px !important;
  }
  
  #banner-carousel-right {
    right: 8px !important;
  }
  
  .banner-carousel-btn svg {
    width: 16px;
    height: 16px;
  }
  
  #banner-carousel-indicators button {
    width: 8px;
    height: 8px;
  }
}
