/* ============================================================
   CuratedLabs 2.0 — Transitions & Animations System
   Premium page transitions, micro-interactions, and effects
   ============================================================ */

/* === PAGE TRANSITION OVERLAY === */
.page-transition {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-transition-curtain {
    position: absolute;
    inset: 0;
    background: var(--bg-0);
    transform: translateY(100%);
    transition: transform 0.6s cubic-bezier(0.76, 0, 0.24, 1);
}

.page-transition.active .page-transition-curtain {
    transform: translateY(0);
}

.page-transition.exit .page-transition-curtain {
    transform: translateY(-100%);
}

.page-transition-logo {
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s;
}

.page-transition.active .page-transition-logo {
    opacity: 1;
    transform: scale(1);
}

/* === PAGE ENTER ANIMATIONS === */
.page-enter {
    opacity: 0;
}

.page-enter-active {
    animation: pageEnter 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === STAGGER ANIMATIONS === */
.stagger-in > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-in.animate > *:nth-child(1) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards; }
.stagger-in.animate > *:nth-child(2) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards; }
.stagger-in.animate > *:nth-child(3) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards; }
.stagger-in.animate > *:nth-child(4) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards; }
.stagger-in.animate > *:nth-child(5) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.25s forwards; }
.stagger-in.animate > *:nth-child(6) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.3s forwards; }
.stagger-in.animate > *:nth-child(7) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.35s forwards; }
.stagger-in.animate > *:nth-child(8) { animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.4s forwards; }

@keyframes staggerFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === REVEAL ON SCROLL === */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* === BUTTON MICRO-INTERACTIONS === */
.btn-magnetic {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-magnetic:hover {
    transform: translateY(-2px);
}

.btn-magnetic:active {
    transform: translateY(0) scale(0.98);
}

/* Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    opacity: 0;
}

.btn-ripple:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* Glow Pulse */
.btn-glow {
    position: relative;
}

.btn-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: inherit;
    opacity: 0;
    filter: blur(12px);
    transition: opacity 0.3s;
    z-index: -1;
}

.btn-glow:hover::before {
    opacity: 0.5;
}

/* === CARD INTERACTIONS === */
.card-lift {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08),
                0 8px 16px rgba(0, 0, 0, 0.04);
}

.card-tilt {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* === INPUT ANIMATIONS === */
.input-float-label {
    position: relative;
}

.input-float-label input,
.input-float-label textarea {
    padding-top: 24px;
}

.input-float-label label {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 15px;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: left center;
}

.input-float-label input:focus ~ label,
.input-float-label input:not(:placeholder-shown) ~ label,
.input-float-label textarea:focus ~ label,
.input-float-label textarea:not(:placeholder-shown) ~ label {
    top: 12px;
    transform: translateY(0) scale(0.75);
    color: var(--accent);
}

.input-focus-line {
    position: relative;
}

.input-focus-line::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateX(-50%);
}

.input-focus-line:focus-within::after {
    width: 100%;
}

/* === LOADING STATES === */
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-2) 25%,
        var(--bg-3) 50%,
        var(--bg-2) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1em;
    margin: 0.5em 0;
}

.skeleton-circle {
    border-radius: 50%;
}

/* Spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-0);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Dots Loader */
.dots-loader {
    display: flex;
    gap: 6px;
}

.dots-loader span {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.dots-loader span:nth-child(2) { animation-delay: 0.2s; }
.dots-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--bg-3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progress-shine 1.5s ease-in-out infinite;
}

@keyframes progress-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* === SUCCESS / CELEBRATION === */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.success-check {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sage), #7a9a7a);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: success-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-check svg {
    width: 40px;
    height: 40px;
    stroke: white;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.success-check svg path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: check-draw 0.5s ease forwards 0.3s;
}

@keyframes success-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes check-draw {
    to { stroke-dashoffset: 0; }
}

/* === TOOLTIP === */
.tooltip {
    position: relative;
}

.tooltip::before,
.tooltip::after {
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.tooltip::before {
    content: attr(data-tooltip);
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 8px 12px;
    background: var(--text-0);
    color: var(--text-inv);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
}

.tooltip::after {
    content: '';
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text-0);
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

.tooltip:hover::before {
    transform: translateX(-50%) translateY(0);
}

/* === MODAL TRANSITIONS === */
.modal-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.modal-content {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* === DRAWER / SLIDE PANEL === */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: var(--bg-1);
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 200;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.1);
}

.drawer.open {
    transform: translateX(0);
}

/* === PARALLAX HELPERS === */
.parallax-slow {
    will-change: transform;
    transition: transform 0.1s linear;
}

.parallax-medium {
    will-change: transform;
    transition: transform 0.08s linear;
}

.parallax-fast {
    will-change: transform;
    transition: transform 0.05s linear;
}

/* === FLOATING ELEMENTS === */
.float {
    animation: float 6s ease-in-out infinite;
}

.float-delayed {
    animation: float 6s ease-in-out infinite 1s;
}

.float-slow {
    animation: float 8s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

/* === GRADIENT ANIMATIONS === */
.gradient-animate {
    background-size: 200% 200%;
    animation: gradient-shift 8s ease infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* === TEXT ANIMATIONS === */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: text-reveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes text-reveal {
    to { transform: translateY(0); }
}

.text-typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--accent);
    animation:
        typewriter 2s steps(30) 0.5s forwards,
        blink 0.7s step-end infinite;
}

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

@keyframes blink {
    50% { border-color: transparent; }
}

/* === COUNTER ANIMATION === */
.counter {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

/* === MORPH ANIMATIONS === */
.morph-blob {
    animation: morph 8s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

/* === SCROLL INDICATOR === */
.scroll-indicator {
    width: 24px;
    height: 40px;
    border: 2px solid var(--text-3);
    border-radius: 12px;
    position: relative;
}

.scroll-indicator::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 4px;
    height: 8px;
    background: var(--text-3);
    border-radius: 2px;
    transform: translateX(-50%);
    animation: scroll-bounce 2s ease-in-out infinite;
}

@keyframes scroll-bounce {
    0%, 100% { top: 8px; opacity: 1; }
    50% { top: 20px; opacity: 0.3; }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
