/* =======================================
   STYLING UTAMA STORYMAP - AESPACE v3
   ======================================= */

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  font-family: "Poppins", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(90deg, #062513 0%, #0d3d25 32%, #e8f5e9 32%);
  color: #e8faf0;
  scroll-behavior: smooth;
}

/* ======================
   MAP FULLSCREEN
   ====================== */
#map {
  position: fixed;
  top: 0;
  right: 0;
  width: 75%;
  height: 100%;
  z-index: 1;
  background: #e8f5e9;
  filter: saturate(1.1) brightness(1);
}

/* ======================
   STORY WRAPPER
   ====================== */
#story-wrapper {
  position: relative;
  z-index: 10;
  width: 100%;
}

/* ======================
   SETIAP BAGIAN CERITA
   ====================== */
section.story {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* PANEL MELAYANG DI ATAS PETA */
.story-panel {
  position: absolute;
  top: 50%;
  left: 3%;
  margin-left: 0;
  transform: translateY(-50%);
  width: 24%;
  min-width: 260px;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(4, 30, 20, 0.92), rgba(13, 65, 35, 0.88));
  backdrop-filter: blur(6px) saturate(1.1);
  border-radius: 22px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 50px rgba(18, 50, 32, 0.45);
  transition: transform 0.6s ease, opacity 0.6s ease, box-shadow 0.4s ease;
  opacity: 0;
  transform-origin: left;
  color: #f6fff5;
}
/* Position panels on the right-hand side for alternating sections */
.story.right .story-panel {
  left: auto;
  right: 3%;
  transform-origin: right;
}

/* Saat aktif di layar */
section.story.active .story-panel {
  opacity: 1;
  transform: translateY(-50%) translateX(6px);
  box-shadow: 0 24px 68px rgba(6, 47, 23, 0.45);
}

/* For right-side panels, shift slightly to left when active so it looks consistent */
.story.right .story-panel.active {
  transform: translateY(-50%) translateX(-6px) scale(1.02);
}

/* Animasi masuk */
.story-panel {
  transform: translateY(-55%);
}

/* Judul Lokasi */
.story-panel h2 {
  font-size: 1.8rem;
  color: #ffffff;
  margin-bottom: 0.55rem;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.2px;
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Teks Narasi */
.story-panel p {
  font-size: 0.98rem;
  line-height: 1.6;
  color: rgba(246,255,245,0.95);
  margin-bottom: 1rem;
  text-align: justify;
}

/* ======================
   GALERI FOTO
   ====================== */
.gallery {
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  margin-top: 1.25rem;
  align-items: flex-start;
  justify-content: center;
}

.gallery img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  object-fit: cover;
  border: 3px solid #52b788;
  cursor: pointer;
  transition: all 0.35s ease;
}

.gallery img:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

/* Only show the first image in the gallery by default (hide thumbnails/below images) */
.gallery img:not(:first-child) {
  display: none;
}

/* ======================
   SCROLL & EFEK AKTIF
   ====================== */
section.story.active .story-panel {
  /* Keep gradient, slightly brighten and border with accent */
  background: linear-gradient(180deg, rgba(15, 66, 35, 0.98), rgba(23, 93, 48, 0.95));
  border: 1px solid rgba(82, 183, 136, 0.18);
}

/* ======================
   RESPONSIVE DESIGN
   ====================== */

/* Large desktops and laptops */
@media screen and (max-width: 1200px) {
  #map {
    width: 70%;
  }

  .story-panel {
    width: 26%;
    max-width: 350px;
  }
}

/* Medium desktops and laptops */
@media screen and (max-width: 1024px) {
  #map {
    width: 65%;
  }

  .story-panel {
    width: 30%;
    padding: 1.6rem;
    max-width: 320px;
  }

  .story-panel h2 {
    font-size: 1.6rem;
  }

  .gallery img {
    width: 140px;
    height: 140px;
  }
}

/* Tablets and small laptops */
@media screen and (max-width: 768px) {
  #map {
    position: relative;
    width: 100%;
    height: 50vh;
    top: auto;
    right: auto;
  }

  #story-wrapper {
    margin-top: 50vh;
  }

  section.story {
    min-height: auto;
    padding: 2rem 0;
  }

  .story-panel {
    position: static;
    transform: none;
    width: 90%;
    max-width: none;
    margin: 0 auto;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  }

  section.story.active .story-panel {
    transform: none;
  }

  .gallery img {
    width: 120px;
    height: 120px;
  }

  .pdf-preview-btn {
    font-size: 0.9rem;
    padding: 0.6rem 1.2rem;
  }
}

/* Mobile landscape */
@media screen and (max-width: 640px) {
  .story-panel {
    width: 95%;
    padding: 1.2rem;
    border-radius: 12px;
  }

  .story-panel h2 {
    font-size: 1.4rem;
  }

  .story-panel p {
    font-size: 0.95rem;
    line-height: 1.5;
  }

  .gallery {
    gap: 8px;
  }

  .gallery img {
    width: 100px;
    height: 100px;
  }

  .pdf-preview-btn {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }
}

/* Mobile portrait */
@media screen and (max-width: 480px) {
  html, body {
    font-size: 14px;
  }

  #map {
    height: 40vh;
  }

  #story-wrapper {
    margin-top: 40vh;
  }

  section.story {
    padding: 1.5rem 0;
  }

  .story-panel {
    width: 95%;
    padding: 1rem;
    border-radius: 10px;
  }

  .story-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
  }

  .story-panel p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .gallery {
    gap: 6px;
    margin-top: 1.5rem;
  }

  .gallery img {
    width: 80px;
    height: 80px;
  }

  .pdf-preview-btn {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    margin-top: 0.8rem;
  }

  .location-label {
    font-size: 10px;
    padding: 1px 3px;
    min-width: 40px;
  }
}

/* Small mobile devices */
@media screen and (max-width: 360px) {
  .story-panel {
    width: 98%;
    padding: 0.8rem;
  }

  .story-panel h2 {
    font-size: 1.2rem;
  }

  .story-panel p {
    font-size: 0.85rem;
  }

  .gallery img {
    width: 70px;
    height: 70px;
  }

  .pdf-preview-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
  }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
  .gallery img:hover {
    transform: none;
  }

  .pdf-preview-btn:hover {
    transform: none;
  }

  .image-marker-container:hover {
    transform: none;
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .story-panel {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  }

  .gallery img {
    border-width: 2px;
  }
}

/* ======================
   SCROLLBAR KUSTOM
   ====================== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background: #74c69d;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #40916c;
}

/* ======================
   TRANSISI HALUS
   ====================== */
section.story .story-panel {
  transition: opacity 0.8s ease, transform 0.8s ease, box-shadow 0.4s ease;
}

/* ======================
   LABEL LOKASI PADA PETA
   ====================== */
.location-label {
  /* Hide legacy map label pills — switch to in-panel small labels */
  display: none !important;
}

/* Small label inside the story panel (below description) */
.photo-label {
  display: inline-block;
  background: linear-gradient(135deg, #1abb3c, #0f4c23);
  color: white;
  padding: 6px 10px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  margin-top: 8px;
}
.photo-label-active {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.26);
}

/* Gallery item wrapper */
.gallery-item {
  position: relative;
  display: inline-block;
  overflow: visible;
  border-radius: 10px;
}

/* Image caption shown under each image (keren) */
.image-caption {
  display: inline-block;
  background: rgba(0,0,0,0.48);
  color: #fff;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 8px;
}

/* ================================
   SLIDER STYLES
   ================================ */
.slider {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.slider:focus { outline: none; box-shadow: 0 0 0 4px rgba(26,187,60,0.12); border-radius: 10px; }
.slider-main {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Hide any leftover multi-image content to ensure a single main image panel */
.slider-content, .slider-inner {
  display: none !important;
}
.slider-main .head {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 20;
  background: rgba(0,0,0,0.38);
  padding: 4px 6px;
  border-radius: 8px;
  color: #fff;
  width: auto;
  max-width: calc(100% - 16px);
  backdrop-filter: blur(2px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.slider-main .head h2 { margin: 0; font-weight: 700; line-height: 1; font-size: clamp(0.75rem, 1.2vw, 0.95rem); }
.slider-main .head p { margin: 2px 0 0; font-size: clamp(0.62rem, 0.9vw, 0.8rem); opacity: 0.85; }
.swap-anim .slider-main-img { transform: scale(0.97) translateY(-4px); opacity: 0.95; filter: saturate(0.98) brightness(0.98); }
.swap-anim .slider-overlay, .slider-overlay.swap-anim { transform: translateY(-10px) scale(1.02); }
.slider-main-img {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 12px;
  border: 3px solid rgba(82,183,136,0.15);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  transition: transform 0.4s ease;
  cursor: pointer;
}
.slider-main-img:hover { transform: scale(1.03); }
.slider-controls { position: absolute; top: 50%; width: 100%; display: flex; justify-content: space-between; transform: translateY(-50%); pointer-events: none; }
.slider-controls button { pointer-events: all; border: none; background: rgba(0,0,0,0.45); color: #fff; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; cursor: pointer; box-shadow: 0 8px 20px rgba(0,0,0,0.35); }
.slider-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px; justify-content: center; }
.slider-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; cursor: pointer; opacity: 0.8; border: 2px solid transparent; }
.slider-thumb.active { opacity: 1; border-color: #1abb3c; transform: scale(1.02); }
.slider-main-caption { margin-top: 6px; font-weight: 800; font-size: 13px; color: #ffffff; background: linear-gradient(90deg, rgba(15,76,35,0.95), rgba(26,187,60,0.95)); padding: 6px 10px; border-radius: 12px; box-shadow: 0 10px 26px rgba(0,0,0,0.18); }

/* Overlay small thumbnail inside the main image (bottom-right) */
.slider-overlay {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 110px;
  height: 82px;
  border-radius: 10px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,0.9);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  transition: transform 0.32s cubic-bezier(.2,.7,.2,1), box-shadow 0.2s ease;
}
.slider-overlay:hover { transform: translateY(-6px); box-shadow: 0 18px 38px rgba(0,0,0,0.6); }
.slider-overlay-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slider-overlay-caption { display: none !important; }

@media screen and (max-width: 1024px) {
  .slider-main-img { height: 180px; }
  .slider-thumb { width: 56px; height: 56px; }
}
@media screen and (max-width: 768px) {
  .slider-main-img { height: 140px; }
  .slider-thumb { width: 44px; height: 44px; }
}

/* When items are smaller (responsive), shrink caption width */
@media screen and (max-width: 1024px) {
  .image-caption { width: 140px; }
}
@media screen and (max-width: 768px) {
  .image-caption { width: 120px; }
}

/* Image modal / lightbox */
#image-modal {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.64);
}
.image-modal-content {
  position: relative;
  max-width: 92%;
  max-height: 92%;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.02));
  border-radius: 12px;
  padding: 6px;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.image-modal img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  border-radius: 8px;
}
.image-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: white;
  font-size: 22px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
}
.image-modal-title {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(15,76,35,0.95), rgba(26,187,60,0.95));
}

/* ======================
   PDF PREVIEW BUTTON
   ====================== */
/* Small badge for the h2 */
.story-panel h2:before { display: none; }
.pdf-preview-btn {
  display: block;
  margin: 1rem auto 0;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(90deg, #20a45d, #12a64b);
  color: white;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 6px 20px rgba(12, 80, 40, 0.4);
}

.pdf-preview-btn:hover {
  background: linear-gradient(135deg, #40916c, #2d6a4f);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(82, 183, 136, 0.4);
}

.pdf-preview-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(82, 183, 136, 0.3);
}

/* ======================
   IMAGE MARKERS ON MAP
   ====================== */
.image-marker-container {
  position: relative;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #52b788;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  cursor: pointer;
}

.image-marker-container:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.image-marker-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.image-marker-border {
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border: 2px solid rgba(82, 183, 136, 0.5);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ======================
   POPUP CONTENT STYLES
   ====================== */
.popup-content {
  max-width: 300px;
  text-align: center;
}

.popup-content h3 {
  margin: 0 0 10px 0;
  font-size: 1.2rem;
  color: #ffffff;
  font-weight: 700;
}

.popup-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-height: 200px;
  overflow-y: auto;
}

.popup-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(82, 183, 136, 0.3);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.popup-image:hover {
  transform: scale(1.05);
  border-color: #52b788;
}

/* ======================
   PDF PREVIEW CONTAINER
   ====================== */
#pdf-preview-container {
  position: fixed;
  top: 5%;
  left: 5%;
  width: 90%;
  height: 90%;
  background: white;
  border: 1px solid #ccc;
  z-index: 1000;
  display: none;
}

#pdf-preview-container .pdf-header {
  padding: 10px;
  background: #f0f0f0;
  border-bottom: 1px solid #ccc;
  position: relative;
}

#close-pdf-preview {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 20px;
  background: none;
  border: none;
  cursor: pointer;
}

#pdf-iframe {
  width: 100%;
  height: calc(100% - 60px);
  border: none;
  pointer-events: auto; /* Allow scrolling */
  user-select: none; /* Prevent text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  overflow: auto; /* Allow scrolling */
  touch-action: pan-y; /* Allow vertical scrolling on touch */
  -webkit-touch-callout: none; /* Disable callout on iOS */
}

#pdf-iframe::-webkit-scrollbar {
  display: none; /* Hide scrollbar if possible */
}
