/**
 * Tracknit Library — Archive Page Styles
 *
 * Covers the Music (/music) and SFX (/sfx) archive pages.
 * Applies to elements rendered by archive-track.php and archive-sfx.php.
 * Tailwind CDN covers utilities; this file handles custom behaviour
 * (waveforms, hover states, active track, AJAX loading, etc.)
 *
 * @package Tracknit
 */

/* ── Root Tokens ── */
:root {
    --tn-primary:     #7CFF00;
    --tn-bg:          #060606;
    --tn-bg-sidebar:  #0a0a0a;
    --tn-border:      rgba(255, 255, 255, 0.04);
    --tn-radius-row:  16px;
    --tn-transition:  cubic-bezier(0.16, 1, 0.3, 1);
}

/* ══════════════════════════════════════════════════════════════════
   WORDPRESS THEME ISOLATION
   Prevents WP theme, admin bar, and plugin CSS from bleeding
   into Tracknit custom templates.
══════════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
}

/* Kill WP admin bar offset on Tracknit pages */
html { margin-top: 0 !important; }
#wpadminbar { display: none !important; }

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--tn-bg) !important;
    font-family: 'Inter', sans-serif !important;
}

/* Reset WP theme heading/link styles */
body h1, body h2, body h3, body h4, body h5, body h6 {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    line-height: 1.2;
}

body a { text-decoration: none; color: inherit; }
body a:hover { text-decoration: none; }

/* ══════════════════════════════════════════════════════════════════
   SCROLLBARS
══════════════════════════════════════════════════════════════════ */

::-webkit-scrollbar              { width: 5px; height: 5px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: #2a2a2a; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover  { background: #3a3a3a; }

/* ══════════════════════════════════════════════════════════════════
   WAVEFORM BARS (archive rows)
   Mirrors the inline CSS in archive-track.php so transitions smoother
══════════════════════════════════════════════════════════════════ */

.waveform-bars {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 32px;
    width: 100%;
    overflow: hidden;
    opacity: 0.5;
    transition: opacity 0.25s ease;
    cursor: pointer;
}

.group:hover .waveform-bars {
    opacity: 1;
}

.tn-row-active .waveform-bars {
    opacity: 1;
}

.waveform-top {
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 50%;
}

.waveform-bottom {
    display: flex;
    align-items: flex-start;
    gap: 1.5px;
    height: 50%;
    transform: scaleY(0.35);
    transform-origin: top center;
    margin-top: 1px;
    opacity: 0.5;
}

.waveform-bar {
    width: 1.5px;
    background-color: #3f3f46;
    border-radius: 2px 2px 0 0;
    transition: background-color 0.2s ease, height 0.2s ease;
    flex-shrink: 0;
}

.group:hover .waveform-bar {
    background-color: #71717a;
}

/* Active playing track — bars turn primary green */
.tn-row-active .waveform-bar {
    background-color: rgba(124, 255, 0, 0.6);
    animation: tn-bar-pulse 1.5s ease-in-out infinite;
}

@keyframes tn-bar-pulse {
    0%, 100% { opacity: 0.6; }
    50%       { opacity: 1; }
}

/* Played bars (synced from player.js updateProgress) */
.waveform-bar.played {
    background-color: var(--tn-primary) !important;
}
.waveform-bar.playhead {
    background-color: white !important;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* ══════════════════════════════════════════════════════════════════
   TRACK ROWS
══════════════════════════════════════════════════════════════════ */

.track-item {
    border-radius: var(--tn-radius-row);
    border: 1px solid transparent;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
    position: relative;
    cursor: pointer;
}

.track-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.04);
}

/* Active (currently playing) row */
.track-item.tn-row-active {
    background-color: rgba(124, 255, 0, 0.03) !important;
    border-color: rgba(124, 255, 0, 0.10) !important;
}

/* ── Album art thumbnail ── */
.track-play-btn {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
}

.play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.60);
    backdrop-filter: blur(1px);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.track-item:hover .play-overlay,
.track-item.tn-row-active .play-overlay {
    opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   SEARCH INPUT
══════════════════════════════════════════════════════════════════ */

#track-search-input,
#sfx-search-input {
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
    /* Tailwind handles the base styles; overrides go here */
}

/* Loading glow (added by search.js while debouncing) */
#track-search-input.tn-search-thinking,
#sfx-search-input.tn-search-thinking {
    box-shadow: 0 0 20px rgba(124, 255, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.4);
    border-color: rgba(124, 255, 0, 0.3) !important;
}

/* ══════════════════════════════════════════════════════════════════
   Tracknit LIST CONTAINER (AJAX target)
══════════════════════════════════════════════════════════════════ */

#Tracknit-list-container {
    /* Smooth fade during AJAX swap — opacity controlled by search.js */
    transition: opacity 0.2s ease;
    min-height: 200px; /* Prevent layout collapse during loading */
}

/* ── Loading skeleton placeholder ── */
.tn-skeleton {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.03) 25%,
        rgba(255, 255, 255, 0.06) 50%,
        rgba(255, 255, 255, 0.03) 75%
    );
    background-size: 200% 100%;
    animation: tn-skeleton-shine 1.5s ease-in-out infinite;
    border-radius: 8px;
}

@keyframes tn-skeleton-shine {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════════════════ */

.tn-empty-state {
    padding: 80px 0;
    text-align: center;
    color: #525252;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════════════
   GENRE TAGS / FILTER CHIPS
══════════════════════════════════════════════════════════════════ */

.tn-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #737373;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.tn-tag:hover, .tn-tag.active {
    background: rgba(124, 255, 0, 0.08);
    border-color: rgba(124, 255, 0, 0.25);
    color: var(--tn-primary);
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════════════ */

aside {
    /* Custom scrollbar inside sidebar */
}

aside::-webkit-scrollbar { width: 3px; }

/* ── Sidebar navigation active state ── */
.sidebar-link-active span {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

/* ══════════════════════════════════════════════════════════════════
   FEATURED BANNER
══════════════════════════════════════════════════════════════════ */

.tn-featured-banner {
    border-radius: 40px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: #111;
}

.tn-featured-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 2s ease;
}

.tn-featured-banner:hover img {
    transform: scale(1.02);
}

.tn-featured-banner .tn-banner-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 60%, transparent 100%);
}

/* ══════════════════════════════════════════════════════════════════
   PROFILE POPOVER
══════════════════════════════════════════════════════════════════ */

#profile-menu {
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 6px 0;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
    animation: tn-menu-in 0.2s var(--tn-transition);
    transform-origin: bottom left;
}

@keyframes tn-menu-in {
    from { opacity: 0; transform: scale(0.95) translateY(4px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .waveform-bars { display: none; }
}

@media (max-width: 768px) {
    .track-item { border-radius: 12px; }
}

/* ══════════════════════════════════════════════════════════════════
   ENTRANCE ANIMATIONS (replaces Framer Motion)
   Provides the cinematic staggered-in feel from the Next.js build.
══════════════════════════════════════════════════════════════════ */

/* Hero banner entrance */
.tn-featured-banner,
section > .group {
    opacity: 0;
    transform: translateY(16px);
    animation: tn-hero-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

@keyframes tn-hero-in {
    to { opacity: 1; transform: translateY(0); }
}

/* Staggered track row entrance */
.track-item {
    opacity: 0;
    transform: translateY(10px);
    animation: tn-row-in 0.35s ease forwards;
}

@keyframes tn-row-in {
    to { opacity: 1; transform: translateY(0); }
}

/* Generate stagger delays for first 20 rows */
.track-item:nth-child(1)  { animation-delay: 0.03s; }
.track-item:nth-child(2)  { animation-delay: 0.06s; }
.track-item:nth-child(3)  { animation-delay: 0.09s; }
.track-item:nth-child(4)  { animation-delay: 0.12s; }
.track-item:nth-child(5)  { animation-delay: 0.15s; }
.track-item:nth-child(6)  { animation-delay: 0.18s; }
.track-item:nth-child(7)  { animation-delay: 0.21s; }
.track-item:nth-child(8)  { animation-delay: 0.24s; }
.track-item:nth-child(9)  { animation-delay: 0.27s; }
.track-item:nth-child(10) { animation-delay: 0.30s; }
.track-item:nth-child(11) { animation-delay: 0.33s; }
.track-item:nth-child(12) { animation-delay: 0.36s; }
.track-item:nth-child(13) { animation-delay: 0.39s; }
.track-item:nth-child(14) { animation-delay: 0.42s; }
.track-item:nth-child(15) { animation-delay: 0.45s; }
.track-item:nth-child(n+16) { animation-delay: 0.48s; }

/* Page-level fade-in for pricing/how-it-works */
.animate-in {
    opacity: 0;
    transform: translateY(10px);
    animation: tn-hero-in 0.7s ease-out forwards;
}

/* ══════════════════════════════════════════════════════════════════
   PORTED NEXT.JS UTILITY CLASSES (from globals.css)
   These provide the premium neon/glass effects missing from the
   Tailwind CDN-only setup.
══════════════════════════════════════════════════════════════════ */

.neon-glow {
    box-shadow: 0 0 20px rgba(124, 255, 0, 0.2);
}
.neon-glow-strong:hover {
    box-shadow: 0 0 30px rgba(124, 255, 0, 0.4);
}
.text-gradient-green {
    background: linear-gradient(180deg, #F0F5ED 0%, #7CFF00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.glass-nav {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(8, 8, 8, 0.8);
}
.soft-neon-orb {
    background: radial-gradient(circle, rgba(124, 255, 0, 0.15) 0%, rgba(124, 255, 0, 0) 70%);
    filter: blur(40px);
}
.glow-primary {
    text-shadow: 0 0 10px rgba(124, 255, 0, 0.4);
}
.glow-box {
    box-shadow: 0 0 15px rgba(124, 255, 0, 0.3);
}
.bg-primary-soft {
    background-color: rgba(124, 255, 0, 0.05);
}
.animate-gradient {
    animation: tn-gradient-xy 15s ease infinite;
}
@keyframes tn-gradient-xy {
    0%, 100% { background-position: 0% 50%; }
    50%      { background-position: 100% 50%; }
}

/* ══════════════════════════════════════════════════════════════════
   FILTER OVERLAY TRANSITIONS
   Replaces hard classList.toggle('hidden') with smooth CSS.
══════════════════════════════════════════════════════════════════ */

#search-filter-overlay {
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
#search-filter-overlay:not(.hidden) {
    pointer-events: auto;
}

/* ══════════════════════════════════════════════════════════════════
   PROFILE MENU TRANSITIONS
   Smooth open/close instead of instant toggle.
══════════════════════════════════════════════════════════════════ */

#profile-menu {
    transition: opacity 0.2s var(--tn-transition), transform 0.2s var(--tn-transition);
}
#profile-menu.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(4px);
    pointer-events: none;
}
