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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    line-height: 1.6;
    color: #e0e0e0;              /* Light text */
    background: #121212;         /* Dark background */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
header {
    border-bottom: 1px solid #333;
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    color: #fff;
}

#topic-description {
    color: #aaa;
    margin-bottom: 0.5rem;
}

.meta-info {
    font-size: 0.875rem;
    color: #888;
}

.meta-info span:not(:last-child)::after {
    content: " • ";
    margin: 0 0.25rem;
}

/* Controls */
.controls {
    margin-bottom: 1.5rem;
}

#search-box {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid #444;
    border-radius: 2px;
    margin-bottom: 0.75rem;
    background: #1e1e1e;
    color: #e0e0e0;
}

#search-box:focus {
    outline: none;
    border-color: #36c;
    box-shadow: inset 0 0 0 1px #36c;
}

#active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    background: #2a2a2a;
    border-radius: 2px;
    font-size: 0.875rem;
    color: #e0e0e0;
}

.filter-tag button {
    margin-left: 0.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-weight: bold;
}

.filter-tag button:hover {
    color: #fff;
}

/* Main Content Layout */
.main-content {
    display: grid;
    gap: 1.5rem;
}

/* Categories Sidebar */
.categories-sidebar h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #ccc;
}

#category-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-item {
    padding: 0.375rem 0.75rem;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    color: #e0e0e0;
}

.category-item:hover {
    background: #2a2a2a;
}

.category-item.active {
    background: #36c;
    color: white;
    border-color: #36c;
}

.category-count {
    margin-left: 0.25rem;
    opacity: 0.7;
}

/* Posts Section */
.posts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #333;
}

#results-count {
    color: #aaa;
    font-size: 0.875rem;
}

#sort-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #444;
    border-radius: 2px;
    background: #1e1e1e;
    color: #e0e0e0;
    font-size: 0.875rem;
}

/* Post Items */
.post-item {
    padding: 1rem;
    border: 1px solid #333;
    border-radius: 2px;
    margin-bottom: 0.75rem;
    background: #1a1a1a;
    transition: box-shadow 0.2s;
}

.post-item:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.6);
}

.post-title {
    color: #4ea3ff;
    text-decoration: none;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.5rem;
}

.post-title:visited {
    color: #8cbcff;
}

.post-title:hover {
    text-decoration: underline;
}

.post-excerpt {
    color: #aaa;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8rem;
    color: #888;
}

.post-categories {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.post-category {
    padding: 0.125rem 0.375rem;
    background: #2a2a2a;
    border-radius: 2px;
    font-size: 0.75rem;
    color: #e0e0e0;
}

.post-source {
    font-style: italic;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: #888;
}

/* Desktop Layout */
@media (min-width: 768px) {
    .container {
        padding: 2rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .main-content {
        grid-template-columns: 250px 1fr;
    }

    #category-list {
        flex-direction: column;
    }

    .category-item {
        display: flex;
        justify-content: space-between;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    color: #888;
}

/* Accessibility */
:focus-visible {
    outline: 2px solid #36c;
    outline-offset: 2px;
}
