/* ===================================
   CSS Variables & Reset
   =================================== */
:root {
    /* Colors - Dark Gray + Matte Red */
    --bg-primary: #121212;
    --bg-secondary: #1a1a1a;
    --bg-card: #222222;
    --bg-card-hover: #2a2a2a;
    --accent: #c74b4b;
    --accent-hover: #d65c5c;
    --accent-muted: rgba(199, 75, 75, 0.15);
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --border: #333333;
    --border-light: #404040;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===================================
   Header
   =================================== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--spacing-md) var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.logo .accent {
    color: var(--accent);
}

.controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

/* ===================================
   Search Box
   =================================== */
.search-box {
    position: relative;
    width: 280px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* ===================================
   Date Navigation
   =================================== */
.date-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.nav-btn:hover {
    background: var(--bg-card);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.nav-btn svg {
    width: 18px;
    height: 18px;
}

.date-input {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

.date-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.date-input::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

/* ===================================
   Main Content
   =================================== */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.stats-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stats-bar .separator {
    color: var(--text-muted);
}

/* ===================================
   Posts Grid
   =================================== */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-md);
}

@media (max-width: 1200px) {
    .posts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .posts-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .search-box {
        width: 100%;
    }
    
    .date-nav {
        justify-content: center;
    }
}

/* ===================================
   Post Card
   =================================== */
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-normal);
    animation: fadeIn 0.3s ease;
}

.post-card:hover {
    background: var(--bg-card-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-media {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect ratio */
    background: var(--bg-primary);
    overflow: hidden;
}

.post-media img,
.post-media video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-normal);
}

.post-card:hover .post-media img,
.post-card:hover .post-media video {
    transform: scale(1.05);
}

.media-type-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-primary);
    backdrop-filter: blur(4px);
}

.media-type-badge.video {
    background: rgba(199, 75, 75, 0.9);
}

.media-type-badge.gif {
    background: rgba(139, 92, 246, 0.9);
}

.post-info {
    padding: var(--spacing-md);
}

.post-caption {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
    min-height: 2.4em;
}

.post-caption:empty::before {
    content: 'No caption';
    color: var(--text-muted);
    font-style: italic;
}

.post-caption a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}

.post-caption a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.post-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.post-author {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.post-author img {
    width: 18px;
    height: 18px;
    border-radius: 50%;
}

/* ===================================
   Empty State
   =================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
}

.hidden {
    display: none !important;
}

/* ===================================
   Loading State
   =================================== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--spacing-md);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===================================
   Lightbox
   =================================== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
    animation: fadeIn 0.2s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.lightbox-close:hover {
    background: var(--accent);
}

.lightbox-close svg {
    width: 24px;
    height: 24px;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.lightbox-caption {
    margin-top: var(--spacing-lg);
    text-align: center;
    max-width: 600px;
}

.lightbox-caption p {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.lightbox-caption span {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===================================
   Scrollbar
   =================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
