/**
 * Tracknit — Sticky Audio Player Styles
 *
 * Covers the #Tracknit-global-player bar injected by player.js.
 * Works with Tailwind CDN for utility classes and defines the
 * parts that require custom CSS (animations, transitions, etc.)
 *
 * @package Tracknit
 */

/* ── Import Font (fallback when Tailwind CDN isn't loaded first) ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Root Tokens (match Tailwind config) ── */
:root {
    --tn-primary:        #7CFF00;
    --tn-primary-dim:    rgba(124, 255, 0, 0.15);
    --tn-bg-player:      #0b0b0e;
    --tn-border:         rgba(255, 255, 255, 0.08);
    --tn-player-height:  90px;
    --tn-radius-pill:    9999px;
    --tn-transition:     cubic-bezier(0.16, 1, 0.3, 1);
}

/* ══════════════════════════════════════════════════════════════════
   PLAYER CONTAINER
══════════════════════════════════════════════════════════════════ */

#Tracknit-global-player {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9000;
    transform: translateY(100%);
    transition: transform 0.5s var(--tn-transition);
    pointer-events: none;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

#Tracknit-global-player.player-visible {
    transform: translateY(0);
    pointer-events: auto;
}

/* Inner chrome */
#Tracknit-global-player .tn-player-chrome {
    background: var(--tn-bg-player);
    border-top: 1px solid var(--tn-border);
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    position: relative;
    pointer-events: auto;
    height: var(--tn-player-height);
}

/* ══════════════════════════════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════════════════════════════ */

#tn-progress-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    z-index: 10;
    transition: height 0.15s ease;
}

#tn-progress-container:hover {
    height: 5px;
}

#tn-progress-bar {
    height: 100%;
    background: var(--tn-primary);
    width: 0;
    will-change: width;
    position: relative;
    box-shadow: 0 0 8px rgba(124, 255, 0, 0.5);
    transition: box-shadow 0.3s ease;
}

/* Scrubber handle — only visible on hover over the progress bar */
#tn-progress-bar::after {
    content: '';
    position: absolute;
    right: -4px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    opacity: 0;
    box-shadow: 0 0 8px rgba(124, 255, 0, 0.8);
    transition: opacity 0.15s ease;
}

#tn-progress-container:hover #tn-progress-bar::after {
    opacity: 1;
}

/* ══════════════════════════════════════════════════════════════════
   PLAYER INNER LAYOUT (max-width wrapper)
══════════════════════════════════════════════════════════════════ */

.tn-player-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    height: var(--tn-player-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

/* ══════════════════════════════════════════════════════════════════
   TRACK INFO (Left Section)
══════════════════════════════════════════════════════════════════ */

.tn-track-info {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 30%;
    min-width: 180px;
    overflow: hidden;
}

#tn-player-img-container {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

#tn-player-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#tn-player-img-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #444;
    background: #1a1a1a;
    letter-spacing: 0.05em;
}

#tn-player-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    margin-bottom: 2px;
}

#tn-player-artist {
    font-size: 12px;
    font-weight: 500;
    color: #737373;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ══════════════════════════════════════════════════════════════════
   CONTROLS (Centre Section)
══════════════════════════════════════════════════════════════════ */

.tn-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 520px;
}

.tn-controls-buttons {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* ── Play/Pause Button ── */
#tn-play-pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.3s ease;
    outline: none;
    flex-shrink: 0;
}

#tn-play-pause-btn:hover {
    background: var(--tn-primary);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(124, 255, 0, 0.4);
}

#tn-play-pause-btn:active {
    transform: scale(0.96);
}

#tn-play-pause-btn svg {
    color: #000;
    width: 18px;
    height: 18px;
}

/* ── Skip / Rewind buttons ── */
.tn-skip-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #525252;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, background 0.2s ease;
    outline: none;
}

.tn-skip-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

/* ── Time display ── */
#tn-time-display {
    font-size: 11px;
    font-weight: 700;
    color: #525252;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

/* ══════════════════════════════════════════════════════════════════
   RIGHT CONTROLS (Volume, Close)
══════════════════════════════════════════════════════════════════ */

.tn-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 30%;
    min-width: 140px;
    justify-content: flex-end;
}

/* ── Volume slider ── */
.tn-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

#tn-volume-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #525252;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    outline: none;
}
#tn-volume-btn:hover { color: white; }

#tn-volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 3px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
    transition: height 0.15s ease;
}
#tn-volume-slider:hover { height: 5px; }
#tn-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(124, 255, 0, 0.5);
}
#tn-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px rgba(124, 255, 0, 0.5);
}

/* ── Close button ── */
#tn-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #3f3f46;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
    outline: none;
}
#tn-close-btn:hover { color: #ef4444; }

/* ══════════════════════════════════════════════════════════════════
   WAVEFORM MINI (inside player bar, showing currently-playing waveform)
══════════════════════════════════════════════════════════════════ */

.tn-mini-waveform {
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 20px;
    overflow: hidden;
}

.tn-mini-waveform .tn-mini-bar {
    width: 2px;
    background: var(--tn-primary);
    border-radius: 1px 1px 0 0;
    opacity: 0.7;
    animation: tn-waveform-pulse 1.4s ease-in-out infinite;
}

@keyframes tn-waveform-pulse {
    0%, 100% { transform: scaleY(1); }
    50%       { transform: scaleY(0.3); }
}

.tn-mini-bar:nth-child(2)  { animation-delay: 0.1s; }
.tn-mini-bar:nth-child(3)  { animation-delay: 0.2s; }
.tn-mini-bar:nth-child(4)  { animation-delay: 0.3s; }
.tn-mini-bar:nth-child(5)  { animation-delay: 0.4s; }
.tn-mini-bar:nth-child(6)  { animation-delay: 0.3s; }
.tn-mini-bar:nth-child(7)  { animation-delay: 0.2s; }
.tn-mini-bar:nth-child(8)  { animation-delay: 0.1s; }

/* Only animate while playing */
#Tracknit-global-player:not(.player-playing) .tn-mini-waveform .tn-mini-bar {
    animation: none;
    opacity: 0.2;
}

/* ══════════════════════════════════════════════════════════════════
   LOADING SPINNER (shown on Howler load)
══════════════════════════════════════════════════════════════════ */

.tn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: tn-spin 0.7s linear infinite;
}

@keyframes tn-spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════════
   PLAYING ROW HIGHLIGHT (on archive pages)
══════════════════════════════════════════════════════════════════ */

/* Row that is currently playing */
.tn-row-active {
    background: rgba(124, 255, 0, 0.03) !important;
    border-color: rgba(124, 255, 0, 0.08) !important;
}

/* Waveform bars inside active row turn primary coloured */
.tn-row-active .waveform-bar {
    background-color: rgba(124, 255, 0, 0.5) !important;
}
.tn-row-active:hover .waveform-bar {
    background-color: var(--tn-primary) !important;
}

/* Play overlay shows pause icon when row is active */
.tn-row-active .play-overlay {
    opacity: 1 !important;
}

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .tn-track-info {
        min-width: 0;
        width: auto;
        flex: 1;
    }
    .tn-right-controls {
        width: auto;
        min-width: 0;
    }
    .tn-volume-wrapper {
        display: none; /* Hide volume on mobile — tap the icon to toggle */
    }
    #tn-volume-slider {
        width: 60px;
    }
    #tn-player-title { font-size: 13px; }
    #tn-player-artist { font-size: 11px; }
}

@media (max-width: 480px) {
    .tn-controls-buttons { gap: 12px; }
    .tn-player-inner { padding: 0 16px; gap: 12px; }
    #tn-player-img-container { width: 40px; height: 40px; }
}
