/* Slideshow Styles */
:root {
    --slideshow-bg: #4a1020;
    --slideshow-text: #ffffff;
    --slideshow-text-muted: #e0e0e0;
    --slideshow-text-subtle: #b0b0b0;
    --t: 0.8s;
    --slide-duration: 5s;
}

.slideshow-container {
    position: relative;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    user-select: none;
    background: radial-gradient(ellipse at center, var(--slideshow-bg) 0%, #3a0d1a 50%, #2a0a12 100%);
}

/* Slides container - holds original slides and transition containers */
.slides {
    position: relative;
    width: 100%;
    height: 100%;
}

/* State machine transition containers */
.slides > div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* cloned slide content inside transition containers */
.slides > div > div {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    box-sizing: border-box;
    color: var(--slideshow-text);
    text-align: center;
    background: radial-gradient(ellipse at center, var(--slideshow-bg) 0%, #3a0d1a 50%, #2a0a12 100%);
}

/* Original slides - keep hidden */
.slides > .slide {
    display: none !important;
}

/* Slide content wrapper - applies to all slide-content, including cloned */
.slide-content {
    width: 100%;
    max-width: 1200px;
    padding: 0 1rem;
}

/* Slide indicator */
.slide-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.slide-indicator .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
}

.slide-indicator .dot.active {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.2);
}

.slide-indicator .dot:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Slide content styles */
.slide h1 {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 700;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
    line-height: 1.2;
    color: var(--slideshow-text);
}

.slide-total {
    margin-top: 2rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--slideshow-text-muted);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.slide p {
    color: var(--slideshow-text-muted);
}

.slide-total .total-sum-value {
    color: #fbbf24;
    font-size: 1.5rem;
    font-weight: 700;
}

/* Description styles */
.slide-description {
    font-size: 2rem;
    color: var(--slideshow-text-subtle);
    margin-top: 5rem;
    line-height: 1.5;
}

/* Ambassador title */
.ambassador-title {
    font-size: clamp(1.8rem, 8vw, 3rem);
    color: var(--slideshow-text);
    margin-bottom: 2rem;
    text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
    font-weight: 700;
}

/* Ambassador name under photo */
.ambassador-name {
    color: var(--slideshow-text-muted);
    font-size: 1.3rem;
    margin-top: 0.75rem;
    text-align: center;
    font-weight: 500;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
    min-height: 2rem;
}

/* Ambassador photos */
.ambassador-photos {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90%;
    margin: 2rem auto;
    padding: 1rem 0;
}

.ambassador-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0.5rem;
}

.ambassador-photo {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--slideshow-text);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ambassador-photo[src=""] {
    display: none;
}

.ambassador-photo:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
}

/* QR container */
.qr-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.qr-item img {
    width: 150px;
    height: 150px;
}

/* Inlined QR code SVGs - white QR modules on dark slide background */
.qr-item svg {
    width: 150px;
    height: 150px;
}

.qr-item svg rect {
    fill: #ffffff;
    stroke: none;
}

.qr-item p {
    font-weight: bold;
    color: var(--slideshow-text-muted);
}

/* SVG styles */
svg {
    fill: currentColor;
}

/* Logo blanc sur fond noir */
.svg-white {
    filter: brightness(0) invert(1);
    max-width: 300px;
    height: auto;
    margin: 1rem auto;
}

.salah-qr {
    max-width: 350px;
    height: auto;
    margin: 1rem auto;
}

/* Party photos container */
.party-photos {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 90%;
    margin: 0 auto;
}

/* Party photo item */
.party-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Party photo */
.party-photo {
    width: 200px;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #444;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    transition: transform var(--t);
}

.party-photo:hover {
    transform: scale(1.05);
}

/* Party Carousel Styles - Vertical Single Image */
.party-carousel-container {
    position: relative;
    width: 100%;
    height: 80vh;
    max-height: 700px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    contain: strict;
}



.party-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.party-carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Party transition containers (created via createTransitionContainer) */
.party-prev,
.party-current,
.party-next {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.party-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: top 0.8s ease-in-out, opacity 0.3s ease;
    pointer-events: none;
}

.party-slide.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

.party-slide.next, .party-slide.prev {
    pointer-events: none;
}

.party-photo-large {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 12px;
    border: 3px solid var(--slideshow-text);
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.party-photo-large:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 48px rgba(0,0,0,0.8);
}

/* Vertical carousel indicator */

/* Total sum animation styles */
.total-sum-value {
    display: inline-block;
    transition: all var(--t);
    position: relative;
    min-width: 2em; /* Ensure enough space for 3 digits */
}

#total-sum-display {
    min-width: 2em; /* Ensure enough space for 3 digits */
    display: inline-block;
}

.total-sum-value.updating {
    opacity: 0.7;
    transform: scale(0.95);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.total-sum-value.pulse {
    animation: pulse 0.3s ease-out;
    color: #fbbf24 !important;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.7);
}

/* Image animation styles */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.image-adding {
    animation: fadeInUp 0.3s ease-out forwards;
}

.image-removing {
    animation: fadeOutDown 0.3s ease-out forwards;
}

.image-updated {
    animation: fadeInScale 0.3s ease-out;
}

/* Ensure images in containers have proper transitions */
.ambassador-item,
.party-item {
    transition: all 0.3s ease-out;
}

/* Ambassador Carrousel Styles */
.ambassador-carrousel-container {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    overflow: hidden;
    padding: 1rem 0;
}

.ambassador-carrousel {
    display: flex;
    gap: 2rem;
    transition: transform 0.5s ease-in-out;
    will-change: transform;
}

.ambassador-carrousel .ambassador-item {
    flex: 0 0 calc(25% - 1.5rem);
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ambassador-carrousel .ambassador-photo {
    width: 200px;
    height: 200px;
}

.ambassador-carrousel .ambassador-photo[src=""] {
    display: none;
}

.ambassador-carrousel .ambassador-name {
    font-size: 1.1rem;
    min-height: 2rem;
}

/* Ambassador Grid Styles - 3 rows */
.ambassador-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    grid-auto-rows: minmax(220px, auto);
    gap: 1rem;
    justify-content: center;
    width: 100%;
    max-width: 1400px;
    margin: 1rem auto 0;
    padding: 0;
}

.ambassador-grid .ambassador-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.ambassador-grid .ambassador-item[data-path=""] {
    display: none;
}

.ambassador-grid .ambassador-photo {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--slideshow-text);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.ambassador-grid .ambassador-photo[src=""] {
    display: none;
}

.ambassador-grid .ambassador-photo:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}

.ambassador-grid .ambassador-name {
    color: var(--slideshow-text-muted);
    font-size: 0.95rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 500;
    text-shadow: 1px 1px 4px rgba(0,0,0,0.8);
    min-height: 1.2rem;
}

/* Responsive adjustments for slideshow */
@media (max-width: 768px) {
    .slide h1 {
        font-size: clamp(1.5rem, 6vw, 2.5rem);
        margin-bottom: 1rem;
    }

    .ambassador-carrousel .ambassador-item {
        flex: 0 0 calc(50% - 1rem);
    }

    .ambassador-carrousel .ambassador-photo {
        width: 150px;
        height: 150px;
    }

    .ambassador-carrousel .ambassador-name {
        font-size: 1.2rem;
    }
}

/* Respect prefers-reduced-motion: collapse transitions/animations to near-instant.
   The JS transition engine mirrors this via matchMedia. */
@media (prefers-reduced-motion: reduce) {
    .slides > div,
    .party-prev,
    .party-current,
    .party-next,
    .party-photo-large,
    .ambassador-photo,
    .ambassador-carrousel,
    .total-sum-value,
    .slide-indicator .dot {
        transition-duration: 0.01s !important;
        animation-duration: 0.01s !important;
    }
}
