/* =====================================================
   ChalcedonX - Animation Stylesheet
   Scroll reveal, transitions, and micro-interactions
   ===================================================== */

/* -------------------- Scroll Reveal Animations -------------------- */

/* Fade In Up */
.animate-fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: var(--delay, 0s);
}

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

/* Text Reveal */
.animate-text-reveal {
    opacity: 0;
    transform: translateY(100%);
    animation: textReveal 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: var(--delay, 0s);
}

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

/* Reveal Text (Scroll Triggered) */
.reveal-text {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-text.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Reveal Left */
.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Reveal Right */
.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

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

/* Reveal Up */
.reveal-up {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    transition-delay: var(--delay, 0s);
}

.reveal-up.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Reveal Scale */
.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* -------------------- Stagger Animations -------------------- */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.revealed > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.revealed > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.revealed > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.revealed > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.revealed > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.revealed > *:nth-child(6) { transition-delay: 0.6s; }
.stagger-children.revealed > *:nth-child(7) { transition-delay: 0.7s; }
.stagger-children.revealed > *:nth-child(8) { transition-delay: 0.8s; }

.stagger-children.revealed > * {
    opacity: 1;
    transform: translateY(0);
}

/* -------------------- Skill Tags Animation -------------------- */
.about-skills .skill-tag {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: var(--delay, 0s);
}

.about-skills.revealed .skill-tag {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* -------------------- Glowing Text Effect - Soft Ghibli -------------------- */
.glow-text {
    animation: textGlow 3s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from {
        text-shadow: 
            0 0 8px rgba(91, 143, 185, 0.3),
            0 0 15px rgba(91, 143, 185, 0.15);
    }
    to {
        text-shadow: 
            0 0 12px rgba(91, 143, 185, 0.4),
            0 0 25px rgba(91, 143, 185, 0.2);
    }
}

/* -------------------- Parallax Effect Classes -------------------- */
[data-parallax] {
    will-change: transform;
}

/* -------------------- Magnetic Button Effect -------------------- */
.btn {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.btn.magnetic {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* -------------------- Typing Animation -------------------- */
.typing-text::after {
    content: '|';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* -------------------- Counter Animation -------------------- */
.stat-number {
    transition: all 0.3s ease;
}

/* -------------------- Shimmer Effect - Gentle Light -------------------- */
.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(135, 206, 235, 0.15) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 3s infinite;
}

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

/* -------------------- Gradient Animation -------------------- */
.animated-gradient {
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* -------------------- Floating Animation -------------------- */
.float {
    animation: float 3s ease-in-out infinite;
}

.float-delayed {
    animation: float 3s ease-in-out infinite;
    animation-delay: 1.5s;
}

/* -------------------- Rotate Animation -------------------- */
.rotate-slow {
    animation: rotateSlow 20s linear infinite;
}

@keyframes rotateSlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotate-reverse {
    animation: rotateReverse 25s linear infinite;
}

@keyframes rotateReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* -------------------- Scale Pulse -------------------- */
.scale-pulse {
    animation: scalePulse 2s ease-in-out infinite;
}

@keyframes scalePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* -------------------- Shake Animation -------------------- */
.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* -------------------- Bounce In -------------------- */
.bounce-in {
    animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* -------------------- Slide In Animations -------------------- */
.slide-in-left {
    animation: slideInLeft 0.6s ease-out forwards;
}

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

.slide-in-right {
    animation: slideInRight 0.6s ease-out forwards;
}

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

.slide-in-up {
    animation: slideInUp 0.6s ease-out forwards;
}

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

.slide-in-down {
    animation: slideInDown 0.6s ease-out forwards;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* -------------------- Zoom Animations -------------------- */
.zoom-in {
    animation: zoomIn 0.5s ease-out forwards;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.zoom-out {
    animation: zoomOut 0.5s ease-out forwards;
}

@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* -------------------- Flip Animations -------------------- */
.flip-in-x {
    animation: flipInX 0.6s ease-out forwards;
}

@keyframes flipInX {
    from {
        opacity: 0;
        transform: perspective(400px) rotateX(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateX(0);
    }
}

.flip-in-y {
    animation: flipInY 0.6s ease-out forwards;
}

@keyframes flipInY {
    from {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

/* -------------------- Blur Animations -------------------- */
.blur-in {
    animation: blurIn 0.6s ease-out forwards;
}

@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(20px);
    }
    to {
        opacity: 1;
        filter: blur(0);
    }
}

/* -------------------- Wave Animation -------------------- */
.wave {
    animation: wave 2.5s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% {
        transform: translateY(0);
    }
    25% {
        transform: translateY(-10px);
    }
    50% {
        transform: translateY(0);
    }
    75% {
        transform: translateY(10px);
    }
}

/* -------------------- Hover Animations -------------------- */

/* Card 3D Tilt */
.tilt-card {
    transform-style: preserve-3d;
    perspective: 1000px;
    transition: transform 0.3s ease;
}

.tilt-card:hover {
    transform: rotateX(5deg) rotateY(5deg);
}

/* Lift Effect - Gentle */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 35px rgba(61, 61, 61, 0.12);
}

/* Glow Effect - Soft */
.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 25px rgba(91, 143, 185, 0.25);
}

/* Border Glow - Natural */
.hover-border-glow {
    position: relative;
    transition: all 0.3s ease;
}

.hover-border-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    padding: 2px;
    background: linear-gradient(135deg, #5B8FB9, #7DB87D, #E8A87C);
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hover-border-glow:hover::before {
    opacity: 1;
}

/* -------------------- Text Animations -------------------- */

/* Letter Spacing Animation */
.hover-letter-spacing {
    transition: letter-spacing 0.3s ease;
}

.hover-letter-spacing:hover {
    letter-spacing: 3px;
}

/* Underline Animation */
.animated-underline {
    position: relative;
}

.animated-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #5B8FB9, #7DB87D);
    transition: width 0.3s ease;
}

.animated-underline:hover::after {
    width: 100%;
}

/* -------------------- Loading Animations -------------------- */

/* Spinner - Gentle */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(91, 143, 185, 0.15);
    border-top-color: #5B8FB9;
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

/* Dots Loading */
.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #5B8FB9;
    border-radius: 50%;
    animation: dotBounce 1.6s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; background: #5B8FB9; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; background: #7DB87D; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; background: #E8A87C; }

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

/* Pulse Loading */
.pulse-loading {
    width: 40px;
    height: 40px;
    background: rgba(91, 143, 185, 0.25);
    border-radius: 50%;
    animation: pulseBeat 2s ease-in-out infinite;
}

@keyframes pulseBeat {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* -------------------- Progress Bar Animation -------------------- */
.progress-bar {
    height: 4px;
    background: rgba(91, 143, 185, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #5B8FB9, #7DB87D, #E8A87C);
    border-radius: 2px;
    animation: progressFill 2s ease-out forwards;
}

@keyframes progressFill {
    from { width: 0; }
    to { width: var(--progress, 100%); }
}

/* -------------------- Morph Animation -------------------- */
.morph {
    animation: morph 8s ease-in-out infinite;
}

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

/* -------------------- Gradient Border Animation - Soft Ghibli -------------------- */
.gradient-border {
    position: relative;
    background: #FBF8F3;
    border-radius: 16px;
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #5B8FB9, #7DB87D, #E8A87C, #A8A0C4, #87CEEB, #5B8FB9);
    background-size: 400% 400%;
    border-radius: 18px;
    z-index: -1;
    animation: gradientBorder 6s ease infinite;
}

@keyframes gradientBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* -------------------- Noise/Grain Effect -------------------- */
.noise-overlay {
    position: relative;
}

.noise-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
}

/* -------------------- Glitch Effect - Softer for Ghibli -------------------- */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 1px;
    text-shadow: -1px 0 #A8A0C4;
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-1 4s infinite linear alternate-reverse;
}

.glitch::after {
    left: -1px;
    text-shadow: -1px 0 #5B8FB9;
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-2 4s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0% { clip: rect(20px, 9999px, 30px, 0); }
    25% { clip: rect(60px, 9999px, 80px, 0); }
    50% { clip: rect(10px, 9999px, 50px, 0); }
    75% { clip: rect(70px, 9999px, 90px, 0); }
    100% { clip: rect(30px, 9999px, 60px, 0); }
}

@keyframes glitch-2 {
    0% { clip: rect(70px, 9999px, 100px, 0); }
    25% { clip: rect(30px, 9999px, 50px, 0); }
    50% { clip: rect(80px, 9999px, 120px, 0); }
    75% { clip: rect(10px, 9999px, 40px, 0); }
    100% { clip: rect(50px, 9999px, 80px, 0); }
}

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

