/* Shared Styles */
body {
    background: linear-gradient(to bottom, #ff4500, #8b0000, #4b0082);
    background-attachment: fixed;
    color: #fff;
    font-family: 'Arial', sans-serif;
    text-align: center;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

.logo {
    max-width: 200px;
    margin: 20px auto;
    transition: all 0.3s ease;
    animation: initialSpin 1s ease-out;  /* Initial spin animation */
}

.logo:hover {
    transform: scale(1.05) rotate(5deg);
}

h1 {
    font-size: 2.5em;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 1);
    margin-top: 10px;
    margin-bottom: 10px;
}

h2 {
    font-size: 1.5em;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 1);
    margin-top: 5px;
    margin-bottom: 20px;
}

.content {
    text-align: left;
    margin: 0 auto;
    max-width: 800px; /* Optional: Keeps the content narrow and readable */
    line-height: 1.6; /* Optional: Improves readability */
}

/* Hyperlink Styles */
a {
    color: #ffdd00; /* Bright yellow for visibility */
    text-decoration: underline;
}

a:hover {
    color: #ffffff; /* White on hover for clarity */
}

/* Code Formatting */
pre {
    background-color: #000; /* Black background */
    color: #ffdd00; /* Yellow text */
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto; /* Enables horizontal scrolling for long lines */
    font-family: 'Courier New', Courier, monospace; /* Monospaced font */
}


/* Index-specific Styles */
/* Album List Styles */
.album-list {
    max-width: 600px; /* Ensure it doesn't exceed catalog width */
    margin: 20px auto;
    padding: 20px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8);
}

.album-item {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space text and icon properly */
    padding: 10px;
    margin-bottom: 10px;
    color: #ffdd00;
    text-decoration: none;
    font-size: 1.2em;
    border-radius: 5px;
    background: rgba(75, 0, 130, 0.3);
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
    box-shadow: 2px 2px 0px rgba(0, 0, 0, 1);
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: calc(var(--animation-order, 0) * 0.1s);
}

.album-item:hover {
    background: rgba(255, 69, 0, 0.6);
    color: #fff;
    box-shadow: 3px 3px 0px rgba(0, 0, 0, 1);
}

.album-item img {
    width: 30px;
    height: 30px;
    margin-left: 10px; /* Space between text and icon */
    order: 2; /* Icon on the right */
}

.album-item span {
    text-align: left;
    max-width: calc(100% - 50px); /* Prevent full width */
    flex-shrink: 1; /* Prevent span from growing unnecessarily */
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Load Tape Section */
.manual-album-entry {
    margin: 20px auto;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.manual-album-entry input {
    flex: 1;
    max-width: 500px;
    padding: 10px;
    font-size: 1em;
    border: 1px solid rgba(255, 69, 0, 0.6);
    border-radius: 5px;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.manual-album-entry button {
    padding: 10px;
    background-color: #ff4500;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 1);
}

.manual-album-entry button:hover {
    background-color: #ff6347;
    box-shadow: 3px 3px 7px rgba(0, 0, 0, 1);
}

.manual-album-entry button img {
    width: 24px;
    height: 24px;
}

#info-button {
    margin-left: 10px;
    padding: 8px;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    background-color: #444;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
}

#info-button:hover {
    background-color: #666;
}


/* Player-specific Styles */

#album-cover {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    margin: 10px auto;
    border: 1px solid #000;
    border-radius: 5px;
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
    object-fit: contain;
    transition: all 0.3s ease;
    padding: 3px;
    display: block;
    opacity: 0;  /* Start invisible */
    animation: fadeIn 1s ease-in forwards;  /* Initial fade in */
    cursor: pointer;
}

/* Only add gradient effects during playback, don't touch opacity */
#album-cover.is-playing {
    opacity: 1;  /* Ensure visibility during playback */
    background: linear-gradient(45deg, #ff4500, #8b0000, #4b0082, #ff4500);
    background-size: 300% 300%;
    animation: 
        fadeIn 1s ease-in forwards,  /* Keep the fade in */
        albumPulse 2s infinite ease-in-out,
        gradientBorder 8s ease infinite;
}

#album-cover:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.4);
}

/* Keep existing animations */
@keyframes gradientBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes albumPulse {
    0% { box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6); }
    50% { box-shadow: 0 0 15px rgba(255, 69, 0, 0.3); }
    100% { box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6); }
}

.media-player h3 {
    margin-bottom: 10px;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 1);
}

.controls {
    margin: 20px auto;  /* Changed from margin-top to margin to center */
    text-align: center;  /* Ensure buttons are centered */
}

.controls button {
    margin: 0 5px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #444;
    color: #fff;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 1);
    transition: all 0.2s ease;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.controls button:hover {
    background-color: #666;
    transform: translateY(-2px);
    box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.8);
}

.controls button:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}

#eject-button {
    background-color: #8b0000; /* Dark red */
}

#eject-button:hover {
    background-color: #ff4500; /* Bright red on hover */
}


/* Tracklist Table Styles */
.tracklist {
    margin-top: 30px;
    text-align: left;
    max-width: 600px;
    margin: 20px auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.tracklist table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
}

.tracklist th,
.tracklist td {
    padding: 10px;
    text-align: left;
    color: #ffdd00;
}

/* Remove hover effect from header row */
.tracklist thead tr:hover {
    background: none;
    cursor: default;
}

/* Only apply hover effect to tbody rows */
.tracklist tbody tr:hover {
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

/* Style for currently playing track */
.tracklist tr.active {
    background: rgba(255, 69, 0, 0.3);
}

/* Keep existing styles */
.tracklist tr {
    border-bottom: 1px solid rgba(255, 69, 0, 0.6);
}

.tracklist tr:last-child {
    border-bottom: none;
}


/* Laser Visualizer Canvas */
#laser-visualizer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: -1;
    display: none; /* Hidden until activated */
    pointer-events: none;
}


/* Toggle Button */
#toggle-visualizer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 15px;
    font-size: 14px;
    color: #fff;
    background-color: #444;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    z-index: 10;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.8);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

#toggle-visualizer:hover {
    background-color: #666;
    box-shadow: 3px 3px 7px rgba(0, 0, 0, 1);
}

/* Optional: Add a laser icon to the button */
#toggle-visualizer::before {
    content: "⚡"; /* Replace with an appropriate icon or emoji */
    margin-right: 5px;
    font-size: 1.2em;
    color: #ff4500; /* Laser-like color */
}

/* Responsive Adjustments */
@media (max-width: 600px) {
    #toggle-visualizer {
        bottom: 10px;
        right: 10px;
        font-size: 12px;
        padding: 8px 12px;
    }

    #toggle-visualizer::before {
        font-size: 1em; /* Adjust icon size */
    }
}

#current-track-title {
    transition: opacity 0.3s ease;
}

#current-track-title.changing {
    opacity: 0;
}

/* Add loading spinner styles */
.loading-spinner {
    display: none;  /* Hidden by default */
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 69, 0, 0.3);
    border-radius: 50%;
    border-top-color: #ff4500;
    animation: spin 1s linear infinite;
    margin: 10px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Add loading state */
#album-cover.loading {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    30% { opacity: 0; } /* Add a small delay before starting */
    100% { opacity: 1; }
}

#back-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #444;
    color: #fff;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 1);
    transition: all 0.2s ease;
    z-index: 1000;
}

#back-button:hover {
    background-color: #666;
    transform: translateX(-2px);
}

#back-button:active {
    transform: translateX(1px);
}

/* Enhanced loading state */
.loading-message {
    text-align: center;
    padding: 20px;
    color: #fff;
    animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Shared button styles */
#load-tape button {
    margin: 0 5px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    color: #fff;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 1);
    transition: all 0.2s ease;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

/* Load tape button specific */
#load-album-button {
    background-color: #ff4500;
}

#load-album-button:hover {
    background-color: #ff6347;
    transform: translateY(-2px);
    box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.8);
}

/* Info button specific */
#info-button {
    background-color: #444;
}

#info-button:hover {
    background-color: #666;
    transform: translateY(-2px);
    box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.8);
}

/* Shared active state */
#load-tape button:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}

@keyframes initialSpin {
    0% {
        transform: rotate(-180deg) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: rotate(0) scale(1);
        opacity: 1;
    }
}

/* Simple fade in for contribute page logo */
.contribute-page #app-logo {
    opacity: 0;
    animation: fadeIn 1s ease-in forwards;
}

.contribute-page #app-logo.loading {
    animation: fadeIn 1s ease-in forwards;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.modal-content {
    margin: auto;
    display: block;
    position: relative;
    top: 50%;
    transform: translateY(-50%);
    max-width: 90%;
    max-height: 90vh;
}

#modal-cover-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 90vh;
    display: block;
    margin: auto;
    border: 2px solid #444;
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.4);
}

.close-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

/* Update modal styles for mobile */
@media (max-width: 768px) {
    .modal-content {
        max-width: 100%;
        margin: 0;
        padding: 10px;
    }

    #modal-cover-image {
        max-height: 80vh; /* Slightly smaller on mobile to ensure close button visibility */
        width: 100%;
        object-fit: contain;
    }

    .close-modal {
        right: 10px;
        top: 10px;
        font-size: 36px; /* Slightly smaller but still tappable */
        padding: 10px; /* Larger tap target */
    }
}

/* Add touch feedback */
@media (hover: none) {
    .close-modal:active {
        color: #ff4500;
        transform: scale(0.95);
    }

    #album-cover:active {
        transform: scale(0.98); /* Subtle feedback on touch */
    }
}

/* Cassette Grid Layout */
.cassette-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Cassette Design */
.cassette {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.3s ease;
}

.cassette:hover {
    transform: translateY(-5px);
}

.cassette-body {
    background: #2a2a2a;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.cassette-window {
    background: #000;
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
    aspect-ratio: 1;
    overflow: hidden;
    position: relative; /* Ensure relative positioning for icon centering */
}

.cassette-window img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 2px;
}

.cassette-label {
    background: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.cassette-band {
    font-weight: bold;
    color: #ff4500;
    margin-bottom: 5px;
    font-size: 1.1em;
}

.cassette-title {
    color: #fff;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.cassette-date {
    color: #888;
    font-size: 0.8em;
}

.cassette-reels {
    height: 20px;
    background: linear-gradient(90deg, #444 25%, #666 25%, #666 50%, #444 50%, #444 75%, #666 75%);
    background-size: 20px 20px;
    border-radius: 2px;
    animation: reelSpin 2s linear infinite;
}

@keyframes reelSpin {
    0% { background-position: 0 0; }
    100% { background-position: 40px 0; }
}

/* Loading Message */
.loading-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
}

.loading-spinner {
    border: 4px solid #333;
    border-top: 4px solid #ff4500;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Video Cassette Styles */
.video-cassette {
    background: linear-gradient(135deg, #1a1a2a, #2a2a3a); /* Gradient background for video */
    border: 2px solid #ff4500; /* Orange border for video */
    box-shadow: 0 4px 16px rgba(255, 69, 0, 0.25), 0 4px 8px rgba(0,0,0,0.3); /* Add strong shadow for video */
}

.video-cassette .cassette-window {
    position: relative;
    border: 1px solid #ff4500; /* Orange border for video window */
}

.video-cassette .cassette-label {
    background: #1a1a2a;
    border: 1px solid #ff4500;
}

.video-cassette .cassette-band {
    color: #ff4500;
    text-shadow: 0 0 5px rgba(255, 69, 0, 0.3);
}

/* Media Icons */
.media-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #ff4500;
    font-size: 2.2em;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 69, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Remove padding for true centering */
    line-height: 1;
}

.video-icon {
    background: rgba(26, 26, 42, 0.9);
    border: 2px solid #ff4500;
}

.audio-icon {
    background: rgba(42, 42, 42, 0.9);
    border: 2px solid #666;
    font-size: 1.8em; /* Slightly smaller to match video icon visual weight */
}

/* Hover Effects */
.cassette:hover .media-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.cassette:hover .cassette-reels {
    animation: reelSpin 2s linear infinite;
}

/* Remove default reel animation */
.cassette-reels {
    animation: none;
}

/* Audio Cassette Specific */
.audio-cassette {
    background: #2a2a2a;
    border: 2px solid #444;
}

.audio-cassette .cassette-window {
    border: 1px solid #444;
}

.audio-cassette .cassette-label {
    background: #1a1a1a;
    border: 1px solid #444;
}

@media (max-width: 600px) {
    .cassette-grid {
        gap: 0.75rem;
        padding: 0.5rem;
    }
    .cassette-body {
        padding: 8px;
    }
    .cassette-window {
        padding: 4px;
        margin-bottom: 7px;
    }
    .cassette-label {
        padding: 6px;
        margin-bottom: 5px;
    }
    .cassette-band {
        font-size: 1em;
    }
    .cassette-title {
        font-size: 0.85em;
    }
    .cassette-date {
        font-size: 0.7em;
    }
    .media-icon {
        width: 36px;
        height: 36px;
        font-size: 1.5em;
    }
}