/* Modern Photo Album CSS - Responsive Design */

/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #60a5fa;
    --primary-hover: #3b82f6;
    --secondary-color: #6b7280;
    --background-color: #0c1220;
    --card-background: #1e2a3a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #2d3748;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header {
    background: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #d2dff5;
    text-decoration: none;
}

.organization {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

.breadcrumb a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.breadcrumb a:hover {
    color: var(--primary-hover);
}

.breadcrumb-separator {
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

.album-header {
    text-align: center;
    margin-bottom: 3rem;
}

.album-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.album-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* Photo Grid - Masonry.js Layout (Official Guidelines) */
.photo-grid {
    margin: 0 auto 3rem auto; /* Center the masonry layout */
}

.photo-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    opacity: 0;
    width: 280px; /* Fixed width for Masonry column calculation */
    margin-bottom: 16px; /* Use px to match gutter setting */
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    transform: translateY(20px);
    /* Note: Masonry handles positioning, avoid layout-affecting transforms */
}

/* Animation states - controlled by JavaScript after Masonry positioning */
.photo-card.animate-in {
    opacity: 1;
    transform: translateY(0);
}

.photo-card:hover {
    box-shadow: var(--shadow-lg);
    /* Avoid transforms that could interfere with Masonry positioning */
}

.photo-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.photo-image {
    width: 100%;
    height: auto;
    display: block;
    transition: var(--transition);
}

.photo-placeholder {
    width: 100%;
    height: auto;
    min-height: 200px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
}

/* Removed scale effect for better UX during photo switching */

.photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.7) 100%);
    opacity: 0;
    transition: var(--transition);
    display: flex;
    align-items: flex-end;
    padding: 1rem;
}

.photo-card:hover .photo-overlay {
    opacity: 1;
}

.photo-title {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Folder Grid */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.folder-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    opacity: 0;
    animation: fadeInUp 0.5s ease-out forwards;
}

.folder-card:nth-child(1) { animation-delay: 0.1s; }
.folder-card:nth-child(2) { animation-delay: 0.2s; }
.folder-card:nth-child(3) { animation-delay: 0.3s; }
.folder-card:nth-child(4) { animation-delay: 0.4s; }
.folder-card:nth-child(n+5) { animation-delay: 0.5s; }

.folder-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.folder-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.folder-name {
    font-weight: 600;
    font-size: 0.875rem;
}

/* Modal/Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    box-sizing: border-box;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

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

.lightbox-image {
    max-width: calc(100vw - 4rem);
    max-height: calc(100vh - 4rem);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--border-radius);
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.lightbox.active .lightbox-image {
    opacity: 1;
}

.lightbox-close {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    z-index: 1001;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    padding: 1rem;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: var(--transition);
    z-index: 1001;
}

.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

/* Album Loading Indicator */
.album-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

.loading-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.loading-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Error States */
.error-message {
    background: #450a0a;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
    padding: 1rem;
    border-radius: var(--border-radius);
    text-align: center;
    margin: 2rem 0;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }

    .album-title {
        font-size: 2rem;
    }

    .photo-card {
        width: 220px;
        margin-bottom: 12px; /* Adjust gutter for smaller screens */
    }

    .folder-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .lightbox {
        padding: 1rem;
    }

    .lightbox-nav {
        display: none;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .photo-card {
        width: 160px;
        margin-bottom: 8px; /* Smaller gutter for mobile */
    }

    .album-title {
        font-size: 1.5rem;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.photo-card:focus,
.folder-card:focus,
.lightbox-close:focus,
.lightbox-nav:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
