/* ===== Global 3D — perspective on main only (not body), keeps cursor fixed to viewport ===== */

.scene-3d {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  perspective: 900px;
}

.shape {
  position: absolute;
  transform-style: preserve-3d;
  will-change: transform;
}

/* --- Floating Cube --- */
.shape-cube {
  width: 48px;
  height: 48px;
  animation: cubeDrift 18s ease-in-out infinite;
}
.shape-cube .cube-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: cubeSpin 12s linear infinite;
}
.shape-cube .face {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.06);
  backdrop-filter: blur(2px);
}
.shape-cube .face.front  { transform: translateZ(24px); }
.shape-cube .face.back   { transform: rotateY(180deg) translateZ(24px); }
.shape-cube .face.right  { transform: rotateY(90deg) translateZ(24px); }
.shape-cube .face.left   { transform: rotateY(-90deg) translateZ(24px); }
.shape-cube .face.top    { transform: rotateX(90deg) translateZ(24px); background: rgba(6, 182, 212, 0.08); border-color: rgba(6, 182, 212, 0.3); }
.shape-cube .face.bottom { transform: rotateX(-90deg) translateZ(24px); }

/* Shapes use CSS vars for mouse parallax offset */
.shape {
  --px: 0px;
  --py: 0px;
  margin-left: var(--px);
  margin-top: var(--py);
}
.shape-cube.shape-1 { top: 18%; right: 12%; }
.shape-cube.shape-2 { bottom: 22%; left: 8%; }
.shape-2 .cube-inner { animation-duration: 16s; animation-direction: reverse; }
.shape-2 .face { border-color: rgba(6, 182, 212, 0.35); background: rgba(6, 182, 212, 0.05); }

@keyframes cubeSpin {
  to { transform: rotateX(360deg) rotateY(360deg); }
}
@keyframes cubeDrift {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-30px) translateX(15px); }
}

/* --- Floating Ring --- */
.shape-ring {
  width: 80px;
  height: 80px;
  top: 60%;
  right: 6%;
  border: 2px solid rgba(245, 158, 11, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.08), inset 0 0 20px rgba(245, 158, 11, 0.05);
  animation: ringFloat 14s ease-in-out infinite;
  transform: rotateX(65deg) rotateZ(0deg);
}
.shape-ring::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(245, 158, 11, 0.2);
  border-radius: 50%;
  animation: ringSpin 8s linear infinite;
}
@keyframes ringFloat {
  0%, 100% { transform: rotateX(65deg) rotateZ(0deg) translateY(0); }
  50% { transform: rotateX(70deg) rotateZ(180deg) translateY(-20px); }
}
@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

/* --- Floating Pyramid (CSS triangle stack) --- */
.shape-pyramid {
  top: 35%;
  left: 5%;
  width: 0;
  height: 0;
  border-left: 28px solid transparent;
  border-right: 28px solid transparent;
  border-bottom: 48px solid rgba(244, 114, 182, 0.12);
  filter: drop-shadow(0 8px 20px rgba(244, 114, 182, 0.15));
  animation: pyramidFloat 16s ease-in-out infinite;
}
.shape-pyramid::after {
  content: '';
  position: absolute;
  top: 20px;
  left: -18px;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-bottom: 30px solid rgba(168, 85, 247, 0.15);
}
@keyframes pyramidFloat {
  0%, 100% { transform: translateY(0) rotateY(0deg); }
  50% { transform: translateY(-25px) rotateY(180deg); }
}

/* --- Glowing orb --- */
.shape-orb {
  width: 100px;
  height: 100px;
  bottom: 15%;
  right: 20%;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(6, 182, 212, 0.2), rgba(168, 85, 247, 0.05) 60%, transparent 70%);
  box-shadow: 0 0 60px rgba(6, 182, 212, 0.12);
  animation: orbPulse 6s ease-in-out infinite;
}
@keyframes orbPulse {
  0%, 100% { transform: scale(1) translateZ(0); opacity: 0.7; }
  50% { transform: scale(1.15) translateZ(30px); opacity: 1; }
}

/* --- Wireframe truck outline --- */
.shape-wire {
  top: 12%;
  left: 15%;
  width: 70px;
  height: 30px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 4px;
  animation: wireFloat 20s ease-in-out infinite;
}
.shape-wire::before {
  content: '';
  position: absolute;
  right: -18px;
  top: 6px;
  width: 22px;
  height: 18px;
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 2px;
}
.shape-wire::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 10px;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 50%;
  box-shadow: 42px 0 0 -1px rgba(168, 85, 247, 0.25);
}
@keyframes wireFloat {
  0%, 100% { transform: rotateX(20deg) rotateY(-15deg) translateY(0); }
  50% { transform: rotateX(25deg) rotateY(15deg) translateY(-18px); }
}

/* ===== Hero title — static, no mouse tilt ===== */
.hero-title {
  transform: none !important;
}

/* ===== 3D Photo Frame ===== */
.reveal-3d {
  opacity: 0;
  transform: perspective(800px) rotateX(18deg) translateY(60px) translateZ(-40px);
  transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-3d.visible {
  opacity: 1;
  transform: perspective(800px) rotateX(0) translateY(0) translateZ(0);
}

/* ===== 3D Photo Frame ===== */
.tilt-3d-wrap {
  transform-style: preserve-3d;
  perspective: 600px;
  transition: transform 0.15s ease-out;
}
.image-frame {
  transform-style: preserve-3d;
}
.image-placeholder {
  transform: translateZ(20px);
  box-shadow:
    0 20px 40px rgba(0,0,0,0.4),
    0 0 0 1px rgba(168, 85, 247, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.05);
}
.image-ring {
  transform: translateZ(10px);
}

/* ===== 3D Stats ===== */
.stat {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat:hover {
  transform: translateZ(16px) scale(1.05);
}
.stat-num {
  display: block;
  transform: translateZ(8px);
  transition: transform 0.3s;
}
.stat:hover .stat-num {
  transform: translateZ(20px) scale(1.08);
}

/* ===== 3D Highlight Cards ===== */
.highlight-card {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, box-shadow 0.4s;
}
.highlight-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(168,85,247,0.08) 0%, transparent 50%);
  transform: translateZ(-1px);
  pointer-events: none;
}
.highlight-card:hover {
  transform: translateY(-8px) translateZ(24px) rotateX(4deg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.35), 0 0 30px rgba(168, 85, 247, 0.1);
}

/* ===== 3D Skill Cards ===== */
.skill-card {
  transform-style: preserve-3d;
  position: relative;
}
.skill-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255,255,255,0.03) 0%, transparent 40%);
  transform: translateZ(1px);
  pointer-events: none;
}
.skill-card .icon-3d {
  transform: translateZ(24px);
}

/* ===== 3D Project Cards — depth layers ===== */
.project-card {
  transform-style: preserve-3d;
}
.project-card .project-img {
  transform-style: preserve-3d;
}
.project-card .project-gradient {
  transform: translateZ(0);
}
.project-card .project-visual {
  transform: translateZ(40px);
}
.project-card:hover {
  box-shadow: 0 25px 50px rgba(0,0,0,0.4), 0 0 40px rgba(168, 85, 247, 0.08);
}

/* ===== 3D Timeline ===== */
.timeline-content {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s, box-shadow 0.4s;
}
.timeline-content:hover {
  transform: translateX(12px) translateZ(20px) rotateY(-3deg);
  box-shadow: -8px 16px 40px rgba(0,0,0,0.3), 0 0 20px rgba(168, 85, 247, 0.08);
}
.timeline-dot {
  transform: translateZ(15px);
  transition: transform 0.3s, box-shadow 0.3s;
}
.timeline-item:hover .timeline-dot {
  transform: translateX(-5px) translateZ(25px) scale(1.3);
  box-shadow: 0 0 30px var(--glow);
}

/* ===== 3D Section Titles ===== */
.section-title {
  transform-style: preserve-3d;
}
.section-num {
  display: inline-block;
  transform: translateZ(12px);
  text-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

/* ===== 3D Buttons ===== */
.btn {
  transform-style: preserve-3d;
  position: relative;
  transition: transform 0.2s, box-shadow 0.3s;
}
.btn-primary {
  box-shadow:
    0 4px 0 #6d28d9,
    0 8px 20px var(--glow);
}
.btn-primary:hover {
  transform: translateY(-2px) translateZ(8px);
  box-shadow:
    0 6px 0 #6d28d9,
    0 14px 40px var(--glow);
}
.btn-primary:active {
  transform: translateY(2px) translateZ(0);
  box-shadow: 0 2px 0 #6d28d9, 0 4px 12px var(--glow);
}
.btn-ghost:hover {
  transform: translateZ(6px);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.15);
}

/* ===== 3D Contact Links ===== */
.contact-link {
  transform-style: preserve-3d;
}
.contact-link:hover {
  transform: translateX(8px) translateZ(12px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

/* ===== 3D Marquee depth ===== */
.marquee {
  transform: rotateX(5deg);
  transform-style: preserve-3d;
}

/* ===== Parallax layers ===== */
.parallax-layer {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ===== Scroll depth on sections ===== */
.section {
  transform-style: preserve-3d;
}

/* ===== Konami / turbo enhanced ===== */
body.turbo-dispatch .shape-cube .cube-inner {
  animation-duration: 3s;
}
body.turbo-dispatch .scene-3d {
  filter: saturate(1.3);
}

/* ===== Mobile: tone down heavy 3D ===== */
@media (max-width: 768px) {
  .scene-3d .shape-cube,
  .scene-3d .shape-pyramid,
  .scene-3d .shape-wire { display: none; }
  .marquee { transform: none; }
  .cursor-ring { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .shape, .reveal-3d, .marquee { animation: none !important; transition: none !important; }
  .orbit-bubble, .orbit-track { animation: none !important; }
  .snapshot-tabs { grid-template-columns: repeat(2, 1fr); }
}
