/* ═══════════════════════════════════════════════════════════════
   CINEMATIC EFFECTS — Film-grade atmosphere & motion
   Inspired by editorial/product reveal videos (film grain, god rays,
   bokeh, color grading, editorial typography, scroll-driven parallax)
   ═══════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────
   1) FILM GRAIN — animated noise overlay (the soul of "cinematic")
   ─────────────────────────────────────────────────────────────── */
.cinema-grain {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 99990;
  opacity: 0.045;
  mix-blend-mode: overlay;
  /* SVG fractal noise — real film grain texture */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-repeat: repeat;
  animation: grainShift 0.6s steps(6) infinite;
}
@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  16%  { transform: translate(-5%, 3%); }
  33%  { transform: translate(3%, -4%); }
  50%  { transform: translate(-2%, 5%); }
  66%  { transform: translate(4%, 2%); }
  83%  { transform: translate(-3%, -3%); }
  100% { transform: translate(0, 0); }
}

/* ───────────────────────────────────────────────────────────────
   2) VIGNETTE — dark corners, movie-frame focus
   ─────────────────────────────────────────────────────────────── */
.cinema-vignette {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 99980;
  background:
    radial-gradient(ellipse at center,
      transparent 35%,
      rgba(0, 0, 0, 0.25) 78%,
      rgba(0, 0, 0, 0.55) 100%);
  mix-blend-mode: multiply;
}

/* ───────────────────────────────────────────────────────────────
   3) GOD RAYS — diagonal light shafts from above
   ─────────────────────────────────────────────────────────────── */
.cinema-rays {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.cinema-rays .ray {
  position: absolute; top: -30%;
  width: 280px; height: 160%;
  background: linear-gradient(to bottom,
    rgba(0, 229, 255, 0.06) 0%,
    rgba(0, 229, 255, 0.02) 40%,
    transparent 100%);
  filter: blur(24px);
  transform-origin: top center;
  transform: rotate(12deg);
  animation: rayDrift 16s ease-in-out infinite;
}
.cinema-rays .ray-1 { left: 12%; animation-delay: 0s; }
.cinema-rays .ray-2 {
  left: 52%; width: 360px;
  background: linear-gradient(to bottom,
    rgba(125, 95, 255, 0.05) 0%,
    rgba(125, 95, 255, 0.015) 40%,
    transparent 100%);
  transform: rotate(-8deg);
  animation-delay: -5s; animation-duration: 20s;
}
.cinema-rays .ray-3 {
  left: 78%; width: 220px;
  background: linear-gradient(to bottom,
    rgba(255, 159, 67, 0.04) 0%,
    transparent 100%);
  transform: rotate(18deg);
  animation-delay: -9s; animation-duration: 24s;
}
@keyframes rayDrift {
  0%, 100% { opacity: 0.4; transform: rotate(12deg) translateX(0); }
  50%      { opacity: 0.85; transform: rotate(12deg) translateX(40px); }
}

/* ───────────────────────────────────────────────────────────────
   4) BOKEH — soft out-of-focus light circles (camera-lens feel)
   ─────────────────────────────────────────────────────────────── */
.cinema-bokeh {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.cinema-bokeh .bokeh-dot {
  position: absolute; border-radius: 50%;
  background: radial-gradient(circle,
    rgba(0, 229, 255, 0.35) 0%,
    rgba(0, 229, 255, 0.08) 60%,
    transparent 100%);
  filter: blur(2px);
  animation: bokehFloat 18s ease-in-out infinite;
}
.cinema-bokeh .b1 { width: 90px; height: 90px; top: 18%; left: 8%;  animation-delay: 0s; }
.cinema-bokeh .b2 { width: 140px; height: 140px; top: 65%; left: 14%; animation-delay: -4s;
  background: radial-gradient(circle, rgba(255,159,67,0.25) 0%, transparent 60%); }
.cinema-bokeh .b3 { width: 70px; height: 70px; top: 30%; left: 85%; animation-delay: -8s;
  background: radial-gradient(circle, rgba(255,0,127,0.28) 0%, transparent 60%); }
.cinema-bokeh .b4 { width: 110px; height: 110px; top: 75%; left: 80%; animation-delay: -12s;
  background: radial-gradient(circle, rgba(125,95,255,0.3) 0%, transparent 60%); }
.cinema-bokeh .b5 { width: 60px; height: 60px; top: 50%; left: 48%; animation-delay: -6s; opacity: 0.6; }
.cinema-bokeh .b6 { width: 100px; height: 100px; top: 8%; left: 60%; animation-delay: -14s;
  background: radial-gradient(circle, rgba(39,201,63,0.18) 0%, transparent 60%); }

@keyframes bokehFloat {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
  33%      { transform: translate(30px, -25px) scale(1.15); opacity: 0.85; }
  66%      { transform: translate(-20px, 35px) scale(0.9); opacity: 0.65; }
}

/* ───────────────────────────────────────────────────────────────
   5) ENHANCED AMBIENT ORBS — deeper, richer, multi-layer glow
   ─────────────────────────────────────────────────────────────── */
.ambient-orb {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 0;
  filter: blur(90px); opacity: 0.4;
}
.ambient-orb--cyan {
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(0,229,255,0.28) 0%, rgba(0,229,255,0.05) 60%, transparent 100%);
  top: 8%; left: -8%;
  animation: orbFloat1 20s ease-in-out infinite;
}
.ambient-orb--pink {
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(255,0,127,0.2) 0%, rgba(255,0,127,0.04) 60%, transparent 100%);
  bottom: 12%; right: -6%;
  animation: orbFloat2 24s ease-in-out infinite;
}
.ambient-orb--violet {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(125,95,255,0.18) 0%, transparent 60%);
  top: 50%; left: 38%;
  animation: orbFloat3 28s ease-in-out infinite;
}
@keyframes orbFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(70px, 50px) scale(1.2); }
  66% { transform: translate(-40px, 80px) scale(0.85); }
}
@keyframes orbFloat2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-60px, -40px) scale(1.15); }
  66% { transform: translate(50px, -70px) scale(0.9); }
}
@keyframes orbFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(80px, -50px) scale(1.25); }
}

/* ───────────────────────────────────────────────────────────────
   6) WORD-BY-WORD HEADING REVEAL (editorial text animation)
   ─────────────────────────────────────────────────────────────── */
.cinema-word {
  display: inline-block;
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}
.cinema-word.in {
  opacity: 1 !important;
  transform: none !important;
  filter: none !important;
}

/* ───────────────────────────────────────────────────────────────
   7) SCROLL-DRIVEN PARALLAX HELPERS (for full-bleed stages)
   ─────────────────────────────────────────────────────────────── */
.parallax-deep   { will-change: transform; }
.parallax-mid    { will-change: transform; }
.parallax-near   { will-change: transform; }

/* ───────────────────────────────────────────────────────────────
   8) FULLSCREEN STAGE CINEMATIC ENHANCEMENTS
   ─────────────────────────────────────────────────────────────── */
.story-slide-fullscreen .bg-stage-img {
  /* Slow cinematic zoom (Ken Burns) */
  animation: kenBurns 24s ease-in-out infinite alternate;
}
@keyframes kenBurns {
  0%   { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.12) translate(-2%, -1.5%); }
}

.story-slide-fullscreen .bg-stage-overlay {
  /* Darkened background overlay to make hero text pop out with maximum contrast */
  background:
    linear-gradient(180deg,
      rgba(8, 12, 22, 0.78) 0%,
      rgba(8, 12, 22, 0.65) 50%,
      rgba(8, 12, 22, 0.94) 100%),
    radial-gradient(ellipse at center, rgba(0, 229, 255, 0.08) 0%, transparent 70%);
}

/* Crisp, high-contrast hero text */
.story-slide-fullscreen h1,
.story-slide-fullscreen .fullscreen-title-huge {
  color: #ffffff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
}

.story-slide-fullscreen h1 .text-red-highlight,
.text-red-highlight {
  color: #ff2a4b !important;
  -webkit-text-fill-color: #ff2a4b !important;
  background: none !important;
  font-weight: 900 !important;
  display: inline !important;
  text-shadow: 0 0 20px rgba(255, 42, 75, 0.9), 0 0 40px rgba(255, 42, 75, 0.6) !important;
}

.chip-pain-tag {
  color: #ff2a4b !important;
  -webkit-text-fill-color: #ff2a4b !important;
  font-size: 11.5px;
  font-weight: 800;
  background: rgba(255, 42, 75, 0.12);
  border: 1px solid rgba(255, 42, 75, 0.3);
  padding: 3px 9px;
  border-radius: 8px;
  margin-right: auto;
}

.story-slide-fullscreen .scene-sub {
  color: rgba(240, 243, 250, 0.95) !important;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

/* The floating overlay card gets a richer glass treatment */
.floating-overlay-card {
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  background: rgba(14, 20, 36, 0.96) !important;
  border: 1.5px solid rgba(0, 229, 255, 0.35);
  max-width: 900px !important;
  padding: 32px 42px !important;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.9),
    0 0 60px rgba(0, 229, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ───────────────────────────────────────────────────────────────
   9) EDITORIAL TYPOGRAPHY (big, confident, letter-spaced display)
   ─────────────────────────────────────────────────────────────── */
.fullscreen-title-huge {
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

/* Gradient text gets a subtle animated shimmer (like the videos) */
.text-gradient-pain,
.text-gradient-hope {
  background-size: 200% 200%;
  animation: gradientPan 6s ease-in-out infinite;
}
.text-gradient-pain {
  background-image: linear-gradient(120deg, #ff007f, #ff5f56, #ff9f43, #ff007f);
}
.text-gradient-hope {
  background-image: linear-gradient(120deg, #00e5ff, #0084ff, #7d5fff, #00e5ff);
}
@keyframes gradientPan {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ───────────────────────────────────────────────────────────────
   10) CINEMATIC REVEAL — richer than the basic reveal
   NOTE: keep the entrance fully reversible/safe. Previously `.reveal` started
   at `opacity:0; transform:translateY(50px); filter:blur(6px)` and relied on
   JS adding `.visible`. If JS/IntersectionObserver didn't fire in time, whole
   sections (the cost calculator, the 02:00 AM alerts) looked empty. The blur
   in particular made half-loaded cards look "cut off". We keep the cinematic
   entrance but make it graceful: smaller translate, no blur, and a fallback
   that reveals content if JS never runs.
   ─────────────────────────────────────────────────────────────── */
.reveal {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
body.js-loaded .reveal:not(.visible) {
  opacity: 0;
  transform: translateY(24px);
}
body.js-loaded .reveal.visible {
  opacity: 1;
  transform: translateY(0);
}
/* Safety net: if JavaScript is disabled or the observer never attaches, the
   content must still be readable after a short delay. */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* ───────────────────────────────────────────────────────────────
   11) GLASS SHIMMER (sweep of light across images)
   ─────────────────────────────────────────────────────────────── */
.glass-shimmer { position: relative; }
.glass-shimmer::after {
  content: ''; position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

/* ───────────────────────────────────────────────────────────────
   12) GLOW PULSE (for CTAs — hypnotic attention pull)
   ─────────────────────────────────────────────────────────────── */
.glow-pulse { animation: glowPulse 2.5s ease-in-out infinite; }
@keyframes glowPulse {
  0%, 100% {
    box-shadow:
      0 4px 20px rgba(0, 229, 255, 0.3),
      0 0 0 0 rgba(0, 229, 255, 0);
  }
  50% {
    box-shadow:
      0 4px 40px rgba(0, 229, 255, 0.6),
      0 0 0 10px rgba(0, 229, 255, 0.08);
  }
}

/* ───────────────────────────────────────────────────────────────
   15) CINEMATIC INTRO SEQUENCE — logo reveal → chaos → network → dissolve
   ─────────────────────────────────────────────────────────────── */
#cinema-intro {
  position: fixed; inset: 0; z-index: 999999;
  display: flex; align-items: center; justify-content: center;
  background: #050a12;
  overflow: hidden;
}
#cinema-intro.done {
  animation: introDissolve 1.2s cubic-bezier(0.4, 0, 0, 1) forwards;
  pointer-events: none;
}
@keyframes introDissolve {
  0%   { opacity: 1; filter: blur(0); }
  60%  { opacity: 0.3; filter: blur(4px); }
  100% { opacity: 0; filter: blur(12px); visibility: hidden; }
}

/* Intro background gradient pulse */
.intro-bg {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(0,229,255,0.08) 0%, transparent 60%);
  animation: introBgPulse 3s ease-in-out infinite;
}
@keyframes introBgPulse {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.15); }
}

/* Intro particles container */
.intro-particles {
  position: absolute; inset: 0; pointer-events: none;
}

/* Intro content centering */
.intro-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 16px;
}

/* Logo */
.intro-logo-wrap {
  position: relative; width: 120px; height: 120px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  animation: introLogoIn 0.6s 0.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes introLogoIn {
  0%   { opacity: 0; transform: scale(0.3) rotate(-20deg); filter: blur(20px) brightness(3); }
  50%  { opacity: 1; transform: scale(1.1) rotate(3deg); filter: blur(0) brightness(1.5); }
  70%  { transform: scale(0.95) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); filter: blur(0) brightness(1); }
}
.intro-logo {
  width: 80px; height: 80px; border-radius: 50%;
  filter: drop-shadow(0 0 30px rgba(0,229,255,0.6));
}

/* Expanding rings */
.intro-logo-ring {
  position: absolute; border-radius: 50%;
  border: 1.5px solid rgba(0,229,255,0.3);
  width: 80px; height: 80px;
  opacity: 0;
}
.intro-logo-ring-1 { animation: ringExpand 2.5s 1s ease-out infinite; }
.intro-logo-ring-2 { animation: ringExpand 2.5s 1.5s ease-out infinite; }
.intro-logo-ring-3 { animation: ringExpand 2.5s 2s ease-out infinite; }
@keyframes ringExpand {
  0%   { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(3.5); opacity: 0; }
}

/* Brand name */
.intro-brand {
  font-size: 2.5rem; font-weight: 900;
  color: #fff; margin: 0;
  display: flex; gap: 8px; justify-content: center;
}
.intro-word {
  display: inline-block;
  opacity: 0; transform: translateY(30px) rotateX(-30deg);
  filter: blur(6px);
}
.iw-1 { animation: wordIn 0.4s 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.iw-2 { animation: wordIn 0.4s 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes wordIn {
  to { opacity: 1; transform: translateY(0) rotateX(0); filter: blur(0); }
}

/* Tagline */
.intro-tagline {
  font-size: 1rem; color: rgba(228,231,239,0.7);
  max-width: 400px; margin: 0;
  opacity: 0;
  animation: fadeInUp 0.5s 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Network diagram area */
.intro-network {
  position: relative; width: 300px; height: 300px;
  margin-top: 20px;
  opacity: 0;
  animation: fadeInUp 0.5s 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.intro-connections {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.intro-line {
  stroke: rgba(0,229,255,0.4);
  stroke-width: 1.5;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
  opacity: 0;
  transition: stroke-dashoffset 1.2s ease, opacity 0.6s ease;
}
.intro-line.active {
  stroke-dashoffset: 0;
  opacity: 1;
}

/* Network nodes */
.intro-node {
  position: absolute;
  top: 50%; left: 50%;
  width: 42px; height: 42px;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(14,20,32,0.9);
  border: 1.5px solid rgba(0,229,255,0.2);
  /* Chaos: scattered, will converge via JS */
  transition: transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color 0.8s ease,
              box-shadow 0.8s ease;
}
.intro-node.connected {
  border-color: rgba(0,229,255,0.7);
  box-shadow: 0 0 20px rgba(0,229,255,0.3);
}
.intro-node-center {
  width: 56px; height: 56px;
  border-color: rgba(0,229,255,0.5);
  box-shadow: 0 0 30px rgba(0,229,255,0.2);
}
.intro-node-img {
  width: 28px; height: 28px; border-radius: 50%; object-fit: contain;
}
.intro-node-center .intro-node-img {
  width: 36px; height: 36px;
}

/* Status banners */
.intro-banner {
  margin-top: 20px; padding: 10px 24px;
  border-radius: 12px; font-size: 0.9rem; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  opacity: 0;
  animation: fadeInUp 0.5s 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  background: rgba(255,159,67,0.15);
  border: 1px solid rgba(255,159,67,0.4);
  color: #ff9f43;
}
.intro-banner-solved {
  background: rgba(0,229,255,0.15);
  border-color: rgba(0,229,255,0.4);
  color: #00e5ff;
}

/* Skip button */
.intro-skip {
  position: absolute; bottom: 40px; right: 40px;
  color: rgba(228,231,239,0.4); font-size: 13px;
  cursor: pointer; z-index: 3;
  transition: color 0.3s;
  font-family: 'Vazirmatn', sans-serif;
  direction: ltr;
}
.intro-skip:hover { color: rgba(228,231,239,0.9); }

/* ───────────────────────────────────────────────────────────────
   13) REDUCED MOTION — disable every cinematic animation
   ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cinema-grain { animation: none !important; opacity: 0.02; }
  .cinema-rays .ray,
  .cinema-bokeh .bokeh-dot,
  .ambient-orb { animation: none !important; }
  .story-slide-fullscreen .bg-stage-img { animation: none !important; }
  .text-gradient-pain, .text-gradient-hope { animation: none !important; }
  .glass-shimmer::after { animation: none !important; opacity: 0; }
  .glow-pulse { animation: none !important; }
  .cinema-word {
    opacity: 1 !important; transform: none !important; filter: none !important;
  }
  .reveal {
    opacity: 1 !important; transform: none !important; filter: none !important;
  }
  /* Intro: skip animations, show briefly then hide */
  #cinema-intro { animation: none !important; }
  .intro-logo-wrap { animation: none !important; opacity: 1 !important; transform: none !important; filter: none !important; }
  .intro-logo-ring { animation: none !important; }
  .intro-word { animation: none !important; opacity: 1 !important; transform: none !important; filter: none !important; }
  .intro-tagline { animation: none !important; opacity: 1 !important; transform: none !important; }
  .intro-network { animation: none !important; opacity: 1 !important; transform: none !important; }
  .intro-banner { animation: none !important; opacity: 1 !important; transform: none !important; }
  .intro-bg { animation: none !important; }
}

/* ───────────────────────────────────────────────────────────────
   14) MOBILE — keep cinematic but lighter (perf)
   ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cinema-grain { opacity: 0.03; }
  .cinema-vignette {
    background: radial-gradient(ellipse at center,
      transparent 40%, rgba(0,0,0,0.35) 100%);
  }
  .cinema-rays .ray { width: 180px; }
  .cinema-bokeh .bokeh-dot { filter: blur(4px); }
  .ambient-orb { filter: blur(70px); opacity: 0.3; }
}
