/* Gallery Styles for Activity Modals */

.modal-galleries {
    margin-top: 20px;
}

.gallery-section {
    margin-bottom: 30px;
}

/* Audio Gallery */
.audio-gallery {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
    clear: both;
}

.audio-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.audio-container audio {
    padding: 20px 0;
}

audio {
    width: 300px;
    height: 54px;
}

.audio-container .caption {
    color: #55757f;
    font-size: 80%;
    padding: 0 2em;
}

/* Iframe Gallery */
.iframe-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.2rem;
    margin: 1rem 0 2rem;
    clear: both;
}

.iframe-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.iframe-container iframe {
    width: 100%;
    max-width: 720px;
    border: 0;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
    background: #fff;
}

.iframe-container .caption {
    color: #55757f;
    font-size: 80%;
    padding: 0.35em 1em 0;
    text-align: center;
}

/* Interactive Map */
.imap-block {
    margin: 1.5rem auto;
}

.imap-image-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

.imap-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.imap-point {
    --imap-accent: var(--Accent);
    --imap-accent-dark: var(--Accent-dark);
    --imap-label-bg: rgba(245, 251, 245, 0.92);
    --imap-label-text: var(--imap-accent);
    --imap-label-border: color-mix(in srgb, var(--imap-accent) 42%, #ffffff);
    position: absolute;
    transform: translate(-50%, -50%);
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    width: 1.5rem;
    height: 1.5rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    z-index: 3;
    overflow: visible;
}

.imap-point-dot {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--imap-accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--imap-accent) 35%, transparent);
    animation: imap-pulse 1.8s infinite;
}

.imap-point-label {
    position: absolute;
    left: calc(100% + 0.48rem);
    top: 50%;
    transform: translateY(-50%);
    display: inline-block;
    white-space: nowrap;
    pointer-events: none;
    background: var(--imap-label-bg);
    color: var(--imap-label-text);
    border-radius: 12px;
    padding: 0.22rem 0.58rem;
    font-size: 1.7rem;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: 0.001em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(2px);
}

/* Label Direction Modifiers */
.imap-point[data-dir="N"] .imap-point-label {
    left: 50%;
    right: auto;
    top: auto;
    bottom: calc(100% + 0.48rem);
    transform: translateX(-50%);
}
.imap-point[data-dir="NE"] .imap-point-label {
    left: calc(100% + 0.2rem);
    bottom: calc(100% + 0.2rem);
    top: auto;
    transform: none;
}
.imap-point[data-dir="E"] .imap-point-label {
    /* Default spacing corresponds to E, keep as is */
}
.imap-point[data-dir="SE"] .imap-point-label {
    left: calc(100% + 0.2rem);
    top: calc(100% + 0.2rem);
    transform: none;
}
.imap-point[data-dir="S"] .imap-point-label {
    left: 50%;
    right: auto;
    top: calc(100% + 0.48rem);
    transform: translateX(-50%);
}
.imap-point[data-dir="SO"] .imap-point-label,
.imap-point[data-dir="SW"] .imap-point-label {
    left: auto;
    right: calc(100% + 0.2rem);
    top: calc(100% + 0.2rem);
    transform: none;
}
.imap-point[data-dir="O"] .imap-point-label,
.imap-point[data-dir="W"] .imap-point-label {
    left: auto;
    right: calc(100% + 0.48rem);
    top: 50%;
    transform: translateY(-50%);
}
.imap-point[data-dir="NO"] .imap-point-label,
.imap-point[data-dir="NW"] .imap-point-label {
    left: auto;
    right: calc(100% + 0.2rem);
    bottom: calc(100% + 0.2rem);
    top: auto;
    transform: none;
}

@media (max-width: 768px) {
    .imap-point-label {
        font-size: 0.72rem;
        padding: 0.16rem 0.46rem;
        max-width: min(38vw, 180px);
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@keyframes imap-pulse {
    0% { transform: scale(1); opacity: 1; }
    70% { transform: scale(1.2); opacity: 0.65; }
    100% { transform: scale(1); opacity: 1; }
}

/* Interactive map modal now reuses global .modal/.modal-content styles from style_grid.css */

/*
Point-specific style classes can override these variables and will be
applied to both the point and the modal (via JS).
*/

/* 1) Vert (Le Plateau / Parc) */
.imap-point.theme-plateau,
.imap-modal.theme-plateau,
.imap-modal-content.theme-plateau {
    --Accent: var(--palette4);
    --Accent-dark: color-mix(in srgb, var(--palette4) 72%, #1b1b1b);
    --imap-accent: var(--palette4);
    --imap-accent-dark: color-mix(in srgb, var(--palette4) 72%, #1b1b1b);
    --imap-label-bg: color-mix(in srgb, var(--palette4) 14%, #ffffff);
    --imap-label-text: var(--palette4);
}

/* 2) Fuchsia (Village de l'Est) */
.imap-point.theme-est,
.imap-modal.theme-est,
.imap-modal-content.theme-est {
    --imap-accent: var(--Accent);
    --imap-accent-dark: var(--Accent-dark);
    --imap-label-bg: color-mix(in srgb, var(--Accent) 14%, #ffffff);
    --imap-label-text: var(--Accent);
}

/* 3) Cyan (Village de l'Ouest) */
.imap-point.theme-ouest,
.imap-modal.theme-ouest,
.imap-modal-content.theme-ouest {
    --Accent: var(--palette5);
    --Accent-dark: color-mix(in srgb, var(--palette5) 68%, #1b1b1b);
    --imap-accent: var(--palette5);
    --imap-accent-dark: color-mix(in srgb, var(--palette5) 68%, #1b1b1b);
    --imap-label-bg: color-mix(in srgb, var(--palette5) 14%, #ffffff);
    --imap-label-text: color-mix(in srgb, var(--palette5) 80%, #1b1b1b);
}

/* 4) Violet (Groupes Universitaires) */
.imap-point.theme-groupes,
.imap-modal.theme-groupes,
.imap-modal-content.theme-groupes {
    --Accent: var(--palette7);
    --Accent-dark: color-mix(in srgb, var(--palette7) 68%, #1b1b1b);
    --imap-accent: var(--palette7);
    --imap-accent-dark: color-mix(in srgb, var(--palette7) 68%, #1b1b1b);
    --imap-label-bg: color-mix(in srgb, var(--palette7) 15%, #ffffff);
    --imap-label-text: var(--palette7);
}

/* 5) Rouge-magenta (Red-Light / Main) */
.imap-point.theme-redlight,
.imap-modal.theme-redlight,
.imap-modal-content.theme-redlight {
    --Accent: var(--palette1);
    --Accent-dark: color-mix(in srgb, var(--palette1) 68%, #1b1b1b);
    --imap-accent: var(--palette1);
    --imap-accent-dark: color-mix(in srgb, var(--palette1) 68%, #1b1b1b);
    --imap-label-bg: color-mix(in srgb, var(--palette1) 14%, #ffffff);
    --imap-label-text: color-mix(in srgb, var(--palette1) 88%, #1b1b1b);
}

/* Optional text usage: apply class directly on headings/content blocks */
.theme-plateau {
    color: var(--palette4);
}

.theme-est {
    color: var(--Accent);
}

.theme-ouest {
    color: var(--palette5);
}

.theme-groupes {
    color: var(--palette7);
}

.theme-redlight {
    color: var(--palette1);
}

.imap-modal-open {
    overflow: hidden;
}

.gallery-slideshow .slideshow-item-caption {
    padding: 12px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.gallery-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 5px;
}

/* Grid Display Mode */
.gallery-grid, .item-grid-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 200px));
    justify-content: center;
    justify-items: center;
    padding-left: 4em;
    padding-right: 4em;
    gap: 2em;
    margin-top: 2em;
    margin-bottom: 2em;
}



.gallery-item, .grid-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.grid-item-wrapper:hover .grid-item-caption {
    color: var(--Contrast);
}

.grid-item-wrapper:hover .grid-item {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.gallery-item img, .gallery-item video, .grid-item img, .gallery-grid > img {
    max-width: 350px;
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
}

.gallery-item-caption, .grid-item-caption {
    font-weight: 400;
    padding-bottom: 1em;
    text-align: center;
    color: var(--Accent);
    transition: color var(--transition-length);
}

.gallery-item-link {
    text-decoration: none;
    color: inherit;
}

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--Overlay);
    backdrop-filter: blur(5px);
    overflow: hidden;
}

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.lightbox-image {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    user-select: none;
    transition: transform 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    transition: color 0.3s;
}

.lightbox-close:hover {
    color: #ccc;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 40px;
    padding: 10px 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s;
    z-index: 10001;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 4px;
    max-width: 80%;
    text-align: center;
    font-size: 0.95rem;
}

/* Mobile responsiveness for lightbox */
@media (max-width: 768px) {
    .lightbox-prev,
    .lightbox-next {
        font-size: 30px;
        padding: 5px 10px;
    }
    
    .lightbox-close {
        top: 10px;
        right: 15px;
        font-size: 35px;
    }
    
    .lightbox-image {
        max-width: 95%;
        max-height: 80vh;
    }
}

/* Slideshow Display Mode */
.gallery-slideshow {
    position: relative;
    margin-bottom: 20px;
}

.gallery-slideshow .slideshow-container {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    gap: 15px;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f0f0f0;
}

.gallery-slideshow .slideshow-container::-webkit-scrollbar {
    height: 8px;
}

.gallery-slideshow .slideshow-container::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.gallery-slideshow .slideshow-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.gallery-slideshow .slideshow-container::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

.gallery-slideshow .slideshow-item {
    flex: 0 0 300px;
    position: relative;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

.gallery-slideshow .slideshow-item:hover {
    transform: scale(1.02);
}

.gallery-slideshow .slideshow-item img, .gallery-slideshow .slideshow-item video {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.gallery-slideshow .slideshow-item-caption {
    padding: 12px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

.gallery-slideshow .slideshow-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.gallery-slideshow .slideshow-nav-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 16px;
}

.gallery-slideshow .slideshow-nav-btn:hover {
    background: #0056b3;
}

.gallery-slideshow .slideshow-nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Video Player Display Mode */
.gallery-video-player {
    margin-bottom: 20px;
}

.video-main-container {
    position: relative;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 15px;
}

.video-main {
    width: 100%;
    height: 400px;
    object-fit: contain;
    display: block;
}

.youtube-embed {
    border: none;
    border-radius: 8px;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    padding: 20px 15px 15px;
    color: white;
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.video-caption {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

.video-playlist {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0;
    scrollbar-width: thin;
    scrollbar-color: #ccc #f0f0f0;
}

.video-playlist::-webkit-scrollbar {
    height: 6px;
}

.video-playlist::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.video-playlist::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.video-playlist-item {
    flex: 0 0 120px;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    border: 2px solid transparent;
}

.video-playlist-item:hover {
    transform: scale(1.05);
}

.video-playlist-item.active {
    border-color: #007bff;
    transform: scale(1.05);
}

.video-playlist-item img, .video-playlist-item video {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.video-playlist-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.video-playlist-item:hover .video-playlist-overlay {
    opacity: 1;
}

/* Media Type Icons */
.media-type-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.media-type-video .media-type-icon::before {
    content: "▶ ";
}

.media-type-youtube .media-type-icon::before {
    content: "📺 ";
}

.media-type-image .media-type-icon::before {
    content: "🖼 ";
}

/* Item-Grid Display Mode */
.gallery-grid.item-grid .gallery-item {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-grid.item-grid .gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.link-thumbnail {
    width: 100%;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.link-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.9;
}

.link-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.media-type-link .gallery-item-caption {
    background: #f8f9fa;
    color: #495057;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 350px));
        justify-content: center;
        gap: 10px;
    }
    
    .carousel-item {
        flex: 0 0 250px;
    }
    
    .carousel-item img, .carousel-item video {
        height: 150px;
    }
    
    .video-main {
        height: 250px;
    }
    
    .video-playlist-item {
        flex: 0 0 100px;
    }
    
    .video-playlist-item img, .video-playlist-item video {
        height: 60px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 350px));
        justify-content: center;
    }
    
    .carousel-item {
        flex: 0 0 200px;
    }
    
    .video-main {
        height: 200px;
    }
    
    .gallery-title {
        font-size: 1.1rem;
    }
}

/* Loading States */
.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.gallery-loading::before {
    content: "⏳ ";
    margin-right: 8px;
}

/* Error States */
.gallery-error {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 10px 0;
}

/* Empty State */
.gallery-empty {
    padding: 30px;
    text-align: center;
    color: #666;
    font-style: italic;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 10px 0;
}

/* Fix for gallery-grid inside modals */
.modal-description .gallery-grid, 
.modal-galleries .gallery-grid {
    padding-left: 0;
    padding-right: 0;
    margin-top: 1rem;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}
