/**
 * MODERN EFFECTS CSS
 * Animations, transitions, and custom scrollbars
 */

/* =============================================
   CUSTOM SCROLLBARS
   Always visible, clickable and draggable
   ============================================= */

/* Make scrollbars always visible */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--steel-400) var(--steel-50);
}

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--steel-50);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--steel-400) 0%, var(--steel-500) 100%);
    border-radius: 5px;
    border: 2px solid var(--steel-50);
    min-height: 40px;
    cursor: grab;
    transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--steel-500) 0%, var(--steel-600) 100%);
}

::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, var(--cyan-primary) 0%, var(--cyan-dark) 100%);
    cursor: grabbing;
}

::-webkit-scrollbar-corner {
    background: var(--steel-50);
}

/* Force scrollbar visibility on macOS */
html {
    overflow-y: scroll;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
}

/* =============================================
   GRAIN OVERLAY — Industrial texture
   ============================================= */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity, 0.03);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* =============================================
   SMOOTH PAGE TRANSITIONS
   ============================================= */

/* Fade in on page load */
@keyframes pageLoad {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

body {
    animation: pageLoad 0.4s ease-out;
}

/* Main content fade in */
main {
    animation: slideUp 0.5s ease-out;
}

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

/* =============================================
   ELEMENT REVEAL ANIMATIONS
   Elements animate in when they become visible
   ============================================= */

/* Base state for animated elements */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

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

/* Slide up animation */
.slide-up {
    animation: slideUp 0.5s ease-out forwards;
}

/* Slide in from left */
.slide-in-left {
    animation: slideInLeft 0.5s ease-out forwards;
}

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

/* Slide in from right */
.slide-in-right {
    animation: slideInRight 0.5s ease-out forwards;
}

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

/* Scale up animation */
.scale-up {
    animation: scaleUp 0.4s ease-out forwards;
}

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

/* =============================================
   STAGGERED ANIMATIONS FOR LISTS
   ============================================= */

.stagger-children > * {
    opacity: 0;
    animation: staggerFadeIn 0.5s ease-out forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(9) { animation-delay: 0.45s; }
.stagger-children > *:nth-child(10) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(11) { animation-delay: 0.55s; }
.stagger-children > *:nth-child(12) { animation-delay: 0.6s; }

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

/* =============================================
   MODERN BUTTON EFFECTS
   ============================================= */

.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: scale(0.98);
}

/* Primary button glow effect */
.btn--primary {
    box-shadow: 0 4px 15px rgba(38, 127, 181, 0.3);
}

.btn--primary:hover {
    box-shadow: 0 6px 25px rgba(38, 127, 181, 0.4);
    transform: translateY(-2px);
}

.btn--primary:active {
    box-shadow: 0 2px 10px rgba(38, 127, 181, 0.3);
    transform: translateY(0) scale(0.98);
}

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

.product-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center bottom;
}

.product-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow:
        0 12px 24px rgba(15, 23, 42, 0.1),
        0 0 0 1px var(--cyan-primary);
}

.product-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--cyan-primary);
    transform: scaleX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.product-card:hover::after {
    transform: scaleX(1);
}

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

/* Skeleton loading animation */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--off-white) 0%,
        #e8e8e8 50%,
        var(--off-white) 100%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

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

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

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

/* Modern spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--off-white);
    border-top-color: var(--cyan-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Dots loading animation */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--cyan-primary);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* =============================================
   SMOOTH INPUT FOCUS EFFECTS
   ============================================= */

input, select, textarea {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--cyan-primary);
    box-shadow: 0 0 0 3px rgba(38, 127, 181, 0.15);
    transform: translateY(-1px);
}

/* Floating label effect */
.form-group {
    position: relative;
}

.form-group label {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   NAVIGATION TRANSITIONS
   ============================================= */

.nav-link {
    position: relative;
    transition: color 0.3s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--cyan-primary);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* =============================================
   MODAL/DROPDOWN ANIMATIONS
   ============================================= */

.modal-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
}

.modal-content {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* Dropdown animation */
.dropdown-menu {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* =============================================
   CART ANIMATIONS
   ============================================= */

/* Cart item add animation */
@keyframes cartItemAdd {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.cart-item {
    animation: cartItemAdd 0.4s ease-out;
}

/* Cart item remove animation */
.cart-item.removing {
    animation: cartItemRemove 0.3s ease-out forwards;
}

@keyframes cartItemRemove {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* Cart count badge bounce */
.cart-count {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-count.bounce {
    animation: badgeBounce 0.5s ease-out;
}

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

/* =============================================
   SMOOTH ACCORDION/COLLAPSE
   ============================================= */

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion.open .accordion-content {
    max-height: 1000px;
}

/* Details/Summary animation */
details summary {
    cursor: pointer;
    transition: color 0.2s ease;
}

details summary:hover {
    color: var(--cyan-primary);
}

details[open] summary {
    color: var(--cyan-primary);
}

/* =============================================
   IMAGE LOADING EFFECTS
   Images visible by default, fade-in is opt-in
   ============================================= */

/* Images are visible by default */
img {
    transition: opacity 0.4s ease;
}

/* Only hide images that JS marks for fade-in animation */
img.fade-in-image {
    opacity: 0;
}

img.fade-in-image.loaded,
img.loaded {
    opacity: 1;
}

/* Blur-up image loading */
.image-blur-up {
    filter: blur(10px);
    transition: filter 0.4s ease;
}

.image-blur-up.loaded {
    filter: blur(0);
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

.toast {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.toast.hide {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
}

/* =============================================
   RIPPLE EFFECT FOR BUTTONS
   ============================================= */

.ripple {
    position: relative;
    overflow: hidden;
}

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

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

/* =============================================
   PROGRESS BAR ANIMATION
   ============================================= */

.progress-bar {
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* =============================================
   SMOOTH SCROLL SECTIONS
   Sections are visible by default - animation is opt-in
   ============================================= */

/* Elements that JavaScript marks for animation */
.will-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.will-animate.in-view,
.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* Hero section stays static - no animations */
.hero,
.hero *,
section.hero {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

/* =============================================
   HOVER LIFT EFFECT
   ============================================= */

.hover-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

/* =============================================
   REDUCED MOTION SUPPORT
   ============================================= */

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

    html {
        scroll-behavior: auto;
    }

    /* Grain overlay stays static (no animation needed) */
    body::after {
        opacity: var(--grain-opacity, 0.03);
    }
}
