/*
 * Product-card motion layer
 * Driver: in-view idle loop + hover/focus response
 * Runtime state: .pcard[data-demo-active="true"]
 * Reduced motion: static, fully readable composition
 */

.wolfcha-stage {
  --motion-duration: 12.5s;
  isolation: isolate;
}

.pcard .wolfcha-cast {
  position: absolute;
  inset: 0;
  display: block;
}

.wolfcha-figure {
  position: absolute;
  bottom: -7%;
  left: var(--character-x);
  z-index: 2;
  width: min(46%, 184px);
  aspect-ratio: 1;
  transform: translateX(-50%) rotate(var(--character-tilt));
  transform-origin: 50% 100%;
  transition: transform 700ms var(--ease), filter 700ms var(--ease);
  will-change: transform;
}

.wolfcha-figure:nth-child(2),
.wolfcha-figure:nth-child(4) {
  bottom: -2%;
  z-index: 3;
}

.wolfcha-figure:nth-child(3) {
  z-index: 5;
}

.wolfcha-character {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.12));
}

.pcard .wolfcha-figure img {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  filter:
    drop-shadow(1.5px 0 0 #fff)
    drop-shadow(-1.5px 0 0 #fff)
    drop-shadow(0 1.5px 0 #fff)
    drop-shadow(0 -1.5px 0 #fff);
}

.wolfcha-bubble {
  position: absolute;
  top: 3%;
  left: 50%;
  z-index: 20;
  max-width: 145px;
  padding: 5px 9px;
  border: 1px solid #1a1a1a;
  border-radius: 999px;
  background: #fff;
  color: #1a1a1a;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  white-space: nowrap;
  transform: translate(-50%, 6px) scale(0.82);
}

.wolfcha-bubble::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid #1a1a1a;
  border-bottom: 1px solid #1a1a1a;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.wolfcha-you {
  position: absolute;
  top: 20%;
  right: 8%;
  padding: 2px 7px;
  border: 1px solid rgba(26, 26, 26, 0.2);
  border-radius: 999px;
  background: var(--hl);
  color: #1a1a1a;
  font-size: 9px;
  font-weight: 700;
}

.wolfcha-moon {
  position: absolute;
  top: 12px;
  right: 18px;
  width: 14px;
  height: 14px;
  border: 1px solid rgba(26, 26, 26, 0.25);
  border-radius: 50%;
  background: var(--hl);
  box-shadow: inset 5px -2px 0 #fff;
}

.wolfcha-star {
  position: absolute;
  z-index: 10;
  width: 5px;
  height: 5px;
  background: #1a1a1a;
  opacity: 0.2;
  transform: rotate(45deg);
}

.wolfcha-star-a { top: 19%; left: 8%; }
.wolfcha-star-b { top: 9%; left: 64%; background: var(--hl); }
.wolfcha-star-c { top: 32%; right: 6%; }

.pcard[data-demo-active="true"] .wolfcha-character {
  animation: wolfcha-character-speak var(--motion-duration) var(--character-delay) infinite both;
}

.pcard[data-demo-active="true"] .wolfcha-bubble {
  animation: wolfcha-bubble-speak var(--motion-duration) var(--character-delay) infinite both;
}

.pcard[data-demo-active="true"] .wolfcha-star {
  animation: wolfcha-star-twinkle 3.4s calc(var(--character-index, 0) * 300ms) infinite;
}

.card-hitbox:is(:hover, :focus-within) .wolfcha-figure {
  transform: translateX(-50%) translateY(calc(-1 * var(--character-lift))) rotate(0deg) scale(1.035);
}

@keyframes wolfcha-character-speak {
  0%, 1%, 11%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  2.5% { transform: translateY(-9px) rotate(-1deg) scale(1.075); }
  4.5% { transform: translateY(-5px) rotate(1deg) scale(1.045); }
  7.5% { transform: translateY(-7px) rotate(0deg) scale(1.06); }
}

@keyframes wolfcha-bubble-speak {
  0%, 1%, 10%, 100% { opacity: 0; transform: translate(-50%, 6px) scale(0.82); }
  2.4%, 8.2% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes wolfcha-star-twinkle {
  0%, 100% { opacity: 0.18; transform: rotate(45deg) scale(0.8); }
  50% { opacity: 0.7; transform: rotate(45deg) scale(1.25); }
}

/* Text-Well: show the actual review -> correction -> success sequence. */
.writing-stage { container-type: inline-size; }

.writing-sheet {
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

.writing-fix {
  position: relative;
  display: inline-block;
  width: var(--fix-width);
  height: 1.25em;
  vertical-align: -0.18em;
}

.writing-old,
.writing-new {
  position: absolute;
  inset: 0 auto auto 0;
  display: block;
  white-space: nowrap;
}

.writing-old::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 1px;
  left: 0;
  height: 2px;
  background: #d35a4c;
  transform: scaleX(0);
  transform-origin: left;
}

.writing-new {
  color: #4f7354;
  font-weight: 750;
  opacity: 0;
}

.pcard[data-demo-active="true"] .writing-sheet {
  animation: writing-sheet-cycle 9s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .writing-old {
  animation: writing-old-cycle 9s var(--fix-delay) infinite;
}

.pcard[data-demo-active="true"] .writing-old::after {
  animation: writing-strike-cycle 9s var(--fix-delay) infinite;
}

.pcard[data-demo-active="true"] .writing-new {
  animation: writing-new-cycle 9s var(--fix-delay) infinite;
}

.pcard[data-demo-active="true"] .writing-check {
  animation: writing-check-cycle 9s var(--ease) infinite;
}

@keyframes writing-sheet-cycle {
  0%, 100% { opacity: 0.84; transform: translateY(3px) rotate(-0.45deg); }
  8%, 82% { opacity: 1; transform: translateY(0) rotate(0deg); }
  92% { opacity: 0; transform: translateY(-2px) rotate(0.25deg); }
}

@keyframes writing-old-cycle {
  0%, 17%, 88%, 100% { opacity: 1; color: #555; }
  25%, 80% { opacity: 0; color: #9d9d9d; }
}

@keyframes writing-strike-cycle {
  0%, 11%, 88%, 100% { transform: scaleX(0); }
  17%, 80% { transform: scaleX(1); }
}

@keyframes writing-new-cycle {
  0%, 19%, 87%, 100% { opacity: 0; transform: translateY(3px); }
  27%, 80% { opacity: 1; transform: translateY(0); }
}

@keyframes writing-check-cycle {
  0%, 48%, 96%, 100% { opacity: 0; transform: translateY(5px) scale(0.92); }
  57%, 84% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Vibe Hub: cycle three terms instead of looping an unrelated flourish. */
.vibe-demo-card {
  position: relative;
  min-height: 146px;
  overflow: hidden;
  transform-origin: 50% 70%;
}

.vibe-demo-index {
  color: #1e40d8;
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
}

.vibe-term-stack {
  position: relative;
  height: 70px;
  margin-top: 12px;
}

.vibe-term {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
}

.vibe-term b,
.vibe-term i {
  display: block;
}

.vibe-term b {
  color: #18181b;
  font-size: 30px;
  letter-spacing: -0.05em;
  line-height: 1;
}

.vibe-term i {
  margin-top: 8px;
  color: #7a7a83;
  font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.vibe-demo-action {
  display: inline-flex;
  width: max-content;
  padding: 6px 10px;
  border: 1px solid #1e40d8;
  border-radius: 6px;
  background: #eef1fd;
  color: #1e40d8;
  font-size: 11px;
  font-weight: 700;
}

.pcard[data-demo-active="true"] .vibe-demo-card {
  animation: vibe-card-cycle 7.2s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .vibe-term {
  animation: vibe-term-cycle 7.2s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .vibe-term:nth-child(2) { animation-delay: 2.4s; }
.pcard[data-demo-active="true"] .vibe-term:nth-child(3) { animation-delay: 4.8s; }
.pcard[data-demo-active="true"] .vibe-demo-action { animation: vibe-action-cycle 2.4s var(--ease) infinite; }

@keyframes vibe-term-cycle {
  0% { opacity: 0; transform: translateY(12px) scale(0.96); }
  5%, 27% { opacity: 1; transform: translateY(0) scale(1); }
  33%, 100% { opacity: 0; transform: translateY(-9px) scale(0.98); }
}

@keyframes vibe-card-cycle {
  0%, 100% { transform: rotate(-2deg) translateY(0); }
  50% { transform: rotate(-1deg) translateY(-3px); }
}

@keyframes vibe-action-cycle {
  0%, 100% { background: #eef1fd; box-shadow: none; transform: translateY(0); }
  42%, 62% { background: #1e40d8; color: #fff; box-shadow: 0 7px 16px rgba(30, 64, 216, 0.22); transform: translateY(-3px); }
}

/* Selector: cursor travels to an element, clicks, then reveals selection state. */
.selector-window { overflow: hidden; }

.selector-cursor {
  position: absolute;
  top: 72%;
  left: 70%;
  z-index: 5;
  opacity: 0;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
  will-change: transform, opacity;
}

.selector-box {
  opacity: 0;
  transform: scale(0.96);
  transform-origin: 50% 50%;
}

.selector-click-ring {
  position: absolute;
  bottom: 31%;
  left: 31%;
  z-index: 4;
  width: 12px;
  height: 12px;
  border: 2px solid #7b61ff;
  border-radius: 50%;
  opacity: 0;
}

.pcard[data-demo-active="true"] .selector-cursor {
  animation: selector-cursor-cycle 6s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .selector-box {
  animation: selector-box-cycle 6s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .selector-click-ring {
  animation: selector-ring-cycle 6s var(--ease) infinite;
}

@keyframes selector-cursor-cycle {
  0%, 8%, 95%, 100% { opacity: 0; transform: translate(40px, 24px) scale(1); }
  16% { opacity: 1; }
  42%, 58% { opacity: 1; transform: translate(-145px, -4px) scale(1); }
  50% { opacity: 1; transform: translate(-145px, -4px) scale(0.82); }
  76% { opacity: 1; transform: translate(-80px, -66px) scale(1); }
  90% { opacity: 0; transform: translate(-80px, -66px) scale(1); }
}

@keyframes selector-box-cycle {
  0%, 44%, 92%, 100% { opacity: 0; transform: scale(0.96); }
  52%, 84% { opacity: 1; transform: scale(1); }
}

@keyframes selector-ring-cycle {
  0%, 46%, 60%, 100% { opacity: 0; transform: scale(0.4); }
  50% { opacity: 0.8; transform: scale(0.7); }
  57% { opacity: 0; transform: scale(2.2); }
}

/* NotchNotes: the black notch owns the reveal; the note content is not moved as a flat sticker. */
.notes-shell {
  position: relative;
  width: 80%;
  padding-top: 14px;
}

.notes-notch {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  width: 78px;
  height: 17px;
  border-radius: 0 0 9px 9px;
  background: #1c1c1e;
  transform: translateX(-50%);
  transform-origin: 50% 0;
}

.notes-shell .notes-window {
  position: relative;
  width: 100%;
  min-height: 130px;
  transform-origin: 50% 0;
  will-change: clip-path, opacity, transform;
}

.notes-shell .notes-window::before { display: none; }

.notes-caret {
  display: inline-block;
  width: 5px;
  height: 1em;
  margin-left: 2px;
  background: #c7a12f;
  vertical-align: -0.15em;
}

.pcard[data-demo-active="true"] .notes-notch {
  animation: notes-notch-cycle 8s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .notes-window {
  animation: notes-window-cycle 8s var(--ease) infinite;
}

.pcard[data-demo-active="true"] .notes-caret {
  animation: notes-caret-blink 1.05s steps(1) infinite;
}

@keyframes notes-notch-cycle {
  0%, 8%, 92%, 100% { width: 78px; height: 17px; border-radius: 0 0 9px 9px; }
  20%, 82% { width: 94%; height: 28px; border-radius: 0 0 13px 13px; }
}

@keyframes notes-window-cycle {
  0%, 8%, 93%, 100% { opacity: 0; clip-path: inset(0 46% 92% 46% round 12px); transform: translateY(-3px) scale(0.98); }
  23%, 82% { opacity: 1; clip-path: inset(0 0 0 0 round 12px); transform: translateY(0) scale(1); }
}

@keyframes notes-caret-blink {
  0%, 54% { opacity: 1; }
  55%, 100% { opacity: 0; }
}

@media (max-width: 760px) {
  .wolfcha-figure {
    width: min(46%, 164px);
  }

  .wolfcha-bubble {
    max-width: 108px;
    padding: 4px 7px;
    font-size: 8px;
    white-space: normal;
  }

  .selector-cursor {
    left: 74%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pcard .wolfcha-character,
  .pcard .wolfcha-bubble,
  .pcard .wolfcha-star,
  .pcard .writing-sheet,
  .pcard .writing-old,
  .pcard .writing-old::after,
  .pcard .writing-new,
  .pcard .writing-check,
  .pcard .vibe-demo-card,
  .pcard .vibe-term,
  .pcard .vibe-demo-action,
  .pcard .selector-cursor,
  .pcard .selector-box,
  .pcard .selector-click-ring,
  .pcard .notes-notch,
  .pcard .notes-window,
  .pcard .notes-caret {
    animation: none !important;
  }

  .wolfcha-bubble,
  .selector-cursor,
  .selector-click-ring {
    display: none;
  }

  .writing-old { opacity: 0; }
  .writing-new,
  .writing-check,
  .vibe-term:first-child,
  .selector-box,
  .notes-window { opacity: 1; transform: none; }
  .vibe-term:not(:first-child) { opacity: 0; }
  .notes-window { clip-path: none; }
}
