/* ─── Reset & base ────────────────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --border: #e4e2dd;
    --text: #1a1a18;
    --text-muted: #8a8880;
    --accent: #2d6a4f;
    --accent-soft: #e8f4ef;
    --badge-fs: #1a5c34;
    --badge-wtb: #1a3a6b;
    --badge-free: #7a3e00;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
    --radius: 6px;
    --header-h: 56px;
    --font-body: "DM Sans", system-ui, sans-serif;
    --font-mono: "DM Mono", monospace;
    --transition: 160ms ease;
}

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap');

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

/* ─── Sticky header shell ─────────────────────────────────────────────── */
#site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ─── Top bar: title + search + sort ─────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--header-h);
}

.site-title {
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
    margin-right: 4px;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
    pointer-events: none;
}

#search {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: .875rem;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

#search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, .12);
    background: var(--surface);
}

#search::placeholder {
    color: var(--text-muted);
}

/* Sort — segmented pill */
.sort-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
    flex-shrink: 0;
}

.sort-btn {
    padding: 6px 12px;
    font-family: var(--font-body);
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.sort-btn+.sort-btn {
    border-left: 1px solid var(--border);
}

.sort-btn.active {
    background: var(--accent);
    color: #fff;
}

.sort-btn:hover:not(.active) {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Filter toggle button */
#filter-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-family: var(--font-body);
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

#filter-toggle:hover,
#filter-toggle[aria-expanded="true"] {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

#filter-toggle .chevron {
    display: inline-block;
    font-size: .6rem;
    transition: transform var(--transition);
}

#filter-toggle .filter-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    display: none;
}

#filter-toggle.has-active .filter-dot {
    display: block;
}

/* ─── Collapsible filter panel ────────────────────────────────────────── */
#filter-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 240ms cubic-bezier(.4, 0, .2, 1), padding 240ms ease;
    border-top: 0px solid var(--border);
}

#filter-panel.open {
    max-height: 140px;
    border-top-width: 1px;
    padding: 12px 0;
}

.filter-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-label {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
}

.intent-btn {
    padding: 5px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    font-family: var(--font-body);
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.intent-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.intent-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Has-image toggle */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-track {
    width: 30px;
    height: 17px;
    background: var(--border);
    border-radius: 999px;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
    transition: transform var(--transition);
}

.toggle-label input:checked~.toggle-track {
    background: var(--accent);
}

.toggle-label input:checked~.toggle-track::after {
    transform: translateX(13px);
}

/* ─── Layout ──────────────────────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ─── Post grid ───────────────────────────────────────────────────────── */
#post-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

/* ─── Card ────────────────────────────────────────────────────────────── */
.post-card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition), transform var(--transition);
}

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

/* Thumbnail */
.thumb-wrapper {
    position: relative;
    width: 100%;
    padding-top: 72%;
    background: #ebebea;
    overflow: hidden;
}

.thumb-wrapper img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 300ms ease;
}

.post-card:hover .thumb-wrapper img {
    transform: scale(1.03);
}

.thumb-wrapper svg.intent-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
}

.icon-wtb path {
    fill: #93afd4;
}

.icon-fs path {
    fill: #86c4a4;
}

.icon-free path {
    fill: #d4ae72;
}

/* Carousel arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, .45);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: none;
    transition: background var(--transition);
    line-height: 1;
    padding-bottom: 1px;
}

.nav-arrow:hover {
    background: rgba(0, 0, 0, .75);
}

.nav-arrow.prev {
    left: 7px;
}

.nav-arrow.next {
    right: 7px;
}

.dot-container {
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
}

.dot {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, .5);
    border-radius: 50%;
    transition: background var(--transition);
}

.dot.active {
    background: #fff;
}

/* Post content */
.post-content {
    padding: 11px 13px 13px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.title-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.post-content a {
    font-size: .875rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    flex: 1;
}

.post-content a:hover {
    color: var(--accent);
}

/* Intent badge */
.intent-badge {
    font-family: var(--font-mono);
    font-size: .65rem;
    font-weight: 500;
    letter-spacing: .04em;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.badge-fs {
    background: #e8f5ee;
    color: var(--badge-fs);
}

.badge-wtb {
    background: #e8eef8;
    color: var(--badge-wtb);
}

.badge-free {
    background: #fdf3e3;
    color: var(--badge-free);
}

.badge-unknown {
    background: #f0f0ee;
    color: var(--text-muted);
}

.meta {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    font-size: .72rem;
    color: var(--text-muted);
}

.location {
    font-weight: 600;
    font-size: .72rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.timestamp {
    font-family: var(--font-mono);
    font-size: .68rem;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ─── Pagination ──────────────────────────────────────────────────────── */

/* Subtle top total counter styling placement rule */
.results-count {
    font-size: 0.85rem;
    color: #718096;
    /* Slate gray */
    margin: 12px 0 6px 4px;
    font-weight: 500;
}

/* Pagination container wrapper alignment formatting rules */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 32px auto;
    padding: 10px;
}

/* Format arrow controls cleanly */
.pagination-controls button {
    font-size: 1.15rem;
    font-weight: 600;
    padding: 4px 16px;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1.2;
    transition: background 0.2s, border-color 0.2s;
}

.pagination-controls button:hover:not(:disabled) {
    background-color: #f7fafc;
    border-color: #cbd5e0;
}

.pagination-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Container holding the button trail */
.pagination-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Individual item rules */
.page-num-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    padding: 0;
    min-width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Hover controls */
.page-num-btn:hover:not(.active):not(:disabled) {
    background-color: #f7fafc;
    border-color: #cbd5e0;
    color: #1a202c;
}

/* Current page assignment highlighting modifier */
.page-num-btn.active {
    background-color: #3182ce;
    /* Match your app's emphasis tone */
    border-color: #3182ce;
    color: #ffffff;
    font-weight: 600;
    cursor: default;
}

.page-num-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Ellipsis label styling */
.pagination-ellipsis {
    color: #a0aec0;
    padding: 0 4px;
    font-weight: 500;
    user-select: none;
    display: inline-block;
    text-align: center;
    min-width: 20px;
}

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .site-title {
        display: none;
    }

    .sort-group {
        display: none;
    }

    /* handled in filter panel on mobile */
    #post-list {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }
}

@media (max-width: 420px) {
    #post-list {
        grid-template-columns: 1fr;
    }
}