/* MICRO-INTERACTIONS & UX POLISH - PROFESSIONAL GRADE */

/* ============================================
   SMOOTH SCROLLING & PERFORMANCE
   ============================================ */

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

@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;
    }
}

/* ============================================
   BUTTON INTERACTIONS
   ============================================ */

button, .btn, a.learn-more-button {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    will-change: transform;
}

/* Ripple effect on click */
button::after,
.btn::after,
a.learn-more-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

button:focus:not(:active)::after,
.btn:focus:not(:active)::after,
a.learn-more-button:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(40, 40);
        opacity: 0;
    }
}

/* ============================================
   LINK INTERACTIONS
   ============================================ */

a:not(.nav-links a):not(.learn-more-button):not(.footer-links a) {
    position: relative;
    display: inline-block;
}

a:not(.nav-links a):not(.learn-more-button):not(.footer-links a)::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -2px;
    left: 0;
    background-color: currentColor;
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}

a:not(.nav-links a):not(.learn-more-button):not(.footer-links a):hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* ============================================
   CARD INTERACTIONS
   ============================================ */

.benefit,
.feature-section,
.calculator-card {
    transform: translateZ(0);
    will-change: transform, box-shadow;
}

/* ============================================
   FOCUS VISIBLE (ACCESSIBILITY)
   ============================================ */

*:focus {
    outline: none;
}

*:focus-visible {
    outline: 3px solid #69B254;
    outline-offset: 3px;
    border-radius: 4px;
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #69B254;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   IMAGE LAZY LOADING EFFECT
   ============================================ */

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

img[loading="lazy"].loaded,
img[loading="lazy"]:not([src=""]) {
    opacity: 1;
}

/* ============================================
   SELECTION STYLES
   ============================================ */

::selection {
    background-color: #69B254;
    color: #fff;
}

::-moz-selection {
    background-color: #69B254;
    color: #fff;
}

/* ============================================
   SCROLLBAR STYLING (Webkit) - DARK THEME
   ============================================ */

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #69B254;
    border-radius: 6px;
    border: 3px solid #1a1a1a;
}

::-webkit-scrollbar-thumb:hover {
    background: #7bc463;
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #69B254 #1a1a1a;
}

/* ============================================
   PULSE ANIMATION (for important elements)
   ============================================ */

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

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

/* ============================================
   SKELETON LOADING (for future use)
   ============================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

/* ============================================
   SMOOTH TRANSITIONS FOR DYNAMIC CONTENT
   ============================================ */

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

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

/* ============================================
   HOVER GLOW EFFECT
   ============================================ */

.glow-on-hover:hover {
    box-shadow: 0 0 20px rgba(105, 178, 84, 0.5);
}

/* ============================================
   MOBILE TOUCH FEEDBACK
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    button:active,
    .btn:active,
    a:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Remove will-change after animation completes */
.animated {
    will-change: auto;
}
