/* ==========================================================================
   Code Craft Innovations — Modern scroll-3D layer (v3)
   Loads AFTER styles.css. Powered by assets/js/scroll-fx.js.
   Immersive hero · pinned horizontal 3D showcase · sticky stacking deck ·
   directional 3D reveals · scroll-scrub parallax · custom cursor · grain.
   ========================================================================== */

:root {
  --font-x: "Space Grotesk", "Poppins", system-ui, sans-serif;
  --violet: #7c5cfc;
}

/* Editorial display type across the homepage */
h1, h2, .display { font-family: var(--font-x); letter-spacing: -0.03em; }
.display { font-family: var(--font-x); }

/* Perspective root + keep position:sticky working (clip, not hidden) */
main { perspective: 1600px; perspective-origin: 50% 40%; }
@supports (overflow: clip) { body { overflow-x: clip; } }

/* ==========================================================================
   1. Entrance reveals (one-shot 3D) — JS adds .is-in; stagger via --d
   ========================================================================== */
[data-anim] {
  opacity: 0;
  will-change: transform, opacity, filter;
  transition:
    opacity 0.9s var(--ease-out),
    transform 1.05s var(--ease-out),
    filter 0.9s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 90ms);
  transform-style: preserve-3d;
  backface-visibility: hidden;
}
[data-anim].is-in { opacity: 1; transform: none; filter: none; }

[data-anim="rise"]       { transform: translate3d(0, 64px, 0); }
[data-anim="fade"]       { transform: translate3d(0, 22px, 0); }
[data-anim="flip-up"]    { transform: rotateX(34deg) translate3d(0, 70px, 0); transform-origin: 50% 100%; filter: blur(3px); }
[data-anim="flip-down"]  { transform: rotateX(-30deg) translate3d(0, -46px, 0); transform-origin: 50% 0%; }
[data-anim="tilt-left"]  { transform: rotateY(-26deg) translate3d(-64px, 24px, -40px); transform-origin: 100% 50%; filter: blur(4px); }
[data-anim="tilt-right"] { transform: rotateY(26deg)  translate3d(64px, 24px, -40px);  transform-origin: 0% 50%;   filter: blur(4px); }
[data-anim="zoom"]       { transform: translateZ(-160px) scale(1.05); filter: blur(7px); }
[data-anim="pop"]        { transform: translateZ(-90px) scale(0.84); }
[data-anim="rotate"]     { transform: rotate(-7deg) translate3d(0, 48px, -30px) scale(0.95); }
[data-anim="swing"]      { transform: rotateY(24deg) rotateX(10deg) translate3d(40px, 30px, -60px); transform-origin: 0% 0%; filter: blur(3px); }
[data-anim="reveal"]     { clip-path: inset(0 0 108% 0); transform: translate3d(0, 12px, 0); filter: none; }
[data-anim="reveal"].is-in { clip-path: inset(-12% 0 -12% 0); }

/* ==========================================================================
   2. Scroll-scrubbed parallax — JS sets --p (0→1) and --pc (-1→+1)
   ========================================================================== */
[data-scrub] { will-change: transform; }

/* ==========================================================================
   3. Custom cursor (desktop, fine-pointer) + magnetic
   ========================================================================== */
.has-cursor, .has-cursor a, .has-cursor button, .has-cursor [data-magnetic] { cursor: none; }
.cursor { position: fixed; top: 0; left: 0; z-index: 400; pointer-events: none; border-radius: 50%; }
.cursor--dot { width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; background: #fff; }
.cursor--ring {
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 1.5px solid rgba(255, 255, 255, 0.65);
  mix-blend-mode: difference;
  transition: width 0.25s var(--ease), height 0.25s var(--ease), margin 0.25s var(--ease), background 0.25s var(--ease), border-color 0.25s var(--ease);
}
.cursor-hover .cursor--ring { width: 58px; height: 58px; margin: -29px 0 0 -29px; background: rgba(255, 255, 255, 0.14); border-color: transparent; }
[data-magnetic] { will-change: transform; }

/* Grain overlay */
.grain {
  position: fixed; inset: -60%; z-index: 350; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px;
  mix-blend-mode: overlay;
  animation: grain 7s steps(6) infinite;
}
@keyframes grain {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-4%, 3%); }
  40%  { transform: translate(3%, -5%); }
  60%  { transform: translate(-2%, 4%); }
  80%  { transform: translate(4%, 2%); }
  100% { transform: translate(0, 0); }
}

/* ==========================================================================
   4. Immersive hero
   ========================================================================== */
.hero-x {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  background: var(--navy-900);
  color: #fff;
  overflow: hidden;
  isolation: isolate;
  padding-top: calc(var(--header-h) + 5vh);
  padding-bottom: 14vh;
}
.hero-x__bg { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.hero-x__objects { position: absolute; inset: 0; z-index: -1; pointer-events: none; }

/* Mesh gradient blobs */
.mesh { position: absolute; border-radius: 50%; filter: blur(85px); opacity: 0.5; mix-blend-mode: screen; will-change: transform; }
.mesh--1 { width: 46vw; height: 46vw; background: radial-gradient(circle, rgba(26,95,180,0.95), transparent 66%); top: -14%; left: -8%; animation: meshA 18s ease-in-out infinite; }
.mesh--2 { width: 42vw; height: 42vw; background: radial-gradient(circle, rgba(32,201,151,0.8), transparent 66%); bottom: -16%; right: -8%; animation: meshB 22s ease-in-out infinite; }
.mesh--3 { width: 32vw; height: 32vw; background: radial-gradient(circle, rgba(124,92,252,0.55), transparent 66%); top: 24%; left: 42%; animation: meshA 27s ease-in-out infinite reverse; }
@keyframes meshA { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6%, 8%) scale(1.12); } }
@keyframes meshB { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-7%, -6%) scale(1.1); } }

/* Retro-futuristic perspective grid floor */
.grid-floor {
  position: absolute; left: 50%; bottom: -8%;
  width: 240%; height: 68%;
  transform: translateX(-50%) perspective(520px) rotateX(72deg);
  transform-origin: 50% 100%;
  background-image:
    linear-gradient(rgba(127,176,238,0.20) 1px, transparent 1px),
    linear-gradient(90deg, rgba(127,176,238,0.20) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: linear-gradient(to top, #000 0%, transparent 78%);
  mask-image: linear-gradient(to top, #000 0%, transparent 78%);
  animation: floor-move 10s linear infinite;
  opacity: 0.8;
}
@keyframes floor-move { to { background-position: 0 64px, 0 0; } }

/* Floating 3D objects */
.hero-x .obj { position: absolute; }
.hero-x .obj--cube { top: 16%; right: 12%; }
.hero-x .obj--ring { bottom: 16%; left: 9%; }

/* Hero content */
.hero-x__inner { position: relative; max-width: 1000px; }
.pill {
  display: inline-flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 1rem; border-radius: var(--r-pill);
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(8px);
  font-size: 0.82rem; font-weight: 500; color: rgba(255,255,255,0.9);
}
.pill__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); animation: pulse 2.2s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(32,201,151,0.5); } 70% { box-shadow: 0 0 0 9px rgba(32,201,151,0); } 100% { box-shadow: 0 0 0 0 rgba(32,201,151,0); } }

.hero-x__title {
  color: #fff;
  font-size: clamp(2.7rem, 8vw, 6rem);
  line-height: 1.02;
  font-weight: 700;
  margin-top: 1.4rem;
}
.hero-x__title .line { display: block; }
.hero-x__lead { margin-top: 1.6rem; max-width: 56ch; font-size: clamp(1.05rem, 1.5vw, 1.25rem); color: rgba(255,255,255,0.78); line-height: 1.65; }
.hero-x__cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 2.3rem; }
.hero-x__meta { margin-top: 3rem; display: flex; flex-wrap: wrap; gap: 1.8rem 3rem; }
.hx-stat b { font-family: var(--font-x); font-size: clamp(1.8rem, 3vw, 2.5rem); display: block; line-height: 1; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hx-stat span { display: block; margin-top: 0.4rem; font-size: 0.85rem; color: rgba(255,255,255,0.6); }

/* Scroll cue */
.scroll-cue { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 0.6rem; color: rgba(255,255,255,0.6); font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase; z-index: 2; }
.scroll-cue__line { position: relative; width: 2px; height: 46px; border-radius: 2px; background: rgba(255,255,255,0.2); overflow: hidden; }
.scroll-cue__line i { position: absolute; left: 0; top: -60%; width: 100%; height: 60%; background: var(--teal); animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { 0% { transform: translateY(0); } 100% { transform: translateY(280%); } }

/* ==========================================================================
   5. Pinned horizontal 3D showcase
   ========================================================================== */
.hx { position: relative; background: var(--navy-900); color: #fff; isolation: isolate; }
.hx::before { content: ""; position: absolute; inset: 0; z-index: 0; background: radial-gradient(60% 60% at 80% 10%, rgba(26,95,180,0.28), transparent 60%), radial-gradient(50% 50% at 10% 90%, rgba(32,201,151,0.22), transparent 60%); pointer-events: none; }
.hx__pin { position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; justify-content: center; z-index: 1; }
.hx__head { position: absolute; top: calc(var(--header-h) + 3vh); left: 0; right: 0; width: min(var(--container), 92vw); margin-inline: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding-inline: var(--gutter); }
.hx__head h2 { color: #fff; font-size: clamp(2rem, 5vw, 3.4rem); margin-top: 0.6rem; }
.hx__hint { display: inline-flex; align-items: center; gap: 0.4rem; color: rgba(255,255,255,0.6); font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.hx__hint svg { animation: nudge 1.6s var(--ease) infinite; }
@keyframes nudge { 0%,100% { transform: translateX(0); } 50% { transform: translateX(5px); } }

.hx__track { display: flex; gap: clamp(1.2rem, 2vw, 2rem); padding-inline: max(calc((100vw - var(--container)) / 2), var(--gutter)); will-change: transform; }
.hx__panel {
  position: relative;
  flex: 0 0 clamp(280px, 34vw, 420px);
  min-height: clamp(360px, 58vh, 520px);
  display: flex; flex-direction: column;
  padding: clamp(1.6rem, 2.6vw, 2.4rem);
  border-radius: var(--r-xl);
  color: #fff;
  background: linear-gradient(160deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03)), var(--navy-800);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 40px 80px -50px rgba(0,0,0,0.9);
  overflow: hidden;
  transform: perspective(1400px) rotateY(var(--rot, 0deg));
  transition: transform 0.12s linear, border-color 0.3s, box-shadow 0.3s;
  will-change: transform;
}
.hx__panel::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: linear-gradient(150deg, rgba(127,176,238,0.55), transparent 55%, rgba(111,227,196,0.4)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0.5; pointer-events: none; }
.hx__panel:hover { border-color: transparent; box-shadow: 0 50px 90px -40px rgba(42,166,201,0.55); }
.hx__num { font-family: var(--font-x); font-weight: 700; font-size: 3.4rem; line-height: 1; color: rgba(255,255,255,0.16); letter-spacing: -0.04em; }
.hx__icon { width: 56px; height: 56px; border-radius: 15px; display: grid; place-items: center; color: #cfe6ff; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); margin: 1.4rem 0 1.2rem; box-shadow: inset 0 0 30px rgba(42,166,201,0.18); }
.hx__icon svg { width: 26px; height: 26px; }
.hx__panel h3 { color: #fff; font-size: 1.5rem; margin-bottom: 0.6rem; }
.hx__panel p { color: rgba(255,255,255,0.72); font-size: 0.98rem; }
.hx__panel .link-arrow { color: var(--teal); margin-top: auto; padding-top: 1.2rem; }
.hx__panel--cta { justify-content: center; align-items: flex-start; background: var(--grad-brand); border: none; }
.hx__panel--cta::before { display: none; }
.hx__panel--cta h3 { font-size: 1.8rem; max-width: 14ch; }
.hx__panel--cta p { color: rgba(255,255,255,0.9); margin-bottom: 1.6rem; }

/* ==========================================================================
   6. Signature: sticky STACKING-CARDS deck
   ========================================================================== */
.deck { position: relative; display: flex; flex-direction: column; gap: clamp(1.2rem, 3vw, 2.2rem); perspective: 1800px; perspective-origin: 50% 0%; margin-top: clamp(2.4rem, 5vw, 3.6rem); }
.deck__card {
  position: sticky;
  top: calc(var(--header-h) + 26px + var(--n, 0) * 14px);
  --cover: 0;
  transform-origin: 50% 0%;
  transform: translateY(calc(var(--cover) * -6px)) scale(calc(1 - var(--cover) * 0.055)) rotateX(calc(var(--cover) * 6deg));
  transition: transform 0.15s linear;
  border-radius: var(--r-xl);
  overflow: hidden;
  isolation: isolate;
  min-height: clamp(300px, 42vh, 380px);
  display: grid;
  grid-template-columns: 128px 1fr auto;
  align-items: center;
  gap: clamp(1.2rem, 3vw, 2.6rem);
  padding: clamp(1.8rem, 3.4vw, 3rem);
  background: linear-gradient(135deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03)), var(--navy-800);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 40px 90px -50px rgba(0,0,0,0.9);
  color: #fff;
  will-change: transform;
}
.deck__card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: linear-gradient(135deg, rgba(127,176,238,0.6), rgba(111,227,196,0.4) 55%, rgba(255,206,122,0.5)); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: 0.6; pointer-events: none; z-index: 3; }
.deck__card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, rgba(6,10,20,0.1), rgba(6,10,20,0.72)); opacity: var(--cover); pointer-events: none; z-index: 2; }
.deck__card > * { position: relative; z-index: 1; }
.deck__index { font-family: var(--font-x); font-weight: 700; font-size: clamp(3.4rem, 7vw, 5.4rem); line-height: 0.9; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: -0.04em; }
.deck__tag { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--teal); margin-bottom: 0.9rem; }
.deck__tag::before { content: ""; width: 22px; height: 2px; border-radius: 2px; background: var(--teal); }
.deck__card h3 { color: #fff; font-size: clamp(1.5rem, 2.6vw, 2.1rem); margin-bottom: 0.7rem; }
.deck__card p { color: rgba(255,255,255,0.74); max-width: 52ch; font-size: 1.02rem; }
.deck__art { width: clamp(84px, 10vw, 120px); height: clamp(84px, 10vw, 120px); border-radius: 22px; display: grid; place-items: center; color: #cfe6ff; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.14); box-shadow: inset 0 0 40px rgba(42,166,201,0.18); transform: translateZ(60px); }
.deck__art svg { width: 46%; height: 46%; }

/* ==========================================================================
   7. Marquee upgrade — big outline-style kinetic type
   ========================================================================== */
.marquee__item { font-family: var(--font-x); font-size: clamp(1.35rem, 3vw, 2.1rem); font-weight: 600; color: var(--text-mute); display: inline-flex; align-items: center; gap: 1.6rem; }
.marquee__item::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand-300); flex-shrink: 0; }

/* ==========================================================================
   8. Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .hero-x .obj--cube, .hero-x .obj--ring { display: none; }
  .hero-x__title { font-size: clamp(2.4rem, 10vw, 3.6rem); }

  /* Horizontal showcase collapses to a native swipe row */
  .hx { height: auto !important; }
  .hx__pin { position: static; height: auto; overflow: visible; padding-block: var(--section-y); }
  .hx__head { position: static; transform: none; width: auto; margin: 0 auto 1.6rem; flex-direction: column; align-items: flex-start; }
  .hx__track { transform: none !important; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 1.2rem; -webkit-overflow-scrolling: touch; }
  .hx__panel { transform: none !important; scroll-snap-align: center; flex-basis: 80vw; min-height: 60vh; }
}
@media (max-width: 820px) {
  .deck__card { grid-template-columns: 76px 1fr; min-height: unset; padding: 1.5rem 1.4rem; }
  .deck__art { display: none; }
  .deck__index { font-size: 3rem; }
}
@media (max-width: 560px) {
  .deck__card { grid-template-columns: 1fr; gap: 0.6rem; }
  .deck__index { font-size: 2.4rem; }
  .hero-x__meta { gap: 1.2rem 1.8rem; }
}

/* ==========================================================================
   9. Reduced-motion & no-JS safety
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  [data-anim] { opacity: 1 !important; transform: none !important; filter: none !important; clip-path: none !important; }
  .deck__card { position: relative; top: auto; transform: none !important; }
  .deck__card::after { opacity: 0; }
  .mesh, .grid-floor, .grain, .pill__dot, .scroll-cue__line i, .hx__hint svg { animation: none !important; }
  .hx__panel { transform: none !important; }
  .cursor { display: none !important; }
}
.no-js [data-anim] { opacity: 1; transform: none; filter: none; clip-path: none; }

/* ==========================================================================
   10. Page preloader (loading screen) — fades out on load; JS adds .is-done
   ========================================================================== */
.cc-preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--navy-900);
  transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}
.cc-preloader.is-done { opacity: 0; visibility: hidden; }
.cc-preloader::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(60% 60% at 50% 40%, rgba(26,95,180,0.35), transparent 70%);
  pointer-events: none;
}
.cc-preloader__inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.cc-preloader__logo { height: 66px; width: auto; filter: brightness(0) invert(1); animation: cc-pre-pulse 1.6s ease-in-out infinite; }
.cc-preloader__bar { position: relative; width: 168px; height: 3px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; }
.cc-preloader__bar i { position: absolute; top: 0; left: -40%; height: 100%; width: 40%; border-radius: 3px; background: var(--grad-brand); animation: cc-pre-load 1.1s var(--ease) infinite; }
@keyframes cc-pre-load { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes cc-pre-pulse { 0%, 100% { opacity: 0.72; transform: scale(0.98); } 50% { opacity: 1; transform: scale(1.02); } }
@media (prefers-reduced-motion: reduce) {
  .cc-preloader__logo, .cc-preloader__bar i { animation: none !important; }
}
