/* ==========================================================================
   base.css — reset, tipografi, dan kerangka aplikasi (app shell) mobile first.
   Mobile: top bar + konten + navigasi bawah.  >= 1024px: navigasi samping.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sx-font);
  font-size: var(--sx-fs-base);
  line-height: var(--sx-lh);
  color: var(--sx-ink);
  background: var(--sx-shell);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd {
  margin: 0;
}

h1, h2, h3, h4 {
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: var(--sx-lh-tight);
}

a {
  color: var(--sx-primary);
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--sx-selection);
}

:focus-visible {
  outline: none;
  box-shadow: var(--sx-focus-ring);
  border-radius: var(--sx-r-sm);
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
}

.visually-hidden {
  /* !important: mengalahkan aturan komponen (mis. .select width:100%) agar elemen benar-benar tersembunyi */
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap;
}

.muted { color: var(--sx-muted); }
.tabular { font-variant-numeric: tabular-nums; }
.arabic {
  font-family: var(--sx-font-quran);
  direction: rtl;
  line-height: 2.1;
}

/* ---------- App shell ---------- */
.app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--sx-space-4));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--sx-z-nav);
  display: flex;
  align-items: center;
  gap: var(--sx-space-3);
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--sx-space-4) 0;
  background: color-mix(in srgb, var(--sx-shell) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--sx-dur-2) var(--sx-ease-out);
}

.topbar.is-scrolled {
  border-bottom-color: var(--sx-line);
}

.topbar__title {
  flex: 1;
  min-width: 0;
  font-size: var(--sx-fs-lg);
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sx-space-2);
  color: var(--sx-ink);
  font-weight: 700;
  font-size: var(--sx-fs-lg);
  letter-spacing: -0.02em;
}

.brand__mark {
  width: 32px;
  height: 32px;
}

.brand__one {
  color: var(--sx-accent);
}

.main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--sx-space-3) var(--sx-space-4) var(--sx-space-6);
}

.main--wide {
  max-width: 1080px;
}

/* Navigasi bawah (mobile) */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--sx-z-nav);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding: 0 var(--sx-space-2) var(--safe-bottom);
  background: color-mix(in srgb, var(--sx-surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--sx-line);
}

.nav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  color: var(--sx-muted);
  font-size: var(--sx-fs-2xs);
  font-weight: 550;
  transition: color var(--sx-dur-2) var(--sx-ease-out);
}

.nav-item .icon {
  width: 23px;
  height: 23px;
  transition: transform var(--sx-dur-3) var(--sx-ease-spring);
}

.nav-item:active .icon {
  transform: scale(0.88);
}

.nav-item.is-active {
  color: var(--sx-primary);
}

.nav-item.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--sx-primary);
}

/* Tombol tengah "Setor" yang menonjol */
.nav-item--cta {
  color: var(--sx-on-primary);
}

.nav-item--cta .nav-cta {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-top: -22px;
  border-radius: 50%;
  background: var(--sx-primary-bg);
  box-shadow: var(--sx-shadow-primary), 0 0 0 5px var(--sx-shell);
  transition: transform var(--sx-dur-3) var(--sx-ease-spring);
}

.nav-item--cta .nav-cta .icon {
  width: 26px;
  height: 26px;
}

.nav-item--cta:active .nav-cta {
  transform: scale(0.92);
}

.nav-item--cta span:last-child {
  color: var(--sx-primary);
}

.nav-item--cta.is-active::before {
  display: none;
}

.side-nav {
  display: none;
}

/* ---------- Desktop: navigasi samping ---------- */
@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: 248px 1fr;
    padding-bottom: 0;
  }

  .bottom-nav {
    display: none;
  }

  .side-nav {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sx-space-1);
    height: 100dvh;
    padding: var(--sx-space-5) var(--sx-space-3);
    border-right: 1px solid var(--sx-line);
    background: var(--sx-surface-2);
  }

  .side-nav .brand {
    padding: 0 var(--sx-space-3) var(--sx-space-5);
  }

  .side-link {
    display: flex;
    align-items: center;
    gap: var(--sx-space-3);
    height: 42px;
    padding: 0 var(--sx-space-3);
    border-radius: var(--sx-r-md);
    color: var(--sx-ink-2);
    font-weight: 550;
    transition: background-color var(--sx-dur-2) var(--sx-ease-out), color var(--sx-dur-2) var(--sx-ease-out);
  }

  .side-link:hover {
    background: var(--sx-fill);
  }

  .side-link.is-active {
    background: var(--sx-primary-soft);
    color: var(--sx-primary);
  }

  .side-nav__spacer {
    flex: 1;
  }

  .side-nav__label {
    padding: var(--sx-space-4) var(--sx-space-3) var(--sx-space-1);
    font-size: var(--sx-fs-2xs);
    font-weight: 650;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sx-faint);
  }

  .topbar .brand {
    display: none;
  }

  .main {
    padding: var(--sx-space-5) var(--sx-space-8) var(--sx-space-10);
  }
}

/* Reveal on scroll (diaktifkan oleh IntersectionObserver di app.js) */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--sx-dur-4) var(--sx-ease-out), transform var(--sx-dur-4) var(--sx-ease-out);
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Halaman masuk ke layar dengan halus */
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.main > * {
  animation: page-in var(--sx-dur-4) var(--sx-ease-out) backwards; /* backwards: setelah selesai tidak menyisakan transform, jadi elemen position:fixed di dalamnya tetap menempel ke layar */
}

.main > *:nth-child(2) { animation-delay: 40ms; }
.main > *:nth-child(3) { animation-delay: 80ms; }
.main > *:nth-child(4) { animation-delay: 120ms; }
.main > *:nth-child(n + 5) { animation-delay: 160ms; }

@view-transition {
  navigation: auto;
}

.app__main {
  min-width: 0;
}

/* Ikon tombol mode: bulan saat terang, matahari saat gelap */
.theme-icon { display: contents; }
:root[data-mode="dark"] .theme-icon--light,
:root:not([data-mode="dark"]) .theme-icon--dark {
  display: none;
}

/* Atribut hidden harus menang dari display komponen (flex/grid) */
[hidden] {
  display: none !important;
}
