/* General Reset */
body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: auto; /* Allow page height to expand with content */
    overflow-x: hidden; /* Prevent horizontal overflow */
    background: rgb(255, 167, 38)
}

body {
    scrollbar-width: none; /* For Firefox */
    -ms-overflow-style: none; /* For Internet Explorer and Edge */
    overflow-y: scroll; /* Allow scrolling but hide the scrollbar */
    user-select: none; /* Disable text selection */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* Internet Explorer/Edge */
    touch-action: manipulation; /* Ensure touch gestures still work */
}

body::-webkit-scrollbar {
    display: none; /* For Chrome, Safari, and Opera */
}

/* Calendar Container */
#calendar-container {
    position: relative;
    width: 100%;
    min-height: 100vh; /* Ensure it covers the full height of the viewport */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px; /* Add padding for spacing around the calendar */
    box-sizing: border-box;
    background: no-repeat center/contain; /* Ensure full background width fits */
    background-attachment: fixed; /* Keep the background image static during scroll */
    background-size: contain; /* Fit the full image within the container */
    background-color: #fff8e1; /* Fallback color */
    z-index: 0;
}

#calendar-background {
    position: absolute;
    width: 100%;
    height: 100%;
    background: no-repeat center/cover;
    z-index: 0;
    pointer-events: none; /* Prevent interaction with background */
}

/* Calendar */
#calendar {
    position: relative;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Responsive grid layout */
    gap: 10px; /* Space between boxes */
    width: 90%; /* Calendar width */
    max-width: 1200px; /* Limit calendar width */
    margin: 0 auto; /* Center calendar horizontally */
    box-sizing: border-box;
    padding-bottom: 20px; /* Add spacing at the bottom */
    z-index: 1; /* Above the background */
    opacity: 1; /* Ensure calendar is visible */
}

/* Calendar Boxes */
.calendar-box {
    position: relative;
    background: transparent;
    border: none;
    cursor: pointer;
    perspective: 1000px; /* Enable 3D flipping effect */
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    aspect-ratio: 1 / 1; /* Keeps boxes square */
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); /* Subtle shadow for gap effect */
}

.calendar-box.clickable {
    cursor: pointer;
}

.calendar-box.disabled {
    cursor: default;
    opacity: 0.5; /* Optional: visually indicate it's not clickable */
}

.calendar-box:not(.disabled):not(.opened) {
    cursor: pointer; /* Hand cursor for clickable squares */
}

/* Add a big white day number to the center */
.calendar-box .box-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: calc(1.2rem + 0.5vw); /* Responsive font size */
    font-weight: bold;
    color: white;
    z-index: 3; /* Above other elements */
    pointer-events: none;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.5); /* Default shadow for numbers */
}

.calendar-box.opened .box-label,
.calendar-box[data-day-current="true"] .box-label {
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 255, 255, 0.6); /* Stronger shadow */
}

/* Black Quadrant in Top-Right Corner */
.calendar-box::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 30%;
    height: 30%;
    background: black;
    clip-path: polygon(100% 0, 100% 100%, 0 0); /* Creates a quarter-circle effect */
    z-index: 2; /* Ensure it is above serrations */
    pointer-events: none;
}

/* Serrated Edges */
.calendar-box::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-top: 2px dashed black; /* Longer serrations */
    border-right: 2px dashed black;
    border-bottom: 2px dashed black;
    border-left: none; /* Left side for fold line */
    pointer-events: none;
    box-shadow: inset 0px 0px 6px rgba(0, 0, 0, 0.8); /* Strong shadow for cuts */
    border-radius: 4px; /* Rounded serrations */
    border-width: 2px;
}

/* Fold Lines on the Left */
.calendar-box .fold-line {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 8px;
    border-left: 2px solid black;
    border-right: 2px solid black;
    pointer-events: none;
    transform: translateX(-4px); /* Slight inset effect */
    box-shadow: inset 0px 0px 4px rgba(0, 0, 0, 0.8); /* Shadow for depth */
}

/* Chocolate Image Underneath */
.calendar-box img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1; /* Below the door */
    pointer-events: auto; /* Allow clicking */
    animation: dimBrighten 3s infinite ease-in-out; /* Chocolate dims and brightens */
}

/* Hover effect for chocolate */
.calendar-box img:hover {
    animation: wiggle 0.3s ease-in-out infinite; /* Wiggling effect */
    cursor: pointer;
}

.jiggling {
    animation: wiggle 0.3s ease-in-out infinite;
}

/* Door Flip Effect */
.calendar-box .door {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white; /* White flap */
    backface-visibility: hidden; /* Hides the back side when flipped */
    transform-origin: left; /* Rotate around the left side */
    z-index: 2;
    transition: transform 0.6s ease; /* Smooth flip effect */
}

/* Opened State */
.calendar-box.opened .door {
    transform: rotateY(-180deg); /* Flip the door back */
}

/* Dim and Brighten Animation */
@keyframes dimBrighten {
    0% {
        opacity: 1; /* Fully visible */
    }
    50% {
        opacity: 0.5; /* Translucent */
    }
    100% {
        opacity: 1; /* Fully visible */
    }
}

/* Wiggling Animation */
@keyframes wiggle {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    50% {
        transform: rotate(5deg);
    }
    75% {
        transform: rotate(-5deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

/* Popup Overlay */
#popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7); /* Semi-transparent background for overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#popup-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Popup Content */
#popup-content {
    position: relative;
    background: rgba(255, 255, 255, 0.8); /* Translucent white background */
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    text-align: center;
    box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px); /* Add a blur effect for readability */
    z-index: 3;
}

/* Popup Title */
#popup-content h1 {
    margin: 0;
    font-size: 1.8em;
    color: #333;
}

/* Wish Textarea */
#wish-text {
    width: 100%;
    height: 150px;
    margin-top: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    font-size: 1.2em;
    box-sizing: border-box;
}

header {
    background-color: #333;
    color: white;
    font-family: Arial, sans-serif;
    padding: 10px 20px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.3);
}

#header-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#music-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

#music-slider-container {
    flex: 1; /* Take up space on the right */
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.music-label {
    font-size: 1.5rem;
    cursor: pointer;
}

#music-slider {
    transform: scale(1.5);
    cursor: pointer;
}

.music-button {
    font-size: 0.7rem; /* Smaller icon size */
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.8); /* Lighter background */
    border: 1.5px solid rgba(0, 0, 0, 0.2); /* Lighter, subtler border */
    border-radius: 4px; /* Slightly rounded square button */
    color: rgba(0, 0, 0, 0.6); /* Softer gray note symbol */
    width: 20px; /* Smaller width */
    height: 20px; /* Smaller height */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.music-button:hover {
    background-color: rgba(255, 255, 255, 0.9); /* Brighter on hover */
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2); /* Slightly deeper shadow on hover */
}

.music-button:active {
    transform: scale(0.9); /* Shrink slightly on click */
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1); /* Lower shadow on click */
}

.music-button.pressed {
    background-color: rgba(0, 128, 0, 0.9);
    color: rgba(255, 255, 255, 0.85); /* Light note symbol when pressed */
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3); /* Inset shadow for pressed effect */
}

#theme-image-container {
    flex: 1; /* Take up space on the left */
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

#theme-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    display: none; /* Initially hidden */
}

#image-popover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8); /* Semi-transparent dark background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    visibility: hidden; /* Initially hidden */
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
}

#image-popover.visible {
    visibility: visible;
    opacity: 1;
}

#popover-image {
    max-width: 66vw; /* Roughly 2/3 of the viewport width */
    max-height: 66vh; /* Roughly 2/3 of the viewport height */
    border-radius: 10px;
    box-shadow: 0px 10px 20px rgba(0, 0, 0, 0.5);
    cursor: pointer; /* Indicate interactivity */
}

#audio-controls-container {
    display: flex;
    flex-direction: column; /* Stack controls and track info vertically */
    align-items: center;    /* Center the entire container */
    gap: 5px;               /* Add space between the controls and track info */
}

.audio-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid white;
    background-color: transparent;
    color: white;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.audio-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* --- Now-playing / favourite indicators --- */

/* Heart button glows steadily when the current track is one of your favourites. */
#favourites.favourite-current {
    box-shadow: 0 0 8px 2px rgba(255, 70, 90, 0.9), 0 0 18px 5px rgba(255, 70, 90, 0.45);
    border-color: rgba(255, 150, 160, 0.95);
}

/* Heart button pulses while the favourites playlist is the one playing. */
#favourites.playlist-active {
    animation: fav-pulse 1.6s infinite ease-in-out;
}

/* Radio button pulses while the advent radio playlist is the one playing. */
#radio-playlist.playlist-active {
    animation: radio-pulse 1.6s infinite ease-in-out;
}

@keyframes fav-pulse {
    0%, 100% {
        box-shadow: 0 0 6px 1px rgba(255, 70, 90, 0.7);
        border-color: rgba(255, 150, 160, 0.9);
    }
    50% {
        box-shadow: 0 0 16px 6px rgba(255, 70, 90, 1), 0 0 30px 12px rgba(255, 70, 90, 0.55);
        border-color: #fff;
    }
}

@keyframes radio-pulse {
    0%, 100% {
        box-shadow: 0 0 6px 1px rgba(255, 200, 90, 0.7);
        border-color: rgba(255, 220, 150, 0.9);
    }
    50% {
        box-shadow: 0 0 16px 6px rgba(255, 200, 90, 1), 0 0 30px 12px rgba(255, 170, 40, 0.55);
        border-color: #fff;
    }
}

#audio-controls {
    display: flex;
    flex-direction: row;    /* Keep buttons in a row */
    gap: 10px;              /* Add space between buttons */
}

#audio-controls.hidden {
    display: none;
}

#track-info {
    font-size: 0.8rem;
    color: white;
    background-color: transparent; /* Transparent background to show progress bar */
    padding: 5px 10px;
    text-align: center;
    border-radius: 3px;
    width: 100%;            /* Make it span across the container */
    box-sizing: border-box; /* Include padding in width calculation */
    max-width: 300px;       /* Optional: Limit the maximum width */
    cursor: pointer;        /* Indicate clickable for seeking */
    position: relative;     /* For positioning progress bar */
    overflow: hidden;       /* Contain the progress bar */
    z-index: 1;             /* Above the progress bar */
}

/* Progress bar overlay */
#track-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;            /* Full width initially */
    background-color: var(--progress-bar-background); /* Black background for unplayed portion */
    z-index: -2;            /* Behind everything */
}

/* Progress bar fill overlay */
#track-info::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;              /* Will be updated dynamically */
    background-color: var(--progress-bar-color); /* Dark orange color for played portion */
    z-index: -1;            /* Behind text but above background */
    transition: width 0.3s ease; /* Smooth transition */
}

#audio-controls, #audio-controls * {
    user-select: none; /* Disable text selection */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* Internet Explorer/Edge */
    touch-action: manipulation; /* Ensure touch gestures still work */
}

.calendar-box.clickable:not(.opened) {
    border: 2px solid rgba(255, 240, 200, 0.5); /* Light creamy border */
    box-shadow: 0 0 15px rgba(255, 240, 200, 0.5), 
                0 0 30px rgba(255, 240, 200, 0.4), 
                0 0 50px rgba(255, 240, 200, 0.3); /* Soft creamy glow */
    transition: box-shadow 0.3s ease; /* Smooth appearance on hover */
}

.calendar-box.clickable:not(.opened) .box-label {
    color: white; /* Ensure the text remains visible */
    text-shadow: 0 0 5px rgba(255, 223, 0, 1), 0 0 10px rgba(255, 223, 0, 0.8);
    animation: outward-pulsate-color 2s infinite ease-in-out; /* Outward blur effect */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center the text */
    font-size: calc(2vw + 2vh); /* Ensure consistency with other numbers */
    font-weight: bold;
    z-index: 3; /* Keep it above other elements */
    pointer-events: none; /* Prevent interaction with the label */
}

/* Outward pulsating blur animation with color transition */
@keyframes outward-pulsate-color {
    0% {
        text-shadow: 0 0 5px rgba(0, 0, 0, 1), 0 0 10px rgba(0, 0, 0, 0.8); /* Dark shadow */
        transform: translate(-50%, -50%) scale(1); /* No size change */
    }
    50% {
        text-shadow: 0 0 40px rgba(255, 255, 255, 1), 0 0 80px rgba(255, 255, 255, 0.9); /* Bright white */
        transform: translate(-50%, -50%) scale(1.2); /* Slightly grow */
    }
    100% {
        text-shadow: 0 0 5px rgba(0, 0, 0, 1), 0 0 10px rgba(0, 0, 0, 0.8); /* Back to dark shadow */
        transform: translate(-50%, -50%) scale(1); /* Return to normal */
    }
}

:root {
    --box-size: 120px; /* Default box size */
    --progress-bar-color: #FF8C00; /* Dark orange color for progress */
    --progress-bar-background: #000000; /* Black color for unplayed portion */
}

@media (max-width: 768px) {
    #calendar {
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); /* Smaller boxes on narrow screens */
        gap: 8px; /* Reduce spacing */
    }
}

@media (max-width: 480px) {
    #calendar {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); /* Very small boxes on narrowest screens */
        gap: 5px;
    }
    #calendar-container {
        padding: 10px; /* Less padding on smaller screens */
    }
}

.toast {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    text-align: center;
    z-index: 1000;
    animation: fadein 0.5s, fadeout 0.5s 1.5s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

@keyframes fadein {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeout {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}
