/* ==========================================================================
   Lockye animations — buddy, waiting screen, celebration
   Light TestLock theme (lilac / purple), matches testlock-ui.css tokens.
   ========================================================================== */

@keyframes lkb-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes lkb-shadow { 0%, 100% { transform: translateX(-50%) scale(1); opacity: .55; } 50% { transform: translateX(-50%) scale(.86); opacity: .35; } }
@keyframes lkb-pop { 0% { transform: scale(.92) translateY(6px); } 60% { transform: scale(1.04) translateY(-2px); } 100% { transform: none; } }
@keyframes lkb-say { 0% { opacity: 0; transform: translateY(6px) scale(.96); } 100% { opacity: 1; transform: none; } }
@keyframes lkb-in { 0% { opacity: 0; transform: translateY(40px) scale(.7); } 70% { opacity: 1; transform: translateY(-6px) scale(1.04); } 100% { transform: none; } }
@keyframes lkb-twinkle { 0%, 100% { opacity: .2; transform: scale(.6) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }
@keyframes lkb-rise { 0% { transform: translateY(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-120vh) rotate(260deg); opacity: 0; } }
@keyframes lkb-fall { 0% { transform: translateY(-10vh) rotate(0); opacity: 1; } 100% { transform: translateY(110vh) rotate(540deg); opacity: .8; } }
@keyframes lkb-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lkb-shimmer { from { background-position: 0 0; } to { background-position: 40px 0; } }

/* ---------------- Buddy ---------------- */
.lk-buddy {
  --lk-w: 120px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.lk-buddy__stage { position: relative; width: var(--lk-w); perspective: 600px; animation: lkb-in .8s cubic-bezier(.2, .9, .3, 1.2) both; }
.lk-buddy__char {
  position: relative;
  width: 100%;
  aspect-ratio: 221 / 262;
  transform-style: preserve-3d;
  transition: transform .25s ease-out;
  animation: lkb-float 3.4s ease-in-out infinite;
}
.lk-buddy__char.is-pop { animation: lkb-pop .45s ease-out, lkb-float 3.4s .45s ease-in-out infinite; }
.lk-buddy__body,
.lk-buddy__pose { position: absolute; display: block; pointer-events: none; -webkit-user-drag: none; }
.lk-buddy__body { inset: 0; width: 100%; height: 100%; z-index: 2; transition: opacity .15s; }
.lk-buddy__pose { z-index: 3; left: 50%; bottom: 0; width: 100%; height: auto; transform: translateX(-50%); opacity: 0; transition: opacity .15s; }
.lk-buddy.is-posed .lk-buddy__pose { opacity: 1; }
.lk-buddy.is-posed .lk-buddy__body,
.lk-buddy.is-posed .lk-buddy__eye { opacity: 0; }

/* Eyes sit behind the body; they show through the transparent eye holes */
.lk-buddy__eye {
  position: absolute;
  z-index: 1;
  width: 27%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff 60%, #F3E8FA 100%);
  transform: translate(-50%, -50%);
  overflow: hidden;
  transition: opacity .15s;
}
.lk-buddy__eye--l { left: 33.5%; top: 60.5%; }
.lk-buddy__eye--r { left: 72%; top: 58.7%; }
.lk-buddy__eye::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #F9F0FC;
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .08s ease-in;
  z-index: 2;
}
.lk-buddy.is-blink .lk-buddy__eye::after { transform: scaleY(1); }
.lk-buddy__pupil {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 66%;
  aspect-ratio: 70 / 73;
  background: center / contain no-repeat;
  transform: translate(-50%, -50%);
  transition: transform .12s ease-out;
}
.lk-buddy__shadow {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 62%;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(89, 17, 128, .28), transparent);
  transform: translateX(-50%);
  animation: lkb-shadow 3.4s ease-in-out infinite;
  z-index: 0;
}

.lk-buddy__say {
  position: relative;
  max-width: 260px;
  min-height: 0;
  padding: 9px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #ECE7F0;
  box-shadow: 0 10px 24px -14px rgba(59, 10, 85, .45);
  font-family: var(--tl-font, Inter, sans-serif);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.45;
  color: #4A4357;
  text-align: center;
  opacity: 0;
}
.lk-buddy__say::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid #ECE7F0;
  border-bottom: 1px solid #ECE7F0;
  transform: translateX(-50%) rotate(45deg);
}
.lk-buddy__say.is-on { opacity: 1; animation: lkb-say .35s ease-out; }
.lk-buddy__say:empty { display: none; }

/* Size variants */
.lk-buddy--form { --lk-w: 104px; margin: 0 auto 14px; }
.lk-buddy--xl { --lk-w: clamp(200px, 26vw, 330px); }
.lk-buddy--xl .lk-buddy__say { font-size: 15px; padding: 11px 16px; max-width: 300px; }
.lk-buddy--side { --lk-w: 190px; }

@media (min-width: 992px) {
  .lk-buddy--form { --lk-w: 118px; }
}

/* ---------------- Landing: welcome section ---------------- */
.lp-welcome {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - var(--lp-nav-h, 72px));
  min-height: calc(100svh - var(--lp-nav-h, 72px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 0 84px;
  background:
    radial-gradient(800px 520px at 22% 45%, rgba(234, 191, 244, .85), transparent 62%),
    radial-gradient(700px 500px at 90% 10%, rgba(254, 207, 251, .6), transparent 60%),
    radial-gradient(600px 400px at 80% 100%, rgba(232, 189, 245, .5), transparent 60%),
    linear-gradient(180deg, #FFFFFF 0%, #FAF7FA 100%);
}
.lp-welcome__sky { position: absolute; inset: 0; pointer-events: none; }
.lp-welcome__sky i {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #FBC02D;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: lkb-twinkle 2.8s ease-in-out infinite;
}
.lp-welcome__sky i:nth-child(3n) { background: #A358B5; width: 10px; height: 10px; }
.lp-welcome__sky i:nth-child(4n) { background: #E8BDF5; width: 18px; height: 18px; }
.lp-welcome__sky i:nth-child(1) { left: 8%; top: 18%; }
.lp-welcome__sky i:nth-child(2) { left: 18%; top: 72%; animation-delay: .6s; }
.lp-welcome__sky i:nth-child(3) { left: 34%; top: 12%; animation-delay: 1.2s; }
.lp-welcome__sky i:nth-child(4) { left: 42%; top: 82%; animation-delay: .3s; }
.lp-welcome__sky i:nth-child(5) { left: 58%; top: 20%; animation-delay: 1.8s; }
.lp-welcome__sky i:nth-child(6) { left: 66%; top: 70%; animation-delay: .9s; }
.lp-welcome__sky i:nth-child(7) { left: 82%; top: 30%; animation-delay: 1.5s; }
.lp-welcome__sky i:nth-child(8) { left: 92%; top: 78%; animation-delay: .2s; }
.lp-welcome__sky i:nth-child(9) { left: 4%; top: 48%; animation-delay: 2.1s; }
.lp-welcome__sky i:nth-child(10) { left: 50%; top: 50%; animation-delay: 1s; }
.lp-welcome__sky b {
  position: absolute;
  bottom: -20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(163, 88, 181, .25);
  animation: lkb-rise 9s linear infinite;
}
.lp-welcome__sky b:nth-of-type(1) { left: 12%; animation-delay: 0s; }
.lp-welcome__sky b:nth-of-type(2) { left: 30%; animation-delay: 3s; width: 14px; height: 14px; }
.lp-welcome__sky b:nth-of-type(3) { left: 70%; animation-delay: 1.5s; }
.lp-welcome__sky b:nth-of-type(4) { left: 88%; animation-delay: 5s; width: 16px; height: 16px; }

.lp-welcome__inner { position: relative; display: grid; grid-template-columns: .9fr 1.1fr; gap: 48px; align-items: center; }
.lp-welcome__buddy { display: flex; justify-content: center; cursor: pointer; }
.lp-welcome__buddy .lk-buddy__stage { filter: drop-shadow(0 30px 40px rgba(89, 17, 128, .25)); }
.lp-welcome__title { margin-top: 18px; font-size: clamp(36px, 3.6vw + 14px, 62px); font-weight: 800; letter-spacing: -.035em; line-height: 1.1; color: var(--lp-ink, #1C1626); }
.lp-welcome__lead { margin-top: 18px; max-width: 540px; font-size: 18px; line-height: 1.65; color: var(--lp-ink-2, #4A4357); }
.lp-welcome__cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.lp-welcome__chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.lp-welcome__chips span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .75); border: 1px solid #ECE7F0;
  font-size: 13px; font-weight: 600; color: #4A4357;
}
.lp-welcome__scroll {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #736B80;
  text-decoration: none;
}
.lp-welcome__scroll span {
  width: 26px; height: 40px; border: 2px solid #C9B8D6; border-radius: 14px; position: relative;
}
.lp-welcome__scroll span::after {
  content: ""; position: absolute; left: 50%; top: 7px; width: 4px; height: 8px; margin-left: -2px;
  border-radius: 2px; background: #A358B5; animation: lkb-float 1.6s ease-in-out infinite;
}
.lp-welcome__scroll:hover { color: #6E2689; }

@media (max-width: 991.98px) {
  .lp-welcome { padding: 28px 0 80px; min-height: auto; }
  .lp-welcome__inner { grid-template-columns: 1fr; gap: 18px; text-align: center; }
  .lp-welcome__lead { margin-left: auto; margin-right: auto; }
  .lp-welcome__cta, .lp-welcome__chips { justify-content: center; }
  .lk-buddy--xl { --lk-w: 200px; }
}
@media (max-width: 575.98px) {
  .lp-welcome__title { font-size: 34px; }
  .lp-welcome__lead { font-size: 16px; }
  .lp-welcome__cta .lp-btn { flex: 1 1 100%; }
  .lk-buddy--xl { --lk-w: 170px; }
  .lk-buddy--xl .lk-buddy__say { font-size: 14px; }
}

/* ---------------- AI waiting screen ---------------- */
.lk-wait {
  display: block;
  padding: 0 !important;
  color: #1C1626 !important;
  font-family: var(--tl-font, Inter, sans-serif) !important;
  font-size: 16px !important;
  background:
    radial-gradient(700px 500px at 50% 20%, rgba(234, 191, 244, .9), transparent 65%),
    radial-gradient(600px 400px at 100% 100%, rgba(254, 207, 251, .6), transparent 60%),
    #F7F5FA !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: center;
}
.lk-wait > :not(.lk-wait__ui) { display: none !important; }
.lk-wait__ui {
  position: relative;
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: lkb-fade .4s ease-out;
}
.lk-wait__sky { position: fixed; inset: 0; pointer-events: none; }
.lk-wait__sky i {
  position: absolute; bottom: -20px; width: 12px; height: 12px; border-radius: 50%;
  background: rgba(163, 88, 181, .22); animation: lkb-rise 10s linear infinite;
}
.lk-wait__sky i:nth-child(odd) { background: rgba(251, 192, 45, .35); width: 8px; height: 8px; }
.lk-wait__sky i:nth-child(1) { left: 6%; } .lk-wait__sky i:nth-child(2) { left: 14%; animation-delay: 2s; }
.lk-wait__sky i:nth-child(3) { left: 24%; animation-delay: 4s; } .lk-wait__sky i:nth-child(4) { left: 34%; animation-delay: 1s; }
.lk-wait__sky i:nth-child(5) { left: 46%; animation-delay: 6s; } .lk-wait__sky i:nth-child(6) { left: 56%; animation-delay: 3s; }
.lk-wait__sky i:nth-child(7) { left: 66%; animation-delay: 5s; } .lk-wait__sky i:nth-child(8) { left: 76%; animation-delay: .5s; }
.lk-wait__sky i:nth-child(9) { left: 86%; animation-delay: 7s; } .lk-wait__sky i:nth-child(10) { left: 94%; animation-delay: 2.5s; }
.lk-wait__sky i:nth-child(11) { left: 40%; animation-delay: 8s; } .lk-wait__sky i:nth-child(12) { left: 70%; animation-delay: 9s; }

.lk-wait__stage { position: relative; width: 210px; height: 230px; display: flex; align-items: flex-end; justify-content: center; margin-top: 56px; }
.lk-wait__pose { width: 200px; height: auto; position: relative; z-index: 1; animation: lkb-float 3s ease-in-out infinite; filter: drop-shadow(0 20px 26px rgba(89, 17, 128, .22)); }
.lk-wait__pose.is-pop { animation: lkb-pop .45s ease-out, lkb-float 3s .45s ease-in-out infinite; }
.lk-wait__shadow { position: absolute; left: 50%; bottom: -4px; width: 120px; height: 14px; border-radius: 50%; background: radial-gradient(closest-side, rgba(89, 17, 128, .25), transparent); animation: lkb-shadow 3s ease-in-out infinite; }
.lk-wait__say {
  position: absolute; top: -52px; left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(320px, 88vw);
  padding: 10px 16px; border-radius: 16px;
  background: #fff; border: 1px solid #ECE7F0; box-shadow: 0 12px 26px -14px rgba(59, 10, 85, .45);
  font-size: 14.5px; font-weight: 700; line-height: 1.45; color: #4A4357; z-index: 2;
}
.lk-wait__say::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 12px; height: 12px; background: #fff; border-right: 1px solid #ECE7F0; border-bottom: 1px solid #ECE7F0; transform: translateX(-50%) rotate(45deg); }
.lk-wait__say.is-pop { animation: lkb-say .35s ease-out; }
.lk-wait__title { margin: 26px 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; color: #1C1626 !important; }
.lk-wait__sub { margin: 0 0 18px; font-size: 14.5px; line-height: 1.6; color: #736B80; }
.lk-wait__bar { width: 100%; max-width: 380px; height: 10px; border-radius: 999px; background: #EEDFF5; overflow: hidden; }
.lk-wait__bar span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: repeating-linear-gradient(45deg, #A358B5 0 10px, #B97ACA 10px 20px);
  background-size: 40px 100%;
  animation: lkb-shimmer 1s linear infinite;
  transition: width .5s ease-out;
}
.lk-wait__pct { margin-top: 6px; font-size: 13px; font-weight: 800; color: #6E2689; font-variant-numeric: tabular-nums; }
.lk-wait__status { min-height: 20px; margin: 6px 0 0; font-size: 13px; font-weight: 600; color: #8C3FA0; }
.lk-wait__status:empty { display: none; }
.lk-wait__steps { list-style: none; margin: 16px 0 0; padding: 14px 16px; width: 100%; max-width: 380px; background: rgba(255, 255, 255, .8); border: 1px solid #ECE7F0; border-radius: 16px; text-align: left; display: grid; gap: 8px; }
.lk-wait__steps li { position: relative; padding-left: 30px; font-size: 14px; line-height: 1.45; color: #9A92A6; transition: color .3s; }
.lk-wait__steps li::before {
  content: ""; position: absolute; left: 0; top: 0; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #E2D6EA; background: #fff; box-sizing: border-box;
}
.lk-wait__steps li.is-active { color: #1C1626; font-weight: 700; }
.lk-wait__steps li.is-active::before { border-color: #A358B5; border-top-color: transparent; animation: lkb-spin .8s linear infinite; }
.lk-wait__steps li.is-done { color: #4A4357; }
.lk-wait__steps li.is-done::before { content: "✓"; border: 0; background: #16A34A; color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
@keyframes lkb-spin { to { transform: rotate(360deg); } }
.lk-wait__tip { margin-top: 14px; width: 100%; max-width: 380px; padding: 12px 14px; border-radius: 14px; background: #FFFBEB; border: 1px solid #FDE68A; text-align: left; font-size: 13px; line-height: 1.55; color: #78350F; }
.lk-wait__tip b { display: block; margin-bottom: 2px; }
@media (max-width: 420px) {
  .lk-wait__stage { width: 170px; height: 190px; }
  .lk-wait__pose { width: 165px; }
  .lk-wait__title { font-size: 21px; }
}

/* Standalone waiting page (processing-result.php) */
.lk-wait--page { position: fixed; inset: 0; z-index: 10; }

/* ---------------- Celebration ---------------- */
.lk-celebrate {
  position: fixed; inset: 0; z-index: 2147483001;
  display: grid; place-items: center; padding: 20px;
  background: rgba(247, 245, 250, .82);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: lkb-fade .3s ease-out;
  font-family: var(--tl-font, Inter, sans-serif);
  transition: opacity .4s;
}
.lk-celebrate.is-out { opacity: 0; }
.lk-celebrate__confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.lk-celebrate__confetti i { position: absolute; top: 0; width: 9px; height: 14px; border-radius: 2px; animation: lkb-fall 3s ease-in forwards; }
.lk-celebrate__card {
  position: relative; width: 100%; max-width: 400px; padding: 26px 24px 24px; text-align: center;
  background: #fff; border: 1px solid #ECE7F0; border-radius: 24px;
  box-shadow: 0 30px 60px -24px rgba(59, 10, 85, .45);
  animation: lkb-in .6s cubic-bezier(.2, .9, .3, 1.2) both;
}
.lk-celebrate__pose { width: 170px; height: auto; margin: -90px auto 6px; display: block; filter: drop-shadow(0 16px 20px rgba(89, 17, 128, .3)); animation: lkb-float 2s ease-in-out infinite; }
.lk-celebrate__card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 800; color: #1C1626; letter-spacing: -.02em; }
.lk-celebrate__card p { margin: 0 0 18px; font-size: 14.5px; line-height: 1.6; color: #736B80; }
.lk-celebrate__btn {
  width: 100%; min-height: 50px; border: 0; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, #8C3FA0, #A358B5); color: #fff; font: inherit; font-size: 16px; font-weight: 800;
  box-shadow: 0 12px 24px -12px rgba(140, 63, 160, .7);
}

/* ---------------- Reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  .lk-buddy__stage, .lk-buddy__char, .lk-buddy__shadow, .lk-buddy__say.is-on,
  .lp-welcome__sky i, .lp-welcome__sky b, .lp-welcome__scroll span::after,
  .lk-wait__pose, .lk-wait__shadow, .lk-wait__sky i, .lk-wait__bar span, .lk-wait__say.is-pop,
  .lk-celebrate__confetti i, .lk-celebrate__pose, .lk-celebrate__card { animation: none !important; }
  .lk-celebrate__confetti { display: none; }
}

/* Landing: the big Lockye already greets, so no extra chat hint here */
.tl-page-index .lk-chat-hint { display: none !important; }
.lk-buddy--xl { gap: 4px; }
.lk-buddy--xl .lk-buddy__say { z-index: 4; }
