/* Styles for Daily Story Bites Gallery */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f9f9f9;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.2rem;
    font-weight: 300;
    margin-bottom: 10px;
    color: #333;
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    font-weight: 300;
}

/* Gallery styles */
.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 30px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.thumbnail {
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background-color: #f0f0f0; /* Background for loading state */
}

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

.thumbnail-image-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

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

.thumbnail-preview {
    padding: 10px 12px;
    font-size: 0.85rem;
    color: #444;
    line-height: 1.3;
    height: 3.4em; /* Height for two lines plus a bit more */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Number of lines to show */
    -webkit-box-orient: vertical;
    background-color: #fff;
}

/* Lazy loading styles */
.lazy-thumbnail {
    opacity: 0;
    transition: opacity 0.3s ease-in;
}

.lazy-thumbnail[src^="data:image"] {
    opacity: 0;
}

.lazy-thumbnail:not([src^="data:image"]) {
    opacity: 1;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow-y: auto;
}

.modal-content {
    position: relative;
    background-color: #fff;
    margin: 40px auto;
    padding: 25px 60px 15px;
    max-width: 800px;
    width: 85%;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close-button {
    position: absolute;
    top: 5px;
    right: 25px;
    font-size: 30px;
    color: #666;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
}

.close-button:hover {
    color: #000;
}

.modal-image {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    margin-bottom: 20px;
    border-radius: 4px;
    background-color: #f0f0f0; /* Placeholder background */
    transition: opacity 0.3s ease-in-out;
    position: relative;
}

.modal-image[src^="data:image"] {
    min-height: 200px; /* Minimum height for placeholder */
    animation: pulse 1.5s ease-in-out infinite; /* Loading animation */
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 0.8; }
    100% { opacity: 0.6; }
}

.modal-text {
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.7;
}

.modal-text p {
    margin-bottom: 15px;
}

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

.modal-date {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    text-align: right;
    margin: 0;
}

.modal-footer {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    margin: 0;
}

/* Button styles */
.button {
    display: block;
    width: 200px;
    margin: 0 auto 40px;
    padding: 12px 20px;
    background-color: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s, transform 0.2s;
}

.button:hover {
    background-color: #555;
    transform: translateY(-2px);
}

.button:active {
    transform: translateY(0);
}

/* Individual story page styles */
.story-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Story date is now in the footer */

.story-image-container {
    margin-bottom: 30px;
    text-align: center;
}

.story-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.story-content {
    line-height: 1.7;
    font-size: 1.1rem;
}

.story-content p {
    margin-bottom: 1em;
}

/* Footer styles */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 0.9rem;
}

.footer-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-text {
    margin: 0;
    text-align: center;
}

footer .story-date {
    margin: 0;
    text-align: right;
    font-size: 0.9rem;
    font-style: italic;
    color: #666;
}

/* Link styles */
a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #666;
    text-decoration: underline;
}

/* Responsive styles */
@media (max-width: 900px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
        max-width: 600px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .modal-content {
        padding: 20px 40px 10px;
        margin: 20px auto;
        width: 90%;
    }
    
    .modal-text {
        font-size: 1rem;
    }
    
    .story-content {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(1, 1fr);
        gap: 20px;
        max-width: 300px;
    }
    
    body {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .button {
        width: 100%;
    }
    
    .story-page {
        padding: 15px;
    }
}
