/* Slow-motion layer: icons that draw themselves, word-by-word titles,
   ambient light in the hero and soft micro-interactions.
   Turns itself off with body.motion-off and prefers-reduced-motion. */
:root {
  --sm-ease: cubic-bezier(.16, 1, .3, 1);
  --sm-ease-io: cubic-bezier(.65, 0, .35, 1);
}

/* Soft curtain on load */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--surface);
  pointer-events: none;
  animation: sm-curtain 1400ms var(--sm-ease-io) 60ms both;
}

@keyframes sm-curtain { to { opacity: 0; visibility: hidden; } }

/* Icons: every stroke draws in when it enters the screen */
.sm-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 2200ms var(--sm-ease-io) var(--sm-delay, 0ms);
}

.sm-draw.is-in { stroke-dashoffset: 0; }

/* Idle loops on whole icons (individual properties, so existing transforms stay intact) */
.scene-active .directory-symbol svg.is-in,
.service-index .directory-symbol svg.is-in {
  animation: sm-sway 7s var(--sm-ease-io) infinite alternate;
  animation-delay: calc(var(--sm-i, 0) * -1.3s);
}

.category-notes svg.is-in,
.development-examples svg.is-in {
  animation: sm-bob 5.5s var(--sm-ease-io) infinite alternate;
  animation-delay: calc(var(--sm-i, 0) * -1.1s);
}

.connected-node svg.is-in,
.connected-hub svg.is-in {
  animation: sm-bob 6.5s var(--sm-ease-io) infinite alternate;
  animation-delay: calc(var(--sm-i, 0) * -1.6s);
}

.infra-symbol.is-in {
  animation: sm-tilt 8s var(--sm-ease-io) infinite alternate;
  animation-delay: calc(var(--sm-i, 0) * -2s);
}

@keyframes sm-sway { from { rotate: -4deg; translate: 0 1px; } to { rotate: 5deg; translate: 0 -3px; } }
@keyframes sm-bob { from { translate: 0 0; scale: 1; } to { translate: 0 -4px; scale: 1.06; } }
@keyframes sm-tilt { from { rotate: -6deg; } to { rotate: 6deg; } }

/* Arrows nudge slowly, and glide further on hover */
.button svg,
.service-link svg,
.directory-arrow {
  transition: translate 900ms var(--sm-ease);
}

.button svg.is-in,
.service-link svg.is-in {
  animation: sm-nudge 3.6s var(--sm-ease-io) 2.4s infinite;
}

.button:hover svg,
.service-link:hover svg,
.directory-link:hover .directory-arrow {
  animation: none;
  translate: 7px 0;
}

@keyframes sm-nudge { 0%, 62%, 100% { translate: 0 0; } 78% { translate: 5px 0; } }

/* Titles reveal word by word behind a mask */
.sm-split .sm-w {
  display: inline-block;
  overflow: hidden;
  padding: .06em .02em .16em;
  margin: -.06em -.02em -.16em;
  vertical-align: top;
}

.sm-split .sm-w > span {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 108%, 0) rotate(4deg);
  transform-origin: 0 100%;
  transition:
    transform 1700ms var(--sm-ease) calc(var(--i, 0) * 110ms + var(--sm-title-delay, 0ms)),
    opacity 1300ms var(--sm-ease) calc(var(--i, 0) * 110ms + var(--sm-title-delay, 0ms));
}

.sm-split.is-in .sm-w > span {
  opacity: 1;
  transform: none;
}

/* Slow golden sheen across the hero headline's last line */
.hero h1 .sm-last > span {
  background: linear-gradient(100deg, var(--ink) 20%, var(--gold) 45%, var(--blue) 60%, var(--ink) 85%);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sm-sheen 10s var(--sm-ease-io) 3s infinite;
}

@keyframes sm-sheen { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }

.hero .lead,
.hero .actions {
  animation: sm-rise 1600ms var(--sm-ease) both;
}

.hero .lead { animation-delay: 750ms; }
.hero .actions { animation-delay: 1050ms; }

@keyframes sm-rise {
  from { opacity: 0; transform: translate3d(0, 24px, 0); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

/* Ambient light drifting behind the hero */
.sm-ambient {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.sm-ambient span {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
}

.sm-ambient span:nth-child(1) {
  top: -30%;
  left: -10%;
  width: 55%;
  aspect-ratio: 1;
  background: radial-gradient(circle, #cfe0f0, transparent 68%);
  animation: sm-drift-a 28s var(--sm-ease-io) infinite alternate;
}

.sm-ambient span:nth-child(2) {
  right: -12%;
  bottom: -40%;
  width: 60%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(53, 166, 227, .30), transparent 66%);
  animation: sm-drift-b 36s var(--sm-ease-io) infinite alternate;
}

.sm-ambient span:nth-child(3) {
  top: 10%;
  left: 38%;
  width: 34%;
  aspect-ratio: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, .9), transparent 65%);
  animation: sm-drift-c 24s var(--sm-ease-io) infinite alternate;
}

.sm-ambient i {
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at var(--hx, 70%) var(--hy, 40%), rgba(255, 255, 255, .75), transparent 60%);
  opacity: 0;
  transition: opacity 1600ms var(--sm-ease);
}

.hero.is-pointer .sm-ambient i { opacity: 1; }

@keyframes sm-drift-a { to { transform: translate3d(30%, 22%, 0) scale(1.2); } }
@keyframes sm-drift-b { to { transform: translate3d(-28%, -20%, 0) scale(.85); } }
@keyframes sm-drift-c { to { transform: translate3d(-40%, 30%, 0) scale(1.3); } }

/* Buttons: sheen sweep and a gentle magnetic pull */
.button,
.nav-cta {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  translate: var(--gx, 0px) var(--gy, 0px);
  transition: transform 900ms var(--sm-ease), background 700ms var(--sm-ease), translate 1100ms var(--sm-ease), box-shadow 1100ms var(--sm-ease);
}

.button::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .3) 50%, transparent 70%);
  transform: translateX(-130%);
  transition: transform 1400ms var(--sm-ease);
}

.button:hover::after { transform: translateX(130%); }
.button:hover { box-shadow: 0 18px 36px -16px rgba(23, 61, 96, .55); }

/* Cards and directory rows: slower, softer hover */
.directory-link,
.category-notes > div,
.development-path > div,
.connected-node,
.connected-hub {
  transition: translate 1100ms var(--sm-ease), background-color 900ms var(--sm-ease), box-shadow 1100ms var(--sm-ease);
}

.directory-link:hover { translate: 8px 0; }
.category-notes > div:hover,
.development-path > div:hover { translate: 0 -6px; }
.connected-node:hover,
.connected-hub:hover { translate: 0 -5px; }

/* Illustrations float on their own, very slowly */
.scene-active .category-image img {
  animation: sm-float-img 11s var(--sm-ease-io) infinite alternate;
}

@keyframes sm-float-img {
  from { translate: 0 0; rotate: -.6deg; }
  to { translate: 0 -12px; rotate: .6deg; }
}

/* Motion off: everything at rest and fully visible */
body.motion-off::after { display: none; }

body.motion-off .sm-draw { stroke-dashoffset: 0; }

body.motion-off .sm-split .sm-w > span,
body.motion-off .hero .lead,
body.motion-off .hero .actions {
  opacity: 1;
  transform: none;
  filter: none;
}

body.motion-off .sm-ambient { display: none; }

@media (prefers-reduced-motion: reduce) {
  body::after,
  .sm-ambient { display: none; }

  .sm-draw { stroke-dashoffset: 0; }

  .sm-split .sm-w > span,
  .hero .lead,
  .hero .actions {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* Floating WhatsApp: slides in after the hero, steps aside at the contact section */
.sm-wa {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px 0 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 570;
  box-shadow: 0 18px 40px -14px rgba(23, 61, 96, .6);
  opacity: 0;
  visibility: hidden;
  translate: 0 24px;
  scale: .92;
  transition: opacity 900ms var(--sm-ease), translate 1100ms var(--sm-ease), scale 1100ms var(--sm-ease), visibility 0s linear 1100ms, background 700ms var(--sm-ease);
}

.sm-wa.is-shown {
  opacity: 1;
  visibility: visible;
  translate: 0 0;
  scale: 1;
  transition-delay: 0s;
}

.sm-wa:hover { background: var(--blue); }

.sm-wa::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  border: 1.5px solid #35a6e3;
  animation: sm-sonar 3.8s var(--sm-ease) 1s infinite;
}

.sm-wa-icon {
  width: 26px;
  height: 26px;
  color: #7fcaf0;
}

.sm-wa-icon circle {
  fill: currentColor;
  stroke: none;
  animation: sm-typing 1.8s var(--sm-ease-io) infinite;
}

.sm-wa-icon circle:nth-of-type(2) { animation-delay: .2s; }
.sm-wa-icon circle:nth-of-type(3) { animation-delay: .4s; }

@keyframes sm-sonar { from { transform: scale(1); opacity: .9; } to { transform: scale(1.25, 1.6); opacity: 0; } }
@keyframes sm-typing { 0%, 60%, 100% { translate: 0 0; opacity: .45; } 30% { translate: 0 -2px; opacity: 1; } }

@media (max-width: 800px) {
  .sm-wa { right: 16px; bottom: 16px; min-height: 52px; padding: 0 14px; }
  .sm-wa span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-wa { translate: none; scale: 1; }
}

/* Menu underline glides in from the left and out to the right */
.nav-links a::after {
  transform-origin: 100% 50%;
  transition: transform 900ms var(--sm-ease);
}

.nav-links a:hover::after,
.nav-links a[aria-current="location"]::after {
  transform-origin: 0 50%;
}
