
/* ============================================
   CTS ULTRA — x5000 experience layer (v2)
   ============================================ */

/* ---- Precise hero timeline ---- */
body.wow-ready .ambient,
body.wow-ready .earth-bg.is-ready {
  animation: ultra-atmosphere-in 1.2s var(--wow-ease-out) 0s both;
}

body.wow-ready .hero__badge {
  animation-delay: 0.3s;
}

body.wow-ready .hero__visual {
  animation-delay: 0.6s;
}

body.wow-ready .hero__title {
  animation-delay: 0.9s;
}

body.wow-ready .hero__subtitle {
  animation-delay: 1.2s;
}

body.wow-ready .hero__actions {
  animation-delay: 1.5s;
}

body.wow-ready .hero__actions .btn--primary {
  animation: ultra-cta-pop 0.7s var(--wow-ease-out) 1.55s both;
}

body.wow-ready .hero__stats {
  animation-delay: 1.8s;
}

@keyframes ultra-atmosphere-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ultra-cta-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* ---- CTS Digital Signature ---- */
.hero {
  position: relative;
}

.cts-signature {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.cts-signature__beam {
  position: absolute;
  top: 42%;
  left: 38%;
  width: 42%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(16, 185, 180, 0.55), rgba(78, 170, 219, 0.35), transparent);
  transform-origin: left center;
  transform: rotate(-8deg) scaleX(0);
  opacity: 0;
  filter: blur(0.5px);
}

body.wow-ready .cts-signature__beam {
  animation: ultra-signature-beam 1.4s var(--wow-ease-out) 1.1s both;
}

.cts-signature__node {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cts-teal);
  box-shadow: 0 0 16px rgba(16, 185, 180, 0.8);
  opacity: 0;
}

.cts-signature__node--a { top: 40%; left: 36%; }
.cts-signature__node--b { top: 36%; right: 22%; }

body.wow-ready .cts-signature__node {
  animation: ultra-signature-node 0.6s var(--wow-ease-out) 1.4s both;
}

body.wow-ready .cts-signature__node--b {
  animation-delay: 1.55s;
}

@keyframes ultra-signature-beam {
  0% { opacity: 0; transform: rotate(-8deg) scaleX(0); }
  100% { opacity: 1; transform: rotate(-8deg) scaleX(1); }
}

@keyframes ultra-signature-node {
  0% { opacity: 0; transform: scale(0); }
  70% { transform: scale(1.3); }
  100% { opacity: 1; transform: scale(1); }
}

.cts-signature__pulse {
  position: absolute;
  top: 38%;
  right: 20%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid rgba(16, 185, 180, 0.2);
  animation: ultra-signature-pulse 4s ease-in-out infinite;
  animation-play-state: paused;
}

body.wow-ready .cts-signature__pulse {
  animation-play-state: running;
  animation-delay: 2s;
}

@keyframes ultra-signature-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.35; }
  50% { transform: scale(1.15); opacity: 0.75; }
}

/* ---- Earth scroll phases ---- */
.earth-bg {
  transition: opacity 0.6s var(--wow-ease-out);
}

.earth-bg[data-earth-phase="mid"] {
  opacity: 0.92;
}

.earth-bg[data-earth-phase="far"] {
  opacity: 0.65;
}

.earth-bg[data-earth-phase="bg"] {
  opacity: 0.28;
}

.earth-bg[data-earth-phase="bg"] .earth-bg__glow {
  opacity: 0.35;
  transform: translateY(-50%) scale(0.7);
}

[data-theme="light"] .earth-bg[data-earth-phase="bg"] {
  opacity: 0.4;
}

/* ---- Premium custom cursor ---- */
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  border-radius: 50%;
  will-change: transform;
}

.cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  background: var(--cts-teal);
  box-shadow: 0 0 12px rgba(16, 185, 180, 0.6);
  transition: width 0.25s var(--wow-ease-out), height 0.25s var(--wow-ease-out), margin 0.25s var(--wow-ease-out), opacity 0.25s ease;
}

.cursor-ring {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 1px solid rgba(16, 185, 180, 0.45);
  transition: width 0.35s var(--wow-ease-out), height 0.35s var(--wow-ease-out), margin 0.35s var(--wow-ease-out), border-color 0.25s ease, opacity 0.25s ease;
}

body.wow-cursor-custom {
  cursor: none;
}

body.wow-cursor-custom a,
body.wow-cursor-custom button,
body.wow-cursor-custom [data-magnetic],
body.wow-cursor-custom .service-card,
body.wow-cursor-custom input,
body.wow-cursor-custom textarea,
body.wow-cursor-custom [contenteditable="true"] {
  cursor: text !important;
}

body.wow-cursor-custom.is-cursor-hover .cursor-ring {
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-color: rgba(16, 185, 180, 0.75);
}

body.wow-cursor-custom.is-cursor-hover .cursor-dot {
  transform: scale(0.5);
}

body.wow-cursor-custom.is-cursor-ai .cursor-ring {
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-color: rgba(78, 170, 219, 0.8);
  background: rgba(16, 185, 180, 0.06);
}

/* ---- CTS AI floating launcher ---- */
.cts-ai__fab {
  position: fixed;
  bottom: 5.75rem;
  right: 1.25rem;
  z-index: 10055;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1rem 0.55rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 180, 0.35);
  background: linear-gradient(135deg, rgba(16, 185, 180, 0.14) 0%, rgba(78, 170, 219, 0.08) 100%);
  backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 40px rgba(16, 185, 180, 0.15);
  color: var(--text-primary);
  transition: transform 0.35s var(--wow-ease-out), box-shadow 0.35s ease, opacity 0.35s ease, visibility 0.35s ease;
}

html[dir="rtl"] .cts-ai__fab {
  right: auto;
  left: 1.25rem;
  padding: 0.55rem 0.55rem 0.55rem 1rem;
}

.cts-ai__fab:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 0 56px rgba(16, 185, 180, 0.25);
}

.cts-ai__fab.is-hidden,
body.cts-ai-open .cts-ai__fab {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px) scale(0.92);
}

/* Restore native cursor when AI is open (panel sits above custom cursor layer) */
body.cts-ai-open.wow-cursor-custom,
body.cts-ai-open.wow-cursor-custom * {
  cursor: auto !important;
}

body.cts-ai-open .cursor-dot,
body.cts-ai-open .cursor-ring,
body.cts-ai-open .cursor-glow {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

.cts-ai__fab-ring {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 1px solid rgba(16, 185, 180, 0.25);
  animation: ultra-fab-ring 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ultra-fab-ring {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.06); }
}

.cts-ai__fab img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.cts-ai__fab-label {
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
  z-index: 1;
}

/* ---- AI panel expand from FAB ---- */
.cts-ai__panel {
  transform-origin: bottom right;
}

html[dir="rtl"] .cts-ai__panel {
  transform-origin: bottom left;
}

.cts-ai__panel.is-expanding {
  animation: ultra-ai-expand 0.45s var(--wow-ease-out) both;
}

@keyframes ultra-ai-expand {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- Contextual section hint ---- */
.wow-section-hint {
  position: fixed;
  bottom: 10rem;
  right: 1.25rem;
  z-index: 10035;
  max-width: 300px;
  padding: 0.9rem 2.25rem 0.9rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--surface-elevated, var(--bg-glass));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.55s var(--wow-ease-out), opacity 0.45s ease;
}

html[dir="rtl"] .wow-section-hint {
  right: auto;
  left: 1.25rem;
  padding: 0.9rem 1rem 0.9rem 2.25rem;
  transform: translateX(-120%);
}

.wow-section-hint.is-visible {
  transform: none;
  opacity: 1;
}

.wow-section-hint__action {
  display: inline-flex;
  margin-top: 0.5rem;
  font-weight: 600;
  color: var(--cts-teal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.wow-section-hint__close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  padding: 0.25rem;
  color: var(--text-muted);
  border-radius: 4px;
  line-height: 1;
}

html[dir="rtl"] .wow-section-hint__close {
  right: auto;
  left: 0.35rem;
}

/* ---- Mobile nav cinematic ---- */
.nav__drawer.is-open .nav__link,
.nav__drawer.is-open .cts-ai__toggle--nav {
  animation: ultra-nav-item-in 0.5s var(--wow-ease-out) both;
}

.nav__drawer.is-open .nav__menu > li:nth-child(1) .nav__link { animation-delay: 0.05s; }
.nav__drawer.is-open .nav__menu > li:nth-child(2) .nav__link { animation-delay: 0.1s; }
.nav__drawer.is-open .nav__menu > li:nth-child(3) .nav__link { animation-delay: 0.15s; }
.nav__drawer.is-open .nav__menu > li:nth-child(4) .nav__link { animation-delay: 0.2s; }
.nav__drawer.is-open .nav__menu > li:nth-child(5) .nav__link { animation-delay: 0.25s; }
.nav__drawer.is-open .nav__menu > li:nth-child(6) .nav__link { animation-delay: 0.3s; }
.nav__drawer.is-open .nav__menu > li:nth-child(7) .nav__link { animation-delay: 0.35s; }
.nav__drawer.is-open .nav__menu > li:nth-child(8) .nav__link,
.nav__drawer.is-open .nav__menu > li:nth-child(8) .cts-ai__toggle--nav { animation-delay: 0.4s; }

@keyframes ultra-nav-item-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.nav__drawer.is-open .nav__actions-mobile {
  animation: ultra-nav-item-in 0.55s var(--wow-ease-out) 0.45s both;
}

/* ---- Theme transition ---- */
html.theme-transitioning,
html.theme-transitioning * {
  transition:
    background-color 0.45s var(--wow-ease-out),
    color 0.35s var(--wow-ease-out),
    border-color 0.45s var(--wow-ease-out),
    box-shadow 0.45s var(--wow-ease-out) !important;
}

/* ---- Final CTA finale ---- */
.cta-section .cta-banner__inner {
  position: relative;
  overflow: hidden;
}

.cta-section .cta-banner__inner::after {
  content: '';
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at 70% 40%, rgba(16, 185, 180, 0.1), transparent 55%);
  animation: ultra-cta-atmosphere 6s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes ultra-cta-atmosphere {
  from { transform: translate(0, 0) scale(1); opacity: 0.6; }
  to { transform: translate(-3%, 2%) scale(1.05); opacity: 1; }
}

.cta-section .cta-banner__title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  letter-spacing: -0.02em;
}

/* ---- Service expand detail ---- */
.services-showcase__preview.is-expanded {
  transform: scale(1.01);
  border-color: rgba(16, 185, 180, 0.5);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(16, 185, 180, 0.12);
}

/* ---- Footer finale ---- */
.footer__accent {
  animation: ultra-footer-glow 4s ease-in-out infinite alternate;
}

@keyframes ultra-footer-glow {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .cts-signature__beam,
  .cts-signature__node,
  .cts-signature__pulse,
  .cts-ai__fab-ring,
  .cta-section .cta-banner__inner::after,
  .footer__accent {
    animation: none !important;
  }

  .cursor-dot,
  .cursor-ring {
    display: none !important;
  }

  body.wow-cursor-custom {
    cursor: auto !important;
  }
}

@media (max-width: 768px) {
  .cts-signature { display: none; }

  .cts-ai__fab {
    bottom: 1.25rem;
    right: 1.25rem;
  }

  html[dir="rtl"] .cts-ai__fab {
    left: 1.25rem;
  }

  .wow-section-hint {
    bottom: 5.5rem;
    left: 1rem;
    right: 1rem;
    max-width: none;
  }

  .cursor-dot,
  .cursor-ring {
    display: none !important;
  }
}

@media (min-width: 769px) {
  body:not(.cts-ai-open) .back-to-top.is-visible {
    bottom: 5.75rem;
  }
}
