/* ═══════════════════════════════════════════════════════════════
   BEBBLO CINEMATIC LAYER
   Additive enhancement on top of styles.css — loaded after it.
   Everything degrades gracefully; reduced-motion users get the
   original experience untouched.
   ═══════════════════════════════════════════════════════════════ */

/* ---------- 0. Tokens ---------- */
:root {
  --cin-lavender: #8B7EC8;
  --cin-lavender-bright: #C4B5FD;
  --cin-sage: #7FB49B;
  --cin-apricot: #F2BC7D;
  --cin-glow: rgba(196, 181, 253, 0.55);
}

/* ---------- 1. 3D starfield canvas ---------- */
#cinStars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.8s ease;
}
#cinStars.cin-on { opacity: 1; }

/* Content must sit above the starfield */
main, nav, footer { position: relative; z-index: 1; }

/* ---------- 2. Film grain ---------- */
body.cinematic::after {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 100;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='256' height='256'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: cin-grain 0.9s steps(4) infinite;
}
@keyframes cin-grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, 3%); }
  50%  { transform: translate(3%, -2%); }
  75%  { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

/* ---------- 3. Scroll progress beam ---------- */
.cin-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  z-index: 120;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg,
    var(--cin-lavender) 0%,
    var(--cin-lavender-bright) 45%,
    var(--cin-sage) 75%,
    var(--cin-apricot) 100%);
  box-shadow: 0 0 12px var(--cin-glow);
  pointer-events: none;
}

/* ---------- 4. Custom cursor (fine pointers only) ---------- */
@media (pointer: fine) {
  .cin-cursor,
  .cin-cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 130;
    pointer-events: none;
    border-radius: 50%;
    will-change: transform;
  }
  .cin-cursor {
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    background: var(--cin-lavender-bright);
    box-shadow: 0 0 14px 3px var(--cin-glow);
  }
  .cin-cursor-ring {
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
    border: 1px solid rgba(196, 181, 253, 0.4);
    transition: width 0.25s ease, height 0.25s ease,
                margin 0.25s ease, border-color 0.25s ease,
                background 0.25s ease;
  }
  body.cinematic.cin-hovering .cin-cursor-ring {
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-color: rgba(196, 181, 253, 0.75);
    background: rgba(139, 126, 200, 0.08);
  }
}

/* ---------- 5. Hero: cinematic entrance ---------- */
body.cinematic .hero-copy .fade-up {
  opacity: 0;
  transform: translateY(46px) scale(0.985);
  filter: blur(14px);
  transition:
    opacity 1.1s cubic-bezier(0.16, 1, 0.3, 1),
    transform 1.1s cubic-bezier(0.16, 1, 0.3, 1),
    filter 1.1s cubic-bezier(0.16, 1, 0.3, 1);
}
body.cinematic .hero-copy .fade-up.revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}
body.cinematic .hero-copy .fade-up-delay-1 { transition-delay: 0.18s; }
body.cinematic .hero-copy .fade-up-delay-2 { transition-delay: 0.42s; }
body.cinematic .hero-copy .fade-up-delay-3 { transition-delay: 0.62s; }
body.cinematic .hero-copy .fade-up-delay-5 { transition-delay: 0.85s; }

body.cinematic .hero-aside .fade-up {
  opacity: 0;
  transform: translateY(60px) rotateX(14deg) scale(0.94);
  filter: blur(10px);
  transition:
    opacity 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.55s,
    transform 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.55s,
    filter 1.4s cubic-bezier(0.16, 1, 0.3, 1) 0.55s;
}
body.cinematic .hero-aside .fade-up.revealed {
  opacity: 1;
  transform: translateY(0) rotateX(0) scale(1);
  filter: blur(0);
}

/* ---------- 6. AI shimmer on the italic hero line ---------- */
body.cinematic .text-hero .text-lavender-light {
  background: linear-gradient(110deg,
    var(--cin-lavender-bright) 20%,
    #ffffff 38%,
    var(--cin-sage) 52%,
    var(--cin-lavender-bright) 70%);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: cin-shimmer 5.5s ease-in-out infinite;
}
@keyframes cin-shimmer {
  0%, 100% { background-position: 100% 0; }
  50%      { background-position: 0% 0; }
}

/* ---------- 7. Aurora ribbons in the hero ---------- */
.cin-aurora {
  position: absolute;
  inset: -10% -20%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  filter: blur(60px) saturate(1.3);
  opacity: 0.5;
}
.cin-aurora span {
  position: absolute;
  width: 60%;
  height: 38%;
  border-radius: 50%;
  mix-blend-mode: screen;
}
.cin-aurora span:nth-child(1) {
  top: 6%; left: -8%;
  background: radial-gradient(ellipse at center, rgba(139,126,200,0.5), transparent 65%);
  animation: cin-aurora-a 16s ease-in-out infinite alternate;
}
.cin-aurora span:nth-child(2) {
  top: 30%; right: -12%;
  background: radial-gradient(ellipse at center, rgba(127,180,155,0.32), transparent 65%);
  animation: cin-aurora-b 21s ease-in-out infinite alternate;
}
.cin-aurora span:nth-child(3) {
  bottom: -4%; left: 22%;
  background: radial-gradient(ellipse at center, rgba(242,188,125,0.18), transparent 65%);
  animation: cin-aurora-c 26s ease-in-out infinite alternate;
}
@keyframes cin-aurora-a {
  from { transform: translate(0, 0) rotate(0deg) scale(1); }
  to   { transform: translate(10%, 14%) rotate(28deg) scale(1.25); }
}
@keyframes cin-aurora-b {
  from { transform: translate(0, 0) rotate(0deg) scale(1.1); }
  to   { transform: translate(-14%, -8%) rotate(-22deg) scale(0.9); }
}
@keyframes cin-aurora-c {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(12%, -16%) scale(1.35); }
}

/* ---------- 8. 3D tilt targets ---------- */
body.cinematic .hero-phone {
  transform-style: preserve-3d;
  will-change: transform;
}
.cin-tilt {
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.cin-tilt.cin-tilting { transition: transform 0.08s linear; }

/* Glare sweep injected inside tilt targets */
.cin-glare {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--gx, 50%) var(--gy, 50%),
    rgba(255, 255, 255, 0.14), transparent 55%);
  opacity: 0;
  transition: opacity 0.35s ease;
}
.cin-tilt:hover .cin-glare,
.hero-phone:hover .cin-glare { opacity: 1; }

/* ---------- 9. Holographic card borders ---------- */
body.cinematic .feature-card,
body.cinematic .pricing-card,
body.cinematic .feature-flow-card {
  position: relative;
  overflow: hidden;
}
body.cinematic .feature-card::before,
body.cinematic .pricing-card::before,
body.cinematic .feature-flow-card::before {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: 0;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(from var(--ha, 0deg),
    transparent 0%,
    rgba(196, 181, 253, 0.0) 20%,
    rgba(196, 181, 253, 0.9) 32%,
    rgba(127, 180, 155, 0.7) 40%,
    rgba(196, 181, 253, 0.0) 52%,
    transparent 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s ease;
}
@property --ha {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}
body.cinematic .feature-card:hover::before,
body.cinematic .pricing-card:hover::before,
body.cinematic .feature-flow-card:hover::before {
  opacity: 1;
  animation: cin-holo 2.6s linear infinite;
}
@keyframes cin-holo {
  to { --ha: 360deg; }
}

/* ---------- 10. Deeper scroll reveals ---------- */
body.cinematic .reveal {
  opacity: 0;
  transform: translateY(38px);
  filter: blur(8px);
  transition:
    opacity 0.95s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0ms),
    transform 0.95s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0ms),
    filter 0.95s cubic-bezier(0.16, 1, 0.3, 1) var(--delay, 0ms);
}
body.cinematic .reveal.revealed {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* ---------- 11. AI pulse on the recommendation card ---------- */
body.cinematic .recommendation-card {
  position: relative;
  overflow: hidden;
}
body.cinematic .recommendation-card::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 45%;
  left: -60%;
  background: linear-gradient(100deg,
    transparent,
    rgba(196, 181, 253, 0.12) 50%,
    transparent);
  animation: cin-scan 4.2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cin-scan {
  0%, 55%  { left: -60%; }
  85%, 100% { left: 130%; }
}

/* ---------- 12. Magnetic buttons ---------- */
.cin-magnet {
  will-change: transform;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.cin-magnet.cin-magnet-active { transition: transform 0.08s linear; }

/* ---------- 13. Section heading glow sweep ---------- */
body.cinematic .section-heading {
  position: relative;
}
body.cinematic .reveal.revealed .section-heading::after,
body.cinematic .section-heading.revealed::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -10px;
  height: 1px;
  width: 64px;
  background: linear-gradient(90deg, var(--cin-lavender-bright), transparent);
  animation: cin-line-grow 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes cin-line-grow {
  from { width: 0; opacity: 0; }
  to   { width: 64px; opacity: 1; }
}

/* ---------- 14. Language selector (header) ---------- */
.lang-select { position: relative; }
.lang-select summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  transition: color 0.2s ease, border-color 0.2s ease;
  user-select: none;
}
.lang-select summary::-webkit-details-marker { display: none; }
.lang-select summary:hover,
.lang-select[open] summary { color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  min-width: 240px;
  background: rgba(16, 14, 35, 0.94);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 8px;
  margin: 0;
  list-style: none;
  z-index: 200;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.lang-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-menu a:hover { background: rgba(139, 126, 200, 0.18); color: #fff; }
.lang-menu a[aria-current="true"] {
  color: #C4B5FD;
  background: rgba(139, 126, 200, 0.12);
  font-weight: 600;
}
@media (max-width: 640px) {
  .lang-menu { position: fixed; left: 12px; right: 12px; top: 64px; min-width: 0; }
}

/* ---------- 15. Reduced motion: kill everything ---------- */
@media (prefers-reduced-motion: reduce) {
  #cinStars,
  .cin-cursor,
  .cin-cursor-ring,
  .cin-progress,
  .cin-aurora,
  .cin-glare { display: none !important; }
  body.cinematic::after { animation: none; }
  body.cinematic .hero-copy .fade-up,
  body.cinematic .hero-aside .fade-up,
  body.cinematic .reveal {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }
}
