/* ==========================================================================
   motion3d.css — Hybrid 3D & Motion Overhaul (Global, Home & Pages p0, p1, p3, p4, p6)
   GPU-accelerated CSS 3D depth, holographic foil, View Transitions circular
   theme wipe, and 3D WebGL stage framing.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. VIEW TRANSITIONS CIRCULAR THEME WIPE (Light <-> Dark)
   -------------------------------------------------------------------------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) {
  z-index: 1;
}
::view-transition-new(root) {
  z-index: 9999;
  animation: zkThemeWipe 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes zkThemeWipe {
  from {
    clip-path: circle(0px at var(--vt-x, 90%) var(--vt-y, 40px));
  }
  to {
    clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 90%) var(--vt-y, 40px));
  }
}

/* --------------------------------------------------------------------------
   2. SHARED REUSABLE 3D TILT, HOLOGRAPHIC FOIL, SPARKS & STAMP
   -------------------------------------------------------------------------- */
.zk-tilt3d {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
}
.zk-holo-foil {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background:
    radial-gradient(
      circle 220px at var(--gx, 50%) var(--gy, 50%),
      rgba(255, 255, 255, 0.42),
      transparent 65%
    ),
    linear-gradient(
      calc(115deg + var(--ga, 0deg)),
      rgba(255, 92, 141, 0.16) 0%,
      rgba(86, 204, 242, 0.18) 33%,
      rgba(255, 218, 92, 0.16) 66%,
      rgba(130, 240, 175, 0.16) 100%
    );
  mix-blend-mode: overlay;
  transition: opacity 0.28s ease;
}
.zk-tilt3d.is-tilting .zk-holo-foil {
  opacity: 1;
}

/* Micro-spark particles (HEX copy / interactions) */
.zk-spark {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1500;
  box-shadow: 0 0 10px currentColor;
}

/* Editorial Ink-Stamp Confirmation */
.pr-stamp {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1400;
  pointer-events: none;
  padding: 12px 26px;
  border: 3px solid #e0463a;
  border-radius: 10px;
  background: rgba(243, 238, 224, 0.94);
  color: #e0463a;
  font:
    800 clamp(14px, 2.2vw, 20px)/1 "Unbounded",
    system-ui,
    sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow:
    0 18px 42px -12px rgba(224, 70, 58, 0.45),
    inset 0 0 0 2px rgba(224, 70, 58, 0.2);
  transform: translate(-50%, -50%) rotate(-8deg);
}

/* --------------------------------------------------------------------------
   3. HOME CARDISTRY HOLOGRAPHIC PRISM SHEEN
   -------------------------------------------------------------------------- */
@media (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .card.on::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 5;
    border-radius: inherit;
    pointer-events: none;
    background: conic-gradient(
      from calc(var(--cx, 0) * 80deg + 120deg) at var(--mx, 50%) var(--my, 50%),
      rgba(255, 110, 160, 0.18),
      rgba(90, 210, 255, 0.18),
      rgba(255, 224, 110, 0.18),
      rgba(120, 245, 185, 0.16),
      rgba(255, 110, 160, 0.18)
    );
    mix-blend-mode: color-dodge;
    opacity: 0;
    transition: opacity 0.35s ease;
  }
  .card.on.tilting::before {
    opacity: 0.65;
  }
  .card.on {
    transform-style: preserve-3d;
  }
}

/* --------------------------------------------------------------------------
   4. PAGE p0 (STORY) — 3D PERSPECTIVE SCROLL CHAPTERS & EMBERS
   -------------------------------------------------------------------------- */
.pg.p0 .st-embers {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.72;
}
.pg.p0 .st-life {
  perspective: 1100px;
}
.pg.p0 .st-ch {
  transform-origin: 20% 50%;
  transition:
    transform 0.85s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}
.pg.p0 .st-ch.st-3d-ready {
  opacity: 0.22;
  transform: perspective(1000px) rotateX(8deg) translate3d(0, 28px, -28px);
}
.pg.p0 .st-ch.st-3d-ready.in-3d {
  opacity: 1;
  transform: perspective(1000px) rotateX(0deg) translate3d(0, 0, 0);
}
.pg.p0 .st-ch.is-pass h3 {
  text-shadow: 0 12px 34px rgba(224, 70, 58, 0.18);
}
.pg.p0 .st-ch.st-active-aura::before {
  content: "";
  position: absolute;
  left: calc(var(--st-g) - 18px);
  top: -12px;
  width: 240px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(224, 70, 58, 0.2), transparent 72%);
  pointer-events: none;
  filter: blur(18px);
  z-index: -1;
}
.pg.p0 .st-end.st-3d-ready {
  opacity: 0;
  transform: perspective(900px) rotateX(10deg) translateY(30px);
  transition:
    transform 0.9s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.8s ease;
}
.pg.p0 .st-end.st-3d-ready.in-3d {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   5. PAGE p1 (MUSIC) — SUNLIT ACOUSTIC RESONANCE STAGE & HARMONIC VISUALIZER
   -------------------------------------------------------------------------- */
.pg.p1 .bg .music-aura-stage {
  position: absolute;
  right: 3.5vmin;
  top: 46%;
  width: min(76vmin, 680px);
  aspect-ratio: 1;
  transform: translate3d(var(--ma-x, 0px), calc(-50% + var(--ma-y, 0px)), 0);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.pg.p1 .bg .music-sun {
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  background: radial-gradient(
    circle at 46% 42%,
    rgba(255, 252, 245, 0.88) 0%,
    rgba(255, 246, 234, 0.56) 28%,
    color-mix(in srgb, var(--acc2, #f59a72) 26%, transparent) 54%,
    color-mix(in srgb, var(--acc, #e0654f) 10%, transparent) 72%,
    transparent 86%
  );
  transform: scale(calc(1 + var(--beat, 0) * 0.085));
  transition: opacity 0.8s ease;
  opacity: 0.9;
  z-index: 0;
}
.pg.p1.playing .bg .music-sun {
  opacity: 1;
}
.pg.p1 .bg .music-rosette {
  position: absolute;
  inset: 4%;
  pointer-events: none;
  z-index: 1;
}
.pg.p1 .bg .music-rosette svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.pg.p1 .bg .music-rosette-outer {
  transform-origin: 200px 200px;
  transform: rotate(calc(var(--rot, 0) * 0.24deg));
}
.pg.p1 .bg .music-rosette-inner {
  transform-origin: 200px 200px;
  transform: rotate(calc(var(--rot, 0) * -0.16deg));
}
.pg.p1 .bg .music-rosette-core {
  transform-origin: 200px 200px;
  transform: scale(calc(1 + var(--beat, 0) * 0.055));
}
.pg.p1 .bg .music-viz-canvas {
  position: absolute;
  inset: -16%;
  width: 132%;
  height: 132%;
  max-width: none;
  max-height: none;
  pointer-events: none;
  z-index: 2;
}
/* Beat-reactive mini player glow (desktop + mobile) */
.pg.p1.playing .np {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 28px calc(48px + var(--beat, 0) * 32px) -20px
      color-mix(in srgb, var(--acc) 78%, rgba(10, 5, 2, 0.7)),
    0 0 calc(20px + var(--beat, 0) * 34px) -4px color-mix(in srgb, var(--acc2) 55%, transparent);
}
.pg.p1.playing .npd {
  scale: calc(1 + var(--beat, 0) * 0.06);
}
@media (max-width: 820px) {
  .pg.p1 .bg .music-aura-stage {
    left: auto;
    right: -12vw;
    top: 3svh;
    bottom: auto;
    width: min(80vw, 350px);
    transform: none;
    opacity: 0.9;
  }
}

/* --------------------------------------------------------------------------
   6. PAGE p3 (FRAME / GALLERY) — VIEWFINDER HUD, SHUTTER & 3D GRID TILT
   -------------------------------------------------------------------------- */
.gvf-hud {
  position: absolute;
  top: clamp(20px, 3.6vw, 42px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 99px;
  font:
    600 9.5px/1 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(20, 20, 20, 0.8);
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(20, 20, 20, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease 0.8s;
}
.gstage.ready .gvf-hud {
  opacity: 1;
}
.gvf-hud i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e0463a;
  box-shadow: 0 0 8px rgba(224, 70, 58, 0.8);
  animation: gvfRec 1.8s ease-in-out infinite;
}
@keyframes gvfRec {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.78);
  }
}
.gshutter {
  position: fixed;
  inset: 0;
  z-index: 410;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.92), rgba(20, 20, 20, 0.35));
}
.gshutter.snap {
  animation: zkShutter 0.24s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes zkShutter {
  0% {
    opacity: 0;
  }
  28% {
    opacity: 0.52;
  }
  100% {
    opacity: 0;
  }
}
.pg.p3 .ggrid-card {
  transform-style: preserve-3d;
  transition:
    transform 0.26s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s ease;
}
.pg.p3 .ggrid-card .ggrid-meta {
  transform: none;
}
.pg.p3 .gk.tl.foc {
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.34),
    0 34px 66px -22px rgba(20, 20, 20, 0.62),
    0 0 0 1.5px rgba(255, 255, 255, 0.45),
    0 0 70px -12px rgba(224, 70, 58, 0.32);
}

/* --------------------------------------------------------------------------
   7. PAGE p4 (SKILL) — HAND-ANCHORED 3D ORBITAL DEPTH & WEBGL GYROSCOPE
   -------------------------------------------------------------------------- */
.pg.p4 .sk-stage {
  perspective: 1100px;
}
.pg.p4 .sk-webgl {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--sk-s, 260px) * 1.9);
  height: calc(var(--sk-s, 260px) * 1.9);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.8s ease 0.35s;
}
.pg.p4.open .sk-webgl.is-live {
  opacity: 0.92;
}
.pg.p4 .sk-orbit {
  transform-style: preserve-3d;
  cursor: grab;
}
.pg.p4 .sk-orbit.is-3d-drag {
  cursor: grabbing;
}
.pg.p4 .sk-orbit .sk-ring {
  transform-style: preserve-3d;
}
.pg.p4 .sk-orbit .sk-out {
  transform: translateZ(22px);
}
.pg.p4 .sk-orbit .sk-inn {
  transform: translateZ(44px);
}
.pg.p4 .sk-orbit .sk-core {
  transform: translateZ(62px);
}
.pg.p4 .sk-orbit .sk-ic {
  box-shadow:
    0 12px 24px -10px rgba(20, 24, 31, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}
.pg.p4 .sk-pc,
.pg.p4 .sk-stat,
.pg.p4 .sk-st {
  transform-style: preserve-3d;
  transition:
    transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s ease;
}
.pg.p4 .sk-bar .sk-rg {
  filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--rc, #14181f) 28%, transparent));
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.pg.p4 .sk-bar:hover .sk-rg {
  transform: scale(1.08) rotate(-6deg);
}

/* --------------------------------------------------------------------------
   8. PAGE p6 (KONTAK) — PRISMATIC 3D DEV PASS LAYER DEPTH
   -------------------------------------------------------------------------- */
.pg.p6 .pass-face {
  transform-style: preserve-3d;
}
.pg.p6 .pass-photo-wrap {
  transform: translateZ(16px);
}
.pg.p6 .pass-chip {
  transform: translateZ(26px);
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, 0.45);
}
.pg.p6 .pass-hologram-seal {
  transform: translateZ(26px);
}
.pg.p6 .pass-info {
  transform: translateZ(12px);
}
.pg.p6 .pass-actions {
  transform: translateZ(14px);
}
.pg.p6 .pass-prism {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 16;
  background: repeating-linear-gradient(
    calc(var(--glare-angle, 135deg) + 32deg),
    rgba(255, 72, 132, 0.14) 0px,
    rgba(72, 202, 255, 0.14) 18px,
    rgba(255, 224, 92, 0.14) 36px,
    rgba(104, 240, 168, 0.14) 54px,
    rgba(176, 114, 255, 0.14) 72px
  );
  mix-blend-mode: color-dodge;
  opacity: 0.42;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 42%, #000 18%, transparent 88%);
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 42%, #000 18%, transparent 88%);
}

/* --------------------------------------------------------------------------
   9. REDUCED MOTION SAFETY OVERRIDES
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root),
  .gvf-hud i,
  .gshutter.snap {
    animation: none !important;
  }
  .pg.p0 .st-ch.st-3d-ready,
  .pg.p0 .st-end.st-3d-ready {
    opacity: 1 !important;
    transform: none !important;
  }
  .pg.p4 .sk-webgl,
  .pg.p0 .st-embers {
    display: none !important;
  }
}

/* --------------------------------------------------------------------------
   10. MOBILE / TOUCH COMPOSITING STABILITY
   Layar sentuh: hilangkan efek yang memaksa raster ulang atau blur langsung
   (backdrop-filter, shadow & filter yang berubah saat kartu aktif berganti)
   supaya kartu dan konten tidak hilang-timbul ketika digeser/digulir.
   -------------------------------------------------------------------------- */
@media (pointer: coarse), (max-width: 700px) {
  /* Roda kartu: bayangan & filter foto tetap, tidak berubah saat .on berpindah */
  .card,
  .card.on {
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.14),
      0 14px 26px -10px rgba(0, 0, 0, 0.34),
      inset 0 0 0 1px rgba(255, 255, 255, 0.16),
      inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  }
  .card .portrait-img,
  .card.on .portrait-img {
    transition: none !important;
    transform: none !important;
    filter: none !important;
    will-change: auto !important;
  }
  .card .dim {
    transition: none;
  }

  /* Panah di atas roda: blur langsung di atas kartu yang bergerak = berkedip */
  .arr {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.9) !important;
  }
  :root[data-theme="dark"] .arr {
    background: rgba(28, 31, 38, 0.92) !important;
  }

  /* Halaman detail: tanpa layer permanen & tanpa backdrop blur saat digulir */
  .pg.open {
    will-change: auto;
  }
  .pg .bk,
  .pg .rows > * {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .pg .bk {
    background: color-mix(in srgb, var(--pbg) 92%, transparent);
  }
}

/* Story: reveal bab cukup fade + geser 2D di layar sentuh/sempit (tanpa perspective 3D & aura blur) */
@media (pointer: coarse), (max-width: 820px) {
  .pg.p0 .st-life {
    perspective: none;
  }
  .pg.p0 .st-ch.st-3d-ready,
  .pg.p0 .st-end.st-3d-ready {
    transform: translate3d(0, 22px, 0);
    transition:
      transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
      opacity 0.6s ease;
  }
  .pg.p0 .st-ch.st-3d-ready.in-3d,
  .pg.p0 .st-end.st-3d-ready.in-3d {
    transform: none;
  }
  .pg.p0 .st-ch.st-active-aura::before {
    display: none;
  }
}
