/* ===================================
   THE TEMPORAL GALLERY - POLISHED VERSION
   Elegant, Professional, Production-Ready
   =================================== */

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition-smooth: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.3s ease;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    transition: var(--transition-smooth);
    position: relative;
    overflow-x: hidden;
}

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

/* ===================================
   ATMOSPHERIC CANVAS
   =================================== */
#atmosphereCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.2s ease;
}

body.night-mode #atmosphereCanvas {
    opacity: 1;
}

/* ===================================
   DAY MODE STYLES
   =================================== */
body.day-mode {
    background: #fafafa;
    color: #1a1a1a;
}

body.day-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 250, 240, 0.4), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(250, 245, 235, 0.3), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ===================================
   NIGHT MODE STYLES
   =================================== */
body.night-mode {
    background: linear-gradient(180deg, #0f0f15 0%, #1a1a24 100%);
    color: #e8e8f0;
}

body.night-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 50% 0%, rgba(80, 60, 120, 0.15), transparent 60%),
        radial-gradient(circle at 0% 100%, rgba(60, 40, 100, 0.1), transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Glitch GIF Background - Night Mode Only */
body.night-mode::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('images/glitch.gif');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: lighten;
    animation: glitchFadeIn 2s ease-in-out forwards;
}

@keyframes glitchFadeIn {
    0% { opacity: 0; }
    100% { opacity: 0.04; }
}

/* ===================================
   TIME CONTROL BAR
   =================================== */
.time-control-bar {
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 24px 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

body.night-mode .time-control-bar {
    background: rgba(20, 20, 30, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.time-control-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
}

.time-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.current-mode {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: #333;
}

body.night-mode .current-mode {
    color: #b8a8d8;
}

.mode-icon {
    font-size: 1.6rem;
    animation: modeIconFloat 3s ease-in-out infinite;
}

@keyframes modeIconFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-3px); }
}

body.night-mode .mode-icon {
    filter: drop-shadow(0 0 8px rgba(184, 168, 216, 0.6));
}

.current-time {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 400;
    letter-spacing: 1px;
    color: #2a2a2a;
}

body.night-mode .current-time {
    color: #d8c8f8;
}

.control-toggle {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.04);
    padding: 4px;
    border-radius: 12px;
}

body.night-mode .control-toggle {
    background: rgba(255, 255, 255, 0.06);
}

.control-btn {
    padding: 10px 24px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition-fast);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    color: #666;
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.control-btn.active {
    background: white;
    color: #2a2a2a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.night-mode .control-btn {
    color: #9a9aaa;
}

body.night-mode .control-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.night-mode .control-btn.active {
    background: rgba(184, 168, 216, 0.2);
    color: #d8c8f8;
    box-shadow: 0 2px 12px rgba(184, 168, 216, 0.2);
}

.time-slider-container {
    flex: 1;
    max-width: 420px;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-fast);
}

.time-slider-container.active {
    opacity: 1;
    pointer-events: all;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 400;
    color: #999;
    margin-bottom: 10px;
    font-family: var(--font-body);
}

body.night-mode .slider-labels {
    color: #7a7a8a;
}

#timeSlider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, 
        #FFD700 0%, 
        #FFA500 25%, 
        #6a5a9a 50%, 
        #4a3a7a 75%, 
        #2a2a4a 100%);
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 12px;
    cursor: pointer;
}

#timeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border: 2px solid #2a2a2a;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: var(--transition-fast);
}

#timeSlider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

body.night-mode #timeSlider::-webkit-slider-thumb {
    border-color: #b8a8d8;
    box-shadow: 0 2px 8px rgba(184, 168, 216, 0.4);
}

.slider-time {
    text-align: center;
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.1rem;
    color: #2a2a2a;
}

body.night-mode .slider-time {
    color: #d8c8f8;
}

/* ===================================
   GALLERY HEADER
   =================================== */
.gallery-header {
    padding: 100px 0 60px;
    text-align: center;
    position: relative;
    z-index: 2;
}

.gallery-title {
    font-family: var(--font-display);
    font-size: 5rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 16px;
    color: #1a1a1a;
    transition: var(--transition-smooth);
}

body.night-mode .gallery-title {
    color: #f8f8ff;
    text-shadow: 0 0 30px rgba(184, 168, 216, 0.3);
}

.gallery-subtitle {
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-weight: 300;
    font-style: italic;
    color: #666;
    letter-spacing: 0.5px;
    transition: var(--transition-smooth);
}

body.night-mode .gallery-subtitle {
    color: #9a9aaa;
}

/* ===================================
   GALLERY GRID
   =================================== */
.gallery-main {
    padding: 40px 0 120px;
    position: relative;
    z-index: 2;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 80px;
}

/* ===================================
   PAINTING FRAMES
   =================================== */
.painting-frame {
    position: relative;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 90px;
}

.painting-frame:hover {
    transform: translateY(-8px);
    z-index: 50;
}

.painting-frame:hover .painting-info {
    opacity: 1;
    transform: translateY(0);
}

.painting-container {
    position: relative;
    border: 18px solid #d4af37;
    border-image: linear-gradient(135deg, #f4e4b7, #d4af37, #c49a37) 1;
    box-shadow: 
        0 12px 48px rgba(0, 0, 0, 0.12),
        inset 0 0 24px rgba(212, 175, 55, 0.15);
    background: #0a0a0a;
    overflow: hidden;
    animation: gentleFloat 5s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: auto;
}

@keyframes gentleFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

body.night-mode .painting-container {
    border-color: #3a3a2a;
    border-image: linear-gradient(135deg, #2a2a2a, #4a4a3a, #3a3a2a) 1;
    box-shadow: 
        0 16px 64px rgba(0, 0, 0, 0.6),
        inset 0 0 32px rgba(100, 60, 140, 0.2);
    animation: eerieFloat 4s ease-in-out infinite;
}

@keyframes eerieFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(0.5deg); }
}

.painting-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 250, 235, 0.25), transparent 60%);
    opacity: 0;
    animation: gentleGlow 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 10;
}

@keyframes gentleGlow {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.5; }
}

body.night-mode .painting-container::before {
    background: radial-gradient(circle, rgba(140, 108, 191, 0.3), transparent 55%);
    animation: eerieGlow 4s ease-in-out infinite;
}

@keyframes eerieGlow {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.7; }
}

/* ===================================
   PAINTING IMAGES
   =================================== */
.painting-day,
.painting-night {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 1.8s ease, filter 1.8s ease;
}

.painting-day {
    opacity: 1;
    filter: saturate(1.08) brightness(1.03) contrast(1.02);
}

.painting-night {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    filter: saturate(0.75) brightness(0.85) contrast(1.15);
    object-fit: cover;
    object-position: center;
}

body.night-mode .painting-day {
    opacity: 0;
}

body.night-mode .painting-night {
    opacity: 1;
}

.painting-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.eyes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8;
    opacity: 0;
    transition: opacity 0.6s ease;
}

body.night-mode .eyes-container {
    opacity: 1;
}

/* ===================================
   PAINTING INFO (Hover Card)
   =================================== */
.painting-info {
    position: absolute;
    bottom: -75px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(16px);
    padding: 28px 32px;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    width: 90%;
    max-width: 520px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.painting-frame:hover .painting-info {
    transform: translateX(-50%) translateY(0);
}

body.night-mode .painting-info {
    background: rgba(25, 25, 35, 0.98);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7),
                0 0 24px rgba(184, 168, 216, 0.1);
}

.painting-info h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 400;
    margin-bottom: 12px;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

body.night-mode .painting-info h3 {
    color: #f8f8ff;
}

.painting-info .artist {
    font-family: var(--font-body);
    font-size: 1.05rem;
    color: #666;
    font-style: italic;
    font-weight: 400;
    margin-bottom: 6px;
}

body.night-mode .painting-info .artist {
    color: #b8a8d8;
}

.painting-info .year {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: #999;
    font-weight: 300;
    margin-bottom: 18px;
}

body.night-mode .painting-info .year {
    color: #7a7a8a;
}

.painting-info .description {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.7;
    color: #444;
    font-weight: 300;
}

body.night-mode .painting-info .description {
    color: #d8d8e8;
}

.painting-info .day-desc {
    display: block;
}

.painting-info .night-desc {
    display: none;
}

body.night-mode .painting-info .day-desc {
    display: none;
}

body.night-mode .painting-info .night-desc {
    display: block;
}

/* ===================================
   FOOTER
   =================================== */
.gallery-footer {
    padding: 80px 0;
    text-align: center;
    background: #f5f5f5;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 2;
    transition: var(--transition-smooth);
}

body.night-mode .gallery-footer {
    background: #15151f;
    border-top-color: rgba(255, 255, 255, 0.06);
}

.footer-main {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 8px;
    color: #2a2a2a;
}

body.night-mode .footer-main {
    color: #d8d8e8;
}

.footer-tagline {
    font-family: var(--font-body);
    font-size: 1rem;
    font-style: italic;
    color: #666;
    margin-bottom: 20px;
    font-weight: 300;
}

body.night-mode .footer-tagline {
    color: #8a8a9a;
}

.footer-credit {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: #999;
    font-weight: 300;
}

body.night-mode .footer-credit {
    color: #6a6a7a;
}

/* ===================================
   TRANSITION MODE (During Change)
   =================================== */
body.transitioning .painting-day,
body.transitioning .painting-night {
    animation: subtleGlitch 0.4s ease-in-out 2;
}

@keyframes subtleGlitch {
    0%, 100% { 
        transform: translate(0, 0);
        filter: none;
    }
    25% { 
        transform: translate(-1px, 1px);
        filter: hue-rotate(20deg);
    }
    75% { 
        transform: translate(1px, -1px);
        filter: hue-rotate(-20deg);
    }
}

/* ===================================
   LOADING STATE
   =================================== */
.painting-day:not([src]),
.painting-night:not([src]) {
    background: linear-gradient(90deg, #f5f5f5 25%, #e8e8e8 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: shimmerLoad 1.8s ease-in-out infinite;
    min-height: 300px;
}

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

/* ===================================
   RESPONSIVE DESIGN
   =================================== */
@media (max-width: 1024px) {
    .container {
        padding: 0 24px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 60px;
    }
    
    .painting-frame {
        margin-bottom: 100px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 20px;
    }
    
    .time-control-bar {
        padding: 20px 0;
    }
    
    .time-control-bar .container {
        flex-direction: column;
        gap: 20px;
    }
    
    .time-info {
        width: 100%;
        justify-content: space-between;
    }
    
    .control-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .time-slider-container {
        max-width: 100%;
        width: 100%;
    }
    
    .gallery-title {
        font-size: 3rem;
    }
    
    .gallery-subtitle {
        font-size: 1rem;
    }
    
    .gallery-header {
        padding: 60px 0 40px;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 70px;
    }
    
    .painting-frame {
        margin-bottom: 120px;
    }
    
    .painting-info {
        width: 95%;
        padding: 24px;
        bottom: -85px;
        font-size: 0.95rem;
    }
    
    .painting-info h3 {
        font-size: 1.4rem;
    }
    
    .painting-info .artist {
        font-size: 1rem;
    }
    
    .painting-info .year {
        font-size: 0.85rem;
    }
    
    .painting-info .description {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .painting-frame .painting-info {
        opacity: 0;
    }
    
    .painting-frame:active .painting-info,
    .painting-frame.show-info .painting-info {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 480px) {
    .gallery-title {
        font-size: 2.2rem;
    }
    
    .current-time {
        font-size: 1.4rem;
    }
    
    .gallery-grid {
        gap: 60px;
    }
}