/* ========================================
   TrackCue Transitions Pack 3
   30 Advanced UX Transitions
   Namespace: cf-tr3-*
   Z-index: 98000-98099 (overlays only)
   Production-ready · isolated from batches 1-2
   ======================================== */

:root {
  --cf-tr3-ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --cf-tr3-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --cf-tr3-ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --cf-tr3-ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --cf-tr3-amber: #ff7a18;
  --cf-tr3-pink: #ff2e6b;
  --cf-tr3-violet: #8b5cf6;
  --cf-tr3-cyan: #5ee0ff;
}

/* ==== 1. Iris zoom (clip-path circle) ==== */
.cf-tr3-iris-page {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  clip-path: circle(100% at 50% 50%);
}

.cf-tr3-iris-page.cf-tr3-exit {
  animation: cf-tr3-iris-shrink 0.6s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-iris-page.cf-tr3-enter {
  animation: cf-tr3-iris-grow 0.6s var(--cf-tr3-ease-out-expo) forwards;
  animation-delay: 0.3s;
}

@keyframes cf-tr3-iris-shrink {
  from { clip-path: circle(100% at 50% 50%); }
  to { clip-path: circle(0% at 50% 50%); }
}

@keyframes cf-tr3-iris-grow {
  from { clip-path: circle(0% at 50% 50%); }
  to { clip-path: circle(100% at 50% 50%); }
}

/* ==== 2. Curtain pull ==== */
.cf-tr3-curtain-page {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-tr3-curtain-left,
.cf-tr3-curtain-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
}

.cf-tr3-curtain-left {
  left: 0;
  animation: cf-tr3-curtain-left-out 0.8s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-curtain-right {
  right: 0;
  animation: cf-tr3-curtain-right-out 0.8s var(--cf-tr3-ease-out-expo) forwards;
}

@keyframes cf-tr3-curtain-left-out {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

@keyframes cf-tr3-curtain-right-out {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

/* ==== 3. Card flip 3D ==== */
.cf-tr3-card-3d {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  transform-style: preserve-3d;
}

.cf-tr3-card-3d.cf-tr3-flip {
  animation: cf-tr3-card-flip 0.8s var(--cf-tr3-ease-out-expo) forwards;
}

@keyframes cf-tr3-card-flip {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(180deg); }
}

/* ==== 4. Cube rotate ==== */
.cf-tr3-cube-stage {
  position: absolute;
  inset: 0;
  perspective: 1000px;
}

.cf-tr3-cube-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.cf-tr3-cube-face.cf-tr3-active {
  animation: cf-tr3-cube-rotate 0.8s var(--cf-tr3-ease-out-expo) forwards;
  opacity: 1;
}

@keyframes cf-tr3-cube-rotate {
  from { transform: rotateY(0deg) rotateX(0deg); }
  to { transform: rotateY(90deg) rotateX(45deg); }
}

/* ==== 5. Glitch effect ==== */
.cf-tr3-glitch-stage {
  position: relative;
  overflow: hidden;
}

.cf-tr3-glitch-text {
  position: relative;
  z-index: 1;
}

.cf-tr3-glitch-r,
.cf-tr3-glitch-g,
.cf-tr3-glitch-b {
  position: absolute;
  left: 0;
  top: 0;
}

.cf-tr3-glitch-r {
  color: rgba(255, 46, 107, 0.8);
  animation: cf-tr3-glitch-r 0.4s steps(3, end) forwards;
}

.cf-tr3-glitch-g {
  color: rgba(94, 224, 255, 0.8);
  animation: cf-tr3-glitch-g 0.4s steps(3, end) forwards;
  animation-delay: 0.1s;
}

.cf-tr3-glitch-b {
  color: rgba(255, 122, 24, 0.8);
  animation: cf-tr3-glitch-b 0.4s steps(3, end) forwards;
  animation-delay: 0.2s;
}

@keyframes cf-tr3-glitch-r {
  0% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  20% { clip-path: inset(60% 0 20% 0); transform: translate(-4px, 4px); }
  40% { clip-path: inset(20% 0 60% 0); transform: translate(4px, -4px); }
  60% { clip-path: inset(10% 0 70% 0); transform: translate(-4px, -4px); }
  80% { clip-path: inset(50% 0 30% 0); transform: translate(4px, 4px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
}

@keyframes cf-tr3-glitch-g {
  0% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  20% { clip-path: inset(20% 0 60% 0); transform: translate(4px, -4px); }
  40% { clip-path: inset(60% 0 20% 0); transform: translate(-4px, 4px); }
  60% { clip-path: inset(30% 0 50% 0); transform: translate(4px, 4px); }
  80% { clip-path: inset(70% 0 10% 0); transform: translate(-4px, -4px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
}

@keyframes cf-tr3-glitch-b {
  0% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
  20% { clip-path: inset(30% 0 50% 0); transform: translate(4px, 4px); }
  40% { clip-path: inset(10% 0 70% 0); transform: translate(-4px, -4px); }
  60% { clip-path: inset(60% 0 20% 0); transform: translate(4px, -4px); }
  80% { clip-path: inset(40% 0 40% 0); transform: translate(-4px, 4px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0, 0); }
}

/* ==== 6. Slide-up stagger ==== */
.cf-tr3-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  animation: cf-tr3-stagger-up 0.5s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-stagger > :nth-child(1) { animation-delay: 0.1s; }
.cf-tr3-stagger > :nth-child(2) { animation-delay: 0.2s; }
.cf-tr3-stagger > :nth-child(3) { animation-delay: 0.3s; }
.cf-tr3-stagger > :nth-child(4) { animation-delay: 0.4s; }
.cf-tr3-stagger > :nth-child(5) { animation-delay: 0.5s; }

@keyframes cf-tr3-stagger-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==== 7. Scale-spring pop ==== */
.cf-tr3-scale-spring {
  opacity: 0;
  transform: scale(0);
  animation: cf-tr3-scale-spring 1.4s var(--cf-tr3-ease-spring) forwards;
}

@keyframes cf-tr3-scale-spring {
  0% {
    opacity: 0;
    transform: scale(0);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ==== 8. Mask reveal slide ==== */
.cf-tr3-mask-reveal {
  position: relative;
  overflow: hidden;
}

.cf-tr3-mask-reveal-content {
  animation: cf-tr3-mask-reveal-slide 1s var(--cf-tr3-ease-out-expo) forwards;
  mask-image: linear-gradient(90deg, transparent 0%, black 50%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 50%, transparent 100%);
  mask-size: 200% 100%;
  -webkit-mask-size: 200% 100%;
  mask-position: 0% 0%;
  -webkit-mask-position: 0% 0%;
}

@keyframes cf-tr3-mask-reveal-slide {
  from {
    mask-position: -100% 0%;
    -webkit-mask-position: -100% 0%;
  }
  to {
    mask-position: 100% 0%;
    -webkit-mask-position: 100% 0%;
  }
}

/* ==== 9. Blur-up image ==== */
.cf-tr3-blur-up {
  animation: cf-tr3-blur-up 1.2s var(--cf-tr3-ease-out-expo) forwards;
  filter: blur(20px);
}

@keyframes cf-tr3-blur-up {
  from { filter: blur(20px); }
  to { filter: blur(0); }
}

/* ==== 10. Origami fold ==== */
.cf-tr3-origami {
  animation: cf-tr3-origami-fold 1.2s var(--cf-tr3-ease-out-expo) forwards;
  perspective: 1200px;
}

@keyframes cf-tr3-origami-fold {
  from {
    transform: rotateX(-90deg);
    opacity: 0;
  }
  to {
    transform: rotateX(0deg);
    opacity: 1;
  }
}

/* ==== 11. Typewriter text ==== */
.cf-tr3-typewriter {
  overflow: hidden;
  border-right: 2px solid var(--cf-tr3-amber);
  white-space: nowrap;
  animation: cf-tr3-typewriter 3s steps(40, end) forwards,
             cf-tr3-blink-cursor 0.8s step-end infinite;
}

@keyframes cf-tr3-typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes cf-tr3-blink-cursor {
  0%, 50% { border-color: var(--cf-tr3-amber); }
  51%, 100% { border-color: transparent; }
}

/* ==== 12. Word stagger ==== */
.cf-tr3-words {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.cf-tr3-words > * {
  opacity: 0;
  animation: cf-tr3-word-appear 0.6s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-words > :nth-child(1) { animation-delay: 0.1s; }
.cf-tr3-words > :nth-child(2) { animation-delay: 0.2s; }
.cf-tr3-words > :nth-child(3) { animation-delay: 0.3s; }
.cf-tr3-words > :nth-child(4) { animation-delay: 0.4s; }
.cf-tr3-words > :nth-child(5) { animation-delay: 0.5s; }

@keyframes cf-tr3-word-appear {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==== 13. Char fade ==== */
.cf-tr3-chars {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  justify-content: center;
}

.cf-tr3-chars > * {
  display: inline-block;
  opacity: 0;
  animation: cf-tr3-char-fade-in 0.8s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-chars > :nth-child(1) { animation-delay: 0.0s; }
.cf-tr3-chars > :nth-child(2) { animation-delay: 0.08s; }
.cf-tr3-chars > :nth-child(3) { animation-delay: 0.16s; }
.cf-tr3-chars > :nth-child(4) { animation-delay: 0.24s; }
.cf-tr3-chars > :nth-child(5) { animation-delay: 0.32s; }
.cf-tr3-chars > :nth-child(6) { animation-delay: 0.4s; }
.cf-tr3-chars > :nth-child(7) { animation-delay: 0.48s; }
.cf-tr3-chars > :nth-child(8) { animation-delay: 0.56s; }

@keyframes cf-tr3-char-fade-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==== 14. Mask wave reveal ==== */
.cf-tr3-mask-wave {
  animation: cf-tr3-mask-wave-move 2s ease-in-out forwards;
  mask-image: linear-gradient(90deg, transparent, black, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, black, transparent);
  mask-size: 200% 100%;
  -webkit-mask-size: 200% 100%;
  mask-position: 0%;
  -webkit-mask-position: 0%;
}

@keyframes cf-tr3-mask-wave-move {
  0% {
    mask-position: 0%;
    -webkit-mask-position: 0%;
  }
  50% {
    mask-position: 50%;
    -webkit-mask-position: 50%;
  }
  100% {
    mask-position: 100%;
    -webkit-mask-position: 100%;
  }
}

/* ==== 15. Number ticker ==== */
.cf-tr3-count {
  font-variant-numeric: tabular-nums;
}

.cf-tr3-count > * {
  display: inline-block;
  min-width: 1em;
  animation: cf-tr3-ticker-roll 2s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-count > :nth-child(1) { animation-delay: 0.2s; }
.cf-tr3-count > :nth-child(2) { animation-delay: 0.4s; }
.cf-tr3-count > :nth-child(3) { animation-delay: 0.6s; }
.cf-tr3-count > :nth-child(4) { animation-delay: 0.8s; }

@keyframes cf-tr3-ticker-roll {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==== 16. Liquid button ==== */
.cf-tr3-liquid {
  position: relative;
  padding: 12px 20px;
  border: 2px solid var(--cf-tr3-amber);
  background: transparent;
  color: var(--cf-tr3-amber);
  border-radius: 24px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: border-radius 0.4s var(--cf-tr3-ease-out-expo),
              background 0.4s var(--cf-tr3-ease-out-expo),
              color 0.4s var(--cf-tr3-ease-out-expo),
              box-shadow 0.4s var(--cf-tr3-ease-out-expo);
}

.cf-tr3-liquid:hover {
  border-radius: 8px;
  background: var(--cf-tr3-amber);
  color: #050406;
}

/* ==== 17. Repulse cursor ==== */
.cf-tr3-repulse-item {
  position: absolute;
  pointer-events: none;
  transition: transform 0.3s ease-out;
  will-change: transform;
}

/* ==== 18. Glow trail ==== */
.cf-tr3-glow-trail::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255, 122, 24, 0.38) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: cf-tr3-glow-expand 0.6s ease-out forwards;
}

@keyframes cf-tr3-glow-expand {
  from {
    width: 0;
    height: 0;
    top: 50%;
    left: 50%;
  }
  to {
    width: 200px;
    height: 200px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
  }
}

/* ==== 19. Shake error ==== */
.cf-tr3-shake {
  animation: cf-tr3-shake-error 0.4s steps(6, end) forwards;
}

@keyframes cf-tr3-shake-error {
  0%, 100% { transform: translateX(0); }
  16.66% { transform: translateX(-6px); }
  33.33% { transform: translateX(6px); }
  50% { transform: translateX(-6px); }
  66.66% { transform: translateX(6px); }
  83.33% { transform: translateX(-6px); }
}

/* ==== 20. Bounce success ==== */
.cf-tr3-success {
  animation: cf-tr3-bounce-pop 0.8s var(--cf-tr3-ease-spring) forwards;
}

@keyframes cf-tr3-bounce-pop {
  0% {
    transform: scale(0) rotate(-180deg);
  }
  60% {
    transform: scale(1.15) rotate(0deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
  }
}

/* ==== 21. Breathing skeleton ==== */
.cf-tr3-breath {
  animation: cf-tr3-breathing-pulse 2s ease-in-out infinite;
}

@keyframes cf-tr3-breathing-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ==== 22. Progress milestones ==== */
[data-cf-tr3-progress] {
  display: flex;
  align-items: center;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 0;
}

[data-cf-tr3-progress] > * {
  flex: 1;
  height: 100%;
  position: relative;
  animation: cf-tr3-milestone-fill 2.5s var(--cf-tr3-ease-out-expo) forwards;
}

[data-cf-tr3-progress] > :nth-child(1) { animation-delay: 0.2s; }
[data-cf-tr3-progress] > :nth-child(2) { animation-delay: 0.5s; }
[data-cf-tr3-progress] > :nth-child(3) { animation-delay: 0.8s; }
[data-cf-tr3-progress] > :nth-child(4) { animation-delay: 1.1s; }

@keyframes cf-tr3-milestone-fill {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* ==== 23. Spinner→check morph ==== */
.cf-tr3-spin-check {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-tr3-spin-check .cf-tr3-spin-circle {
  position: absolute;
  border: 3px solid transparent;
  border-top-color: var(--cf-tr3-amber);
  border-right-color: var(--cf-tr3-pink);
  border-radius: 50%;
  animation: cf-tr3-spin-morph 2s var(--cf-tr3-ease-out-expo) forwards;
}

@keyframes cf-tr3-spin-morph {
  0% {
    transform: rotate(0deg);
    stroke-dasharray: 0, 200;
  }
  60% {
    transform: rotate(720deg);
    opacity: 1;
  }
  100% {
    transform: rotate(720deg) scale(0.6);
    opacity: 0;
  }
}

/* ==== 24. Dots wave ==== */
.cf-tr3-dots {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.cf-tr3-dots > * {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  animation: cf-tr3-dot-wave-motion 1.4s ease-in-out infinite;
}

.cf-tr3-dots > :nth-child(1) { animation-delay: 0.0s; }
.cf-tr3-dots > :nth-child(2) { animation-delay: 0.2s; }
.cf-tr3-dots > :nth-child(3) { animation-delay: 0.4s; }

@keyframes cf-tr3-dot-wave-motion {
  0%, 100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-10px);
  }
}

/* ==== 25. Brand reveal ==== */
.cf-tr3-brand-reveal {
  display: flex;
  gap: 3px;
}

.cf-tr3-brand-reveal > * {
  opacity: 0;
  animation: cf-tr3-char-pop 0.6s var(--cf-tr3-ease-spring) forwards;
}

.cf-tr3-brand-reveal > :nth-child(1) { animation-delay: 0.1s; }
.cf-tr3-brand-reveal > :nth-child(2) { animation-delay: 0.2s; }
.cf-tr3-brand-reveal > :nth-child(3) { animation-delay: 0.3s; }
.cf-tr3-brand-reveal > :nth-child(4) { animation-delay: 0.4s; }
.cf-tr3-brand-reveal > :nth-child(5) { animation-delay: 0.5s; }
.cf-tr3-brand-reveal > :nth-child(6) { animation-delay: 0.6s; }
.cf-tr3-brand-reveal > :nth-child(7) { animation-delay: 0.7s; }
.cf-tr3-brand-reveal > :nth-child(8) { animation-delay: 0.8s; }

@keyframes cf-tr3-char-pop {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.1) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* ==== 26. 3D tilt ==== */
.cf-tr3-tilt {
  transform-style: preserve-3d;
  transition: transform 0.1s ease-out;
  will-change: transform;
  perspective: 1200px;
}

/* ==== 27. Border draw ==== */
.cf-tr3-border-draw {
  position: relative;
  overflow: hidden;
}

.cf-tr3-border-draw::before,
.cf-tr3-border-draw::after {
  content: "";
  position: absolute;
  background: var(--cf-tr3-amber);
}

.cf-tr3-border-draw::before {
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  animation: cf-tr3-border-draw-h 1.2s var(--cf-tr3-ease-out-expo) forwards;
  animation-delay: 0.4s;
  width: 0;
}

.cf-tr3-border-draw::after {
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  animation: cf-tr3-border-draw-h-rev 1.2s var(--cf-tr3-ease-out-expo) forwards;
  animation-delay: 1.2s;
  width: 0;
}

.cf-tr3-border-draw .cf-tr3-border-v {
  position: absolute;
  width: 2px;
  height: 0;
  background: var(--cf-tr3-amber);
  animation: cf-tr3-border-draw-v 1.2s var(--cf-tr3-ease-out-expo) forwards;
}

.cf-tr3-border-draw .cf-tr3-border-v:nth-child(1) {
  left: 0;
  top: 0;
  animation-delay: 0.0s;
}

.cf-tr3-border-draw .cf-tr3-border-v:nth-child(2) {
  right: 0;
  top: 0;
  animation-delay: 1.6s;
}

@keyframes cf-tr3-border-draw-h {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes cf-tr3-border-draw-h-rev {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes cf-tr3-border-draw-v {
  from { height: 0; }
  to { height: 100%; }
}

/* ==== 28. Marquee scroll ==== */
.cf-tr3-marquee {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.cf-tr3-marquee > * {
  animation: cf-tr3-marquee-scroll 10s linear infinite;
  white-space: nowrap;
  will-change: transform;
}

@keyframes cf-tr3-marquee-scroll {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* ==== 29. Sticky header shrink ==== */
.cf-tr3-sticky-shrink {
  position: sticky;
  top: 0;
  z-index: 98010;
  transition: padding 0.3s ease-out,
              font-size 0.3s ease-out,
              background 0.3s ease-out,
              backdrop-filter 0.3s ease-out;
}

.cf-tr3-sticky-shrink.cf-tr3-shrunk {
  padding: 6px 12px;
  font-size: 11px;
  backdrop-filter: blur(6px);
}

/* ==== 30. Snap scroll magnetic ==== */
.cf-tr3-snap {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  will-change: scroll-position;
}

.cf-tr3-snap > * {
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* ==== Media queries ==== */
@media (prefers-reduced-motion: reduce) {
  *[class*="cf-tr3-"] {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (pointer: coarse) {
  .cf-tr3-tilt {
    display: none;
  }

  .cf-tr3-glow-trail::before {
    display: none;
  }

  .cf-tr3-repulse-item {
    display: none;
  }
}
