/**
 * CreatorSense — Immersive site layer (paired with assets/js/home-immersive.js)
 * Site-wide hero depth/motion. Theme-aware: the fallback gradient and glows use
 * brand tokens, so Creator pages render sapphire and Agency pages render gold
 * automatically (via core.css + website-agency-surface.css).
 */

/* Prevent the full-bleed (100vw) backdrop from creating horizontal scroll. */
html {
  overflow-x: clip;
}

/* ── Any hero becomes a layered stage ─────────────────────────────────────── */
.cs-immersive-stage {
  position: relative;
  isolation: isolate;
}

/* keep all existing hero content above the backdrop */
.cs-immersive-stage > *:not(.cs-immersive) {
  position: relative;
  z-index: 1;
}

/* Backdrop host: true full-viewport-width bleed, covering the whole hero,
   even though the hero itself is a centered max-width column. */
.cs-immersive {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  margin-left: -50vw;
  z-index: 0;
  pointer-events: none;
  /* CSS fallback if WebGL is unavailable — same brand gradient as the shader.
     --brand-* and --brand-gradient-bg are re-themed gold on agency surfaces. */
  background:
    radial-gradient(
      60% 80% at 70% 20%,
      rgba(var(--brand-primary-rgb, 74, 140, 255), 0.18),
      transparent 60%
    ),
    radial-gradient(
      55% 75% at 20% 80%,
      rgba(var(--brand-primary-rgb, 74, 140, 255), 0.14),
      transparent 62%
    ),
    var(--brand-gradient-bg, linear-gradient(180deg, #000 0%, #06080f 55%, #02040a 100%));
}

.cs-immersive__canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* soft mask so the backdrop melts into the page below the hero */
.cs-immersive::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    transparent 55%,
    rgba(0, 0, 0, 0.35) 82%,
    var(--bg-primary, #000) 100%
  );
}

/* When WebGL fails the JS adds this class — gentle drift so it still feels alive */
.cs-immersive--fallback {
  animation: cs-immersive-drift 18s ease-in-out infinite alternate;
}

@keyframes cs-immersive-drift {
  from {
    background-position: 0% 0%, 0% 0%, 0% 0%;
  }
  to {
    background-position: 12% 8%, -10% -6%, 0% 0%;
  }
}

/* ── Foreground light-particle field ──────────────────────────────────────── */
.cs-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Cinematic staggered hero entrance (added by JS, never hides no-JS copy) ── */
.cs-anim-ready > *:not(.cs-immersive) {
  opacity: 0;
  transform: translateY(32px);
  filter: blur(7px);
  transition:
    opacity 0.95s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.95s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.95s ease;
}

.cs-anim-ready.is-entered > *:not(.cs-immersive) {
  opacity: 1;
  transform: none;
  filter: blur(0);
}

/* child 1 is the backdrop (skipped); copy starts at child 2 */
.cs-anim-ready.is-entered > *:nth-child(2) { transition-delay: 0.05s; }
.cs-anim-ready.is-entered > *:nth-child(3) { transition-delay: 0.15s; }
.cs-anim-ready.is-entered > *:nth-child(4) { transition-delay: 0.25s; }
.cs-anim-ready.is-entered > *:nth-child(5) { transition-delay: 0.35s; }
.cs-anim-ready.is-entered > *:nth-child(6) { transition-delay: 0.45s; }
.cs-anim-ready.is-entered > *:nth-child(7) { transition-delay: 0.55s; }
.cs-anim-ready.is-entered > *:nth-child(8) { transition-delay: 0.65s; }

/* ── Living glow on the primary CTA ───────────────────────────────────────── */
.cs-immersive-stage .btn-primary {
  animation: cs-cta-glow 3.2s ease-in-out infinite;
}

@keyframes cs-cta-glow {
  0%,
  100% {
    box-shadow: 0 10px 30px -10px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.5);
  }
  50% {
    box-shadow: 0 14px 48px -8px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.85);
  }
}

/* ── Home hero: luminous lift on the highlighted line ─────────────────────── */
.cs-immersive-stage .home-hero__headline em {
  background: linear-gradient(
    100deg,
    var(--brand-primary-lighter, #93c5fd),
    #ffffff 50%,
    var(--accent-secondary, #6eb0ff) 75%,
    var(--brand-primary-lighter, #93c5fd)
  );
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: cs-text-shimmer 7s linear infinite;
}

@keyframes cs-text-shimmer {
  to {
    background-position: 200% center;
  }
}

/* ── Hero product showcase (Higgsfield render, floats over the backdrop) ───── */
.cs-hero-showcase {
  margin: 2.75rem auto 0;
  max-width: 760px;
  width: 100%;
  perspective: 1400px;
}

.cs-hero-showcase img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.28);
  box-shadow:
    0 40px 120px -30px rgba(0, 0, 0, 0.85),
    0 0 80px -20px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.35);
  transform: rotateX(8deg) translateZ(0);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  animation: cs-showcase-float 7s ease-in-out infinite alternate;
}

.cs-hero-showcase img:hover {
  transform: rotateX(2deg) scale(1.015);
}

@keyframes cs-showcase-float {
  from {
    transform: rotateX(8deg) translateY(0);
  }
  to {
    transform: rotateX(6deg) translateY(-12px);
  }
}

/* ── Product story: real depth on the See / Spot / Act panels ──────────────── */
.home-product-story__grid {
  perspective: 1100px;
}

.home-product-panel,
.cs-tilt {
  transform-style: preserve-3d;
  transition:
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.5s ease,
    border-color 0.5s ease;
  will-change: transform;
}

.home-product-panel:hover,
.cs-tilt:hover {
  box-shadow:
    0 30px 80px -20px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.25),
    0 0 60px -10px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.22);
  border-color: rgba(var(--brand-primary-rgb, 74, 140, 255), 0.4);
}

/* Section showcase render (reuses hero-showcase look, tighter top margin) */
.cs-section-showcase {
  margin: 1.5rem auto 0.5rem;
  max-width: 720px;
  width: 100%;
  perspective: 1400px;
}

.cs-section-showcase img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.24);
  box-shadow:
    0 36px 100px -30px rgba(0, 0, 0, 0.8),
    0 0 70px -22px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.3);
}

.home-product-panel__mock {
  transform: translateZ(34px);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Agency "Explore the desk" cards: row on desktop, stacked on mobile ───── */
.agency-hub-cards__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.agency-hub-cards__grid .agency-hub-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
}

@media (max-width: 640px) {
  .agency-hub-cards__grid {
    grid-template-columns: 1fr;
  }
}

/* ── Scroll-pinned cinematic beat ─────────────────────────────────────────── */
.cs-pin {
  --p: 1; /* JS overrides 0→1 while scrolling; default 1 keeps it shown w/o JS */
  position: relative;
  height: 200vh;
}

.cs-pin__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  overflow: hidden;
  padding: 2rem 1.5rem;
}

.cs-pin__glow {
  position: absolute;
  width: 60vw;
  height: 60vw;
  max-width: 760px;
  max-height: 760px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(var(--brand-primary-rgb, 74, 140, 255), 0.2),
    transparent 60%
  );
  filter: blur(50px);
  opacity: calc(0.25 + var(--p) * 0.75);
  pointer-events: none;
}

.cs-pin__media {
  margin: 0;
  width: 100%;
  max-width: 900px;
  perspective: 1300px;
}

.cs-pin__media img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-xl, 16px);
  border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.3);
  box-shadow:
    0 44px 130px -30px rgba(0, 0, 0, 0.85),
    0 0 90px -16px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.42);
  transform: perspective(1300px) rotateX(calc((1 - var(--p)) * 10deg))
    scale(calc(0.8 + var(--p) * 0.22));
  transform-origin: center bottom;
}

.cs-pin__caption {
  text-align: center;
  max-width: 700px;
  opacity: var(--p);
  transform: translateY(calc((1 - var(--p)) * 22px));
}

.cs-pin__step {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-primary-light, #6eb0ff);
  margin: 0 0 0.4rem;
}

.cs-pin__title {
  font-family: var(--font-family, "Montserrat", sans-serif);
  font-size: clamp(1.6rem, 4vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  color: var(--text-primary);
  margin: 0;
}

/* Mobile: drop the pin, show it as a normal centered showcase */
@media (max-width: 760px) {
  .cs-pin {
    height: auto;
  }
  .cs-pin__sticky {
    position: static;
    height: auto;
    padding: 2.5rem 1.25rem;
  }
  .cs-pin__media img {
    transform: none;
  }
  .cs-pin__caption {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cs-pin {
    height: auto;
  }
  .cs-pin__sticky {
    position: static;
    height: auto;
  }
  .cs-pin__media img,
  .cs-pin__caption {
    transform: none;
    opacity: 1;
  }
}

/* ── Interactive ROI calculator (sliders) ─────────────────────────────────── */
.roi-calc {
  max-width: 1040px;
  margin: 3rem auto;
  padding: 2rem 1.5rem 2.25rem;
  border-radius: var(--radius-2xl, 24px);
  border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.22);
  background:
    radial-gradient(120% 140% at 80% 0%, rgba(var(--brand-primary-rgb, 74, 140, 255), 0.1), transparent 60%),
    var(--bg-card, #121212);
  box-shadow: 0 30px 90px -40px rgba(0, 0, 0, 0.8);
}

.roi-calc__headline {
  font-family: var(--font-family, "Montserrat", sans-serif);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0 0 0.4rem;
  color: var(--text-primary);
}

.roi-calc__lede {
  text-align: center;
  color: var(--text-secondary);
  margin: 0 auto 1.75rem;
  max-width: 540px;
  font-size: 0.95rem;
}

.roi-calc__inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
  align-items: stretch;
}

.roi-calc__controls {
  grid-column: 1;
  grid-row: 1;
}

.roi-calc__results {
  grid-column: 2;
  grid-row: 1;
}

.roi-calc__inputs-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.roi-calc__inputs-summary-item {
  background: rgba(var(--brand-primary-rgb, 74, 140, 255), 0.08);
  border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.22);
  border-radius: var(--radius-lg, 12px);
  padding: 0.75rem 0.85rem;
  text-align: center;
}

@media (max-width: 760px) {
  .roi-calc {
    padding: 1.15rem 1rem 1rem;
    margin: 2rem auto;
  }

  .roi-calc__headline {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
  }

  .roi-calc__lede {
    font-size: 0.82rem;
    margin-bottom: 1rem;
  }

  .roi-calc__inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
  }

  .roi-calc__results {
    order: 1;
    flex: 0 0 auto;
    padding-bottom: 0.75rem;
  }

  .roi-calc__controls {
    order: 2;
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-primary, #2a2a2a);
    gap: 1.1rem;
    position: relative;
    z-index: 2;
  }

  .roi-calc__inputs-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
  }

  .roi-calc__inputs-summary-item {
    background: rgba(var(--brand-primary-rgb, 74, 140, 255), 0.1);
    border: 1px solid rgba(var(--brand-primary-rgb, 74, 140, 255), 0.28);
    border-radius: var(--radius-lg, 12px);
    padding: 0.65rem 0.75rem;
    text-align: center;
  }

  .roi-calc__inputs-summary-item .roi-calc__metric-num {
    font-size: 1.2rem;
  }

  .roi-calc__metrics-grid {
    gap: 0.5rem;
  }

  .roi-calc__metric {
    padding: 0.65rem 0.75rem;
  }

  .roi-calc__metric-num {
    font-size: 1.15rem;
  }

  .roi-calc__verdict {
    margin-top: 0.25rem;
    font-size: 0.88rem;
  }

  .roi-calc__verdict p {
    margin: 0.2rem 0;
  }

  .roi-calc__field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
  }

  .roi-calc__label {
    order: 1;
    margin-bottom: 0;
    font-size: 0.8rem;
  }

  .roi-calc__value {
    display: none;
  }

  .roi-calc__slider {
    order: 2;
    margin-top: 0;
    height: 10px;
  }

  .roi-calc__slider::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }

  .roi-calc__slider::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }

  .roi-calc__plan-toggle button {
    font-size: 0.78rem;
    padding: 0.45rem 0.5rem;
  }

  .roi-calc__disclaimer {
    font-size: 0.7rem;
    margin-top: 0.85rem;
  }
}

.roi-calc__controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  justify-content: center;
}

.roi-calc__field {
  display: block;
}

.roi-calc__label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: 0.35rem;
}

.roi-calc__value {
  display: block;
  font-family: var(--font-family, "Montserrat", sans-serif);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

/* Range slider, brand-filled track */
.roi-calc__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--brand-primary, #4a8cff) 0%,
    var(--brand-primary, #4a8cff) var(--roi-fill, 30%),
    rgba(255, 255, 255, 0.12) var(--roi-fill, 30%),
    rgba(255, 255, 255, 0.12) 100%
  );
  outline: none;
  cursor: pointer;
  touch-action: pan-x;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 1;
}

.roi-calc__metric-num--pulse {
  transform: translateY(-3px);
  color: var(--brand-primary-light, #6eb0ff);
}

@media (prefers-reduced-motion: reduce) {
  .roi-calc__metric-num {
    transition: none;
  }

  .roi-calc__metric-num--pulse {
    transform: none;
    color: var(--text-primary);
  }
}

.roi-calc__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-primary, #4a8cff);
  box-shadow: 0 0 16px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.6);
  cursor: pointer;
}

.roi-calc__slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--brand-primary, #4a8cff);
  box-shadow: 0 0 16px rgba(var(--brand-primary-rgb, 74, 140, 255), 0.6);
  cursor: pointer;
}

.roi-calc__plan {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.roi-calc__plan-toggle {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.roi-calc__plan-toggle button {
  flex: 1 1 auto;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-full, 999px);
  border: 1px solid var(--border-primary, #2a2a2a);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.roi-calc__plan-toggle button.is-active {
  background: var(--brand-primary, #4a8cff);
  border-color: var(--brand-primary, #4a8cff);
  color: #fff;
}

.roi-calc__results {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-content: start;
}

.roi-calc__metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.roi-calc__metric {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-primary, #2a2a2a);
  border-radius: var(--radius-lg, 12px);
  padding: 0.9rem 1rem;
}

.roi-calc__metric-label {
  display: block;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.roi-calc__metric-num {
  font-family: var(--font-family, "Montserrat", sans-serif);
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-primary);
  display: inline-block;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), color 0.28s ease;
}

.roi-calc__metric--total {
  grid-column: 1 / -1;
  background: rgba(var(--brand-primary-rgb, 74, 140, 255), 0.12);
  border-color: rgba(var(--brand-primary-rgb, 74, 140, 255), 0.4);
}

.roi-calc__metric--total .roi-calc__metric-num {
  color: var(--brand-primary-light, #6eb0ff);
}

.roi-calc__verdict {
  grid-column: 1 / -1;
  text-align: center;
  margin-top: 0.4rem;
  font-size: 1rem;
  color: var(--text-secondary);
}

.roi-calc__verdict strong {
  color: var(--text-primary);
}

.roi-calc__annual {
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}

.roi-calc__annual strong {
  color: var(--success, #22c55e);
}

.roi-calc__disclaimer {
  text-align: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin: 1.5rem auto 0;
  max-width: 600px;
}

/* ── Respect reduced motion: flatten everything ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cs-immersive--fallback {
    animation: none;
  }
  .home-product-panel,
  .home-product-panel__mock {
    transform: none !important;
    transition: none;
  }
  .cs-immersive-stage .home-hero__headline em,
  .cs-immersive-stage .btn-primary,
  .cs-hero-showcase img {
    animation: none;
  }
  .cs-anim-ready > *:not(.cs-immersive) {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }
}
