* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: white;
    min-height: 100vh;
    padding: 40px 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.title {
    text-align: center;
    color: #333;
    font-size: 3rem;
    margin-bottom: 50px;
}

.polaroid-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    position: relative;
}

.polaroid {
    background: white;
    padding: 15px 15px 60px 15px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4),
                0 10px 20px rgba(0, 0, 0, 0.5);
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease, z-index 0s;
    cursor: pointer;
    width: 280px;
    margin: -10px;
    will-change: transform;
}

.polaroid:hover {
    transform: scale(1.1) rotate(0deg) !important;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45),
                0 15px 30px rgba(0, 0, 0, 0.55);
    z-index: 100;
}



.polaroid:nth-child(odd) {
    transform: rotate(-3deg);
    --rotation: -3deg;
}

.polaroid:nth-child(even) {
    transform: rotate(3deg);
    --rotation: 3deg;
}

.polaroid:nth-child(3n) {
    transform: rotate(-5deg);
    --rotation: -5deg;
}

.polaroid:nth-child(5n) {
    transform: rotate(5deg);
    --rotation: 5deg;
}

.polaroid-image {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
    background: white;
}

.polaroid-caption {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    padding: 0 10px;
    text-align: center;
    font-size: 16px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.polaroid-location {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.polaroid-date {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

/* Loading state */
.polaroid.loading {
    background: #f5f5f5;
}

.polaroid.loading .polaroid-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}


/* View Toggle FAB & Container */
.fab-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 1000;
}

.action-fab {
    width: 60px;
    height: 60px;
    background: rgba(102, 126, 234, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    border: none;
    outline: none;
    color: white;
}

.action-fab:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.action-fab:active {
    transform: scale(0.95);
}

.action-fab svg {
    width: 28px;
    height: 28px;
}

/* Layers Modal */
.layers-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.layers-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.layers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.layers-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.layers-list {
    overflow-y: auto;
    flex: 1;
    margin-bottom: 20px;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}

.layer-item:hover {
    background: #f5f5f5;
}

.layer-checkbox {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.layer-label {
    flex: 1;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
}

.layer-count {
    background: #e2e8f0;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #4a5568;
}

.layers-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.text-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-weight: 500;
}

.apply-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.apply-btn:hover {
    background: #5a67d8;
}

/* Photo Modal */
.photo-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.photo-modal.active {
    display: flex;
}

.modal-close {
    position: fixed;
    top: 30px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    z-index: 10001;
    transition: color 0.3s;
}

.modal-close:hover {
    color: #667eea;
}

/* Modal Navigation Arrows */
.modal-nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 60px;
    height: 100px;
    font-size: 50px;
    cursor: pointer;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, color 0.3s;
}

.modal-nav-arrow:hover {
    background: rgba(102, 126, 234, 0.8);
    color: white;
}

.modal-nav-arrow.prev {
    left: 0;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

.modal-nav-arrow.next {
    right: 0;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}

.polaroid-flip-container {
    perspective: 2000px;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.polaroid-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
}

.polaroid-card.flipped {
    transform: rotateY(180deg);
}

.polaroid-front,
.polaroid-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.polaroid-back {
    transform: rotateY(180deg);
}

.modal-polaroid {
    background: white;
    padding: 2vw 2vw 9vw 2vw;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6),
                0 30px 60px rgba(0, 0, 0, 0.7);
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    pointer-events: auto;
    box-sizing: border-box;
}

.modal-polaroid.portrait {
    padding: 1.5vw 1.5vw 8vw 1.5vw;
}

.modal-polaroid.portrait .modal-date-display {
    bottom: 5.5vw;
}

.modal-polaroid.portrait .modal-caption {
    bottom: 2.5vw;
}

.modal-photo {
    width: auto;
    height: auto;
    max-height: calc(95vh - 13vw);
    max-width: 90vw;
    display: block;
    margin: 0 auto;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.modal-date-display {
    position: absolute;
    bottom: 6.5vw;
    left: 3vw;
    color: #999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.modal-caption {
    position: absolute;
    bottom: 3.5vw;
    
    width: 100%;
    text-align: center;
    color: #333;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* Flip Icons */
.flip-icon {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    z-index: 10;
    pointer-events: auto;
}

.flip-icon:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.1);
}

.flip-icon:active {
    transform: scale(0.95);
}

.flip-icon svg {
    pointer-events: none;
}

.polaroid-card.flipped ~ #flip-to-map {
    display: none;
}

.polaroid-card:not(.flipped) ~ #flip-to-photo {
    display: none;
}

/* Map on back side */
.modal-map {
    width: 100%;
    height: 100%;
    background: #f0f0f0;
    position: relative;
    z-index: 1;
}

/* Ensure Leaflet map fills container */
.modal-map .leaflet-container {
    width: 100%;
    height: 100%;
}
