/*
Theme Name: My Masonry Theme
Description: A WordPress theme with a dynamic tag cloud and Pinterest-style post grid layout.
Author: Your Name
Version: 1.0
*/

/* Global styles */
body {
    font-family: 'Open Sans', sans-serif;
    font-size: 16px;
    color: #333;
    background-color: #fff;
    line-height: 1.6;
    margin: 0;
}

h1, h2, h3, .post-title {
    font-family: 'Libre Baskerville', serif;
}

/* Tag Cloud Section */
.tag-cloud-section {
    margin: 2rem 0;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-link {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #e9ecef;
    color: #495057;
    text-decoration: none;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.tag-link:hover {
    background: #007bff;
    color: white;
    transform: translateY(-2px);
}

/* Masonry post grid */
.post-grid {
    column-count: 3;
    column-gap: 1.5rem;
    padding: 2rem 0;
}

/* Each post card */
.post-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 1.5rem 0;
    break-inside: avoid-column;
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.post-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Post title styling */
.post-title {
    font-size: 1.2rem;
    margin: 0 0 0.5rem;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.post-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.3s ease;
}

.post-title a:hover {
    color: #007bff;
}

/* Excerpt text styling */
.post-excerpt {
    font-size: 1rem;
    line-height: 1.6;
    color: #666;
}

/* Responsive Design */
/* 2-column layout on tablets */
@media (max-width: 900px) {
    .post-grid {
        column-count: 2;
    }
}

/* 1-column layout on narrow mobile screens */
@media (max-width: 600px) {
    .post-grid {
        column-count: 1;
    }
    
    .tag-cloud-section {
        padding: 1rem;
    }
    
    .tag-link {
        /* limit font growth on very small screens */
        font-size: max(0.9rem, 4vw);
    }
}

/* Site Header */
.site-header {
    background: #343a40;
    color: white;
    padding: 1rem 0;
}

.site-title {
    text-align: center;
    margin: 0;
    font-size: 2rem;
}

.site-title a {
    color: white;
    text-decoration: none;
}

/* Main content wrapper */
.site-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Site Footer */
.site-footer {
    background: #343a40;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* Single Post Styles */
.single-post-content {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.single-post {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.post-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.post-meta {
    font-size: 0.9rem;
    color: #666;
    margin: 0.5rem 0;
}

.post-meta time {
    font-weight: 500;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content h2, .post-content h3, .post-content h4 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.post-content p {
    margin-bottom: 1.5rem;
}

.post-footer {
    border-top: 1px solid #eee;
    padding-top: 1rem;
    margin-top: 2rem;
}

.post-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #eee;
}

.post-navigation a {
    color: #007bff;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid #007bff;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.post-navigation a:hover {
    background: #007bff;
    color: white;
}

/* Archive Styles */
.archive-header {
    text-align: center;
    margin: 2rem 0;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.archive-title {
    color: #343a40;
    margin-bottom: 1rem;
}

.archive-description {
    color: #666;
    font-size: 1.1rem;
}

/* Pagination */
.pagination-wrapper {
    width: 100%;
    column-span: all;
    margin: 2rem 0;
}

.page-numbers {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-numbers a,
.page-numbers span {
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.page-numbers a:hover,
.page-numbers .current {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

/* No posts found */
.no-posts {
    text-align: center;
    padding: 3rem;
    background: #f8f9fa;
    border-radius: 8px;
    width: 100%;
    column-span: all;
}

/* Post tags styling */
.post-tags {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.post-tags a {
    color: #007bff;
    text-decoration: none;
    margin-right: 0.5rem;
}

.post-tags a:hover {
    text-decoration: underline;
}

/* Site description */
.site-description {
    text-align: center;
    margin: 0.5rem 0 0;
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Search Styles */
.search-header {
    text-align: center;
    margin: 2rem 0;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.search-title {
    color: #343a40;
    margin-bottom: 1rem;
}

.search-form-container {
    margin-top: 1rem;
}

.search-form {
    display: flex;
    max-width: 400px;
    margin: 0 auto;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    font-size: 1rem;
    outline: none;
}

.search-submit {
    background: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.3s ease;
}

.search-submit:hover {
    background: #0056b3;
}

.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    width: 1px !important;
    height: 1px !important;
    overflow: hidden;
}

/* Additional responsive improvements */
@media (max-width: 900px) {
    .tag-cloud-section h2,
    .archive-title,
    .search-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 600px) {
    .single-post-content {
        padding: 0 0.5rem;
    }
    
    .single-post {
        padding: 1rem;
    }
    
    .post-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .archive-header,
    .search-header {
        padding: 1rem;
    }
    
    .site-content {
        padding: 0 0.5rem;
    }
    
    .search-form {
        flex-direction: column;
        border-radius: 8px;
    }
    
    .search-submit {
        border-radius: 0 0 8px 8px;
    }
    
    .search-field {
        border-radius: 8px 8px 0 0;
    }
    
    .site-title {
        font-size: 1.5rem;
    }
    
    .post-card {
        margin-bottom: 1rem;
    }
}

/* Infinite Scroll Styles */
.infinite-scroll-loading,
.infinite-scroll-end,
.infinite-scroll-error {
    width: 100%;
    column-span: all;
    text-align: center;
    padding: 2rem;
    margin: 2rem 0;
}

.infinite-scroll-loading {
    background: rgba(248, 249, 250, 0.9);
    border-radius: 8px;
}

.infinite-scroll-end {
    background: #e9ecef;
    border-radius: 8px;
    color: #6c757d;
}

.infinite-scroll-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
}

/* Loading Spinner Animation */
.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.infinite-scroll-loading p,
.infinite-scroll-end p,
.infinite-scroll-error p {
    margin: 0;
    font-weight: 500;
}

/* Post card fade-in animation for infinite scroll */
.post-card {
    transition: opacity 0.3s ease-in-out;
}

/* Load more button (fallback for mobile) */
.load-more-button {
    display: block;
    width: 200px;
    margin: 2rem auto;
    padding: 1rem 2rem;
    background: #007bff;
    color: white;
    text-decoration: none;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.load-more-button:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

/* Mobile optimizations for infinite scroll */
@media (max-width: 600px) {
    .infinite-scroll-loading,
    .infinite-scroll-end,
    .infinite-scroll-error {
        padding: 1rem;
        margin: 1rem 0;
    }
    
    .loading-spinner {
        width: 30px;
        height: 30px;
    }
    
    .load-more-button {
        width: 100%;
        max-width: 300px;
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Hide pagination wrapper in infinite scroll mode */
.pagination-wrapper {
    display: none;
}