/* Landing scroll — rapi, futuristik, tema biru Kabupaten Brebes */

:root {
  --lsb-size: 5px;
  --lsb-gap: 14px;
  --lsb-thumb-min: 56px;
  --lsb-color: #0d7fb4;
  --lsb-color-light: #3a9bc9;
  --lsb-track-bg: rgba(13, 127, 180, 0.12);
  --lsb-back-size: 44px;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Sembunyikan scrollbar native saat kustom aktif */
html.landing-has-custom-scrollbar,
html.landing-has-custom-scrollbar body {
  scrollbar-width: none !important;
  -ms-overflow-style: none;
}

html.landing-has-custom-scrollbar::-webkit-scrollbar,
html.landing-has-custom-scrollbar body::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

/* Fallback mobile / tanpa JS */
html.landing-scroll-themed:not(.landing-has-custom-scrollbar),
html.landing-scroll-themed:not(.landing-has-custom-scrollbar) body {
  scrollbar-width: thin;
  scrollbar-color: #0d7fb4 rgba(13, 127, 180, 0.15);
}

html.landing-scroll-themed:not(.landing-has-custom-scrollbar)::-webkit-scrollbar,
html.landing-scroll-themed:not(.landing-has-custom-scrollbar) body::-webkit-scrollbar {
  width: 8px;
}

html.landing-scroll-themed:not(.landing-has-custom-scrollbar)::-webkit-scrollbar-thumb,
html.landing-scroll-themed:not(.landing-has-custom-scrollbar) body::-webkit-scrollbar-thumb {
  border-radius: 100px;
  background: linear-gradient(180deg, #3a9bc9, #0d7fb4);
}

/* ========== Scrollbar kustom ========== */
.landing-scrollbar {
  position: fixed;
  top: var(--lsb-gap);
  right: 6px;
  bottom: var(--lsb-gap);
  width: calc(var(--lsb-size) + 8px);
  z-index: 9990;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.landing-scrollbar.is-ready {
  opacity: 0.55;
  visibility: visible;
}

.landing-scrollbar.is-ready:hover,
.landing-scrollbar.is-active,
.landing-scrollbar.is-dragging {
  opacity: 1;
}

.landing-scrollbar__track {
  position: absolute;
  inset: 0;
  width: var(--lsb-size);
  right: 0;
  left: auto;
  margin: 0 auto;
  pointer-events: auto;
  cursor: pointer;
  border-radius: 100px;
}

.landing-scrollbar__rail {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--lsb-track-bg);
}

.landing-scrollbar__thumb {
  position: absolute;
  left: 0;
  right: 0;
  min-height: var(--lsb-thumb-min);
  border-radius: inherit;
  cursor: grab;
  touch-action: none;
  background: linear-gradient(180deg, var(--lsb-color-light), var(--lsb-color));
  box-shadow: 0 0 8px rgba(13, 127, 180, 0.35);
  transition: box-shadow 0.2s ease;
  will-change: top, height;
}

.landing-scrollbar__thumb:hover,
.landing-scrollbar.is-dragging .landing-scrollbar__thumb {
  box-shadow: 0 0 12px rgba(13, 127, 180, 0.5);
}

.landing-scrollbar.is-dragging .landing-scrollbar__thumb,
.landing-scrollbar.is-dragging .landing-scrollbar__track {
  cursor: grabbing;
}

/* ========== Progress bar atas ========== */
.scroll-progress--futuristic .scroll-progress__top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 10000;
  pointer-events: none;
  background: rgba(38, 43, 53, 0.06);
}

.scroll-progress--futuristic .scroll-progress__top-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #085578, #0d7fb4, #3a9bc9);
  transition: transform 0.1s linear;
  will-change: transform;
}

/* ========== Tombol kembali ke atas ========== */
.scroll-progress.scroll-progress--futuristic {
  position: fixed;
  top: auto;
  right: 20px;
  bottom: 24px;
  left: auto;
  z-index: 9985;
  mix-blend-mode: normal;
  transform: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.scroll-progress.scroll-progress--futuristic.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.scroll-progress.scroll-progress--futuristic:not(.visible) {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.scroll-progress--futuristic .scroll-progress__back-top {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--lsb-back-size);
  height: var(--lsb-back-size);
  padding: 0;
  border: 1px solid rgba(13, 127, 180, 0.35);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: var(--lsb-color);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(26, 34, 40, 0.12);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease,
    color 0.2s ease;
}

.scroll-progress--futuristic .scroll-progress__back-top:hover,
.scroll-progress--futuristic .scroll-progress__back-top:focus-visible {
  border-color: var(--lsb-color);
  color: #085578;
  box-shadow: 0 6px 24px rgba(13, 127, 180, 0.22);
  transform: translateY(-2px);
  outline: none;
}

.scroll-progress--futuristic .scroll-progress__back-top:focus-visible {
  outline: 2px solid var(--lsb-color);
  outline-offset: 3px;
}

.scroll-progress--futuristic .scroll-progress__ring {
  position: absolute;
  inset: 0;
}

.scroll-progress--futuristic .scroll-progress__ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  display: block;
}

.scroll-progress--futuristic .scroll-progress__ring-bg {
  fill: none;
  stroke: rgba(13, 127, 180, 0.18);
  stroke-width: 2;
}

.scroll-progress--futuristic .scroll-progress__ring-fill {
  fill: none;
  stroke: url(#scroll-progress-gradient);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.12s linear;
}

.scroll-progress--futuristic .scroll-progress__pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--alt-font);
  font-size: 10px;
  font-weight: 600;
  color: var(--lsb-color);
  line-height: 1;
  pointer-events: none;
}

.scroll-progress--futuristic .scroll-progress__pct::after {
  content: '%';
  font-size: 7px;
  opacity: 0.8;
  margin-left: 0.5px;
}

.scroll-progress--futuristic .scroll-progress__icon {
  position: relative;
  z-index: 1;
  font-size: 16px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.scroll-progress--futuristic .scroll-progress__back-top:hover .scroll-progress__pct,
.scroll-progress--futuristic .scroll-progress__back-top:focus-visible .scroll-progress__pct {
  opacity: 0;
}

.scroll-progress--futuristic .scroll-progress__back-top:hover .scroll-progress__icon,
.scroll-progress--futuristic .scroll-progress__back-top:focus-visible .scroll-progress__icon {
  opacity: 1;
  transform: translateY(0);
}

/* Sembunyikan saat modal terbuka */
html.w-html-warta-detail-open .landing-scrollbar,
html.w-html-warta-detail-open .scroll-progress--futuristic,
html:has(.layanan-modal.is-open) .landing-scrollbar,
html:has(.layanan-modal.is-open) .scroll-progress--futuristic,
html:has(.diseminasi-modal.is-open) .landing-scrollbar,
html:has(.diseminasi-modal.is-open) .scroll-progress--futuristic,
html:has(.iks-modal.is-open) .landing-scrollbar,
html:has(.iks-modal.is-open) .scroll-progress--futuristic,
html:has(.sosialisasi-modal.is-open) .landing-scrollbar,
html:has(.sosialisasi-modal.is-open) .scroll-progress--futuristic,
html:has(.policy-brief-modal.is-open) .landing-scrollbar,
html:has(.policy-brief-modal.is-open) .scroll-progress--futuristic,
html:has(.sosialisasi-panduan-modal.is-open) .landing-scrollbar,
html:has(.sosialisasi-panduan-modal.is-open) .scroll-progress--futuristic {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 991.98px) {
  .landing-scrollbar {
    display: none !important;
  }

  .scroll-progress.scroll-progress--futuristic {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-progress--futuristic .scroll-progress__top-fill,
  .scroll-progress--futuristic .scroll-progress__ring-fill,
  .landing-scrollbar__thumb {
    transition: none;
  }
}
