/**
 * Derek Shreds - Music Portfolio Styles
 * 
 * Modern, responsive design for electronic music showcase
 * 
 * @author Derek Morris (Derek Shreds)
 * @copyright 2025 Derek Morris
 */

/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --dark-bg: #0f172a;
    --darker-bg: #020617;
    --card-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --success: #10b981;
    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--darker-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Hero Section */
.hero {
    position: relative;
    height: 98vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-1);
    overflow: hidden;
    border-radius: 20px;
    margin: 1vh;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(236, 72, 153, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.3) 0%, transparent 50%);
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(2px);
}

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 2rem;
}

.brand-name {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fadeInUp 1s ease-out;
}

.tagline {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    animation: fadeInUp 1s ease-out 0.2s both;
}

.bio {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 2rem;
    line-height: 1.6;
    animation: fadeInUp 1s ease-out 0.3s both;
}

/* Social Links */
.social-links {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    animation: fadeInUp 1s ease-out 0.4s both;
}

.social-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.social-link:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
}

.social-link svg {
    flex-shrink: 0;
}

.social-link span {
    font-size: 0.875rem;
    letter-spacing: 0.05em;
}

/* Responsive Social Links */
@media (max-width: 640px) {
    .social-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .social-link {
        width: 100%;
        max-width: 250px;
        justify-content: center;
    }
}


@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 3;
    animation: bounce 2s infinite;
}

.scroll-indicator span {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    40% {
        transform: translateX(-50%) translateY(-10px);
    }
    60% {
        transform: translateX(-50%) translateY(-5px);
    }
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 4rem 2rem;
}

.tracks-section {
    margin-bottom: 4rem;
}

.section-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 3rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Tracks Grid */
.tracks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.track-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s ease;
}

.track-card.reveal {
    opacity: 1;
    transform: translateY(0);
}

/* Stabilize on mobile to prevent flicker */
@media (hover: none) and (pointer: coarse) {
    .track-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .track-card.reveal {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

.track-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
    border-color: var(--primary-color);
}

/* Mobile auto-focus: apply hover-like effects when card is 100% in viewport */
@media (hover: none) and (pointer: coarse) {
    .track-card.focused {
        transform: translateY(-8px);
        box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
        border-color: var(--primary-color);
    }
    
    .track-card.focused .track-artwork img {
        transform: scale(1.05);
        transition: transform 0.3s ease-in-out; /* Apply transition to the 'transform' property */
        /* Webkit prefix for older iOS/Safari compatibility (though generally not needed for modern iOS) */
        -webkit-transition: transform 0.3s ease-in-out;
    }
    
    .track-card.focused .play-overlay {
        /*background: rgba(15, 23, 42, 0.5);*/
        opacity: 1;
    }
}

.track-card.playing {
    border-color: var(--secondary-color);
    box-shadow: 0 20px 40px rgba(236, 72, 153, 0.3);
}

.track-artwork {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--darker-bg) 100%);
    /* Prevent iOS rendering issues */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    isolation: isolate;
}

.track-artwork img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    /* Prevent iOS Safari from blurring images */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Ensure crisp image rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.track-artwork-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-1);
    font-size: 4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.track-card:hover .track-artwork img {
    transform: scale(1.05);
    transition: transform 0.3s ease-in-out; /* Apply transition to the 'transform' property */
    /* Webkit prefix for older iOS/Safari compatibility (though generally not needed for modern iOS) */
    -webkit-transition: transform 0.3s ease-in-out;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    /*backdrop-filter: blur(4px);*/
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    /* Prevent repaint issues on iOS */
    will-change: opacity;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.play-overlay > * {
    pointer-events: auto;
}

.track-card:hover .play-overlay,
.track-card.playing .play-overlay {
    opacity: 1;
}

/* Always show play button on mobile/touch devices - WITHOUT backdrop blur */
@media (hover: none) and (pointer: coarse) {
    .play-overlay {
        /* Remove backdrop-filter to prevent image blur on iOS */
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        /* Make overlay transparent so images aren't blurred */
        background: transparent;
        /* Always show the button - IMPORTANT: set to 1 and keep it stable */
        opacity: 1 !important;
        /* Prevent iOS from changing this */
        will-change: auto;
    }
    
    .track-card.playing .play-overlay {
        /* Add slight overlay only when playing */
        background: rgba(15, 23, 42, 0.3);
    }
}

.play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.3);
    /* Ensure visibility */
    position: relative;
    z-index: 10;
    /* Better touch target */
    -webkit-tap-highlight-color: transparent;
    /* Add subtle backdrop blur to button itself on mobile for contrast */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.5);
}

.play-btn:active {
    transform: scale(0.95);
}

.track-card.playing .play-btn {
    background: var(--gradient-2);
}

.track-info {
    padding: 1.5rem;
}

.track-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.track-artist {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.track-duration {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 300;
}

.waveform-container {
    padding: 0 1.5rem 1.5rem;
    min-height: 80px;
    overflow: hidden;
    /* Stabilize container on iOS */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    position: relative;
}

.waveform-container canvas {
    display: block;
    width: 100%;
    height: 60px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Force hardware acceleration on iOS */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Prevent touch callout on long press */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    /* Prevent iOS from clearing canvas during scroll */
    will-change: contents;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Force compositing layer */
    isolation: isolate;
}

/* Footer */
.site-footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 3rem 2rem;
    text-align: center;
}

.footer-content p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.footer-tagline {
    font-size: 0.875rem;
    font-weight: 300;
    font-style: italic;
}

.footer-social {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.footer-social a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    color: var(--text-muted);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.footer-social a:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.footer-copyright {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tracks-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .container {
        padding: 2rem 1rem;
    }
    
    .hero-content {
        padding: 1rem;
    }
    
    .social-icon {
        width: 40px;
        height: 40px;
    }
    
    .play-btn {
        width: 70px;
        height: 70px;
        /* Add a semi-transparent background for better visibility on mobile */
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
        box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
    }
    
    .play-btn svg {
        width: 36px !important;
        height: 36px !important;
    }
    
    /* Ensure waveform is visible */
    .waveform-container {
        padding: 0 1rem 1rem;
    }
    
    /* Prevent image blur on mobile */
    .track-artwork img {
        image-rendering: auto;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .tracks-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1400px) {
    .tracks-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Loading animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Focus styles for accessibility */
.play-btn:focus-visible,
.social-icon:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}
