/* ============================================
   TACTILE MAXIMALISM - CHATFLY 2026
   ============================================ */

/* Spring Physics Variables */
:root {
    /* Spring curves - more bounce */
    --spring-fast: cubic-bezier(0.34, 1.56, 0.64, 1);
    --spring-medium: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --spring-slow: cubic-bezier(0.175, 0.885, 0.32, 1.275);

    /* Jelly effect */
    --jelly: cubic-bezier(0.5, 1.5, 0.5, 0.8);

    /* Smooth easing */
    --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ============================================
   SQUISHY BUTTONS (Clay/Jelly Texture)
   ============================================ */

.btn-squishy {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    transition: all 0.3s var(--spring-medium);
    box-shadow:
        0 4px 12px rgba(255, 0, 110, 0.2),
        inset 0 -2px 0 rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-squishy::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 60%);
    border-radius: inherit;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.btn-squishy::after {
    content: '';
    position: absolute;
    inset: -50%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.4), transparent 70%);
    opacity: 0;
    transform: scale(0);
    transition: all 0.6s var(--spring-fast);
    pointer-events: none;
}

/* Hover State - Squish Effect */
.btn-squishy:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow:
        0 8px 24px rgba(255, 0, 110, 0.35),
        inset 0 -3px 0 rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.2);
}

/* Active State - Bounce */
.btn-squishy:active {
    transform: scale(0.95) translateY(1px);
    box-shadow:
        0 2px 8px rgba(255, 0, 110, 0.2),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
    transition-duration: 0.1s;
}

/* Ripple Effect on Click */
.btn-squishy:active::after {
    opacity: 1;
    transform: scale(2);
    transition-duration: 0s;
}

/* Focus State - Keyboard Navigation */
.btn-squishy:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 4px;
    transform: scale(1.02);
}

/* ============================================
   KINETIC TYPOGRAPHY
   ============================================ */

.kinetic-text {
    display: inline-block;
    position: relative;
    white-space: nowrap;
}

.kinetic-text.active {
    animation: liquify 1.5s var(--spring-slow) forwards;
}

@keyframes liquify {
    0%, 100% {
        transform: scaleX(1) scaleY(1);
    }
    20% {
        transform: scaleX(1.08) scaleY(0.92);
    }
    40% {
        transform: scaleX(0.95) scaleY(1.05);
    }
    60% {
        transform: scaleX(1.03) scaleY(0.97);
    }
    80% {
        transform: scaleX(0.98) scaleY(1.02);
    }
}

/* Per-character liquify effect */
.kinetic-char {
    display: inline-block;
    transition: transform 0.3s var(--jelly);
}

.kinetic-text:hover .kinetic-char:nth-child(odd) {
    animation: char-wave 0.6s ease-in-out infinite;
    animation-delay: calc(var(--char-index) * 0.05s);
}

.kinetic-text:hover .kinetic-char:nth-child(even) {
    animation: char-wave-reverse 0.6s ease-in-out infinite;
    animation-delay: calc(var(--char-index) * 0.05s);
}

@keyframes char-wave {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes char-wave-reverse {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

/* ============================================
   BENTO GRID LAYOUT
   ============================================ */

.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
    width: 100%;
}

@media (min-width: 768px) {
    .bento-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 24px;
    }
}

.bento-card {
    position: relative;
    background: var(--bg-card);
    border-radius: 24px;
    padding: 24px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    transition: all 0.4s var(--spring-medium);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Hover - Card Lift */
.bento-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--color-primary);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 0, 110, 0.1);
}

/* Active - Card Press */
.bento-card:active {
    transform: translateY(-2px) scale(0.98);
    transition-duration: 0.1s;
}

/* Gradient Overlay on Hover */
.bento-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

.bento-card:hover::before {
    opacity: 1;
}

/* Card Glow Effect */
.bento-card::after {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(135deg, var(--color-primary), #ff3380);
    border-radius: 24px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.bento-card:hover::after {
    opacity: 0.2;
    animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.4; }
}

/* ============================================
   MOOD-AWARE COLOR SHIFTING
   ============================================ */

/* Calm Mood (Default) */
[data-mood="calm"] {
    --mood-bg: #0f0f1e;
    --mood-primary: #8b5cf6;
    --mood-accent: #a78bfa;
}

/* Energetic Mood */
[data-mood="energetic"] {
    --mood-bg: #1e0f1a;
    --mood-primary: #ff006e;
    --mood-accent: #ff3380;
}

/* Chill Mood */
[data-mood="chill"] {
    --mood-bg: #0f1e1e;
    --mood-primary: #06b6d4;
    --mood-accent: #22d3ee;
}

/* Excited Mood */
[data-mood="excited"] {
    --mood-bg: #1e1e0f;
    --mood-primary: #f59e0b;
    --mood-accent: #fbbf24;
}

.mood-container {
    background: var(--mood-bg);
    transition: background 2s ease;
}

.mood-accent {
    color: var(--mood-accent);
    transition: color 1.5s ease;
}

/* ============================================
   PARTICLE EFFECTS (Emoji Explosions)
   ============================================ */

@keyframes particle-explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

.particle {
    position: absolute;
    pointer-events: none;
    font-size: 24px;
    animation: particle-explode 1s ease-out forwards;
}

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s var(--spring-slow);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger effect for multiple reveals */
.reveal:nth-child(1) { transition-delay: 0.1s; }
.reveal:nth-child(2) { transition-delay: 0.2s; }
.reveal:nth-child(3) { transition-delay: 0.3s; }
.reveal:nth-child(4) { transition-delay: 0.4s; }
.reveal:nth-child(5) { transition-delay: 0.5s; }

/* ============================================
   LOADING SHIMMER (Skeleton Screens)
   ============================================ */

.shimmer {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 0%,
        var(--bg-hover) 50%,
        var(--bg-secondary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ============================================
   GLASS MORPHISM EFFECTS
   ============================================ */

.glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-hover {
    transition: all 0.3s ease;
}

.glass-hover:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Use GPU acceleration for transforms */
.btn-squishy,
.bento-card,
.kinetic-text,
.reveal {
    will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
