/* ---------- Page entry animation ---------- */
body.vanish {
  opacity: 0;
  transform: scale(1.05); /* Slight zoom out */
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
  pointer-events: none;
}

/* ---------- Default home visibility ---------- */
#default_home_page {
  display: block;
  width: 1152px;
  justify-self: center;
  margin: 64px auto 32px auto;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#default_home_page.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------- General section layout ---------- */
.home_section {
  max-width: 1152px;
  margin: 12px auto;
  padding: 0 16px;
}

.home_section h3 {
  margin: 0px;
  margin-bottom: 10px;
  text-align: left;
}

/* ---------- General Container Background ---------- */
#home_section_authors,
#home_section_list,
#home_section_for_you {
  background: var(--bc_primary_lighter);
  width: 100%;
  padding: 0;
}

.home_section {
  margin: 0 auto;
  padding: 24px 0 24px 16px !important;
  box-sizing: border-box;
  max-width: 1152px;
}

/* ---------- Scroll containers ---------- */
.novel_scroll,
.scroll-container {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.novel_scroll::-webkit-scrollbar,
.scroll-container::-webkit-scrollbar {
  display: none;
}

#keepreading .novel-item {
  flex-shrink: 0; /* Prevent shrinking */
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  border-radius: 4px;
  background-color: var(--soft-card-color);
}

#keep_reading {
  max-width: 1080px;
  display: flex;
  gap: 16px;
  overflow-x: hidden; /* Prevent manual scroll */
}

.keep_reading-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 1080px;
  overflow: hidden; /* Prevent container overflow */
}

.scroll-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: var(--button-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  opacity: 0.8;
  transition: opacity 0.3s ease;
}

.scroll-btn:hover {
  opacity: 1;
}

.scroll-btn:disabled {
  opacity: 0;
  cursor: default;
}

.scroll-left {
  left: -18px; /* Half of button width to stick out */
}

.scroll-right {
  right: -18px; /* Half of button width to stick out */
}

/* ---------- Novel cards ---------- */
.novel {
  width: 120px;
  overflow: hidden;
  border-radius: 4px;
}

.novel img {
  width: 120px;
  aspect-ratio: 2 / 3;
}

.novel img.img_error {
  width: 20%;
  height: auto;
  object-fit: contain;
}

.novel h3 {
  display: -webkit-box;
  margin: 0;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
}

.novel p {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 16px var(--shadow-semitransparent-color);
  overflow: hidden;
}

/* ---------- Keep Reading specific elements ---------- */

#keepreading .novel-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

#keepreading .novel-cover {
  width: 60px;
  aspect-ratio: 2/3;
  border-radius: 4px;
}

#keepreading .novel-author,
#keepreading .novel-title {
  white-space: nowrap;
  margin: 0;
}

#keepreading .novel-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-left: 10px;
}

/* Progress bar */
#keepreading .progress-container {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#keepreading .progress-bar-bg {
  flex: 0 0 80px;
  height: 8px;
  background-color: var(--text-offwhite-color);
  border-radius: 4px;
  overflow: hidden;
}

#keepreading .progress-bar-fill {
  height: 100%;
  background-color: var(--text-yellow-color);
  border-radius: 4px;
}

/* ---------- Authors Section ---------- */
.author-div {
  width: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow: hidden;
}

.author-info {
  height: 100%;
  padding: 0 10px;
}

.author-info h3 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  margin-bottom: 0;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-bio {
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.author-avatar {
  width: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.author-div:hover .author-avatar {
  box-shadow: 0 8px 16px var(--shadow-semitransparent-color);
  transition: box-shadow 0.3s ease;
}

.author-div:hover {
  transform: scale(1.03);
}

/* ---------- Lists Section ---------- */
.list-collage.grid-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  width: 170px;
  height: 180px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.list-collage.grid-layout:hover {
  transform: scale(1.03);
}

.cover-slot {
  background-size: cover;
  background-position: center;
  background-color: var(--text-grey-color);
}

.cover-slot:nth-child(1) {
  grid-row: 1 / span 2;
  grid-column: 1;
}
.cover-slot:nth-child(2) {
  grid-row: 1;
  grid-column: 2;
}
.cover-slot:nth-child(3) {
  grid-row: 2;
  grid-column: 2;
}

.cover-slot.placeholder {
  background-color: var(--aux-background-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-grey-color);
}

.list-item {
  width: 170px;
  overflow: hidden;
}

.list-item h4,
.list-item p {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

/* ---------- Genres Section ---------- */
#genres {
  padding: 2px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 1152px;
  margin: 0 auto;
}

.genre-card {
  border-radius: 8px;
  width: 150px;
  height: 68px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow: hidden;
  line-height: 1.3;
  text-overflow: ellipsis;
  box-shadow: 0 3px 8px var(--shadow-semitransparent-color);
}

.genre-card:hover {
  transform: scale(1.03);
}

/* ---------- Scroll Buttons (optional) ---------- */
.keep_reading-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  max-width: 1080px;
  overflow: visible; /* Allow buttons to stick out */
}


/* Responsive adjustments for small screens */
@media (max-width: 768px) {
  #default_home_page {
    margin-top: 0px;
    margin-bottom: 16px;
    width: 100%;
  }
  #carousel_wrapper {
    width: 100%;
  }
  #home_section_authors, #home_section_list, #home_section_for_you, #home_section_genres {
    padding: 0;
  }
  /* Keep Reading Section - Enable touch scroll */
  #keep_reading {
    overflow-x: auto !important; 
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #keep_reading::-webkit-scrollbar {
    display: none;
  }

  /* Hide scroll buttons on mobile */
  .scroll-btn {
    display: none !important;
  }

  .novel {
    width: 100px;
  }
  .novel_scroll, .scroll-container {
    gap: 16px;
    padding-right: 16px;
    overflow-x: auto;
  }
  .novel img {
    width: 100px;
    border-radius: 8px;
  }

  .author-div {
    width: 100px;
    gap: 8px;
  }

  .list-collage.grid-layout {
    width: 120px;
    height: 130px;
  }

  .list-item {
    width: 120px;
  }

  #genres {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 10px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    line-height: 1.3;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #genres::-webkit-scrollbar {
    display: none;
  }
}