/**
 * Railroad Photo Gallery Frontend Styles
 */


/* Base gallery styles */
.railroad-photo-gallery {
    margin: 20px 0;
    clear: both;
}

.railroad-photo-gallery-empty,
.railroad-photo-gallery-error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
}

.railroad-photo-gallery-error {
    color: #dc3232;
    border-color: #dc3232;
    background: #fef7f7;
}

/* Grid layout */
.railroad-photo-gallery-grid .gallery-grid {
    display: grid;
    gap: 15px;
    margin: 0;
    padding: 0;
}

.railroad-photo-gallery-grid.photos-per-row-2 .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
}

.railroad-photo-gallery-grid.photos-per-row-3 .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
}

.railroad-photo-gallery-grid.photos-per-row-4 .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
}

.railroad-photo-gallery-grid.photos-per-row-5 .gallery-grid {
    grid-template-columns: repeat(5, 1fr);
}

/* Gallery items */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.gallery-link {
    display: block;
    position: relative;
    overflow: hidden;
}

.gallery-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

/* Gallery captions */
.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px 15px 15px;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.railroad-photo-gallery.show-captions .gallery-item:hover .gallery-caption {
    opacity: 1;
}

/* Masonry layout */
.railroad-photo-gallery-masonry .gallery-masonry {
    column-count: 3;
    column-gap: 15px;
    margin: 0;
    padding: 0;
}

.railroad-photo-gallery-masonry.photos-per-row-2 .gallery-masonry {
    column-count: 2;
}

.railroad-photo-gallery-masonry.photos-per-row-3 .gallery-masonry {
    column-count: 3;
}

.railroad-photo-gallery-masonry.photos-per-row-4 .gallery-masonry {
    column-count: 4;
}

.railroad-photo-gallery-masonry.photos-per-row-5 .gallery-masonry {
    column-count: 5;
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: 15px;
    display: inline-block;
    width: 100%;
}

/* Carousel layout */
.railroad-photo-gallery-carousel {
    position: relative;
    margin: 20px 0;
}

.carousel-container {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.carousel-track {
    display: flex;
    transition: transform 0.5s ease;
}

.carousel-slide {
    min-width: 100%;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.carousel-slide.active {
    opacity: 1;
}

.carousel-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: cover;
}

.carousel-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px;
    font-size: 16px;
    line-height: 1.5;
}

/* Carousel controls */
.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    z-index: 10;
}

.carousel-prev:hover,
.carousel-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
    left: 15px;
}

.carousel-next {
    right: 15px;
}

/* Carousel dots */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
}

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    background: #ccc;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.carousel-dot.active,
.carousel-dot:hover {
    background: #0073aa;
}

/* Recent galleries styles */
.recent-railroad-galleries {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.gallery-item-preview {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.gallery-item-preview:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.gallery-thumbnail {
    position: relative;
    padding-bottom: 60%; /* 5:3 aspect ratio */
    overflow: hidden;
}

.gallery-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item-preview:hover .gallery-thumbnail img {
    transform: scale(1.05);
}

.no-thumbnail {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ccc;
    font-size: 48px;
}

.gallery-info {
    padding: 15px;
}

.gallery-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    line-height: 1.4;
}

.gallery-title a {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
}

.gallery-title a:hover {
    color: #0073aa;
}

.gallery-meta {
    margin-bottom: 10px;
}

.photo-count {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

.gallery-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 10px;
}

.gallery-date {
    font-size: 12px;
    color: #999;
}

/* Responsive design */
@media (max-width: 768px) {
    .railroad-photo-gallery-grid.photos-per-row-4 .gallery-grid,
    .railroad-photo-gallery-grid.photos-per-row-5 .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .railroad-photo-gallery-masonry.photos-per-row-4 .gallery-masonry,
    .railroad-photo-gallery-masonry.photos-per-row-5 .gallery-masonry {
        column-count: 2;
    }
    
    .recent-railroad-galleries {
        grid-template-columns: 1fr;
    }
    
    .carousel-prev,
    .carousel-next {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .carousel-prev {
        left: 10px;
    }
    
    .carousel-next {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .railroad-photo-gallery-grid .gallery-grid,
    .railroad-photo-gallery-masonry .gallery-masonry {
        grid-template-columns: 1fr;
        column-count: 1;
        gap: 10px;
    }
    
    .gallery-caption,
    .carousel-caption {
        padding: 15px 10px;
        font-size: 14px;
    }
    
    .gallery-info {
        padding: 12px;
    }
    
    .gallery-title {
        font-size: 15px;
    }
}

/* Lightbox styles (basic) */
.gallery-link[data-lightbox] {
    cursor: zoom-in;
}

/* Loading states */
.railroad-photo-gallery.loading {
    opacity: 0.6;
    pointer-events: none;
}

.railroad-photo-gallery.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #0073aa;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pagination styles */
.gallery-load-more-container {
    text-align: center;
    margin: 30px 0;
    padding: 20px 0;
}

.gallery-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    min-width: 160px;
    justify-content: center;
}

.gallery-load-more-btn:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.gallery-load-more-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.gallery-load-more-btn.loading {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.gallery-load-more-btn.loading:hover {
    background: #6c757d;
    transform: none;
    box-shadow: none;
}

.loading-spinner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.gallery-error {
    color: #dc3232;
    margin-top: 10px;
    text-align: center;
    font-size: 14px;
    padding: 10px;
    background: #fef7f7;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

/* Additional grid containers for pagination */
.gallery-grid-additional,
.gallery-masonry-additional {
    margin-top: 15px;
}

/* Smooth animation for new photos */
.gallery-item {
    animation: fadeInUp 0.5s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hide load more button when no more photos */
.gallery-load-more-container.hidden {
    display: none;
}

/* Accessibility improvements */
.gallery-link:focus,
.carousel-prev:focus,
.carousel-next:focus,
.carousel-dot:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gallery-item {
        border: 2px solid #000;
    }
    
    .gallery-caption,
    .carousel-caption {
        background: rgba(0, 0, 0, 0.9);
    }
    
    .carousel-prev,
    .carousel-next {
        background: #000;
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-image,
    .gallery-caption,
    .carousel-slide,
    .carousel-track {
        transition: none;
    }
    
    .railroad-photo-gallery.loading::after {
        animation: none;
    }
}

/* Related item links */
.railroad-photo-gallery-single .related-item {
    margin: 15px 0;
    padding: 10px;
    background: #f8f9fa;
    border-left: 3px solid #0073aa;
    border-radius: 3px;
}

.railroad-photo-gallery-single .related-item strong {
    color: #333;
    margin-right: 8px;
}

.railroad-photo-gallery-single .related-item a {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.railroad-photo-gallery-single .related-item a:hover {
    color: #005a87;
    text-decoration: underline;
}

/* Archive page railroad sections */
.railroad-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #eee;
}

.railroad-section:last-of-type {
    border-bottom: none;
}

.railroad-section-title {
    font-size: 1.8em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.railroad-section-title a {
    color: #0073aa;
    text-decoration: none;
    transition: color 0.3s ease;
}

.railroad-section-title a:hover {
    color: #005a87;
    text-decoration: underline;
}

.other-galleries-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #eee;
}

.other-galleries-title {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #666;
}

/* Adjust gallery item styling for grouped layout */
.railroad-section .gallery-item h3.gallery-title {
    font-size: 1.1em;
    margin-bottom: 8px;
}

.other-galleries-section .gallery-item h3.gallery-title {
    font-size: 1.2em;
    margin-bottom: 10px;
}

/* Archive Page Styles */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.max-width-container {
    width: 100%;
}

.page-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.jump-menu {
    margin-top: 20px;
    margin-bottom: 20px;
}

.jump-menu .flex {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.jump-menu a {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    background-color: #f3f4f6;
    color: #374151;
}

.jump-menu a:hover {
    background-color: #e5e7eb;
    color: #111827;
}

.jump-menu a span {
    margin-left: 8px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
}

.page-title {
    font-size: 2.5em;
    margin-bottom: 10px;
    color: #333;
}

.archive-description {
    font-size: 16px;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Railroad Cards Grid */
.railroads-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin: 40px 0;
}

.railroad-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.railroad-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    border-color: #0073aa;
}

.railroad-featured-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.railroad-featured-image a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.railroad-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.railroad-card:hover .railroad-image {
    transform: scale(1.05);
}

.railroad-card-header {
    padding: 24px 24px 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.railroad-title {
    margin: 0 0 12px 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.railroad-title-link {
    color: #1f2937;
    text-decoration: none;
    transition: color 0.3s ease;
    flex: 1;
    min-width: 0;
}

.railroad-title-link:hover {
    color: #0073aa;
    text-decoration: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.railroad-card-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.railroad-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
}

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #0073aa;
    line-height: 1;
    margin-bottom: 4px;
    text-align: center;
    width: 100%;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    width: 100%;
}

.railroad-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 24px;
}

.railroad-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: auto;
    padding-top: 20px;
}

.view-galleries-btn,
.view-railroad-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.3s ease;
    flex: 1;
    justify-content: center;
    min-width: 140px;
}

.view-galleries-btn {
    background: #0073aa;
    color: white;
}

.view-galleries-btn:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.view-railroad-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.view-railroad-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.view-galleries-btn .dashicons,
.view-railroad-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.photo-count {
    background: #0073aa;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.gallery-excerpt {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 15px;
}

.gallery-date {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Pagination */
.pagination {
    margin: 40px 0;
    text-align: center;
}

.page-numbers {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    transition: background-color 0.3s ease;
}

.page-numbers:hover,
.page-numbers.current {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
}

/* No galleries found */
.no-galleries-found {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-galleries-found h2 {
    margin-bottom: 15px;
    color: #333;
}

.no-galleries-found p {
    margin-bottom: 20px;
    font-size: 16px;
}

.no-galleries-found .button {
    display: inline-block;
    padding: 12px 24px;
    background: #0073aa;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.no-galleries-found .button:hover {
    background: #005a87;
}

/* Archive Page Responsive Design */
@media (max-width: 1200px) {
    .railroads-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 24px;
    }
}

@media (max-width: 992px) {
    .railroads-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .page-title {
        font-size: 2em;
    }

    .railroads-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        margin: 30px 0;
    }

    .railroad-card-header {
        padding: 20px 20px 12px 20px;
    }

    .railroad-title {
        font-size: 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .railroad-featured-image {
        height: 160px;
    }

    .railroad-card-content {
        padding: 20px;
    }

    .railroad-stats {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .stat-item {
        flex-direction: row;
        justify-content: center;
        gap: 8px;
    }

    .stat-number {
        font-size: 24px;
        margin-bottom: 0;
    }

    .stat-label {
        font-size: 14px;
    }

    .railroad-actions {
        flex-direction: column;
    }

    .view-galleries-btn,
    .view-railroad-btn {
        flex: none;
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .page-header {
        margin-bottom: 30px;
    }

    .railroad-photo-galleries-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .gallery-thumbnail {
        padding-bottom: 50%;
    }

    .no-thumbnail .dashicons {
        font-size: 48px;
    }
}

/* Loading state */
.railroad-photo-galleries-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Filter options (if added later) */
.gallery-filters {
    margin-bottom: 30px;
    text-align: center;
}

.gallery-filters select,
.gallery-filters input {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0 5px;
}

.gallery-filters button {
    padding: 8px 16px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.gallery-filters button:hover {
    background: #005a87;
}

/* Status badges */
.railroad-section-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.railroad-section-title a {
    display: inline-flex;
    align-items: center;
}

.status-badge.active {
    background-color: #dcfce7;
    color: #166534;
}

.status-badge.construction {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.legacy {
    background-color: #f3f4f6;
    color: #374151;
}

/* Jump menu status styling */
.jump-menu a .status-badge {
    margin-left: 8px;
    font-size: 10px;
    padding: 2px 8px;
}
