/* ============================================================
   MOTION CSS - Animation System for Jolchobi Setabganj
   ============================================================ */

/* Custom Properties */
:root {
    --e-out: cubic-bezier(.22, 1, .36, 1);
    --e-spring: cubic-bezier(.34, 1.42, .64, 1);
    --e-in-out: cubic-bezier(.65, 0, .35, 1);
    --d-1: 130ms;
    --d-2: 220ms;
    --d-3: 340ms;
    --d-4: 520ms;
    --d-5: 780ms;
    --d-6: 1100ms;
}

/* ------------------------------------------------------------
   Keyframes
   ------------------------------------------------------------ */

/* Sheen sweep across buttons */
@keyframes btn-sheen {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(130%); }
}

/* 360-degree rotation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Expanding ring pulse */
@keyframes pulse-badge {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
    70% { box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* Dot pulse shadow */
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

/* Ring pulse shadow */
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* Up-down floating */
@keyframes float-y {
    0% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
    100% { transform: translateY(0); }
}

/* Orbit rotation */
@keyframes orbit-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Left-to-right shimmer sweep */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Loader bar slide */
@keyframes loader-slide {
    0% { left: -110%; }
    100% { left: 320%; }
}

/* Page veil entrance */
@keyframes veil-in {
    0% { opacity: 0; transform: translateY(10px) scale(0.94); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Alert entrance */
@keyframes alert-in {
    0% { opacity: 0; transform: translateY(-10px) scale(0.97); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast slide-in from right */
@keyframes toast-in {
    0% { transform: translateX(28px); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* Toast slide-out to right */
@keyframes toast-out {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(28px); opacity: 0; }
}

/* Message entrance */
@keyframes msg-in {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Drawer item fade-in */
@keyframes drawer-item {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* Heart burst pop */
@keyframes heart-burst {
    0% { transform: scale(1); }
    30% { transform: scale(1.32); }
    60% { transform: scale(0.94); }
    100% { transform: scale(1); }
}

/* Pop-in scale */
@keyframes pop-in {
    0% { transform: scale(0.7); opacity: 0; }
    50% { transform: scale(1.06); opacity: 1; }
    100% { transform: scale(1); }
}

/* Ripple expanding */
@keyframes ripple-out {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(2.6); opacity: 0; }
}

/* Count tick */
@keyframes count-tick {
    0% { transform: translateY(-40%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Gradient background pan */
@keyframes gradient-pan {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Glow breathe */
@keyframes glow-breathe {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* Horizontal marquee */
@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* Ring loader spin */
@keyframes ring-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Shine sweep across surface */
@keyframes shine-sweep {
    0% { transform: translateX(-100%) skewX(-12deg); }
    100% { transform: translateX(100%) skewX(-12deg); }
}

/* Drop-in entrance */
@keyframes drop-in {
    0% { opacity: 0; transform: translateY(-8px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Share/composer sheet slide-up */
@keyframes sheet-up {
    0% { transform: translateY(40px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Profile pane slide-in */
@keyframes paneIn {
    0% { opacity: 0; transform: translateY(6px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Call card pop-in */
@keyframes call-pop {
    0% { opacity: 0; transform: scale(0.85); }
    100% { opacity: 1; transform: scale(1); }
}

/* Call ring buzz */
@keyframes call-buzz {
    0%, 100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(236, 72, 153, 0); }
}

/* ------------------------------------------------------------
   Animation Classes
   ------------------------------------------------------------ */

/* Reveal states */
[data-reveal] {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
    transition: opacity var(--d-3) var(--e-out), transform var(--d-3) var(--e-out);
}

[data-reveal].is-in,
[data-reveal].is-visible {
    opacity: 1 !important;
    transform: none !important;
}

[data-reveal="down"] {
    transform: translate3d(0, 26px, 0);
}

[data-reveal="up"] {
    transform: translate3d(0, -26px, 0);
}

[data-reveal="fade"] {
    transform: none;
}

[data-reveal="left"] {
    transform: translate3d(-26px, 0, 0);
}

[data-reveal="right"] {
    transform: translate3d(26px, 0, 0);
}

/* Stagger delays */
.stagger > *,
[data-stagger] > * {
    animation-delay: calc(var(--si, 0) * 70ms);
    animation-fill-mode: both;
}

.stagger-fast > *,
[data-stagger-fast] > * {
    animation-delay: calc(var(--si, 0) * 34ms);
    animation-fill-mode: both;
}

/* Entrance classes */
.float-in {
    animation: drop-in var(--d-3) var(--e-out) both;
}

.pop-in {
    animation: pop-in var(--d-3) var(--e-out) both;
}

.sheet-up {
    animation: sheet-up var(--d-4) var(--e-out) both;
}

.pane-in {
    animation: paneIn var(--d-3) var(--e-out) both;
}

/* Continuous effects */
.float-y {
    animation: float-y 4s var(--e-in-out) infinite;
}

.orbit-spin {
    animation: orbit-spin 3s linear infinite;
}

.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #ffffff 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

.spin {
    animation: spin 1s linear infinite;
}

.pulse-dot {
    animation: pulse-dot 2s infinite;
}

.pulse-ring {
    animation: pulse-ring 2s infinite;
}

.pulse-badge {
    animation: pulse-badge 2s infinite;
}

.glow-breathe {
    animation: glow-breathe 3s var(--e-in-out) infinite;
}

.marquee {
    display: inline-block;
    animation: marquee 26s linear infinite;
}

.ring-spin {
    animation: ring-spin 1s linear infinite;
}

/* Button sheen */
.btn-sheen {
    position: relative;
    overflow: hidden;
}

.btn-sheen::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 20%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.4), transparent);
    transform: rotate(25deg);
    animation: btn-sheen 3s infinite;
}

/* Veil overlay */
.page-veil {
    position: fixed;
    inset: 0;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--d-4) var(--e-out), visibility var(--d-4) var(--e-out);
}

.page-veil.active {
    opacity: 1;
    visibility: visible;
}

.page-veil-inner {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #0b1220 0%, #111c33 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(10px) scale(0.94);
}

.page-veil.active .page-veil-inner {
    animation: veil-in var(--d-4) var(--e-out) both;
}

/* Alert */
.alert-in {
    animation: alert-in var(--d-2) var(--e-out) both;
}

/* Toast */
.toast-in {
    animation: toast-in var(--d-2) var(--e-out) both;
}

.toast-out {
    animation: toast-out var(--d-2) var(--e-out) both;
}

/* Msg */
.msg-in {
    animation: msg-in var(--d-2) var(--e-out) both;
}

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

.ripple::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    transform: scale(0);
    opacity: 0.4;
    background: currentColor;
    animation: ripple-out 0.6s linear;
}

/* Count */
.count-tick {
    animation: count-tick var(--d-2) var(--e-out) both;
}

/* ============================================================
   LOADING & COURIER ANIMATIONS
   ============================================================ */

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: linear-gradient(135deg, #0b1220 0%, #111c33 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--d-4) var(--e-out), visibility var(--d-4) var(--e-out);
}

.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 4px solid rgba(255,255,255,0.15);
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loading-text {
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    font-family: 'Noto Sans Bengali', 'Inter', sans-serif;
    text-align: center;
    letter-spacing: 0.5px;
}

/* Courier delivering animation */
.courier-delivering {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: linear-gradient(135deg, #0b1220 0%, #111c33 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--d-5) var(--e-out), visibility var(--d-5) var(--e-out);
}

.courier-delivering.hidden {
    opacity: 0;
    visibility: hidden;
}

.courier-box {
    position: relative;
    width: 200px;
    height: 140px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    margin-bottom: 24px;
    overflow: hidden;
}

.courier-box::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
}

.courier-roof {
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 32px;
    background: #2563eb;
    border-radius: 8px 8px 0 0;
    clip-path: polygon(0 40%, 20% 0, 80% 0, 100% 40%);
}

.courier-window {
    position: absolute;
    top: 32px;
    left: 16px;
    width: 40px;
    height: 28px;
    background: #e5e7eb;
    border-radius: 4px;
}

.courier-window2 {
    position: absolute;
    top: 32px;
    right: 16px;
    width: 40px;
    height: 28px;
    background: #e5e7eb;
    border-radius: 4px;
}

.courier-wheel {
    position: absolute;
    bottom: 12px;
    width: 24px;
    height: 24px;
    background: #1f2937;
    border-radius: 50%;
    border: 3px solid #e5e7eb;
}

.courier-wheel.left { left: 28px; }
.courier-wheel.right { right: 28px; }

.courier-wheel::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid #9ca3af;
    border-radius: 50%;
}

.courier-wheel.left::after { animation: wheel-spin 1s linear infinite; }
.courier-wheel.right::after { animation: wheel-spin 1s linear infinite; }

.courier-person {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    background: #d1d5db;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.courier-person::after {
    content: "🚴‍♂️";
    font-size: 32px;
}

.courier-bounce {
    animation: courier-bounce 1.5s var(--e-in-out) infinite;
}

.courier-text {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Noto Sans Bengali', 'Inter', sans-serif;
    text-align: center;
    margin-top: 8px;
}

.courier-subtext {
    color: #9ca3af;
    font-size: 0.9rem;
    font-family: 'Noto Sans Bengali', 'Inter', sans-serif;
    text-align: center;
    margin-top: 4px;
}

@keyframes courier-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

@keyframes wheel-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #ffffff 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.75rem;
}

.skeleton-title {
    height: 1.25rem;
    width: 60%;
    margin-bottom: 1rem;
}

/* Button loading state */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: "";
    position: absolute;
    inset: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================================
   END LOADING & COURIER ANIMATIONS
   ============================================================ */

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 1ms !important;
        scroll-behavior: auto !important;
    }
    
    [data-reveal] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    
    .page-veil {
        display: none !important;
    }
    
    .float-y, .orbit-spin, .shimmer, .spin, .pulse-dot, .pulse-ring,
    .pulse-badge, .glow-breathe, .marquee, .ring-spin, .float-in,
    .pop-in, .sheet-up, .pane-in {
        animation: none !important;
    }
    
    .stagger > *, .stagger-fast > * {
        animation-delay: 0ms !important;
        animation: none !important;
    }
}
/* Hide scroll-to-top button on mobile (user request: no back/up button in new mobile design) */
@media (max-width: 1023px) {
    #back-to-top {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}
