/*
Theme Name: Masonry Flow Theme
Theme URI: https://example.com/masonry-flow
Author: Your Name
Author URI: https://example.com
Description: A beautiful masonry grid WordPress theme with infinite scroll. Perfect for showcasing your posts in a dynamic, Pinterest-style layout with smooth animations and responsive design.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: masonry-flow
Tags: blog, two-columns, three-columns, four-columns, grid-layout, custom-colors, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ==========================
   CSS Variables & Design System
   ========================== */
:root {
    /* Brand Colors */
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;

    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing */
    --gap: 20px;
    --container-padding: 20px;

    /* Shadow */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

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

body {
    font-family: var(--font-primary);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-base);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ==========================
   Header
   ========================== */
.site-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    padding: 60px 0 40px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="40" height="40" patternUnits="userSpaceOnUse"><path d="M 40 0 L 0 0 0 40" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.site-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.site-title a {
    color: var(--white);
}

.site-title a:hover {
    opacity: 0.9;
}

.site-description {
    font-size: 1.2rem;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

/* ==========================
   Search & Navigation
   ========================== */
.search-section {
    background: var(--white);
    padding: 25px 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
}

.search-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 280px;
}

.search-box i,
.search-box .dashicons {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-box input[type="search"] {
    width: 100%;
    padding: 10px 15px 10px 45px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.search-box input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ==========================
   Main Content
   ========================== */
.site-main {
    padding: 40px 0 80px;
}

/* ==========================
   Masonry Grid
   ========================== */
.masonry-grid {
    column-count: 4;
    column-gap: var(--gap);
}

.post-card {
    break-inside: avoid;
    margin-bottom: var(--gap);
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-base);
    opacity: 0;
    animation: fadeIn var(--transition-slow) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* Card Components */
.card-media {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: var(--gray-100);
    aspect-ratio: 4 / 3;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.post-card:hover .card-media img {
    transform: scale(1.05);
}

.post-category {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--white);
    background: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.card-content {
    padding: 20px;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.4;
    color: var(--gray-900);
}

.card-title a {
    color: var(--gray-900);
}

.card-title a:hover {
    color: var(--primary);
}

.card-excerpt {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--gray-700);
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gray-200);
}

.card-author-info {
    flex: 1;
}

.card-author {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 2px;
}

.card-date {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.card-stats {
    display: flex;
    gap: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--gray-200);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.stat-item .dashicons {
    color: var(--gray-400);
    width: 18px;
    height: 18px;
    font-size: 18px;
}

/* ==========================
   Infinite Scroll Loading
   ========================== */
.loading-indicator {
    text-align: center;
    padding: 40px 0;
    display: none;
}

.loading-indicator.active {
    display: block;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    margin-top: 15px;
    color: var(--gray-500);
    font-size: 0.95rem;
}

.no-more-posts {
    text-align: center;
    padding: 40px 0;
    color: var(--gray-500);
    font-size: 0.95rem;
    display: none;
}

.no-more-posts.active {
    display: block;
}

/* ==========================
   Back to Top Button
   ========================== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all var(--transition-base);
    opacity: 0;
    pointer-events: none;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: all;
}

.back-to-top:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

/* ==========================
   Single Post
   ========================== */
.single-post-container {
    max-width: 900px;
    margin: 40px auto;
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.single-post-media {
    width: 100%;
    max-height: 500px;
    overflow: hidden;
    background: var(--gray-100);
}

.single-post-media img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

.single-post-content {
    padding: 40px;
}

.single-post-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    line-height: 1.2;
}

.single-post-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-200);
}

.entry-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--gray-700);
}

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

.entry-content h2,
.entry-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--gray-900);
}

/* ==========================
   Responsive Design
   ========================== */
@media (max-width: 1199px) {
    .masonry-grid {
        column-count: 3;
    }

    .site-title {
        font-size: 2.5rem;
    }
}

@media (max-width: 767px) {
    .masonry-grid {
        column-count: 2;
    }

    .site-title {
        font-size: 2rem;
    }

    .site-description {
        font-size: 1rem;
    }

    .search-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        min-width: 100%;
    }
}

@media (max-width: 479px) {
    .masonry-grid {
        column-count: 1;
    }

    .site-header {
        padding: 40px 0 30px;
    }

    .single-post-content {
        padding: 30px 20px;
    }

    .single-post-title {
        font-size: 2rem;
    }
}