/**
 * Base Theme Styles
 *
 * Common styles and animations shared across all themes.
 * Individual theme CSS files extend these base styles.
 */

/* ============================================
   Page Transitions
   ============================================ */

body {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

body.page-loaded {
    opacity: 1;
}

/* ============================================
   Scroll Animations
   ============================================ */

[data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

[data-animate].animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Animation delays for staggered effects */
[data-animate][data-delay="1"] {
    transition-delay: 0.1s;
}

[data-animate][data-delay="2"] {
    transition-delay: 0.2s;
}

[data-animate][data-delay="3"] {
    transition-delay: 0.3s;
}

[data-animate][data-delay="4"] {
    transition-delay: 0.4s;
}

/* ============================================
   Button Enhancements
   ============================================ */

button, .btn, a.button {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Ripple effect on click (optional - can be enhanced with JS) */
button::after, .btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:active::after, .btn:active::after {
    width: 300px;
    height: 300px;
}

/* ============================================
   Smooth Scrolling
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* ============================================
   Focus Styles (Accessibility)
   ============================================ */

*:focus {
    outline: 2px solid var(--color-accent, #6366f1);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================
   Loading States
   ============================================ */

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

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   Image Loading
   ============================================ */

img {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

img.loaded,
img[loading="lazy"],
#amplitude-player img,
.hero img,
section img {
    opacity: 1;
}

/* ============================================
   Utility Classes
   ============================================ */

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

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

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

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

/* Slide animations */
.slide-in-up {
    animation: slideInUp 0.5s ease-out;
}

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

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

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

/* ============================================
   Performance Optimizations
   ============================================ */

/* GPU acceleration for animations */
[data-animate],
button,
.btn {
    will-change: transform, opacity;
}

/* Remove will-change after animation completes to free resources */
[data-animate].animate-in {
    will-change: auto;
}

/* ============================================
   Reduced Motion Support (Accessibility)
   ============================================ */

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

    [data-animate] {
        opacity: 1;
        transform: none;
    }
}

/* ============================================
   REUSABLE VISUAL EFFECT UTILITIES
   ============================================ */

/* Neon Glow Utilities */
.neon-glow-primary {
    text-shadow:
        0 0 10px var(--color-primary),
        0 0 20px var(--color-primary),
        0 0 30px var(--color-primary);
}

.neon-glow-secondary {
    text-shadow:
        0 0 10px var(--color-secondary),
        0 0 20px var(--color-secondary);
}

.neon-glow-accent {
    text-shadow:
        0 0 10px var(--color-accent),
        0 0 20px var(--color-accent);
}

/* Box Shadow Utilities */
.shadow-subtle {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.shadow-moderate {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.shadow-dramatic {
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(var(--color-accent-rgb), 0.3);
}

.shadow-glow-primary {
    box-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.5);
}

.shadow-glow-secondary {
    box-shadow: 0 0 20px rgba(var(--color-secondary-rgb), 0.5);
}

/* Gradient Utilities */
.gradient-diagonal {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

.gradient-diagonal-reverse {
    background: linear-gradient(315deg, var(--color-primary), var(--color-secondary));
}

.gradient-horizontal {
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}

.gradient-vertical {
    background: linear-gradient(180deg, var(--color-primary), var(--color-secondary));
}

.gradient-radial {
    background: radial-gradient(circle, var(--color-primary), var(--color-secondary));
}

/* Border Utilities */
.border-glow-primary {
    border: 1px solid rgba(var(--color-primary-rgb), 0.3);
    box-shadow: 0 0 10px rgba(var(--color-primary-rgb), 0.2);
}

.border-glow-accent {
    border: 1px solid rgba(var(--color-accent-rgb), 0.3);
    box-shadow: 0 0 10px rgba(var(--color-accent-rgb), 0.2);
}

/* ============================================
   REUSABLE ANIMATION UTILITIES
   ============================================ */

/* Pulse Animation */
@keyframes pulse-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

.pulse-glow {
    animation: pulse-glow 3s ease-in-out infinite;
}

/* Fade Up Animation */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-up {
    animation: fade-up 0.6s ease-out;
}

/* Scale In Animation */
@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scale-in 0.5s ease-out;
}

/* Shimmer Animation */
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

.shimmer {
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

/* Rotate Animation */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.rotate {
    animation: rotate 3s linear infinite;
}

/* Float Animation */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

/* ============================================
   HOVER EFFECT UTILITIES
   ============================================ */

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

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

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

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(var(--color-accent-rgb), 0.5);
}

/* Scale on Hover */
.hover-scale {
    transition: transform 0.3s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Brighten on Hover */
.hover-brighten {
    transition: filter 0.3s ease;
}

.hover-brighten:hover {
    filter: brightness(1.1);
}

/* ============================================
   TEXTURE UTILITIES
   ============================================ */

/* Noise Texture Overlay */
.texture-noise::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1;
}

/* Grid Pattern Overlay */
.texture-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(0deg, transparent 24%, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.05) 26%, transparent 27%),
        linear-gradient(90deg, transparent 24%, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.05) 26%, transparent 27%);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 1;
}

/* Scan Lines Overlay */
.texture-scanlines::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9998;
}

/* ============================================
   DECORATION UTILITIES
   ============================================ */

/* Underline Decoration */
.underline-accent {
    position: relative;
    padding-bottom: 0.5rem;
}

.underline-accent::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), transparent);
}

/* Divider Line */
.divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--color-primary) 50%,
        transparent 100%
    );
    margin: 2rem 0;
}

/* Corner Accents */
.corner-accents {
    position: relative;
}

.corner-accents::before,
.corner-accents::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-primary);
    opacity: 0.3;
}

.corner-accents::before {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
}

.corner-accents::after {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
}

/* ============================================
   PARALLAX UTILITIES
   ============================================ */

/* Parallax layers (requires JS to set transform values) */
.parallax-slow {
    transition: transform 0.1s ease-out;
}

.parallax-medium {
    transition: transform 0.15s ease-out;
}

.parallax-fast {
    transition: transform 0.2s ease-out;
}

/* ============================================
   GLASSMORPHISM UTILITIES
   ============================================ */

.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.glass-dark {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    [data-animate] {
        opacity: 1;
        transform: none;
    }

    button::after,
    .btn::after {
        display: none;
    }

    /* Hide decorative elements in print */
    .texture-noise::before,
    .texture-grid::before,
    .texture-scanlines::before,
    .corner-accents::before,
    .corner-accents::after {
        display: none;
    }
}
