/* ===== Rounds to Riches: 3D layer (preview) ===== */

/* --- Hero 3D stage --- */
.hero-wrap { isolation: isolate; }
.hero-3d, .hero-3d-fallback {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.hero-3d { opacity: 0; transition: opacity 1.2s var(--ease); }
.has-webgl .hero-3d.ready { opacity: 1; }
.has-webgl .hero-3d-fallback { opacity: 0; transition: opacity 1s var(--ease); }
.hero { z-index: 2; }

/* CSS-only fallback: perspective floor + rising gold bars */
.hero-3d-fallback { overflow: hidden; perspective: 900px; }
.hero-3d-fallback .floor {
  position: absolute; left: -30%; right: -30%; bottom: -10%; height: 70%;
  background-image:
    linear-gradient(rgba(201,162,39,0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,162,39,0.18) 1px, transparent 1px);
  background-size: 56px 56px;
  transform: rotateX(72deg);
  transform-origin: 50% 100%;
  mask-image: linear-gradient(to top, #000 10%, transparent 85%);
  -webkit-mask-image: linear-gradient(to top, #000 10%, transparent 85%);
}
.hero-3d-fallback .bars {
  position: absolute; right: 2%; bottom: 12%;
  display: flex; align-items: flex-end; gap: 14px;
  transform: rotateX(-8deg) rotateY(-28deg); transform-style: preserve-3d;
  opacity: 0.5;
}
.hero-3d-fallback .bars i {
  display: block; width: 26px; border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, #8a6d12, #e8c547 45%, #b8921e);
  box-shadow: 0 0 30px rgba(201,162,39,0.25);
}
.hero-3d-fallback .bars i:nth-child(1){height:40px}
.hero-3d-fallback .bars i:nth-child(2){height:70px}
.hero-3d-fallback .bars i:nth-child(3){height:104px}
.hero-3d-fallback .bars i:nth-child(4){height:146px}
.hero-3d-fallback .bars i:nth-child(5){height:196px}
@media (max-width: 960px) {
  .hero-3d-fallback .bars { display: none; }
}

/* Legibility veil so copy always reads over the scene */
.hero-wrap .hero > div:first-child { position: relative; }
@media (max-width: 960px) {
  .has-webgl .hero-3d { opacity: 0; }
  .has-webgl .hero-3d.ready { opacity: 0.55; }
  .hero-wrap::before { z-index: 1; }
}

/* --- Hero product stack in true 3D --- */
.has-3d .hero-visual { perspective: 1100px; }
.has-3d .hero-stage {
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.6s var(--ease);
  background:
    radial-gradient(circle at 78% 12%, rgba(201,162,39,0.20), transparent 42%),
    radial-gradient(circle at 20% 80%, rgba(26,122,122,0.18), transparent 45%),
    linear-gradient(160deg, rgba(26,26,26,0.72) 0%, rgba(10,18,18,0.62) 55%, rgba(8,8,8,0.78) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow: visible;
}
.has-3d .hero-stage > .stage-bg { border-radius: 24px; opacity: 0.22; }
.has-3d .product-stack { transform-style: preserve-3d; }
.has-3d .product-stack .card { will-change: transform; }
.has-3d .product-stack .card.c1 { transform: translate3d(-44%, 8%, 30px) rotateY(18deg) rotateZ(-7deg); }
.has-3d .product-stack .card.c2 { transform: translate3d(0, -6%, 90px) rotateY(0deg); }
.has-3d .product-stack .card.c3 { transform: translate3d(44%, 10%, 50px) rotateY(-18deg) rotateZ(6deg); }
.has-3d .hero-visual:hover .product-stack .card.c1 { transform: translate3d(-52%, 4%, 60px) rotateY(24deg) rotateZ(-8deg); }
.has-3d .hero-visual:hover .product-stack .card.c2 { transform: translate3d(0, -10%, 140px) scale(1.02); }
.has-3d .hero-visual:hover .product-stack .card.c3 { transform: translate3d(52%, 6%, 80px) rotateY(-24deg) rotateZ(7deg); }
.has-3d .hero-stage .panel { transform: translateZ(60px); border-radius: 0 0 24px 24px; }

/* --- 3D tilt cards (offers, curriculum, steps, problem) --- */
.has-3d .tilt-scope { perspective: 1200px; }
.has-3d .tilt {
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transition: transform 0.5s var(--ease), border-color 0.3s, box-shadow 0.35s;
  will-change: transform;
  position: relative;
}
.has-3d .tilt.is-tilting { transition: transform 0.08s linear, border-color 0.3s, box-shadow 0.35s; }
.has-3d .tilt:hover { box-shadow: 0 40px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(201,162,39,0.25); }
.has-3d .offer.tilt:hover, .has-3d .teach.tilt:hover, .has-3d .step.tilt:hover {
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-6px);
}
.has-3d .tilt .glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255,236,170,0.16), transparent 55%);
  opacity: 0; transition: opacity 0.35s;
}
.has-3d .tilt:hover .glare, .has-3d .tilt.is-tilting .glare { opacity: 1; }
/* Lift inner layers off the card face */
.has-3d .offer.tilt .offer-media { transform: translateZ(28px); }
.has-3d .offer.tilt .offer-body h3, .has-3d .offer.tilt .price { transform: translateZ(22px); }
.has-3d .offer.tilt .offer-foot .btn { transform: translateZ(34px); }
.has-3d .offer.tilt { overflow: visible; }
.has-3d .offer.tilt .offer-media { border-radius: 22px 22px 0 0; }
.has-3d .teach.tilt h3, .has-3d .step.tilt .n { transform: translateZ(26px); }

/* --- Perspective section transitions --- */
.has-3d .reveal {
  transform: perspective(1200px) translate3d(0, 46px, -90px) rotateX(14deg);
  transform-origin: 50% 100%;
  transition: opacity 0.9s var(--ease), transform 1s var(--ease);
}
.has-3d .reveal.in { transform: none; }
.has-3d .reveal.tilt.in { transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }

/* Scroll-driven depth layers (set via --depth-y from JS) */
.has-3d [data-depth] { transform: translate3d(0, var(--depth-y, 0px), 0); will-change: transform; }
.has-3d .reveal[data-depth].in { transform: translate3d(0, var(--depth-y, 0px), 0); }

/* Roster frames fan out in 3D */
.has-3d .roster-duo { perspective: 1000px; transform-style: preserve-3d; }
.has-3d .roster-duo .roster-frame { transition: transform 0.6s var(--ease); }
.has-3d .roster-duo .roster-frame:first-child { transform: rotateY(14deg) translateZ(-20px); }
.has-3d .roster-duo .roster-frame:last-child { transform: rotateY(-14deg) translateZ(-20px); }
.has-3d .roster-duo:hover .roster-frame { transform: none; }

/* CTA band floats */
.has-3d .cta-band.reveal.in { transform: perspective(1200px) rotateX(var(--cta-rx, 0deg)); }

/* Video shell gets subtle depth */
.has-3d .intro-video-inner { perspective: 1200px; }
.has-3d .video-shell { transform: rotateY(var(--vry, 0deg)) rotateX(var(--vrx, 0deg)); transition: transform 0.6s var(--ease); }

/* --- Motion safety --- */
@media (prefers-reduced-motion: reduce) {
  .reveal, .has-3d .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .has-3d .tilt, .has-3d .hero-stage, .has-3d [data-depth], .has-3d .video-shell { transform: none !important; transition: none !important; }
  .hero-3d { display: none; }
  html { scroll-behavior: auto; }
}

/* --- Hero composition with live WebGL: scene lives in the visual column --- */
.has-webgl .hero-stage {
  background: transparent; border-color: transparent; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.has-webgl .hero-stage > .stage-bg { display: none; }
.has-webgl .hero-stage .panel {
  background: linear-gradient(180deg, rgba(10,10,10,0.35), rgba(5,5,5,0.82) 45%);
  border: 1px solid var(--border); border-radius: 20px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  left: 6%; right: 6%; bottom: 0;
}
.has-webgl .product-stack { inset: auto; left: 0; bottom: 3%; width: 44%; height: 44%; z-index: 4; }
.has-webgl .product-stack .card { width: 50%; box-shadow: 0 24px 50px rgba(0,0,0,0.6), 0 0 0 1px rgba(201,162,39,0.18); }
.has-webgl .product-stack .card.c2 { width: 54%; }
.has-webgl .hero-stage .panel { left: 41%; right: 0; padding: 1.3rem 1.25rem 1.2rem; }
.has-webgl .hero-stage .big { font-size: clamp(2.1rem, 3.2vw, 2.8rem); }
@media (min-width: 961px) {
  .has-webgl .hero-visual, .has-webgl .hero-stage { min-height: 560px; }
}
@media (max-width: 960px) {
  .hero-3d { top: auto; bottom: 0; height: 640px; }
  .hero-3d-fallback { top: auto; height: 640px; bottom: 0; }
  .has-webgl .hero-3d.ready { opacity: 1; }
  .has-webgl .hero-visual, .has-webgl .hero-stage { min-height: 600px; }
  .has-webgl .product-stack { left: 6%; right: 6%; width: auto; bottom: auto; top: 40%; height: 26%; }
  .has-webgl .product-stack .card { width: 30%; }
  .has-webgl .product-stack .card.c2 { width: 33%; }
  .has-webgl .hero-stage .panel { left: 0; right: 0; }
}
