/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --bg: #050505;
    --surface: rgba(255, 215, 0, 0.03);
    --border: rgba(255, 215, 0, 0.08);
    --border-hover: rgba(255, 215, 0, 0.22);
    --text: #e8e8ed;
    --text-muted: #9e9484;
    --gold: #d4a012;
    --gold-light: #f0c040;
    --gold-glow: rgba(212, 160, 18, 0.25);
    --radius: 16px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== ANIMATED BACKGROUND ===== */
.bg-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: var(--bg);
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    /* Reduced from 100px */
    pointer-events: none;
    opacity: 0.35;
    /* Reduced from 0.45 */
    will-change: transform;
    transform: translateZ(0);
    /* Force GPU */
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(212, 160, 18, 0.4) 0%, transparent 70%);
    top: -200px;
    left: -150px;
    animation: drift1 12s ease-in-out infinite alternate;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 200, 50, 0.3) 0%, transparent 70%);
    bottom: -180px;
    right: -120px;
    animation: drift2 14s ease-in-out infinite alternate;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(180, 130, 10, 0.25) 0%, transparent 70%);
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: drift3 10s ease-in-out infinite alternate;
}

.glow-cursor {
    position: fixed;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.12) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    filter: blur(50px);
    /* Slightly reduced */
    will-change: transform;
    transform: translateZ(0);
}

@keyframes drift1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(80px, 60px) scale(1.15);
    }

    100% {
        transform: translate(-40px, 100px) scale(0.95);
    }
}

@keyframes drift2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(-70px, -50px) scale(1.1);
    }

    100% {
        transform: translate(60px, -80px) scale(0.9);
    }
}

@keyframes drift3 {
    0% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-40%, -60%) scale(1.2);
    }

    100% {
        transform: translate(-60%, -40%) scale(0.85);
    }
}

/* ===== CONTAINER ===== */
.container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 60px 24px 80px;
}

/* ===== HERO ===== */
.hero {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeDown 0.6s ease-out both;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, #fff 20%, var(--gold-light) 50%, #fff 80%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textShimmer 6s ease-in-out infinite;
}

.hero p {
    margin-top: 12px;
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

@keyframes textShimmer {

    0%,
    100% {
        background-position: 0% center;
    }

    50% {
        background-position: 200% center;
    }
}

/* ===== BEATS GRID ===== */
.beats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

/* ===== BEAT CARD ===== */
.beat-card {
    display: flex;
    flex-direction: column;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: all var(--transition);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: fadeUp 0.5s ease-out both;
    animation-delay: calc(var(--delay) * 0.07s);
    contain: layout paint;
    content-visibility: auto;
    contain-intrinsic-size: 260px;
}

.beat-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    background: rgba(255, 215, 0, 0.06);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 30px var(--gold-glow);
}

/* ===== BEAT HEADER ===== */
.beat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.beat-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.beat-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold-light);
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* ===== AUDIO PLAYER (iframe embed) ===== */
.beat-player-wrapper {
    position: relative;
    width: 100%;
    height: 80px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    overflow: hidden;
    contain: strict;
}

.beat-player {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.preview-trigger {
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}

.preview-trigger:hover {
    border-color: rgba(255, 215, 0, 0.35);
    background: rgba(255, 215, 0, 0.08);
    color: var(--text);
}

.preview-trigger:disabled {
    cursor: default;
    opacity: 0.75;
}

/* Audio players no longer use a pulse animation to prevent "breathing" effect */

/* ===== BEAT ACTIONS ===== */
.beat-actions {
    display: flex;
    gap: 10px;
}

.btn-buy {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    letter-spacing: 0.01em;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #0a0a0a;
    box-shadow: 0 4px 16px rgba(212, 160, 18, 0.3);
}

.btn-buy:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(212, 160, 18, 0.45);
    filter: brightness(1.1);
}

.btn-buy:active {
    transform: translateY(0);
}

.btn-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* ===== BEAT TAG ===== */
.beat-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 3px 10px;
    border-radius: 6px;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ===== BACK BUTTON ===== */
.back-wrapper {
    text-align: center;
}

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition);
    animation: fadeUp 0.5s ease-out 0.6s both;
}

.back-button:hover {
    color: #fff;
    background: rgba(255, 215, 0, 0.06);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px var(--gold-glow);
}

/* ===== LOADING STATE ===== */
.beats-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    animation: fadeUp 0.5s ease-out both;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 215, 0, 0.1);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== EMPTY STATE ===== */
.beats-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
    font-size: 0.95rem;
    animation: fadeUp 0.5s ease-out both;
}

.beats-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

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

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.3);
}

@media (max-width: 768px), (pointer: coarse) {
    .bg-canvas {
        display: none;
    }

    body {
        background: radial-gradient(circle at 20% 0%, #18120a 0%, #050505 55%);
    }

    .glow {
        filter: blur(50px);
        opacity: 0.2;
    }

    .glow-1 {
        width: 400px;
        height: 400px;
    }

    .glow-2 {
        width: 300px;
        height: 300px;
    }

    .glow-3 {
        width: 250px;
        height: 250px;
    }

    .link-card,
    .beat-card,
    .setup-item {
        backdrop-filter: none !important;
        /* Disabling backdrop filter on mobile is the biggest performance win */
        -webkit-backdrop-filter: none !important;
        background: rgba(20, 20, 20, 0.8);
        /* Solid-ish fallback */
    }

    .hero,
    .hero h1,
    .beat-card,
    .beats-loading,
    .beats-empty,
    .back-button {
        animation: none !important;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .container {
        padding: 40px 16px 60px;
    }

    .hero h1 {
        font-size: 2.2rem;
    }

    .beats-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .beat-card {
        padding: 20px;
    }

    .beat-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .beat-actions {
        flex-direction: column;
    }

    .back-button {
        padding: 12px 24px;
        font-size: 0.85rem;
    }
}
