/* ============================================================
   scroll-fx.css — parallax, reveals, smooth motion
   ============================================================ */

:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Disable global smooth scroll — Lenis handles it */
html.has-lenis { scroll-behavior: auto; }

html.lenis-smooth {
  scroll-behavior: auto;
}
html.lenis-smooth body { overscroll-behavior: contain; }

/* ============================================================
   Scroll progress bar (top of viewport)
   ============================================================ */
.sd-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, #62bbff 50%, var(--accent) 100%);
  background-size: 200% 100%;
  transform: scaleX(0);
  transform-origin: left center;
  z-index: 100;
  pointer-events: none;
  will-change: transform;
  animation: sd-progress-shimmer 4s linear infinite;
}

@keyframes sd-progress-shimmer {
  from { background-position: 0% 0%; }
  to   { background-position: -200% 0%; }
}

/* ============================================================
   Hero — parallax orbs + grain + glow
   ============================================================ */
.sd-orbs {
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  filter: saturate(1.05);
}

.sd-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
}

.sd-orb--1 {
  width: 460px; height: 460px;
  left: -4%; top: 8%;
  background: radial-gradient(circle at 30% 30%, rgba(33, 150, 243, 0.5), rgba(33, 150, 243, 0) 65%);
}

.sd-orb--2 {
  width: 560px; height: 560px;
  right: -6%; top: -8%;
  background: radial-gradient(circle at 60% 40%, rgba(33, 150, 243, 0.38), rgba(33, 150, 243, 0) 65%);
}

.sd-orb--3 {
  width: 600px; height: 600px;
  right: 12%; bottom: -24%;
  background: radial-gradient(circle at 50% 50%, rgba(98, 187, 255, 0.4), rgba(33, 150, 243, 0) 65%);
}

.sd-orb--4 {
  width: 400px; height: 400px;
  left: 25%; bottom: -16%;
  background: radial-gradient(circle at 40% 60%, rgba(33, 150, 243, 0.3), rgba(33, 150, 243, 0) 70%);
}

/* orb floating animations removed — JS parallax + static gradients handle motion */

/* Hero noise grain overlay — adds tactile depth */
.sd-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
  mix-blend-mode: multiply;
}

/* Inner wrapper for hero mouse-tilt */
.sd-hero__inner {
  position: relative;
  z-index: 2;
  transition: transform 600ms var(--ease-out-quart);
  transform-style: preserve-3d;
  will-change: transform;
}

/* Floating chips — subtle abstract shapes near hero title */
.sd-hero__shapes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.sd-shape {
  position: absolute;
  border: 1px solid rgba(33, 150, 243, 0.25);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  box-shadow: 0 10px 30px -16px rgba(33, 150, 243, 0.4);
}

.sd-shape--1 {
  width: 64px; height: 64px;
  top: 18%; left: 8%;
  border-radius: 18px;
  rotate: -12deg;
}
.sd-shape--2 {
  width: 48px; height: 48px;
  top: 32%; right: 10%;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(33, 150, 243, 0.18), rgba(33, 150, 243, 0.06));
}
.sd-shape--3 {
  width: 38px; height: 38px;
  bottom: 22%; left: 14%;
  border-radius: 10px;
  rotate: 18deg;
}
.sd-shape--4 {
  width: 84px; height: 84px;
  bottom: 18%; right: 8%;
  border-radius: 22px;
  rotate: -8deg;
}

@media (max-width: 720px) {
  .sd-shape { display: none; }
  .sd-orb { opacity: 0.5; filter: blur(50px); }
}

/* ============================================================
   Word-by-word title reveal
   ============================================================ */
.sd-words {
  display: inline;
}

.sd-word {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 0.55em, 0);
  transition:
    opacity 1000ms var(--ease-out-quart),
    transform 1000ms var(--ease-out-quart);
  transition-delay: var(--word-delay, 0ms);
  will-change: opacity, transform;
}

.sd-word.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

/* Hero title paints immediately (fast LCP) — keep the slide-up, drop the opacity gate */
.sd-hero__title .sd-word { opacity: 1; }

/* gradient sweep on the highlight word */
.sd-hero__title em.sd-word {
  background: linear-gradient(90deg, var(--accent) 0%, #62bbff 50%, var(--accent) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: sd-text-shimmer 5s linear infinite;
}

@keyframes sd-text-shimmer {
  from { background-position: 0% 0%; }
  to   { background-position: -200% 0%; }
}

/* ============================================================
   Reveal on scroll — uses `translate`/`scale` individual props
   so it composes with `transform`-based tilt without conflict
   ============================================================ */
[data-reveal] {
  opacity: 0;
  translate: 0 24px;
  transition:
    opacity 1100ms cubic-bezier(0.22, 0.61, 0.36, 1),
    translate 1100ms cubic-bezier(0.22, 0.61, 0.36, 1),
    scale 1100ms cubic-bezier(0.22, 0.61, 0.36, 1),
    filter 1100ms cubic-bezier(0.22, 0.61, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}
[data-reveal]:not(.is-visible) {
  will-change: opacity, translate;
}

[data-reveal="up"]    { translate: 0 24px; }
[data-reveal="left"]  { translate: -28px 0; }
[data-reveal="right"] { translate: 28px 0; }
[data-reveal="scale"] { translate: 0 0; scale: 0.96; }
[data-reveal="blur"]  { translate: 0 0; filter: blur(10px); }
[data-reveal="fade"]  { translate: 0 0; }

[data-reveal].is-visible {
  opacity: 1;
  translate: 0 0;
  scale: 1;
  filter: blur(0);
}

/* Stagger children when parent has data-stagger */
[data-stagger] > * { transition-delay: calc(var(--stagger-step, 80ms) * var(--i, 0)); }

/* ============================================================
   Parallax — handled by JS via translate3d
   ============================================================ */
[data-parallax] { will-change: transform; }

/* ============================================================
   3D Tilt cards (subtle, ~5deg)
   ============================================================ */
[data-tilt] {
  transition: transform 500ms var(--ease-out-quart), box-shadow 500ms var(--ease-out-quart);
  transform-style: preserve-3d;
}

[data-tilt]:hover {
  box-shadow: 0 24px 48px -20px rgba(17, 17, 17, 0.18),
              0 2px 6px rgba(17, 17, 17, 0.06);
}

.sd-card[data-tilt]:hover,
.sd-category[data-tilt]:hover {
  box-shadow: 0 30px 60px -24px rgba(33, 150, 243, 0.28),
              0 2px 8px rgba(17, 17, 17, 0.08);
}

.sd-card--dark[data-tilt]:hover,
.sd-category--accent[data-tilt]:hover {
  box-shadow: 0 30px 60px -24px rgba(33, 150, 243, 0.55),
              0 0 0 1px rgba(33, 150, 243, 0.18);
}

/* Card icon pops forward on tilt hover */
[data-tilt] .sd-card__visual,
[data-tilt] .sd-category__visual {
  transition: transform 600ms var(--ease-out-quart);
  will-change: transform;
}

[data-tilt]:hover .sd-card__visual,
[data-tilt]:hover .sd-category__visual {
  transform: translate3d(-12px, -16px, 0) scale(1.08);
}

/* Card title lifts forward */
[data-tilt] .sd-card__body,
[data-tilt] .sd-category__body {
  transition: transform 600ms var(--ease-out-quart);
}

[data-tilt]:hover .sd-card__body,
[data-tilt]:hover .sd-category__body {
  transform: translate3d(0, -4px, 0);
}

/* ============================================================
   Magnetic CTA buttons
   ============================================================ */
[data-magnetic] {
  position: relative;
  transition: transform 280ms var(--ease-spring), box-shadow 280ms var(--ease-out-quart);
  will-change: transform;
}

[data-magnetic]::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: inherit;
  z-index: -1;
}

/* Glow halo on accent magnetic buttons */
.sd-btn--accent[data-magnetic]:hover {
  box-shadow:
    0 0 0 1px rgba(33, 150, 243, 0.5),
    0 18px 48px -14px rgba(33, 150, 243, 0.85),
    0 4px 14px -4px rgba(33, 150, 243, 0.5);
}

/* ============================================================
   Navbar: shrink + frosted glass when scrolled
   ============================================================ */
.sd-nav {
  position: sticky;
  top: 0;
  transition:
    background 400ms var(--ease-out-quart),
    border-color 400ms var(--ease-out-quart),
    backdrop-filter 400ms var(--ease-out-quart),
    box-shadow 400ms var(--ease-out-quart);
  will-change: background, backdrop-filter;
}

.sd-nav.is-scrolled {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom-color: rgba(17, 17, 17, 0.06);
  box-shadow: 0 1px 0 rgba(17, 17, 17, 0.03), 0 12px 24px -20px rgba(17, 17, 17, 0.18);
}

/* ============================================================
   Section divider — animated thin line
   ============================================================ */
.sd-section-divider {
  position: relative;
  overflow: hidden;
}
.sd-section-divider::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(33, 150, 243, 0.5) 50%,
    transparent 100%);
  transform: translateX(-100%);
  animation: sd-divider-sweep 5s ease-in-out infinite;
}
@keyframes sd-divider-sweep {
  0%, 100% { transform: translateX(-100%); }
  50%      { transform: translateX(100%); }
}

/* ============================================================
   Sticky band: wiki section gets a subtle parallax on visual
   ============================================================ */
.sd-band__visual {
  will-change: transform;
}

/* ============================================================
   FAQ — slide in on click
   ============================================================ */
.sd-faq__item {
  transition: background 280ms var(--ease-out-quart), border-color 280ms var(--ease-out-quart);
}
.sd-faq__item[open] {
  background: rgba(33, 150, 243, 0.04);
}
.sd-faq__answer {
  animation: sd-faq-slide 500ms var(--ease-out-quart);
}
@keyframes sd-faq-slide {
  from { opacity: 0; transform: translate3d(0, -6px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* ============================================================
   CTA section glow — ambient pulse
   ============================================================ */
.sd-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.sd-cta::before {
  content: "";
  position: absolute;
  width: 700px; height: 700px;
  left: 50%; top: 100%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(33, 150, 243, 0.18), rgba(33, 150, 243, 0) 70%);
  filter: blur(40px);
  z-index: -1;
  animation: sd-cta-pulse 8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sd-cta-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  50%      { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

/* ============================================================
   Reduced motion safety
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  [data-reveal], .sd-word {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
  }
  .sd-orb, .sd-shape { animation: none !important; }
  .sd-progress, .sd-section-divider::after, .sd-cta::before { animation: none !important; }
  [data-tilt] { transform: none !important; }
  [data-tilt]:hover .sd-card__visual,
  [data-tilt]:hover .sd-category__visual,
  [data-tilt]:hover .sd-card__body,
  [data-tilt]:hover .sd-category__body { transform: none !important; }
  .sd-hero__title em.sd-word { animation: none !important; background: var(--accent); -webkit-text-fill-color: transparent; }
}
