/**
 * Gallery Styles
 * Chanraverse Art Gallery
 *
 * Styles for homepage slideshow, gallery grid, painting details, and collection filters
 */

/* ==========================================================================
   Hero Slideshow
   ========================================================================== */

.hero-slideshow {
    position: relative;
    width: 100%;
    height: 600px;
    background: #000;
    overflow: hidden;
}

.slideshow-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 800ms ease-in-out;
}

.slide.active {
    opacity: 1;
    z-index: 1;
}

.slide img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.slide-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    background: rgba(0, 0, 0, 0.68);
    display: flex;
    align-items: center;
    z-index: 2;
}

.slide-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.875rem 2rem;
    width: 100%;
    color: white;
    z-index: 2;
}

.slide-content h2 {
    font-size: 1.25rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.slide-year {
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.75;
    white-space: nowrap;
    flex-shrink: 0;
}

.slide-content .btn {
    margin-left: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.slide-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    z-index: 3;
}

.slide-nav:hover {
    background: rgba(255, 255, 255, 0.3);
}

.slide-prev {
    left: 2rem;
}

.slide-next {
    right: 2rem;
}

.slide-indicators {
    position: absolute;
    bottom: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.75rem;
    z-index: 3;
}

.indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    transition: background 0.3s, transform 0.3s;
}

.indicator:hover {
    background: rgba(255, 255, 255, 0.7);
    transform: scale(1.2);
}

.indicator.active {
    background: white;
    transform: scale(1.3);
}

.hero-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
}

.hero-fallback h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

/* ==========================================================================
   Hero Triptych
   ========================================================================== */

.hero-triptych {
    background: #b393ec;
    padding: 3.5rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.triptych-frame {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 0;
    width: 100%;
    box-sizing: border-box;
}

.triptych-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.triptych-link {
    display: block;
    text-decoration: none;
    transition: transform 0.35s ease;
}

.triptych-link:hover {
    transform: translateY(-8px);
}

.triptych-mat {
    padding: 10px;
    background: #fff;
    line-height: 0;
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.55);
    transition: box-shadow 0.35s ease;
    border: 1px black solid;
}

.triptych-link:hover .triptych-mat {
    box-shadow: 0 14px 48px rgba(138, 43, 226, 0.35), 0 8px 24px rgba(0, 0, 0, 0.5);
}

.triptych-img {
    display: block;
    width: auto;
    height: auto;
    /* CSS fallback before JS calculates the optimal size */
    max-height: 480px;
    max-width: 800px;
    border: 1px black solid;
}

.triptych-caption {
    padding: 0.875rem 0.25rem 0;
    text-align: center;
}

.triptych-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: 0.03em;
}

.triptych-year {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 0.2rem;
}

.triptych-fallback {
    text-align: center;
    color: white;
    padding: 4rem 0;
}

/* ==========================================================================
   Welcome Section
   ========================================================================== */

.welcome-section {
    padding: 4rem 0;
    background: white;
}

.welcome-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.welcome-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color, #8a2be2);
}

.welcome-content .lead {
    font-size: 1.25rem;
    line-height: 1.8;
    color: #666;
    margin-bottom: 2rem;
}

.welcome-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   Collections Preview
   ========================================================================== */

.collections-preview {
    padding: 4rem 0;
    background: #f8f9fa;
}

.collections-preview h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    color: #333;
}

.collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.collection-card {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
    color: inherit;
}

.collection-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.collection-image {
    width: 100%;
    min-height: 200px;
    max-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    overflow: hidden;
}

.collection-image img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    transition: transform 0.3s;
}

.collection-card:hover .collection-image img {
    transform: scale(1.05);
}

.collection-info {
    padding: 1.5rem;
}

.collection-info h3 {
    font-size: 1.5rem;
    margin: 0 0 0.5rem 0;
    color: #333;
}

.collection-info p {
    margin: 0;
    color: #666;
}

/* ==========================================================================
   CTA Section
   ========================================================================== */

.cta-section {
    padding: 4rem 0;
    background: linear-gradient(135deg, var(--primary-color, #8a2be2), #663399);
    color: white;
    text-align: center;
}

.cta-section h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.cta-section p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

/* ==========================================================================
   Page Header
   ========================================================================== */

.page-header {
    background: linear-gradient(135deg, var(--primary-color, #8a2be2), #663399);
    color: white;
    padding: 3rem 0;
    text-align: center;
}

.page-header h1 {
    font-size: 3rem;
    margin: 0 0 0.5rem 0;
}

.page-subtitle {
    font-size: 1.25rem;
    opacity: 0.95;
    margin: 0;
}

/* ==========================================================================
   Collection Filter
   ========================================================================== */

.collection-filter {
    padding: 2rem 0;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.collection-filter .container {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-label {
    font-weight: 600;
    color: #333;
}

.filter-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 2px solid #ddd;
    border-radius: 25px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.filter-btn:hover {
    border-color: var(--primary-color, #8a2be2);
    color: var(--primary-color, #8a2be2);
}

.filter-btn.active {
    background: var(--primary-color, #8a2be2);
    border-color: var(--primary-color, #8a2be2);
    color: white;
}

.filter-btn .count {
    opacity: 0.7;
    margin-left: 0.25rem;
}

/* ==========================================================================
   Gallery Grid
   ========================================================================== */

.gallery-container {
    max-width: none;
    margin: 0 auto;
    padding: 0 5rem; /* Wide margins on large screens */
}

.gallery-section {
    padding: 4rem 0;
}

.gallery-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    justify-content: center;
}

.gallery-item {
    background: white;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    flex: 0 0 auto;
    height: fit-content;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.gallery-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.gallery-image-wrapper {
    position: relative;
    background: #f0f0f0;
    overflow: hidden;
    display: inline-block;
    border: 1px black solid;
}

.gallery-item .gallery-image,
.gallery-item img.gallery-image {
    width: auto;
    height: auto;
    max-height: min(30vw, 450px);
    max-width: min(30vw, 450px);
    display: block;
}

.featured-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color, #8a2be2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    font-size: 0.875rem;
    font-weight: 600;
    display: none;
}

.gallery-item-info {
    padding: 1.5rem;
}

.gallery-title {
    font-size: 1.25rem;
    margin: 0 0 0.5rem 0;
    color: #333;
}

.gallery-year,
.gallery-medium {
    margin: 0.25rem 0;
    color: #666;
    font-size: 0.9rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state svg {
    margin-bottom: 1rem;
}

.empty-state h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #666;
}

.empty-state p {
    color: #999;
    line-height: 1.8;
}

.gallery-cta {
    background: #f8f9fa;
    padding: 3rem 0;
    text-align: center;
}

.gallery-cta h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.gallery-cta p {
    color: #666;
    margin-bottom: 2rem;
}

/* ==========================================================================
   Painting Detail Page
   ========================================================================== */

.painting-detail {
    padding: 3rem 0;
}

.painting-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    margin-bottom: 3rem;
}

.painting-gallery {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.main-image-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.main-image {
    width: auto;
    height: auto;
    max-width: min(80vw, 800px);
    max-height: min(80vh, 800px);
    display: block;
    image-rendering: high-quality;
    border: 1px black solid;
}

.image-thumbnails {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.thumbnail-btn {
    width: 80px;
    height: 80px;
    border: 3px solid transparent;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    padding: 0;
    transition: border-color 0.3s;
}

.thumbnail-btn:hover {
    border-color: #ddd;
}

.thumbnail-btn.active {
    border-color: var(--primary-color, #8a2be2);
}

.thumbnail-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.no-image {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    background: #f8f9fa;
    border-radius: 10px;
}

.no-image p {
    color: #999;
    margin-top: 1rem;
}

.painting-info {
}

.painting-title {
    font-size: 2.5rem;
    margin: 0 0 1.5rem 0;
    color: #333;
}

.painting-meta {
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.meta-item:not(:last-child) {
    border-bottom: 1px solid #e0e0e0;
}

.meta-item strong {
    color: #333;
}

.meta-item span {
    color: #666;
}

.painting-description {
    margin-bottom: 2rem;
}

.painting-description h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #333;
}

.painting-description p {
    line-height: 1.8;
    color: #666;
}

.painting-collections {
    margin-bottom: 2rem;
}

.painting-collections h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: #333;
}

.collection-tags {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.collection-tag {
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border-radius: 25px;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background 0.3s, color 0.3s;
}

.collection-tag:hover {
    background: var(--primary-color, #8a2be2);
    color: white;
}

.painting-pricing {
    background: #f8f9fa;
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.painting-pricing h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: #333;
}

.price-option {
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.price-option:last-child {
    margin-bottom: 0;
}

.price-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

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

.price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color, #8a2be2);
}

.price-description {
    color: #666;
    margin-bottom: 1rem;
}

.not-for-sale {
    text-align: center;
    color: #999;
    font-style: italic;
}

.painting-contact {
    text-align: center;
    padding: 2rem;
    background: #fff;
    border-radius: 10px;
    border: 2px dashed #ddd;
}

.painting-contact p {
    margin-bottom: 1rem;
    color: #666;
}

.back-link {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid #e0e0e0;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 968px) {
    /* Triptych */
    .hero-triptych {
        padding: 2.5rem 1rem;
    }

    .triptych-img {
        max-height: 300px; /* Fallback — JS overrides this */
    }

    /* Slideshow */
    .hero-slideshow {
        height: 400px;
    }

    .slide-content {
        padding: 0.75rem 1.25rem;
        gap: 1rem;
    }

    .slide-content h2 {
        font-size: 1rem;
    }

    .slide-nav {
        width: 40px;
        height: 40px;
    }

    .slide-prev {
        left: 1rem;
    }

    .slide-next {
        right: 1rem;
    }

    .welcome-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .collections-grid {
        grid-template-columns: 1fr;
    }

    .gallery-container {
        padding: 0 3rem; /* Smaller margins on tablets */
    }

    .gallery-grid {
        gap: 1.5rem;
    }

    .gallery-item .gallery-image,
    .gallery-item img.gallery-image {
        max-height: min(70vw, 450px);
        max-width: min(70vw, 450px);
    }

    .painting-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .painting-gallery {
        position: static;
    }

    .price-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 600px) {
    /* Triptych stacks vertically on small screens, center panel first */
    .triptych-frame {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }

    .triptych-panel.triptych-left  { order: 2; }
    .triptych-panel.triptych-center { order: 1; }
    .triptych-panel.triptych-right  { order: 3; }

    .triptych-img {
        max-height: none;
        max-width: 80vw;
        width: 80vw;
        height: auto !important; /* override JS-set heights when stacked */
    }
}

@media (max-width: 480px) {
    .hero-slideshow {
        height: 300px;
    }

    .slide-content {
        padding: 0.625rem 1rem;
        gap: 0.75rem;
    }

    .slide-content h2 {
        font-size: 0.9rem;
    }

    .slide-year {
        display: none;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .gallery-container {
        padding: 0 1.5rem; /* Standard margins on mobile */
    }

    .gallery-grid {
        gap: 1rem;
    }

    .gallery-item .gallery-image,
    .gallery-item img.gallery-image {
        max-height: none;
        max-width: none;
        width: 100%;
        height: auto;
    }

    .filter-buttons {
        width: 100%;
    }

    .filter-btn {
        flex: 1;
        text-align: center;
    }
}
