/* =====================
   VARIABLES
===================== */
:root {
    /* Colors */
    --teal: #264653;
    --orange: #ff641e;
    --cream: #F4F1DE;
    --dark: #1D3557;
    --primary: #2A9D8F;
    --secondary: #E76F51;
    --background: #F4F1DE;
    --text: #264653;
    --accent: #E9C46A;
    
    /* Breakpoints - Bootstrap-like */
    --breakpoint-xs: 575px;  /* Extra small devices */
    --breakpoint-sm: 767px;  /* Small devices */
    --breakpoint-md: 991px;  /* Medium devices */
    --breakpoint-lg: 1199px; /* Large devices */
    --breakpoint-xl: 1200px; /* Extra large devices */
    
    /* Common styling elements */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 20px;
    --box-shadow-sm: 0 2px 5px rgba(0,0,0,0.1);
    --box-shadow-md: 0 2px 8px rgba(0,0,0,0.2);
    --box-shadow-lg: 0 3px 14px rgba(0,0,0,0.4);
    --transition-fast: all 0.2s ease;
    --transition-medium: all 0.3s ease;
    --transition-slow: all 0.5s ease;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 20px;
    --spacing-xl: 40px;
}

/* =====================
   BASE STYLES
===================== */
body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--cream);
}

/* =====================
   FILTER COMPONENTS
===================== */
/* Day filter styles */
#filter-container {
    padding: 10px;
    background-color: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden; /* Hide overflow but don't enable scrolling on the container */
    white-space: nowrap;
}

.filter-title {
    color: white;
    font-weight: bold;
    margin-right: 10px;
    position: absolute;
    left: 10px;
}

#day-filters {
    display: inline-flex;
    gap: 8px;
    padding: 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    padding: 0 40px; /* Add padding for the buttons */
    width: 100%;
}

#day-filters::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.day-filter {
    background-color: var(--cream);
    color: var(--teal);
    border: 2px solid var(--cream);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xs) var(--spacing-md);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.day-filter.active {
    background-color: var(--accent);
    color: var(--dark);
}

/* Favorites filter styles */
#favorites-filter {
    background-color: var(--cream);
    color: var(--teal);
    border: 2px solid var(--teal);
    margin-right: var(--spacing-md);
}

#favorites-filter.active {
    background-color: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

/* Tag filter styles */
#tag-filter-container {
    background-color: var(--teal);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--teal);
    border-bottom: 1px solid var(--teal);
    position: relative;
    overflow: hidden; /* Hide overflow but don't enable scrolling on the container */
    white-space: nowrap;
}

#tag-filters {
    display: inline-flex;
    gap: 8px;
    padding: 0 40px; /* Add padding for the buttons */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    width: 100%;
}

#tag-filters::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.tag-filter {
    background-color: var(--cream);
    color: var(--teal);
    border: 2px solid var(--cream);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xs) var(--spacing-md);
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.tag-filter.active {
    background-color: var(--accent);
    color: var(--dark);
}

/* Add a title for the tag filters with proper styling */
#tag-filter-container::before {
    color: white;
    font-weight: bold;
    position: absolute;
    left: 10px;
    display: none; /* Hide by default, show on larger screens */
}

/* Remove gradient indicators since we have buttons now */
#filter-container::after, #tag-filter-container::after {
    display: none;
}

/* Filter scroll buttons */
.scroll-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border: none;
    color: var(--teal);
    font-weight: bold;
    font-size: 18px;
    transition: background-color 0.2s;
}

.scroll-button:active {
    background-color: var(--accent);
}

.scroll-left {
    left: 0px;
}

.scroll-right {
    right: 0px;
}

/* =====================
   MAP COMPONENTS
===================== */
#map {
    height: 60vh;
}

.map-logo {
    pointer-events: none;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.2));
}

.map-disclaimer {
    position: absolute;
    bottom: 2px;
    left: 4px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 2px;
    border-radius: 2px;
    font-size: 10px;
    color: #666;
    pointer-events: none;
}

.custom-marker div {
    width: 25px;
    height: 41px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    mask: url(https://unpkg.com/leaflet@1.7.1/dist/images/marker-icon.png) no-repeat center;
    -webkit-mask: url(https://unpkg.com/leaflet@1.7.1/dist/images/marker-icon.png) no-repeat center;
}

/* Custom map marker colors */
.leaflet-marker-icon {
    filter: none;
}

/* =====================
   TIMELINE COMPONENTS
===================== */
#timeline {
    height: 40vh;
    display: flex;
    flex-direction: column;
}

.timeline-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    position: relative;
}

#gantt {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Make the bars interactive */
rect:hover {
    cursor: pointer;
}

.timeline-header {
    margin-left: 20px; /* Match left margin */
    border-bottom: 1px solid var(--teal);
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: var(--cream);
}

.timeline-header svg {
    background-color: var(--cream);
}

.scrollable-timeline {
    overflow-x: auto;
    overflow-y: auto;
    height: calc(100% - 50px); /* Adjust for header height */
    position: relative;
    margin: 0 0 0 20px; /* Match left margin */
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.scrollable-timeline:active {
    cursor: grabbing;
}

/* Scrollbar styling */
.scrollable-timeline::-webkit-scrollbar {
    height: 8px;
}

.scrollable-timeline::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.scrollable-timeline::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.scrollable-timeline::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.timeline-tooltip {
    position: absolute;
    padding: var(--spacing-md);
    background: white;
    border: 2px solid var(--teal);
    border-radius: var(--border-radius-md);
    pointer-events: none;
    font-size: 14px;
    box-shadow: var(--box-shadow-md);
}

.timeline-tooltip strong {
    color: var(--dark);
}

.festival-bar {
    opacity: 0.8;
    cursor: pointer;
    transition: all 0.2s;
}

.past-festival {
    fill: #999;
    opacity: 0.5;
}

.current-date-line {
    pointer-events: none;
}

.event-group text {
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.event-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    pointer-events: none;
}

.event-label[fill="#fff"] {
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.event-group rect {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.event-group rect.selected {
    opacity: 1;
}

.date-label {
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* =====================
   POPUP COMPONENTS
===================== */
.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius-md);
    background: var(--cream);
}

.leaflet-popup-content {
    margin: 15px;
}

.leaflet-popup-tip {
    background: var(--cream);
}

.festival-popup {
    text-align: center;
    position: relative;
}

.festival-popup img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--teal);
}

.festival-popup h3 {
    color: var(--dark);
    margin: 10px 0;
}

.timeline-popup {
    background: var(--cream);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--box-shadow-lg);
    max-width: 350px;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 10000;
    pointer-events: auto;
    cursor: default;
    position: fixed;
    animation: fadeIn 0.2s ease-out;
}

/* Default arrow for bottom position (when popup is above timeline) */
.timeline-popup.arrow-bottom::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: var(--cream) transparent transparent;
}

/* Arrow for top position (when popup is below timeline) */
.timeline-popup.arrow-top::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 10px 10px;
    border-style: solid;
    border-color: transparent transparent var(--cream);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.timeline-popup .festival-popup {
    text-align: center;
    position: relative;
}

.timeline-popup .festival-popup img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid var(--teal);
    margin-bottom: 10px;
}

.timeline-popup .festival-popup h3 {
    color: var(--dark);
    margin: 10px 0;
    font-size: 16px;
}

.timeline-popup .festival-popup p {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

/* Close buttons */
.leaflet-popup-close-button {
    font-size: 18px !important;
    width: 24px !important;
    height: 24px !important;
    line-height: 24px !important;
    top: 5px !important;
    right: 5px !important;
    color: var(--dark) !important;
    background-color: rgba(255,255,255,0.7) !important;
    border-radius: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.close-button {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background-color: rgba(255,255,255,0.7);
    border-radius: 12px;
    font-size: 18px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 1000;
    user-select: none;
    color: var(--dark);
}

/* =====================
   UTILITY COMPONENTS
===================== */
.rsvp-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--teal);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.location-link {
    color: var(--teal);
    text-decoration: none;
    transition: color 0.2s ease;
}

/* =====================
   MEDIA QUERIES
===================== */

/* Feature/capability queries - independent of screen size */

/* Hover-capable devices */
@media (hover: hover) {
    .day-filter:hover,
    .tag-filter:hover {
        transform: translateY(-2px);
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    .scroll-button:hover {
        background-color: white;
    }

    .rsvp-button:hover {
        background-color: var(--orange);
    }

    .location-link:hover {
        color: var(--orange);
        text-decoration: underline;
    }

    .close-button:hover {
        background-color: rgba(255,255,255,1);
    }
    
    .festival-bar:hover {
        opacity: 1;
    }
    
    .past-festival:hover {
        fill: #666;
        opacity: 0.8;
    }
}

/* Touch devices */
@media (pointer: coarse) {
    .day-filter:hover, 
    .tag-filter:hover {
        transform: none;
        box-shadow: none;
    }
    
    .day-filter:active, 
    .tag-filter:active {
        opacity: 0.8;
    }
    
    .scroll-button {
        opacity: 0.9;
    }
}

/* Responsive breakpoints - mobile first approach */

/* Extra small devices (phones) - Base styles defined at top level */
/* All base styles at the top of the document serve as the mobile-first defaults */

/* Small devices (tablets) */
@media (min-width: 576px) {
    /* Add tablet-specific styles here */
}

/* Medium devices (tablets and small desktops) */
@media (min-width: 768px) {
    #tag-filter-container::before {
        display: block;
        left: 45px; /* Move label to accommodate scroll button */
    }
    
    #day-filters, 
    #tag-filters {
        padding: 0 40px 0 100px; /* Add space for the label on larger screens */
    }
    
    /* Less condensed filters on larger screens */
    .day-filter,
    .tag-filter {
        padding: 5px 12px;
        font-size: initial;
        border-radius: 20px;
        border-width: 2px;
    }
    
    /* Larger buttons on desktop */
    .scroll-button {
        width: 30px;
        height: 40px;
        font-size: 18px;
    }
}

/* Large devices (desktops) */
@media (min-width: 992px) {
    /* Add desktop-specific styles here */
}

/* Extra large devices (large desktops) */
@media (min-width: 1200px) {
    /* Add large desktop-specific styles here */
}

/* Special case: Legacy max-width breakpoints */
/* These should eventually be refactored to mobile-first,
   but keeping for backward compatibility */

/* Small devices and below (phones and small tablets) */
@media (max-width: 767px) {
    /* Map and logo adjustments */
    .map-logo {
        width: 75px !important;
    }
    
    /* Reposition logo container for small screens */
    .leaflet-control-container .leaflet-top.leaflet-right {
        top: unset !important;
        bottom: 20px;
    }

    #map {
        box-sizing: border-box;
        height: 60vh;
        width: 100%;
        margin: 0;
    }

    /* Timeline adjustments */
    .timeline-header,
    .scrollable-timeline {
        margin-left: 10px; /* Smaller margin for mobile */
    }

    /* Close button adjustments */
    .leaflet-popup-close-button {
        font-size: 22px !important;
        width: 32px !important;
        height: 32px !important;
        line-height: 32px !important;
        top: 5px !important;
        right: 5px !important;
    }

    .close-button {
        width: 32px;
        height: 32px;
        font-size: 22px;
        line-height: 30px;
    }
}

/* Medium devices and below (tablets and phones) */
@media (max-width: 968px) {
    #tag-filter-container, 
    #filter-container {
        padding: 8px 10px;
    }
    
    #day-filters, 
    #tag-filters {
        padding: 0 40px; /* Keep space for buttons */
    }
    
    .tag-filter {
        padding: 4px 10px;
        font-size: 10px;
        border-radius: 0px;
        border: 1px solid var(--cream);
    }

    .day-filter {
        border: 2px solid var(--cream);
        border-radius: 0px;
        padding: 4px 10px;
        font-weight: bold;
        font-size: 10px;
        cursor: pointer;
        user-select: none;
    }
}

.heart-icon {
    position: absolute;
    top: -10px;
    left: 0px;
    font-size: 30px;
    color: gray;
    cursor: pointer;
    transition: color 0.3s ease;
}

.heart-icon.active {
    color: red !important;
}

/* Social Share Styles */
#social-share-container {
    position: fixed;
    left: 50%;
    bottom: 0;
    width: 220px; /* Set a fixed width */
    background-color: var(--cream);
    border-radius: var(--border-radius-lg);
    padding: 10px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
    /* Initially show only top third */
    transform: translate(-50%, 66%);
    cursor: pointer;
}

#social-share-container.expanded {
    transform: translate(-50%, 0);
}

.share-title {
    font-weight: bold;
    color: var(--teal);
    margin-bottom: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.expand-indicator {
    font-size: 10px;
    transition: transform 0.3s ease;
}

#social-share-container.expanded .expand-indicator {
    transform: rotate(180deg);
}

.share-buttons {
    display: flex;
    gap: 10px;
}

.share-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.twitter-share {
    background-color: #1DA1F2;
}

.facebook-share {
    background-color: #4267B2;
}

.linkedin-share {
    background-color: #0077B5;
}

.copy-link {
    background-color: var(--teal);
}

.share-button svg {
    width: 18px;
    height: 18px;
}

.share-button:hover {
    transform: scale(1.1);
}

.copy-link.copied {
    background-color: #28a745;
}

/* Toast notification for copy link */
.toast {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background-color: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    font-size: 14px;
    z-index: 1001;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Mobile adjustments for social share */
@media (max-width: 767px) {
    #social-share-container {
        width: 90%;
        max-width: 300px;
        padding: 8px 12px;
        /* Keep the same transform behavior */
        transform: translate(-50%, 66%);
    }
    
    #social-share-container.expanded {
        transform: translate(-50%, 0);
    }
    
    .share-title {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .share-buttons {
        gap: 8px;
    }
    
    .share-button {
        width: 32px;
        height: 32px;
    }
    
    .share-button svg {
        width: 16px;
        height: 16px;
    }
}