/* Mobile-First Foundation */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: Inter, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 38%),
        radial-gradient(circle at bottom left, rgba(255, 255, 255, 0.02), transparent 42%),
        #000000;
    color: #ffffff;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    padding-bottom: 5rem;
}

/* Glass Morphism Base */
.glass {
    background: rgba(17, 17, 17, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(14px);
    border-radius: 1.5rem;
}

/* Forum-Style Thread Rows */
.forum-thread {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(17, 17, 17, 0.72);
    backdrop-filter: blur(14px);
    transition: all 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.listing-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100%;
    width: 100%;
}

.listing-card .forum-thumbnail {
    width: 100%;
    height: 220px;
}

.listing-card .forum-content {
    margin-top: 1rem;
}

.listing-card .forum-price,
.listing-card .forum-action {
    margin-top: 1rem;
    flex-shrink: 0;
}

.listing-card .forum-price {
    text-align: left;
}

.listing-card .forum-action {
    align-self: flex-end;
}

/* Ensure threads don't force horizontal scroll */
.forum-thread {
    min-width: 0;
    overflow: hidden;
}

.forum-thread:hover {
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 24px rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.forum-thumbnail {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.forum-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.forum-content {
    flex: 1;
    min-width: 0;
}

.forum-title {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    /* allow wrapping but clamp to two lines for compactness */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

.forum-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.25rem;
    flex-wrap: wrap;
}

.forum-meta-item {
    white-space: nowrap;
}

.forum-price {
    text-align: right;
    flex-shrink: 0;
}

.forum-price-amount {
    font-size: 1.125rem;
    font-weight: 700;
    color: #ffffff;
    display: block;
}

.forum-status {
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-top: 0.25rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Button Styles */
.mono-btn-primary {
    background: #ffffff;
    color: #000000 !important;
    border: 1px solid rgba(255, 255, 255, 0.9);
    transition: opacity 0.2s ease, transform 0.2s ease;
    min-height: 44px;
    font-weight: 600;
    cursor: pointer;
    padding: 0.75rem 1.25rem;
}

.mono-btn-primary.text-white,
.mono-btn-primary .text-white {
    color: #000000 !important;
}

.mono-btn-primary:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.mono-btn-secondary {
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: border-color 0.2s ease, transform 0.2s ease;
    min-height: 44px;
    font-weight: 600;
    cursor: pointer;
    padding: 0.75rem 1.25rem;
}

.mono-btn-secondary:hover {
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}

/* Input Styles */
.mono-input {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.mono-input:focus {
    outline: 1px solid rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Status Chips */
.status-chip {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    white-space: nowrap;
    display: inline-flex;
}

.status-available {
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.status-reserved {
    border-color: rgba(229, 229, 229, 0.26);
    color: #e5e5e5;
}

.status-sold {
    border-color: rgba(140, 140, 140, 0.3);
    color: #8c8c8c;
}

/* Responsive Media Queries */
img,
iframe,
video,
canvas {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Listing feed grid: 1 column mobile, 2 columns on tablet, 3 columns on desktop */
#listing-feed.listing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    grid-auto-rows: auto;
}

@media (min-width: 768px) {
    #listing-feed.listing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1rem;
    }
}

@media (min-width: 1200px) {
    #listing-feed.listing-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 1.25rem;
    }

    /* center and constrain wide desktop layouts */
    .content-centered {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Category pills: wrap cleanly on small screens */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
}
.category-grid a {
    flex: 0 1 auto;
    max-width: 100%;
}

/* Mobile safe area for bottom nav */
body { padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
nav.sticky-bottom { padding-bottom: env(safe-area-inset-bottom); z-index: 60; }

button,
input,
select,
textarea {
    font: inherit;
}

.mobile-safe {
    min-height: calc(100vh - 6rem);
}

.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
}

/* Mobile Navigation */
nav.sticky-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 40;
    transition: transform 0.3s ease;
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0;
    padding: 0.5rem 0;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 0.5rem;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.6);
    transition: color 0.2s ease;
    font-size: 0.75rem;
    gap: 0.25rem;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
    color: #ffffff;
}

.bottom-nav-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tablet and Up */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    nav.sticky-bottom {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        border-top: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        background: transparent;
    }

    .bottom-nav-items {
        justify-content: flex-start;
        gap: 2rem;
        padding: 0.75rem 1rem;
        max-width: none;
    }

    .bottom-nav-item {
        flex: none;
        padding: 0;
        font-size: 0.875rem;
        flex-direction: row;
        gap: 0.5rem;
    }

    .forum-thread {
        padding: 1.25rem;
        gap: 1.25rem;
    }

    .forum-thumbnail {
        width: 100px;
        height: 100px;
    }

    .forum-title {
        font-size: 1.125rem;
    }
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    .card-hover:hover {
        transform: translateY(0);
        box-shadow: none;
    }

    .status-chip {
        width: fit-content;
    }

    .mono-input,
    .mono-btn-primary,
    .mono-btn-secondary {
        font-size: 0.95rem;
    }

    .forum-thread {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .forum-thumbnail {
        width: 70px;
        height: 70px;
    }

    .forum-title {
        font-size: 0.9rem;
    }

    .forum-meta {
        font-size: 0.7rem;
    }

    .forum-price-amount {
        font-size: 1rem;
    }
}
