/* =====================================================
   BAB — Layar Pilih Bab (Pulau-Pulau Nusantara)
   Layout Responsif Penuh Tinggi & Lebar (Landscape & Desktop)
   ===================================================== */

#screen-bab {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: none;
  flex-direction: column;
  background-image: url("../assets/images/backgrounds/bg-main-menu.webp");
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-attachment: scroll !important;
  overflow: hidden;
  position: relative;
}


#screen-bab.active {
  display: flex;
}

#screen-bab > * {
  position: relative;
  z-index: 1;
}

/* =====================================================
   CONTAINER PETA PULAU (Flexbox Centered Vertical & Horizontal)
   ===================================================== */
#screen-bab .bab-grid {
  flex: 1;
  width: 100%;
  max-width: min(96vw, 1200px);
  height: 100%;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-evenly;
  padding: var(--gap-md) var(--gap-lg);
  gap: var(--gap-lg);
  box-sizing: border-box;
}

@media (max-width: 767px) {
  #screen-bab .bab-grid {
    flex-direction: column;
    justify-content: center;
  }
  .bab-item {
    --img-w: clamp(100px, 40vw, 160px);
    max-width: 100%;
  }
}

/* =====================================================
   ITEM PULAU
   ===================================================== */
.bab-item {
  --img-w: clamp(140px, min(26vw, 42vh), 320px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vh, 8px);
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  flex: 1;
  max-width: min(32vw, 360px);
  z-index: 2;
  user-select: none;
}

.bab-item:hover {
  transform: translateY(-8px) scale(1.06);
  filter: brightness(1.05);
}

.bab-item:active {
  transform: translateY(2px) scale(0.96);
}

/* Gambar Pulau */
.bab-item img {
  width: 100%;
  max-width: var(--img-w);
  height: auto;
  max-height: min(44vh, 260px);
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(91, 58, 30, 0.35));
  transition: transform 0.2s ease;
}

/* Nama Bab */
.bab-item .bab-nama {
  font-family: var(--font-judul);
  font-weight: 800;
  font-size: clamp(1rem, 2.8vmin, 1.5rem);
  color: var(--putih);
  text-shadow: 0 2px 0 var(--coklat), 0 0 10px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

/* Badge Bintang */
.bab-item .bab-bintang {
  background: var(--putih);
  border-radius: 999px;
  padding: clamp(3px, 0.8vh, 6px) clamp(10px, 2vw, 18px);
  font-weight: 800;
  font-size: clamp(0.82rem, 2.2vmin, 1.15rem);
  box-shadow: 0 3px 0 rgba(91, 58, 30, 0.18), 0 4px 10px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  color: var(--coklat);
}

/* Sentuhan artistik dinamis: variasi posisi kepulauan */
.bab-item.bab-budaya,
.bab-item:nth-child(2) {
  transform: translateY(clamp(-8px, -1.8vh, -4px));
}
.bab-item.bab-budaya:hover,
.bab-item:nth-child(2):hover {
  transform: translateY(clamp(-16px, -3.5vh, -10px)) scale(1.06);
}

.bab-item.bab-agama,
.bab-item:nth-child(3) {
  transform: translateY(clamp(6px, 1.5vh, 12px));
}
.bab-item.bab-agama:hover,
.bab-item:nth-child(3):hover {
  transform: translateY(clamp(-2px, 0vh, 4px)) scale(1.06);
}

/* =====================================================
   MEDIA QUERIES KHUSUS HP LANDSCAPE PENDEK (max-height: 480px)
   ===================================================== */
@media (max-height: 480px) and (orientation: landscape) {
  #screen-bab .bab-grid {
    padding: 2px 12px 10px;
    gap: clamp(6px, 1.5vw, 16px);
  }
  .bab-item {
    --img-w: clamp(120px, min(24vw, 42vh), 200px);
    gap: 3px;
  }
  .bab-item img {
    max-height: 38vh;
  }
  .bab-item .bab-nama {
    font-size: clamp(0.85rem, 2.4vmin, 1.1rem);
  }
  .bab-item .bab-bintang {
    padding: 2px 10px;
    font-size: clamp(0.72rem, 2vmin, 0.9rem);
  }
}

.mini-game-btn {
  position: absolute;
  top: 10%;
  right: -5%;
  width: clamp(48px, 10vw, 70px);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease;
  z-index: 10;
  animation: floatMini 3s ease-in-out infinite;
}
.mini-game-btn:hover {
  transform: scale(1.15) rotate(5deg);
  filter: brightness(1.1);
}
.mini-game-btn:active {
  transform: scale(0.95);
}
.mini-game-btn img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}
@keyframes floatMini {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
