/* ============================================
   INFINITY OS - MOTION & ANIMATIONS
   Smooth Transitions & Effects
   ============================================ */

/* ============================================
   FADE ANIMATIONS
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.fade-in {
    animation: fadeIn var(--transition-base);
}

.fade-out {
    animation: fadeOut var(--transition-base);
}

/* ============================================
   SLIDE ANIMATIONS
   ============================================ */

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.slide-in-left {
    animation: slideInLeft var(--transition-base);
}

.slide-in-right {
    animation: slideInRight var(--transition-base);
}

.slide-in-up {
    animation: slideInUp var(--transition-base);
}

/* ============================================
   SCALE ANIMATIONS
   ============================================ */

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.scale-in {
    animation: scaleIn var(--transition-base);
}

/* ============================================
   GLOW PULSE ANIMATIONS
   ============================================ */

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(0, 240, 255, 0.6);
    }
}

@keyframes glowPulseMagenta {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 0, 170, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 0, 170, 0.6);
    }
}

.glow-pulse-cyan {
    animation: glowPulse 2s ease-in-out infinite;
}

.glow-pulse-magenta {
    animation: glowPulseMagenta 2s ease-in-out infinite;
}

/* ============================================
   SHIMMER EFFECT
   ============================================ */

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ============================================
   SKELETON LOADING
   ============================================ */

.skeleton {
    background: var(--glass-bg);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-sm);
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--space-md);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

.hover-lift {
    transition: transform var(--transition-fast);
}

.hover-lift:hover {
    transform: translateY(-4px);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--glow-cyan);
}

.motion-surface-hover {
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-fast);
}

.motion-surface-hover:hover {
    transform: translateY(-4px);
}

.motion-control-hover {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}

.motion-control-hover:hover {
    transform: translateY(-2px);
}

.motion-control-press:active {
    transform: translateY(0) scale(0.995);
}

.motion-focus-ring:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(10, 15, 25, 0.9), 0 0 0 4px rgba(0, 240, 255, 0.34);
}

/* ============================================
   STAGGER ANIMATIONS
   ============================================ */

.stagger-item {
    opacity: 0;
    animation: slideInUp var(--transition-base) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.05s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.15s; }
.stagger-item:nth-child(4) { animation-delay: 0.2s; }
.stagger-item:nth-child(5) { animation-delay: 0.25s; }
.stagger-item:nth-child(6) { animation-delay: 0.3s; }

/* ============================================
   SPINNER ANIMATION
   ============================================ */

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

.spinner-ring {
    position: relative;
    width: 40px;
    height: 40px;
}

.spinner-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-radius: 50%;
}

.spinner-circle:nth-child(1) {
    border-top-color: var(--neon-cyan);
    animation: spin 1s linear infinite;
}

.spinner-circle:nth-child(2) {
    border-right-color: var(--neon-magenta);
    animation: spin 1.5s linear infinite;
}

.spinner-circle:nth-child(3) {
    border-bottom-color: var(--neon-green);
    animation: spin 2s linear infinite;
}

/* ============================================
   REDUCE MOTION (Accessibility)
   ============================================ */

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

    .motion-surface-hover:hover,
    .motion-control-hover:hover,
    .motion-control-press:active {
        transform: none !important;
    }
}

/* ============================================
   PHASE 5 — INTERACTION PATTERN REFINEMENTS
   Card float consistency, focus accessibility, skeleton tuning, panel transitions
   ============================================ */

/* --- Card hover float (spring easing for dimensional feel) --- */
@keyframes cardFloat {
    0%   { transform: translateY(0); }
    60%  { transform: translateY(-5px); }
    100% { transform: translateY(-4px); }
}

.motion-surface-hover {
    transition:
        transform 260ms cubic-bezier(0.34, 1.4, 0.64, 1),
        box-shadow 260ms cubic-bezier(0.34, 1.4, 0.64, 1),
        border-color 180ms ease;
}

.motion-surface-hover:hover {
    transform: translateY(-4px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.30),
        0 2px 8px rgba(0, 0, 0, 0.20),
        0 0 0 1px rgba(0, 240, 255, 0.08);
}

/* Portal-accent card float (client portal uses magenta) */
.motion-surface-hover--accent:hover {
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.30),
        0 2px 8px rgba(0, 0, 0, 0.20),
        0 0 0 1px rgba(255, 0, 170, 0.1);
}

/* Subtler float for content surfaces (not interactive cards) */
.motion-surface-hover--soft {
    transition:
        transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.motion-surface-hover--soft:hover {
    transform: translateY(-2px);
}

/* Control hover — faster spring for small controls */
.motion-control-hover {
    transition:
        transform 160ms cubic-bezier(0.34, 1.4, 0.64, 1),
        box-shadow 160ms ease,
        filter 120ms ease;
}

.motion-control-hover:hover {
    transform: translateY(-2px);
}

/* --- Keyboard focus rings — standardized double-ring pattern --- */
.motion-focus-ring:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 2px var(--bg-primary),
        0 0 0 4px rgba(0, 240, 255, 0.60);
}

/* Portal-specific focus rings (client portal = magenta) */
.app-client-portal .motion-focus-ring:focus-visible,
.app-client-portal button:focus-visible,
.app-client-portal a:focus-visible,
.app-client-portal input:focus-visible,
.app-client-portal select:focus-visible,
.app-client-portal textarea:focus-visible {
    box-shadow:
        0 0 0 2px var(--bg-primary),
        0 0 0 4px rgba(255, 0, 170, 0.55);
}

/* --- Skeleton shimmer — tuned speed and gradient --- */
@keyframes skeletonShimmer {
    0%   { background-position: -600px 0; }
    100% { background-position: 600px 0; }
}

.skeleton {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.00) 0%,
        rgba(255, 255, 255, 0.07) 40%,
        rgba(255, 255, 255, 0.07) 60%,
        rgba(255, 255, 255, 0.00) 100%
    );
    background-size: 600px 100%;
    animation: skeletonShimmer 1.8s ease-in-out infinite;
}

/* --- Panel / modal entrance transitions --- */
@keyframes panelEnter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes panelExit {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
}

.motion-panel-enter {
    animation: panelEnter 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.motion-panel-exit {
    animation: panelExit 160ms cubic-bezier(0.36, 0, 0.66, 0) both;
}

/* Page-level section reveal */
@keyframes sectionReveal {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.motion-section-reveal {
    animation: sectionReveal 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* --- Glow ripple on CTA focus (auth / hero buttons) --- */
@keyframes glowRipple {
    0%   { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.35); }
    70%  { box-shadow: 0 0 0 10px rgba(0, 240, 255, 0.00); }
    100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.00); }
}

.motion-cta-ripple:focus-visible {
    animation: glowRipple 0.6s ease-out;
}

/* --- Reduced motion overrides (comprehensive) --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .motion-surface-hover:hover,
    .motion-surface-hover--soft:hover,
    .motion-control-hover:hover,
    .motion-control-press:active,
    .hover-lift:hover,
    .hover-glow:hover {
        transform: none !important;
    }

    .skeleton::after {
        animation: none;
        opacity: 0.5;
    }

    .motion-panel-enter,
    .motion-panel-exit,
    .motion-section-reveal,
    .stagger-item {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .glow-pulse-cyan,
    .glow-pulse-magenta {
        animation: none;
    }
}

/* ============================================
   STATUS PULSE DOT
   Live indicator for system / payroll status
   ============================================ */

@keyframes statusPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.6), 0 0 6px rgba(0, 255, 136, 0.4);
    }
    60% {
        box-shadow: 0 0 0 5px rgba(0, 255, 136, 0), 0 0 12px rgba(0, 255, 136, 0.2);
    }
}

.status-pulse {
    animation: statusPulse 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ============================================
   ENHANCED STAGGER — CARD GRID REVEALS
   Apply .reveal-stagger to a grid parent;
   children enter in sequence on page load.
   ============================================ */

@keyframes cardRevealUp {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.98);
        filter: blur(1px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

.reveal-stagger > * {
    opacity: 0;
    animation: cardRevealUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.reveal-stagger > *:nth-child(1)  { animation-delay: 0.04s; }
.reveal-stagger > *:nth-child(2)  { animation-delay: 0.09s; }
.reveal-stagger > *:nth-child(3)  { animation-delay: 0.14s; }
.reveal-stagger > *:nth-child(4)  { animation-delay: 0.19s; }
.reveal-stagger > *:nth-child(5)  { animation-delay: 0.24s; }
.reveal-stagger > *:nth-child(6)  { animation-delay: 0.29s; }
.reveal-stagger > *:nth-child(7)  { animation-delay: 0.34s; }
.reveal-stagger > *:nth-child(8)  { animation-delay: 0.38s; }

@media (prefers-reduced-motion: reduce) {
    .status-pulse             { animation: none; }
    .reveal-stagger > *       { opacity: 1; animation: none; transform: none; filter: none; }
}
