/**
 * Khả Văn UI Effects — HTML/CSS/JS thuần (WordPress / Django / static)
 *
 * Cảm hứng & giấy phép (chỉ tier miễn phí):
 * - Magic UI (MIT): shimmer text, dot pattern, border beam
 *   https://github.com/magicuidesign/magicui
 * - Aceternity UI (free components): spotlight intro
 *   https://ui.aceternity.com/components/spotlight
 * - Uiverse (MIT): glass card hover glow
 *   https://github.com/uiverse-io/galaxy
 *
 * Triển khai gốc cho Khả Văn — không copy demo/branding bên thứ ba.
 */

:root {
  --kv-fx-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --kv-fx-shimmer-w: 120px;
}

/* ── Dot grid (Magic UI Dot Pattern inspired) ── */
.kv-fx-dots {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.35;
  background-image: radial-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 88%);
}

/* ── Spotlight intro (Aceternity Spotlight inspired) ── */
.kv-fx-spotlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.kv-fx-spotlight::before {
  content: "";
  position: absolute;
  width: min(42rem, 90vw);
  height: min(42rem, 90vw);
  left: 0;
  top: 0;
  transform: translate(-55%, -58%) scale(0.55);
  opacity: 0;
  background: radial-gradient(circle, rgba(255, 198, 23, 0.22) 0%, rgba(255, 198, 23, 0.08) 28%, transparent 62%);
  animation: kv-fx-spotlight-in 2.2s var(--kv-fx-ease) 0.4s forwards;
}

.kv-fx-spotlight-cursor {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
  background: radial-gradient(
    520px circle at var(--kv-fx-x, 30%) var(--kv-fx-y, 40%),
    rgba(255, 198, 23, 0.14),
    transparent 42%
  );
}

.kv-fx-hero.is-spotlight-ready .kv-fx-spotlight-cursor {
  opacity: 1;
}

@keyframes kv-fx-spotlight-in {
  to {
    opacity: 1;
    transform: translate(-42%, -48%) scale(1);
  }
}

/* ── Shimmer chữ — glow vàng, KHÔNG dùng background-clip (tránh mất chữ) ── */
.kv-fx-shimmer,
.kv-fx-hero .kv-hero__title .text-kv-yellow {
  display: inline;
  color: var(--kv-yellow) !important;
  -webkit-text-fill-color: var(--kv-yellow) !important;
  background: none !important;
  animation: kv-fx-shimmer-glow 2.8s ease-in-out infinite;
}

@keyframes kv-fx-shimmer-glow {
  0%, 100% {
    text-shadow:
      0 0 6px rgba(255, 198, 23, 0.35),
      0 0 2px rgba(255, 255, 255, 0.2);
  }
  50% {
    text-shadow:
      0 0 16px rgba(255, 198, 23, 0.95),
      0 0 4px rgba(255, 255, 255, 0.55),
      0 0 32px rgba(255, 198, 23, 0.45);
  }
}

/* ── Blur fade-in text (Aceternity blur reveal inspired) ── */
.kv-fx-blur-in > * {
  animation: kv-fx-blur-in 0.85s var(--kv-fx-ease) both;
}

.kv-fx-blur-in .kv-hero-kicker { animation-delay: 0.05s; }
.kv-fx-blur-in .kv-hero__title { animation-delay: 0.12s; }
.kv-fx-blur-in .kv-hero__lead { animation-delay: 0.22s; }
.kv-fx-blur-in .kv-hero__actions { animation-delay: 0.32s; }

/* Ghi đè animation premium cũ khi dùng blur-in */
.kv-premium .kv-fx-blur-in .kv-hero-kicker,
.kv-premium .kv-fx-blur-in .kv-hero__title,
.kv-premium .kv-fx-blur-in .kv-hero__lead,
.kv-premium .kv-fx-blur-in .kv-hero__actions {
  animation: kv-fx-blur-in 0.85s var(--kv-fx-ease) both !important;
}

/* bỏ rule transparent cũ — gây mất chữ */

@keyframes kv-fx-blur-in {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

/* ── Border beam wrapper (Magic UI Border Beam inspired) ── */
.kv-fx-beam-wrap {
  position: relative;
  padding: 1px;
  border-radius: calc(var(--kv-radius) + 2px);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 198, 23, 0.55),
    rgba(10, 107, 61, 0.45),
    transparent
  );
  background-size: 220% 100%;
  animation: kv-fx-beam-slide 5s linear infinite;
}

.kv-fx-beam-wrap > .kv-stats,
.kv-fx-beam-wrap > .kv-fx-beam-inner {
  border-radius: var(--kv-radius);
}

@keyframes kv-fx-beam-slide {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Glass / glow card (Uiverse + Magic UI shine inspired) ── */
.kv-fx-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.kv-fx-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.35s var(--kv-fx-ease);
  background: radial-gradient(
    360px circle at var(--kv-spot-x, 50%) var(--kv-spot-y, 0%),
    rgba(255, 198, 23, 0.16),
    transparent 42%
  );
  pointer-events: none;
  z-index: 0;
}

.kv-fx-card:hover::before {
  opacity: 1;
}

.kv-fx-card > * {
  position: relative;
  z-index: 1;
}

/* Shine sweep on hover */
.kv-fx-card--shine::after {
  content: "";
  position: absolute;
  inset: -40% auto -40% -60%;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg) translateX(-120%);
  transition: transform 0.65s var(--kv-fx-ease);
  pointer-events: none;
  z-index: 2;
}

.kv-fx-card--shine:hover::after {
  transform: skewX(-18deg) translateX(320%);
}

/* Glass badge */
.kv-fx-glass {
  background: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  transition:
    transform 0.3s var(--kv-fx-ease),
    box-shadow 0.3s var(--kv-fx-ease),
    border-color 0.3s;
}

.kv-fx-glass:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 198, 23, 0.55);
  box-shadow:
    0 14px 32px rgba(6, 73, 45, 0.14),
    0 0 0 1px rgba(255, 198, 23, 0.2);
}

/* CTA moving border (Aceternity moving border inspired — CSS only) */
.kv-fx-btn-glow {
  position: relative;
  overflow: hidden;
  z-index: 0;
}

.kv-fx-btn-glow::before {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: conic-gradient(
    from var(--kv-fx-angle, 0deg),
    transparent 0 25%,
    rgba(255, 198, 23, 0.85) 25% 35%,
    transparent 35% 100%
  );
  animation: kv-fx-conic 3.5s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.kv-fx-btn-glow:hover::before,
.kv-fx-btn-glow:focus-visible::before {
  opacity: 1;
}

@keyframes kv-fx-conic {
  to { --kv-fx-angle: 360deg; }
}

@property --kv-fx-angle {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

/* Section title gradient underline */
.kv-fx-title-line {
  position: relative;
  display: inline-block;
}

.kv-fx-title-line::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -0.35rem;
  width: 3rem;
  height: 3px;
  border-radius: 999px;
  transform: translateX(-50%) scaleX(0);
  background: linear-gradient(90deg, var(--kv-green), var(--kv-yellow));
  transition: transform 0.5s var(--kv-fx-ease);
}

.kv-section__head.is-revealed .kv-fx-title-line::after,
.kv-fx-title-line.is-revealed::after {
  transform: translateX(-50%) scaleX(1);
}

/* Stat item pulse on count done */
.kv-stat.kv-fx-stat-pop .kv-stat__icon {
  animation: kv-fx-stat-pop 0.55s var(--kv-fx-ease);
}

@keyframes kv-fx-stat-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .kv-fx-shimmer,
  .kv-fx-beam-wrap,
  .kv-fx-spotlight::before,
  .kv-fx-btn-glow::before {
    animation: none !important;
  }

  .kv-fx-blur-in > * {
    animation: none !important;
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
  }

  .kv-fx-spotlight-cursor {
    display: none !important;
  }

  .kv-fx-card--shine::after {
    display: none;
  }
}

@media (max-width: 1023px) {
  .kv-fx-spotlight-cursor {
    display: none;
  }
}
