/* ============================================================
   Nexus — Lapisan dasar bersama (Obsidian Neon Interface)
   Dimuat di setiap halaman sebelum <style> khusus halaman.
   Berisi: token warna inti, ikon Material, shell body, dan sistem toast.
   Sengaja CSS murni (bukan kelas Tailwind) agar komponen yang disuntik
   JS tetap tampil utuh tanpa menunggu CDN memindai DOM.
   ============================================================ */

/* ---------- Token warna inti ---------- */
:root {
  --nx-void: #0a0e17;
  --nx-surface: #0f131c;
  --nx-surface-low: #181b25;
  --nx-surface-container: #1c1f29;
  --nx-outline: #3a494b;
  --nx-on-surface: #dfe2ef;
  --nx-on-surface-variant: #b9cacb;
  --nx-cyan: #00f2fe;
  --nx-emerald: #00ffa3;
  --nx-error: #ffb4ab;
}

/* ---------- Ikon Material Symbols ---------- */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

/* ---------- Shell body ---------- */
html { -webkit-tap-highlight-color: transparent; }

body {
  min-height: max(884px, 100dvh);
  overscroll-behavior-y: none;
}

/* Fokus keyboard yang terlihat tanpa merusak estetika */
:focus-visible {
  outline: 2px solid var(--nx-cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================
   Toast (disuntik oleh NX.toast)
   ============================================================ */
.nx-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--nx-toast-naik, 24px));
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 26rem);
  pointer-events: none;
}

.nx-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(24, 27, 37, 0.94);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8);
  color: var(--nx-on-surface);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  line-height: 20px;
  pointer-events: auto;
  animation: nx-toast-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.nx-toast--leaving { animation: nx-toast-out 0.22s ease forwards; }

.nx-toast .material-symbols-outlined { font-size: 20px; }

.nx-toast--info { border-color: rgba(0, 242, 254, 0.35); }
.nx-toast--info .material-symbols-outlined { color: var(--nx-cyan); }

.nx-toast--success { border-color: rgba(0, 255, 163, 0.4); }
.nx-toast--success .material-symbols-outlined { color: var(--nx-emerald); }

/* Reward mining: pill kecil turun dari atas seperti notifikasi. */
.nx-toast-host--top {
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  bottom: auto;
}
.nx-toast-host--top .nx-toast { animation-name: nx-toast-in-top; }
.nx-toast-host--top .nx-toast--leaving { animation-name: nx-toast-out-top; }
.nx-toast--mining {
  align-self: center;
  width: max-content;
  max-width: 100%;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  border-color: rgba(0, 255, 163, .24);
  background: rgba(15, 30, 29, .96);
  color: var(--nx-emerald);
  font: 600 12px/18px 'Space Grotesk', sans-serif;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.nx-toast--mining .material-symbols-outlined { font-size: 16px; }

.nx-toast--error { border-color: rgba(255, 180, 171, 0.4); }
.nx-toast--error .material-symbols-outlined { color: var(--nx-error); }

@keyframes nx-toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes nx-toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.97); }
}

@keyframes nx-toast-in-top {
  from { opacity: 0; transform: translateY(-24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes nx-toast-out-top {
  to { opacity: 0; transform: translateY(-16px) scale(0.97); }
}

@media (prefers-reduced-motion: reduce) {
  .nx-toast, .nx-toast--leaving,
  .nx-toast-host--top .nx-toast, .nx-toast-host--top .nx-toast--leaving { animation: none; }
}

/* ============================================================
   Layar aplikasi (satu berkas, sembilan layar)
   Perpindahan dianimasikan lewat class, bukan transform permanen,
   supaya elemen position:fixed di dalam layar tetap benar saat diam.
   ============================================================ */
.nx-screen {
  display: none;
  width: 100%;
}

.nx-screen.is-active {
  display: block;
}

/* Router menyembunyikan layar lama langsung; hanya layar tujuan dianimasikan. */

/* PENTING: animasi layar TIDAK BOLEH memakai transform.
   Elemen dengan transform menjadi containing block bagi anak position:fixed,
   sehingga bilah nav bawah dan latar glow milik layar akan lepas dari viewport
   selama animasi berlangsung lalu "nyeplos" kembali setelah selesai.
   Karena itu perpindahan memakai opacity saja. */
@keyframes nx-masuk-maju {
  from { opacity: 0; }
  to { opacity: 1; }
}

.nx-screen.is-entering { animation: nx-masuk-maju 0.26s cubic-bezier(0.22, 1, 0.36, 1); }

@media (prefers-reduced-motion: reduce) {
  .nx-screen.is-entering { animation: none; }
}

/* Latar viewport bersama, di luar animasi dan susunan lapisan setiap layar. */
.nx-app-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 500px 350px at 50% 0%, rgba(0, 242, 254, 0.06), transparent 75%),
    radial-gradient(ellipse 300px 300px at 100% 60%, rgba(0, 255, 163, 0.035), transparent 75%),
    radial-gradient(ellipse 320px 320px at 0% 100%, rgba(0, 242, 254, 0.025), transparent 75%),
    var(--nx-void);
}

/* Header dan area konten bersama. */
.nx-app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(10, 14, 23, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(58, 73, 75, 0.3);
}
.nx-app-header-inner {
  max-width: 448px;
  margin: 0 auto;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.nx-header-leading { display: flex; align-items: center; gap: 6px; min-width: 0; }
.nx-header-trailing { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.nx-header-protection { display: inline-flex; align-items: center; justify-content: center; gap: 4px; flex-shrink: 0; padding: 5px 7px; border: 1px solid rgba(0,255,163,.2); border-radius: 999px; background: rgba(0,255,163,.05); color: var(--nx-emerald); font: 600 8px/14px 'Space Grotesk', sans-serif; white-space: nowrap; }
.nx-header-protection .material-symbols-outlined { font-size: 13px; }
.nx-header-latency { display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; padding: 5px 7px; border: 1px solid rgba(58,73,75,.4); border-radius: 999px; background: rgba(28,31,41,.8); color: var(--nx-cyan); font: 500 9px/14px ui-monospace, monospace; white-space: nowrap; }
.nx-latency-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--nx-emerald); box-shadow: 0 0 6px rgba(0,255,163,.7); }
.nx-notification-button, .nx-header-brand-icon { width: 36px; height: 36px; flex-shrink: 0; }
.nx-app-brand { display: flex; align-items: center; gap: 6px; color: #e0fdff; font: 700 24px/32px 'Space Grotesk', sans-serif; letter-spacing: 1.2px; }
.nx-brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nx-cyan); box-shadow: 0 0 8px var(--nx-cyan); }
.nx-header-brand-icon { display: flex; align-items: center; justify-content: center; }
.nx-notification-button { display: flex; align-items: center; justify-content: center; justify-self: end; border: 0; border-radius: 8px; color: var(--nx-cyan); background: transparent; cursor: pointer; }
.nx-notification-button:hover { background: rgba(38,42,52,.4); }
.nx-brand-mark { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 28px; border: 1px solid rgba(0,242,254,.4); border-radius: 8px; background: #262a34; box-shadow: 0 0 10px rgba(0,242,254,.3); }
.nx-brand-mark .material-symbols-outlined { color: var(--nx-cyan); font-size: 18px; font-variation-settings: 'FILL' 1; }
@media (max-width: 420px) {
  .nx-header-trailing { gap: 4px; }
  .nx-header-protection { width: 28px; height: 28px; padding: 0; }
  .nx-protection-label { display: none; }
}
@media (max-width: 360px) {
  .nx-app-header-inner { gap: 4px; }
  .nx-header-leading { gap: 3px; }
  .nx-header-brand-icon { width: 28px; }
  .nx-header-latency { gap: 4px; padding: 4px 5px; font-size: 8px; }
}
.nx-screen[data-with-nav] { position: relative; z-index: 1; min-height: calc(100dvh - 60px); }
.nx-app-content { width: 100%; max-width: 448px; margin: 0 auto; padding: 16px 16px calc(112px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }

/* Navigasi kapsul bersama. Hanya menu aktif yang mengembang. */
.nx-bottom-nav {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 400px);
  padding: 7px;
  border: 1px solid rgba(185, 202, 203, 0.16);
  border-radius: 999px;
  background: rgba(15, 23, 32, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), inset 0 1px rgba(255, 255, 255, 0.05);
}
.nx-bottom-nav-inner { display: flex; align-items: center; gap: 6px; }
.nx-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 52px;
  min-width: 0;
  height: 52px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--nx-on-surface-variant);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: flex-grow 240ms ease, background-color 240ms ease, border-color 240ms ease, color 240ms ease;
}
.nx-nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nx-nav-icon .material-symbols-outlined { font-size: 23px; font-variation-settings: 'FILL' 0, 'wght' 450; }
.nx-nav-label {
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 240ms ease, margin-left 240ms ease;
}
.nx-nav-item[aria-current="page"] {
  flex-grow: 1;
  color: var(--nx-cyan);
  border-color: rgba(0, 242, 254, 0.3);
  background: rgba(0, 242, 254, 0.1);
  box-shadow: inset 0 0 18px rgba(0, 242, 254, 0.06), 0 0 14px rgba(0, 242, 254, 0.07);
}
.nx-nav-item[aria-current="page"] .nx-nav-label {
  max-width: 120px;
  margin-left: 8px;
  opacity: 1;
  transition: max-width 240ms ease, margin-left 240ms ease, opacity 120ms ease 120ms;
}
.nx-nav-item[aria-current="page"] .material-symbols-outlined { font-variation-settings: 'FILL' 1, 'wght' 600; }
@media (max-width: 360px) {
  .nx-nav-item { flex-basis: 48px; padding: 0 10px; }
}
@media (hover: hover) {
  .nx-nav-item:not([aria-current="page"]):hover { background: rgba(185, 202, 203, 0.08); color: var(--nx-on-surface); }
}
@media (prefers-reduced-motion: reduce) {
  .nx-nav-item, .nx-nav-label, .nx-nav-item[aria-current="page"] .nx-nav-label { transition: none; }
}

/* Layar dengan bilah nav bawah: toast dinaikkan supaya tidak menutupi nav
   beserta tombol yang baru saja ditekan pengguna. */
body.nx-ada-nav {
  --nx-toast-naik: 100px;
}
