/* ═══════════════════════════════════════════════════════════════
   SIFA — Initial Loading Screen ("Tumpukan Kartu")
   Kartu-kartu ilustrasi melayang bertumpuk dalam 3D, miring mengikuti
   mouse, bisa diseret/dilempar, dan dikocok selama memuat. Saat siap,
   kartu SIFA maju lalu membesar menutup layar. Logika: loading-screen.js
   Theme-aware: reads html[data-theme] set synchronously by theme-init.js
   ═══════════════════════════════════════════════════════════════ */

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

body {
  margin: 0;
  overflow: hidden;
}

html {
  overflow: hidden scroll;
}

/* ── Theme tokens (mirrors src/plugins/vuetify/theme.js) ───────── */
:root,
html[data-theme='dark'] {
  --iron-accent: #666CFF;
  --cs-desk: #0D0F18;
  --cs-text-soft: rgba(184, 188, 204, 0.6);
  --cs-word-stroke: rgba(184, 188, 204, 0.09);
  --cs-paper: #1C2030;
  --cs-paper-ink: #CDD0DC;
  --cs-skel: rgba(205, 208, 220, 0.12);
  --cs-skel-strong: rgba(205, 208, 220, 0.5);
  --cs-ink-card: #262A3B;
  --cs-ink-card-text: #E6E7EE;
  --cs-gold: #FDB528;
  --cs-gold-ink: #3A2A05;
  --cs-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 34px 60px -24px rgba(0, 0, 0, 0.75), 0 8px 18px -8px rgba(0, 0, 0, 0.5);
}

html[data-theme='light'] {
  --cs-desk: #F5F1EE;
  --cs-text-soft: rgba(51, 46, 42, 0.55);
  --cs-word-stroke: rgba(51, 46, 42, 0.09);
  --cs-paper: #FFFFFF;
  --cs-paper-ink: #332E2A;
  --cs-skel: rgba(51, 46, 42, 0.08);
  --cs-skel-strong: rgba(51, 46, 42, 0.75);
  --cs-ink-card: #332E2A;
  --cs-ink-card-text: #F5F1EE;
  --cs-gold: #FDB528;
  --cs-gold-ink: #3A2A05;
  --cs-shadow: 0 30px 50px -26px rgba(51, 46, 42, 0.38), 0 6px 14px -6px rgba(51, 46, 42, 0.16);
}

/* ── Root overlay ───────────────────────────────────────────── */
#loading-container {
  --cs-w: clamp(280px, 40vw, 520px);
  --cs-h: calc(var(--cs-w) / 1.6);

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cs-desk);
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.4s ease;
}

#loading-container.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.cs-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Giant outlined wordmark behind the stack ───────────────── */
.cs-bg-word {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34vw;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--cs-word-stroke);
  pointer-events: none;
  will-change: transform;
  transition: opacity 0.5s ease;
}

#loading-container.is-finishing .cs-bg-word,
#loading-container.is-finishing .cs-foot {
  opacity: 0;
}

/* ── Stage & stack ──────────────────────────────────────────── */
.cs-stage {
  position: relative;
  z-index: 1;
  perspective: 1600px;
}

.cs-stack {
  position: relative;
  width: var(--cs-w);
  height: var(--cs-h);
  transform-style: preserve-3d;
}

.cs-card {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--cs-shadow);
  backface-visibility: hidden;
  touch-action: none;
  cursor: grab;
  transition:
    transform 0.7s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.4s ease,
    border-radius 0.6s ease;
  will-change: transform;
}

.cs-card.is-dragging {
  cursor: grabbing;
}

.cs-card-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(var(--cs-w) * 0.065);
  transition: opacity 0.25s ease;
}

.cs-card-body--row {
  flex-direction: row;
  align-items: center;
}

.cs-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cs-label {
  font-size: calc(var(--cs-w) * 0.032);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Card: Invoice ──────────────────────────────────────────── */
.cs-card--invoice {
  background: var(--cs-paper);
  color: var(--cs-paper-ink);
}

.cs-pill {
  font-size: calc(var(--cs-w) * 0.024);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--iron-accent);
  border: 1.5px solid var(--iron-accent);
  border-radius: 999px;
  padding: 0.3em 0.9em;
  transform: rotate(-4deg);
}

.cs-skel {
  display: flex;
  flex-direction: column;
  gap: calc(var(--cs-h) * 0.06);
}

.cs-skel i,
.cs-invoice-total i {
  display: block;
  height: calc(var(--cs-h) * 0.045);
  border-radius: 999px;
  background: var(--cs-skel);
}

.cs-skel-a { width: 72%; }
.cs-skel-b { width: 54%; }
.cs-skel-c { width: 63%; }
.cs-skel-d { width: 28%; }

.cs-invoice-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: calc(var(--cs-h) * 0.06);
  border-top: 1.5px dashed var(--cs-skel);
}

.cs-blob {
  display: block;
  width: 34%;
  height: calc(var(--cs-h) * 0.085);
  border-radius: 999px;
  background: var(--cs-skel-strong);
}

/* ── Card: Arus Kas ─────────────────────────────────────────── */
.cs-card--cash {
  background: var(--cs-ink-card);
  color: var(--cs-ink-card-text);
}

.cs-trend {
  font-size: calc(var(--cs-w) * 0.045);
  line-height: 1;
  color: var(--iron-accent);
}

.cs-bars {
  display: flex;
  align-items: flex-end;
  gap: 4%;
  height: 52%;
}

.cs-bars i {
  flex: 1;
  border-radius: 6px 6px 2px 2px;
  background: var(--iron-accent);
  transform-origin: 50% 100%;
  animation: cs-bar 1.8s ease-in-out infinite alternate;
}

.cs-bars i:nth-child(1) { height: 38%; opacity: 0.55; animation-delay: -0.2s; }
.cs-bars i:nth-child(2) { height: 60%; opacity: 0.62; animation-delay: -0.9s; }
.cs-bars i:nth-child(3) { height: 46%; opacity: 0.69; animation-delay: -0.5s; }
.cs-bars i:nth-child(4) { height: 74%; opacity: 0.76; animation-delay: -1.3s; }
.cs-bars i:nth-child(5) { height: 58%; opacity: 0.84; animation-delay: -0.1s; }
.cs-bars i:nth-child(6) { height: 88%; opacity: 0.92; animation-delay: -1.1s; }
.cs-bars i:nth-child(7) { height: 100%; animation-delay: -0.7s; }

/* ── Card: Anggaran ─────────────────────────────────────────── */
@property --cs-p {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 0%;
}

.cs-card--budget {
  background: var(--cs-gold);
  color: var(--cs-gold-ink);
}

.cs-budget-text {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-self: stretch;
  flex: 1;
}

.cs-legend {
  display: flex;
  flex-direction: column;
  gap: calc(var(--cs-h) * 0.07);
}

.cs-legend i {
  display: block;
  height: calc(var(--cs-h) * 0.045);
  border-radius: 999px;
  background: rgba(58, 42, 5, 0.18);
}

.cs-legend-a { width: 62%; background: rgba(58, 42, 5, 0.8) !important; }
.cs-legend-b { width: 46%; }
.cs-legend-c { width: 54%; }

.cs-donut {
  --cs-p: 72%;

  flex: none;
  width: calc(var(--cs-h) * 0.62);
  height: calc(var(--cs-h) * 0.62);
  border-radius: 50%;
  background: conic-gradient(var(--cs-gold-ink) 0 var(--cs-p), rgba(58, 42, 5, 0.15) 0);
  -webkit-mask: radial-gradient(circle, transparent 52%, #000 53%);
  mask: radial-gradient(circle, transparent 52%, #000 53%);
  animation: cs-fill 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite alternate;
}

/* ── Card: SIFA (brand) ─────────────────────────────────────── */
.cs-card--brand {
  background-color: var(--iron-accent);
  background-image:
    repeating-radial-gradient(circle at 100% 100%, rgba(255, 255, 255, 0.1) 0 1px, transparent 1px 26px),
    linear-gradient(150deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.12));
  color: #FFFFFF;
}

.cs-card--brand.is-zoom {
  border-radius: 0;
  box-shadow: none;
}

.cs-card--brand.is-zoom .cs-card-body {
  opacity: 0;
}

.cs-brand-mark {
  width: calc(var(--cs-w) * 0.1);
  height: auto;
  fill: #FFFFFF;
}

.cs-brand-text {
  display: flex;
  flex-direction: column;
}

.cs-brand-name {
  font-size: calc(var(--cs-w) * 0.105);
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}

.cs-brand-sub {
  margin-top: 0.5em;
  font-size: calc(var(--cs-w) * 0.03);
  font-weight: 500;
  opacity: 0.8;
}

/* ── Footer: status + drag hint ─────────────────────────────── */
.cs-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(28px, 7vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--cs-text-soft);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cs-status {
  letter-spacing: 0.04em;
}

.cs-hint {
  font-size: 0.7rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.cs-hint.is-on {
  opacity: 0.8;
  transform: translateY(0);
}

/* ── Keyframes ──────────────────────────────────────────────── */
@keyframes cs-bar {
  from { transform: scaleY(0.62); }
  to   { transform: scaleY(1); }
}

@keyframes cs-fill {
  from { --cs-p: 34%; }
  to   { --cs-p: 78%; }
}

/* ── Small screens ──────────────────────────────────────────── */
@media (max-width: 520px) {
  #loading-container {
    --cs-w: 84vw;
  }

  .cs-bg-word {
    font-size: 46vw;
  }

  .cs-card {
    border-radius: 18px;
  }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cs-card {
    transition-duration: 0.01ms !important;
  }

  .cs-bars i,
  .cs-donut {
    animation: none;
  }
}
