/* ===== VARIABLES & RESET ===== */
:root {
    --color-primary: #3a86ff;
    --color-secondary: #ff2e63;
    --color-accent: #ff9e00;
    --color-dark: #1e1e2a;
    --color-light: #f8f9fa;
    --color-gray: #e9ecef;
    --color-text: #2d3436;
    --color-text-light: #636e72;
    --font-primary: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --font-heading: 'Playfair Display', 'Roboto', serif;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    color: var(--color-text);
    background-color: var(--color-light);
    line-height: 1.6;
}

a {
    text-decoration: none;
}

.homepage-container {
    max-width: 1150px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== HERO SECTION REVISI LENGKAP ===== */
.kliknovel-hero {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 100px 0;
    margin-bottom: 0;
    width: 100%;
}

.hero-content {
    flex: 1;
    max-width: 550px;
    text-align: left;
}

.hero-content h1 {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
    color: var(--color-dark);
    text-align: left;
}

.hero-content h1 span {
    color: var(--color-secondary);
    background: linear-gradient(135deg, var(--color-secondary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-content p {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--color-text-light);
    margin-bottom: 24px;
    max-width: 100%;
}

.hero-cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.cta-button {
    padding: 10px 22px;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    font-size: 1rem;
}

.cta-button:first-child {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-accent));
    color: white;
}

.cta-button:first-child:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.cta-button.secondary {
    background-color: var(--color-primary);
    color: white;
}

.cta-button.secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* PENULIS POPULER */
.authors-carousel-section {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    padding: 10px 15px;
    background: #3a86ff;
    color: white;
    box-sizing: border-box;
}

.authors-carousel-section .inner-wrapper {
    max-width: 1125px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.authors-carousel {
    max-width: 1150px;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.authors-carousel::-webkit-scrollbar {
    display: none;
}

.author-carousel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: white;
    color: var(--color-dark);
    border-radius: 15px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    flex-shrink: 0;
    width: 250px;
    height: 85px;
}

.author-carousel-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: #f7f7f7;
}

/* Icon */
.author-icon {
    width: 75px;
    height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    background-color: #ffcc00;
    flex-shrink: 0;
}

.author-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 15px;
}

/* Fallback icon */
.author-fallback-icon {
    font-size: 1.25rem;
    font-weight: 900;
    color: #000;
    text-align: center;
    line-height: 1;
}

/* Nama penulis */
.author-name {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* ===== CAROUSEL LAYOUT ===== */
.novel-section {
    margin-bottom: 30px;
    position: relative;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-dark);
}

.see-all {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* CAROUSEL NAVIGATION ON SIDES */
.carousel-container {
    position: relative;
}

.carousel-nav-side {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    gap: 5px;
}

.carousel-nav-side.left {
    left: -25px;
}

.carousel-nav-side.right {
    right: -25px;
}

.carousel-nav-side button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--color-gray);
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.carousel-nav-side button:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ===== BARU UPDATE & NOVEL TAMAT ===== */
.novel-carousel.covers-only {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 5px 0;
}

.novel-carousel.covers-only::-webkit-scrollbar {
    display: none;
}

.novel-carousel.covers-only .novel-card {
    flex: 0 0 auto;
    width: 175px;
    display: flex;
    justify-content: center;
}

.novel-carousel.covers-only .novel-thumb {
    border-radius: 5px;
    overflow: hidden;
    box-shadow: var(--shadow);
    width: 100%;
}

.novel-carousel.covers-only .novel-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.novel-carousel.covers-only .novel-card:hover .novel-thumb img {
    transform: scale(1.05);
}

/* Badge positioned below cover */
.update-badge-below {
    display: block;
    width: 100%;
    background: #007bff;
    color: white;
    padding: 6px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    border-radius: 0 0 4px 4px;
    margin-top: -4px; /* Connects visually with the cover */
}

/* ===== TOP 4 PER GENRE SEPERTI DREAME (RAPI & COMPACT) ===== */
.genre-ranking-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.genre-ranking-column {
    background: white;
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.genre-ranking-column .section-header {
    margin-bottom: 12px;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 8px;
}

.genre-ranking-column .section-header h2 {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin: 0;
}

.ranking-novel-card {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-gray);
}

.ranking-novel-card:last-child {
    border-bottom: none;
}

.ranking-number {
    position: absolute;
    top: 5px;
    left: 5px;
    width: 24px;
    height: 24px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    z-index: 2;
}

.ranking-novel-card .novel-thumb {
    position: relative;
    width: 80px;
    aspect-ratio: 2/3;
    border-radius: 5px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.ranking-novel-card .novel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ranking-novel-card .novel-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.ranking-novel-card .novel-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 16px;
}

.ranking-novel-card .novel-excerpt {
    font-size: 0.75rem;
    color: var(--color-text-light);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    margin-bottom: 2px;
}

.ranking-novel-card .novel-views {
    font-size: 0.75rem;
    color: var(--color-text-light);
    line-height: 1.2;
    margin: 5px 0 0;
}

/* ===== GENRES ===== */
.genres-carousel-section {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    padding: 0 20px 60px;
    background: #123499;
    color: white;
    box-sizing: border-box;
}

.genres-carousel-section .inner-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.genres-carousel-section h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
}

.genres-carousel {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-height: calc((80px * 2) + 12px); /* tinggi 2 item + 1 gap */
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.genres-carousel.expanded {
    max-height: 2000px; /* nilai besar agar semua item terlihat */
}

.load-more-genres {
    margin-top: 20px;
    text-align: center;
}

.load-more-genres button {
    padding: 14px 32px;
    font-size: 1.1rem;
    border: none;
    border-radius: 25px;
    background: #ffaa00;
    color: #444;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.load-more-genres button:hover {
    background: #ffaa00;
    color: #000;
    transform: translateY(-2px);
}

.genre-carousel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: #f0f0f0;
    color: var(--color-dark);
    border-radius: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    flex-shrink: 0;
    width: 250px;
    height: 80px;
}

.genre-carousel-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: #fff;
}

/* Icon */
.genre-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #3a86ff; /* biru KlikNovel */
    flex-shrink: 0;
}

.genre-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* Fallback icon */
.genre-fallback-icon {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    text-align: center;
}

/* Nama genre */
.genre-name {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1;
}

/* SERIES POPULER */
.series-carousel-section {
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    width: 100vw;
    padding: 10px 15px;
    background: #00072d;
    color: white;
    box-sizing: border-box;
}

.series-carousel-section .inner-wrapper {
    max-width: 1125px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.series-carousel {
    max-width: 1150px;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.series-carousel::-webkit-scrollbar {
    display: none;
}

.series-carousel-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    background: var(--color-primary);
    color: #f0f0f0;
    border-radius: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    flex-shrink: 0;
    width: 200px;
    height: 45px;
}

.series-carousel-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: #f0f0f0;
    color: #444;
}

/* Icon */
.series-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #ffcc00;
    flex-shrink: 0;
}

.series-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Fallback icon */
.series-fallback-icon {
    font-size: 1.25rem;
    font-weight: 900;
    color: #000;
    text-align: center;
    line-height: 1;
}

/* Nama Series */
.series-name {
    font-weight: 600;
    font-size: 1.05rem;
    line-height: 1.2;
    white-space: nowrap;
}

/* ===== GENRE NOVEL CAROUSEL (COVER PENUH) ===== */
.genre-novel-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    padding: 5px;
}

.genre-novel-carousel::-webkit-scrollbar {
    display: none;
}

.genre-novel-carousel .novel-card {
    width: 175px;
    flex: 0 0 auto;
    transition: var(--transition);
}

.genre-novel-carousel .novel-thumb {
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 2/3;
    box-shadow: var(--shadow);
}

.genre-novel-carousel .novel-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.genre-novel-carousel .novel-card:hover .novel-thumb img {
    transform: scale(1.05);
}

/* ========== HOMEPAGE — MOBILE OVERRIDES (<= 768px) ========== */
/* Layout order: gambar -> title+cta -> penulis populer carousel -> Baru Di-update (full-width carousel) -> Top 4 (carousel-per-kolom) -> genre populer -> series populer -> genre-novel carousels */
@media (max-width: 768px) {

  /* container lebih sempit di mobile */
  .homepage-container {
    padding: 0 12px;
    max-width: 100%;
  }

  /* ----- HERO: gambar ON TOP, content below, CTA centered ----- */
  .kliknovel-hero {
    display: flex;
    flex-direction: column; /* stack vertically */
    align-items: center;
    gap: 12px;
    padding: 18px 0;
  }

  /* letakkan hero-image di paling atas tanpa mengubah HTML (order) */
  .kliknovel-hero .hero-image { order: -1; width:100%; display:block; }
  .kliknovel-hero .hero-image img {
    width:100%;
    height:auto;
    display:block;
    border-radius: 12px;
  }

  .hero-content {
    width:100%;
    max-width: 720px;
    text-align: center;
    padding: 0 6px;
  }

  .hero-content h1 {
    font-size: 1.6rem;
    line-height: 1.18;
    margin-bottom: 8px;
  }
  .hero-content p {
    font-size: 0.98rem;
    margin-bottom: 12px;
    color: var(--color-text-light);
  }

  .hero-cta { justify-content:center; gap:10px; }
  .cta-button { padding: 10px 18px; font-size: 0.98rem; border-radius: 10px; }

  /* ----- PENULIS POPULER (carousel) - lebar menyesuaikan layar ----- */
  .authors-carousel-section { padding: 8px 10px; }
  .authors-carousel-section .inner-wrapper { padding: 6px 0; }

  .authors-carousel {
    gap: 10px;
    padding: 8px 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .authors-carousel::-webkit-scrollbar { display:none; }

  /* Tampilkan 2 item per viewport (adaptive) */
  .author-carousel-item {
    min-width: calc(50% - 14px);
    max-width: calc(50% - 14px);
    width: calc(50% - 14px);
    height: 84px;
    padding: 8px 12px;
    border-radius: 12px;
  }

  .author-icon { width: 56px; height:56px; border-radius:10px; }
  .author-name { font-size: 0.98rem; white-space: normal; overflow: hidden; }

  /* ----- BARU DI-UPDATE (covers-only) - carousel selebar layar, cover lebih besar ----- */
  .novel-carousel.covers-only {
    gap: 14px;
    padding: 10px 6px;
    overflow-x: auto;
  }
  .novel-carousel.covers-only .novel-card {
    flex: 0 0 72%;         /* setiap slide ambil ~72% viewport -> nampak 1 (dominant) + peek next */
    max-width: 72%;
    margin: 0 6px;
  }
  .novel-carousel.covers-only .novel-thumb { border-radius: 10px; }
  .novel-carousel.covers-only .novel-thumb img { width:100%; height:auto; display:block; }

  /* ----- TOP 4 per-genre: jadikan horizontal swipe per-column ----- */
  .genre-ranking-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 6px;
  }
  .genre-ranking-container .genre-ranking-column {
    flex: 0 0 86%;            /* each column takes most of viewport - swipe to view next */
    max-width: 86%;
    min-width: 86%;
    box-sizing: border-box;
    margin: 0 6px;
    padding: 12px;
  }
  /* adjust internal sizes inside each ranking column */
  .genre-ranking-column .section-header h2 { font-size: 1.1rem; }
  .ranking-novel-card .novel-thumb { width: 72px; aspect-ratio: 2/3; }
  .ranking-novel-card .novel-title { font-size: 0.95rem; }
  .ranking-novel-card .novel-excerpt { display:none; } /* ringkas untuk mobile, hanya judul & thumb */

  /* ----- GENRE POPULER: responsive grid (2 kolom) ----- */
  .genres-carousel-section { padding: 6px 12px 24px; }
  .genres-carousel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-height: none; /* allow 2 rows visible or controlled by JS */
    overflow: visible;
    padding: 6px 4px;
  }
  .genre-carousel-item {
    flex: 0 0 calc(50% - 12px); /* 2 kolom */
    width: calc(50% - 12px);
    height: auto;
    padding: 12px;
    border-radius: 12px;
    align-items: center;
  }
  .genre-icon { width:44px; height:44px; }
  .genre-name { font-size: 0.96rem; }

  /* ----- SERIES POPULER: horizontal, item size responsive ----- */
  .series-carousel {
    gap: 10px;
    padding: 8px 6px;
    overflow-x: auto;
  }
  .series-carousel-item {
    flex: 0 0 46%;     /* show ~2 per viewport */
    width: 46%;
    max-width: 46%;
    height: 54px;
    padding: 8px 10px;
    border-radius: 10px;
  }
  .series-icon { width:44px; height:44px; }

  /* ----- GENRE NOVEL CAROUSELS: tampil 1-2 cards, cover lebih besar ----- */
  .genre-novel-carousel {
    gap: 12px;
    padding: 8px 6px;
    overflow-x: auto;
  }
  /* two-up on wider mobiles, one-up on narrow phones */
  .genre-novel-carousel .novel-card { flex: 0 0 60%; min-width: 60%; max-width: 60%; }
  @media (max-width: 420px) {
    .genre-novel-carousel .novel-card { flex: 0 0 85%; min-width: 85%; max-width: 85%; } /* one big card */
  }
  .genre-novel-carousel .novel-thumb { border-radius: 8px; }

  /* ----- GENERAL TWEAKS: text sizes, spacing ----- */
  .section-header h2 { font-size: 1.15rem; }
  .see-all { font-size: 0.9rem; }
  .author-name, .genre-name, .series-name { font-size: 0.97rem; }
  .novel-title-large { font-size: 1.5rem; }

  /* ensure nav buttons (if present) not overlapping on small screens */
  .carousel-nav-side.left { left: 6px; }
  .carousel-nav-side.right { right: 6px; }
  .carousel-nav-side button { width: 34px; height: 34px; }

  /* Accessibility / touch targets */
  .author-carousel-item, .genre-carousel-item, .series-carousel-item, .novel-card { -webkit-tap-highlight-color: rgba(0,0,0,0.06); }

} /* end media <= 768px */

/* ========== FURTHER COMPACT ADJUSTMENTS FOR VERY SMALL PHONES <= 420px ========== */
@media (max-width: 420px) {

  .hero-content h1 { font-size: 1.45rem; }
  .hero-content p { font-size: 0.95rem; }

  .author-carousel-item { min-width: calc(50% - 10px); height:78px; }
  .author-icon { width:52px; height:52px; }

  .novel-carousel.covers-only .novel-card { flex: 0 0 88%; max-width: 88%; }

  .genre-ranking-column { flex: 0 0 92%; max-width: 92%; min-width: 92%; }

  .genre-carousel-item { flex: 0 0 calc(100% - 12px); width: calc(100% - 12px); } /* fallback: single column on very small phones */

  .series-carousel-item { flex: 0 0 72%; width: 72%; }

  .genre-novel-carousel .novel-card { flex: 0 0 92%; min-width: 92%; }

  .section-header h2 { font-size: 1rem; }
}
