/* ══════════════════════════════════════════════════════════════
   ux-enhancements.css — Webmari UX Premium v1
   Animações, micro-interações e melhorias de experiência
   ══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════
   PRELOADER
══════════════════════════════ */
.wm-preloader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--bg);
  display: grid;
  place-items: center;
  transition: opacity 0.6s cubic-bezier(.2,.8,.2,1), visibility 0.6s;
}

.wm-preloader__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8rem;
}

.wm-preloader__logo {
  width: 140px;
  height: auto;
  animation: preloaderPulse 1.4s ease-in-out infinite;
}

.wm-preloader__bar {
  width: 140px;
  height: 3px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}

.wm-preloader__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--primary), var(--primary2));
  border-radius: inherit;
  animation: preloaderSlide 1.1s cubic-bezier(.4,0,.2,1) infinite;
}

.wm-preloader__text {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
  animation: preloaderPulse 1.4s ease-in-out infinite;
}

@keyframes preloaderPulse {
  0%, 100% { opacity: 0.55; transform: scale(0.97); }
  50%       { opacity: 1;    transform: scale(1);    }
}

@keyframes preloaderSlide {
  0%   { transform: translateX(-100%); }
  50%  { transform: translateX(0%);    }
  100% { transform: translateX(100%);  }
}

.wm-preloader.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}


/* ══════════════════════════════
   SCROLL PROGRESS BAR
══════════════════════════════ */
.wm-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary2) 100%);
  z-index: 100001;
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(79, 124, 255, 0.6);
  pointer-events: none;
  /* No transition — JS updates this on scroll for instant feedback */
}


/* ══════════════════════════════
   BACK TO TOP BUTTON
══════════════════════════════ */
.wm-back-to-top {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  z-index: 8900;
  box-shadow: 0 8px 28px rgba(79, 124, 255, 0.42);
  opacity: 0;
  transform: translateY(16px) scale(0.8);
  transition: opacity 0.35s cubic-bezier(.2,.8,.2,1), transform 0.35s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
}

.wm-back-to-top svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.wm-back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .wm-back-to-top:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 16px 44px rgba(79, 124, 255, 0.58);
  }
  .wm-back-to-top:active {
    transform: translateY(0) scale(0.95);
  }
}


/* ══════════════════════════════
   TOAST NOTIFICATIONS
══════════════════════════════ */
.wm-toast-container {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  z-index: 99997;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  pointer-events: none;
  max-width: min(90vw, 340px);
}

.wm-toast {
  background: color-mix(in srgb, var(--card) 97%, transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  font-size: 0.88rem;
  color: var(--text);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  /* backdrop-filter removido — muito pesado em GPU; fundo sólido é suficiente */
  transform: translateX(calc(100% + 2rem));
  transition: transform 0.28s ease-out, opacity 0.2s;
  pointer-events: auto;
  line-height: 1.4;
}

.wm-toast.is-visible {
  transform: translateX(0);
}

.wm-toast--success { border-color: rgba(34, 197, 94,  0.4); }
.wm-toast--error   { border-color: rgba(239, 68,  68,  0.4); }
.wm-toast--info    { border-color: rgba(79,  124, 255, 0.4); }

.wm-toast__icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.wm-toast--success .wm-toast__icon { background: rgba(34, 197, 94,  0.2); color: #22c55e; }
.wm-toast--error   .wm-toast__icon { background: rgba(239, 68,  68,  0.2); color: #ef4444; }
.wm-toast--info    .wm-toast__icon { background: rgba(79,  124, 255, 0.2); color: var(--primary); }

.wm-toast__msg {
  flex: 1;
  font-size: 0.875rem;
}

.wm-toast__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  line-height: 1;
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-left: 0.25rem;
  transition: color 0.15s, transform 0.15s;
  font-family: inherit;
}
.wm-toast__close:hover {
  color: var(--text);
  transform: scale(1.2);
}


/* cursor personalizado removido a pedido do utilizador */
.wm-cursor,
.wm-cursor-ring {
  display: none !important;
}


/* ══════════════════════════════
   RIPPLE EFFECT ON BUTTONS
══════════════════════════════ */
.btn {
  position: relative;
  overflow: hidden;
}

.quiz-btn {
  position: relative;
  overflow: hidden;
}

.wm-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  transform: scale(0);
  animation: wmRipple 0.65s linear forwards;
  pointer-events: none;
  z-index: 0;
}

.btn--outline .wm-ripple {
  background: rgba(79, 124, 255, 0.15);
}

@keyframes wmRipple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}


/* ══════════════════════════════
   CTA PULSE GLOW
   Usa opacity em vez de box-shadow para evitar repaint constante.
   O pseudo-elemento cria a sombra e anima apenas a sua opacidade.
══════════════════════════════ */
.btn--primary {
  position: relative;
}

.btn--primary::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 18px 60px rgba(79, 124, 255, 0.55);
  opacity: 0.5;
  animation: ctaPulseGlow 3.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes ctaPulseGlow {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.75; }
}

.btn--primary:hover::after,
.btn--primary:focus-visible::after {
  animation: none;
  opacity: 0.8;
}


/* ══════════════════════════════
   ENHANCED CARD HOVER EFFECTS
══════════════════════════════ */
@media (hover: hover) and (pointer: fine) {
  .card--icon {
    position: relative;
    /* overflow:hidden garante que nenhum filho escapa durante hover */
    overflow: hidden;
  }

  .card--icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    background: linear-gradient(135deg,
      color-mix(in srgb, var(--primary) 8%, transparent),
      color-mix(in srgb, var(--primary2) 5%, transparent));
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  .card--icon:hover::before {
    opacity: 1;
  }

  /* Removido scale(1.02): causava overflow visual fora dos limites do card.
     Mantido apenas translateY para o efeito de "lift" sem expansão. */
  .card--icon:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 48px rgba(79, 124, 255, 0.18);
    border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  }

  /* Ícone: mantém rotação mas sem spring overshoot */
  .card--icon:hover .card__icon {
    transform: scale(1.1) rotate(-5deg);
    transition: transform 0.28s ease-out;
    border-color: color-mix(in srgb, var(--primary) 60%, transparent);
  }

}


/* ══════════════════════════════
   STAGGER GRID ANIMATION
   (delays for .reveal children in grids)
══════════════════════════════ */
.services__grid > .reveal:nth-child(2),
.about__cards   > .reveal:nth-child(2),
.testimonials__grid > .reveal:nth-child(2) { transition-delay: 90ms;  }

.services__grid > .reveal:nth-child(3),
.about__cards   > .reveal:nth-child(3),
.testimonials__grid > .reveal:nth-child(3) { transition-delay: 180ms; }

.services__grid > .reveal:nth-child(4) { transition-delay: 270ms; }
.services__grid > .reveal:nth-child(5) { transition-delay: 360ms; }
.services__grid > .reveal:nth-child(6) { transition-delay: 450ms; }


/* ══════════════════════════════
   PORTFOLIO FILTER BUTTONS
══════════════════════════════ */
.wm-filter {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 2.5rem;
}

.wm-filter__btn {
  padding: 0.45rem 1.05rem;
  min-height: 44px; /* touch target mínimo */
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.25s cubic-bezier(.2,.8,.2,1);
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .wm-filter__btn:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
    color: var(--text);
    transform: translateY(-1px);
  }
}

.wm-filter__btn.is-active {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  border-color: transparent;
  color: #061026;
  font-weight: 600;
  box-shadow: 0 8px 28px rgba(79, 124, 255, 0.35);
}


/* ══════════════════════════════
   PORTFOLIO ITEM FILTER TRANSITION
   (overrides the floating animation for hidden items)
══════════════════════════════ */
.project.is-hidden {
  opacity: 0 !important;
  transform: scale(0.88) !important;
  animation: none !important;
  pointer-events: none !important;
  filter: blur(2px);
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.35s ease !important;
}


/* ══════════════════════════════
   ANIMATED COUNTERS DISPLAY
══════════════════════════════ */
.about__statNum {
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}


/* ══════════════════════════════
   NAVBAR SCROLL POLISH
   (transparent → solid with shadow on scroll)
══════════════════════════════ */
.header {
  transition: background 0.4s cubic-bezier(.2,.8,.2,1),
              box-shadow 0.4s cubic-bezier(.2,.8,.2,1),
              border-color 0.3s;
}

.header[data-elevated="true"] {
  box-shadow: 0 4px 40px rgba(0,0,0,0.15);
}

html[data-theme="light"] .header[data-elevated="true"] {
  background: rgba(255,255,255, 0.96) !important;
  box-shadow: 0 4px 32px rgba(11, 19, 48, 0.09);
}

html[data-theme="dark"] .header[data-elevated="true"] {
  background: rgba(11, 16, 32, 0.97) !important;
}


/* ══════════════════════════════
   DARK MODE TOGGLE HOVER POLISH
══════════════════════════════ */
@media (hover: hover) and (pointer: fine) {
  .theme-switch:hover {
    transform: rotate(15deg) scale(1.1);
  }

  .theme-switch {
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1);
  }
}


/* ══════════════════════════════
   MOBILE MENU ANIMATION POLISH
══════════════════════════════ */
@media (max-width: 860px) {
  .nav__panel {
    transition: transform 0.38s cubic-bezier(.2,.8,.2,1),
                opacity 0.38s ease !important;
  }

  .nav__panel[data-open="false"] {
    pointer-events: none;
  }
}


/* ══════════════════════════════
   HERO PARALLAX CONTAINER
══════════════════════════════ */
.hero__parallax {
  will-change: transform;
  transition: transform 0.05s linear;
}


/* ══════════════════════════════
   PAGE TRANSITION OVERLAY
══════════════════════════════ */
.wm-page-transition {
  position: fixed;
  inset: 0;
  z-index: 999998;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(.2,.8,.2,1);
}

.wm-page-transition.is-active {
  opacity: 1;
  pointer-events: auto;
}


/* ══════════════════════════════
   LAZY IMAGE FADE-IN
══════════════════════════════ */
img[loading="lazy"] {
  transition: opacity 0.5s ease;
}

img[loading="lazy"]:not(.is-loaded) {
  opacity: 0;
}

img[loading="lazy"].is-loaded {
  opacity: 1;
}


/* ══════════════════════════════
   HERO SCROLL INDICATOR ANIMATION
══════════════════════════════ */
.hero__scrollIcon {
  animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0);   opacity: 0.6; }
  50%       { transform: translateY(6px); opacity: 1;   }
}


/* ══════════════════════════════
   CHIP ENTRANCE (hero chips)
══════════════════════════════ */
@media (hover: hover) and (pointer: fine) {
  .chip {
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.25s ease,
                border-color 0.25s ease;
  }

  .chip:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 12px 30px rgba(79, 124, 255, 0.18);
  }
}


/* ══════════════════════════════
   ABOUT PANEL — stat number glow on count
══════════════════════════════ */
.about__statNum.is-counting {
  color: var(--primary2);
  text-shadow: 0 0 20px rgba(35, 212, 255, 0.35);
}


/* ══════════════════════════════
   MOBILE IMPROVEMENTS
══════════════════════════════ */
@media (max-width: 640px) {
  .wm-back-to-top {
    bottom: 1.25rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
  }

  .wm-toast-container {
    bottom: 4.5rem;
    right: 0;
    left: 0;
    max-width: 100%;
    padding: 0 0.75rem;
    align-items: stretch;
  }

  .wm-toast {
    max-width: 100%;
  }

  .wm-filter {
    gap: 0.38rem;
  }

  .wm-filter__btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    min-height: 44px; /* mantém touch target no mobile */
  }
}


/* ══════════════════════════════
   PARALLAX: desativado em touch
══════════════════════════════ */
@media (pointer: coarse) {
  .hero__parallax {
    will-change: auto !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ══════════════════════════════
   MOBILE NAV OVERLAY: animação suave
══════════════════════════════ */
@media (max-width: 860px) {
  .nav__panel[data-open="true"] {
    animation: navPanelIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  @keyframes navPanelIn {
    from {
      opacity: 0;
      transform: translateY(-8px) scale(0.97);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
}


/* ══════════════════════════════
   ACTIVE NAV LINK (scrollspy)
══════════════════════════════ */
@media (hover: hover) and (pointer: fine) {
  .header .nav__link.is-active-section {
    color: var(--text);
  }

  .header .nav__link.is-active-section::after {
    transform: scaleX(1) !important;
    background: var(--primary) !important;
    opacity: 0.85;
  }
}


/* ══════════════════════════════
   TESTIMONIALS STAR RATING POLISH
══════════════════════════════ */
.quote__stars {
  color: #f59e0b;
  letter-spacing: 0.05em;
  font-size: 1.05rem;
  margin-bottom: 0.6rem;
  /* Sem transform no hover: as estrelas saíam fora do border-radius do card */
}


/* ══════════════════════════════
   SERVICES GRID ICON ANIMATION
══════════════════════════════ */
.services__grid .card--icon .card__icon {
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1),
              background 0.35s ease,
              border-color 0.35s ease;
}


/* ══════════════════════════════
   REDUCED MOTION OVERRIDES
══════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .wm-preloader__logo,
  .wm-preloader__bar::after,
  .btn--primary,
  .wm-back-to-top,
  .hero__scrollIcon,
  .chip {
    animation: none !important;
    transition: none !important;
  }

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

  .project.is-hidden {
    opacity: 0 !important;
    transform: none !important;
    filter: none !important;
  }

  img[loading="lazy"]:not(.is-loaded) {
    opacity: 1;
  }
}
