/* ====== Layout / Section ====== */
.carousel_home_section{
  align-items: center;
  height: 400px;
  min-width: 100%;
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 16px;
}

/* Titulo seccion */
.main_section_title{
  margin: 0;
  margin-bottom: 12px;
}

/* ====== Carousel Base (Desktop defaults) ====== */
#carousel{
  max-width: 752px;  /* was width: 752px */
  width: 100%;
}

/* Make the wrapping link not shrink-wrap past viewport */
#carousel > a {
  display: block;
  width: 100%;
}

/* General Carousel */
.carousel_container {
  z-index: 0;
  background: var(--background-color);
  height: 360px;
  width: 716px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.carousel_background_wrapper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 4px;
  z-index: 0;
}

.carousel_background {
  z-index: -1;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-position: 50%;
  background-size: cover;
  background-repeat: no-repeat;
  -webkit-transform: scale(1.1);
  -webkit-filter: blur(15px) brightness(1.2);
  filter: blur(15px) brightness(1.2);
  transform: scale(1.1);
  opacity: 0.6;
  transition: background-image 0.5s ease;
}

/* ====== Big layout image stack ====== */
.carousel_img {
  margin-right: 12px;
  position: relative;
  height: 300px;
  aspect-ratio: 2 / 3;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--shadow-semitransparent-color); 
  overflow: visible; 
}

/* Img size + animation */
.carousel_img img {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  border-radius: 0.5rem;
  object-fit: cover;
  transition: transform 0.3s ease, z-index 0.3s ease;
  will-change: transform, opacity, filter;
  backface-visibility: hidden; /* helps prevent flicker */
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ====== Content ====== */
.carousel_container_data {
  display: flex;
  flex-direction: column;
  justify-content: space-between; 
  align-items: flex-start;
  padding: 0 1rem;
}

/* All data except button transition */
.carousel_metadata_wrapper {
  animation: fadeInText 0.3s ease;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Data transition Out / In */
.carousel_metadata_wrapper.fade-out { opacity: 0; }
.carousel_metadata_wrapper.fade-in  { opacity: 1; }

/* All data except button layout */
.carousel_metadata{
  margin: 12px 16px 12px 12px;
  min-height: 180px;
  width: auto;
  overflow: hidden;
}

/* Under title information */
.carousel_novel_info{
  margin: 8px 0 16px 0;
}

/* Style under title */
.carousel_metadata h3,
.carousel_metadata p{
  margin: 0;
  padding: 0;
}

/* Sinopsis */
.carousel_synopsis p {
  margin: 0.5rem 0;
}

/* Genres layout */
.carousel_genres {
  margin-top: 12px;
  padding-left: 4px;
}

/* Genre style */
.genre_tag {
  background: var(--card-color);
  border-radius: 0.5rem;
  padding: 5px 12px;
  margin-right: 8px;
  margin-bottom: 8px;
  display: inline-block;
  box-shadow: 0 3px 8px var(--shadow-semitransparent-color);
}
.genre_tag:hover { transform: scale(1.03); }

/* Button read style */
.read_button {
  width: 40%;
  margin: 6px 0 8px 0;
  text-align: center;
  text-decoration: none;
  align-self: center;
  padding: 0.6rem 1.2rem;
  background-color: var(--button-color);
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  box-shadow: 0 0.2rem 0.5rem var(--shadow-semitransparent-color);
}

/* Hover button style */
.read_button:hover {
  background-color: var(--button-hover-color);
  transform: scale(1.03);
}

/* Fade text */
@keyframes fadeInText {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.carousel_container_data.fade-out { opacity: 0; }
.carousel_container_data.fade-in  { opacity: 1; }

/* ====== Small screens (CarouselSmall layout) ====== */
@media (max-width: 768px) {

  .carousel_background {
    opacity: 0.9;                      /* more visible but darker */
    filter: blur(15px) brightness(0.38); /* darken for contrast */
  }

  .carousel_home_section a{
    text-decoration: none;
    color: inherit;
  }

  .carousel_home_section {
    flex-direction: column;   /* prevent row overflow */
    height: auto;
    width: 100%;
    gap: 8px;
  }

  #carousel { 
    width: 100%; 
    max-width: 100%;          /* override desktop cap */
  }

  .carousel_container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    margin-bottom: -16px;
    height: 508px;
    padding: 0 24px;
    justify-content: normal;
    box-sizing: border-box;
    overflow: hidden;         /* clip drag transform (whole card moves) */
    will-change: transform;   /* smoother drag */
  }

  .carousel_container a {
    text-decoration: none;
    color: inherit;
  }

  /* Image wrapper and cover image */
  .carousel_img_wrapper {      
    display: flex;
    margin-top: 96px;
    margin-bottom: 28px;
    justify-content: center;
    width: 100%;
    overflow: hidden; 
    touch-action: pan-y;       /* vertical page scroll; horizontal drag ok */
  }

  .carousel_cover {
    width: 140px;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 8px var(--shadow-semitransparent-color);
  }

  /* Data container */
  .carousel_container_data {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    text-align: left;
    overflow: hidden;
  }

  .carousel_container_data h3 {
    margin: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .carousel_container_data span {
    margin-bottom: 10px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .carousel_container_data p {
    display: -webkit-box;       /* Limit to 2 lines */
    -webkit-line-clamp: 2;
    margin: 0;
    -webkit-box-orient: vertical;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
  }

  /* Genres: single line, hide overflow */
  .carousel_genres {
    margin-top: 8px;
    display: flex;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow: hidden;           /* Clip overflowing genres */
    white-space: nowrap;
    width: 100%;
    position: relative;
  }

  .carousel_genres .genre_tag {
    background: var(--shadow-semitransparent-color); /* 30% opacity */
    max-width: 100px;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Navigation dots */
  .carousel_dots {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    gap: 8px;
  }

  .carousel_dot {
    width: 8px;
    height: 8px;
    background: lightgray;
    border-radius: 50%;
    cursor: pointer;
  }

  .carousel_dot.active {
    background: white;
  }
}

