/**
 * site.css
 *
 * Layout и компоненты публичной части сайта:
 * header, карточки объявлений, детальная страница,
 * фильтры поиска, лайтбокс, footer, legal-страницы, 404.
 *
 * Зависит от base.css.
 */

/* ========== Header ========== */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.header-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header h1 a {
    color: var(--text);
}

.brand-block {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: 16px;
}

.header-saved-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    text-decoration: none;
    transition: 0.18s ease;
}

.header-saved-link:hover {
    background: var(--surface-2);
}

.header-saved-link #savedCount {
    font-weight: 700;
    min-width: 18px;
    text-align: center;
}

/* ========== Cards / surfaces ========== */

.card,
.viewer-card,
.details-card,
.search-panel,
.empty-state,
.legal-card,
.notfound-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card,
.viewer-card,
.details-card,
.empty-state,
.legal-card,
.notfound-card {
    border-radius: var(--radius-lg);
}

.search-panel {
    border-radius: 16px;
}

/* ========== Home / listing grid ========== */

.page-title {
    margin: 0 0 20px;
    font-size: 34px;
    letter-spacing: -0.03em;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 20px;
}

.card {
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 34px rgba(75, 62, 48, 0.12);
}

.card-media {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    overflow: hidden;
    position: relative;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-body {
    padding: 20px 18px 18px;
}

.card-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.card-head-row h3 {
    margin: 0;
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: -0.02em;
    flex: 1;
}

.listing-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.listing-head-row .listing-title {
    margin: 0 0 10px;
}

.favorite-btn-large {
    width: 48px;
    height: 48px;
    font-size: 22px;
    flex-shrink: 0;
}

.price,
.listing-price {
    margin: 0 0 12px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.card .price {
    margin: 0 0 14px;
    font-size: 20px;
}

.desc {
    margin: 14px 0 0;
    color: var(--muted);
}

.card .desc {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--muted);
}

.card .btn {
    margin-top: 18px;
}

.card-mini-specs {
    margin: 0 0 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card-mini-specs span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.card .risk-pill {
    margin-bottom: 14px;
}

/* ========== Listing page ========== */

.listing-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.9fr);
    gap: 24px;
    align-items: start;
}

.viewer-card {
    position: sticky;
    top: 92px;
    align-self: start;
    padding: 18px;
}

.details-card {
    position: sticky;
    top: 96px;
    padding: 24px;
}

.main-image-wrap {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: var(--surface-2);
    border: none;
    padding: 0;
    overflow: hidden;
    position: relative;
}

.main-viewer-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer-empty {
    min-height: 380px;
}

.thumb-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.thumb-btn {
    width: 92px;
    height: 72px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 12px;
    background: var(--surface-2);
    overflow: hidden;
    opacity: 0.82;
    transition: 0.18s ease;
}

.thumb-btn:hover {
    opacity: 1;
}

.thumb-btn.active {
    border-color: var(--accent);
    opacity: 1;
}

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

.listing-title {
    margin: 0 0 10px;
    font-size: 38px;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.spec-list {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.spec-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.spec-row span {
    color: var(--muted);
    font-size: 14px;
}

.spec-row strong {
    font-size: 14px;
    text-align: right;
}

.compact-specs {
    margin-top: 18px;
}

.description-block,
.extra-block {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.description-block {
    color: var(--muted);
}

.description-block h3,
.extra-block h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.listing-disclaimer {
    margin-top: 18px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.listing-disclaimer p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--muted);
}

/* ========== Search / filters ========== */

.reset-btn {
    font-size: 14px;
    color: var(--muted);
}

.nav-search {
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(760px, 100%);
    margin-left: 24px;
}

.nav-search input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.nav-search-btn,
.filter-toggle-btn {
    height: 46px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}

.filter-toggle-btn {
    width: 46px;
    padding: 0;
    font-size: 18px;
}

.search-panel {
    display: none;
    margin-top: 18px;
    margin-bottom: 24px;
    padding: 18px;
}

.search-panel.open {
    display: block;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.advanced-filters {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.advanced-filters.open {
    display: flex;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
    margin-top: 14px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
}

.checkbox-row span {
    color: var(--text);
    font-size: 15px;
}

.popular-searches {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.chip {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 14px;
    transition: all 0.15s ease;
}

.chip:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ========== Empty / utility states ========== */

.empty-state {
    margin-top: 20px;
    padding: 32px 24px;
    text-align: center;
    line-height: 1.5;
}

.empty-state h3 {
    margin: 0 0 10px;
    font-size: 28px;
}

.empty-state p {
    margin: 0 0 18px;
    color: var(--muted);
}

/* ========== Pagination ========== */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 28px;
    padding: 18px 16px;
}

.pagination-nav,
.pagination-btn,
.page-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    text-decoration: none;
    transition: 0.18s ease;
}

.pagination-nav:hover,
.pagination-btn:hover {
    background: var(--border);
}

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

/* ========== Lightbox ========== */

.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    background: rgba(20, 18, 16, 0.86);
}

.lightbox.is-open {
    display: flex;
}

.lightbox-content {
    max-width: min(1200px, 88vw);
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 100%;
    max-height: 88vh;
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
}

.lightbox-close {
    top: 22px;
    right: 24px;
    width: 48px;
    height: 48px;
    font-size: 28px;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    font-size: 28px;
}

.lightbox-prev {
    left: 22px;
}

.lightbox-next {
    right: 22px;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: #fff;
}

/* ========== Footer / legal / 404 ========== */

.site-footer {
    margin-top: 40px;
    border-top: 1px solid var(--border);
    background: var(--footer-bg);
}

.footer-inner {
    min-height: 88px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.footer-inner p {
    margin: 0;
    color: var(--muted);
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    padding: 28px 0 20px;
}

.footer-col h3 {
    margin: 0 0 10px;
    font-size: 18px;
}

.footer-col p {
    margin: 0 0 8px;
    color: var(--muted);
    line-height: 1.5;
}

.footer-col a:hover {
    color: var(--accent);
}

.footer-bottom {
    border-top: 1px solid var(--border);
    padding: 14px 0 20px;
}

.footer-bottom p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.legal-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 0 20px;
}

.legal-page h1 {
    margin: 0 0 18px;
    font-size: 38px;
    letter-spacing: -0.03em;
}

.legal-card {
    padding: 24px;
}

.legal-card p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.75;
}

.legal-card p:last-child {
    margin-bottom: 0;
}

.notfound-page {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

.notfound-card {
    width: 100%;
    max-width: 480px;
    padding: 40px 28px;
    text-align: center;
}

.notfound-card h1 {
    margin: 0 0 10px;
    font-size: 72px;
    color: var(--accent);
}

.notfound-card h2 {
    margin: 0 0 14px;
    font-size: 24px;
}

.notfound-card p {
    margin-bottom: 20px;
    color: var(--muted);
}

.notfound-actions {
    display: flex;
    justify-content: center;
}

/* ========== Responsive ========== */

@media (max-width: 980px) {
    .listing-layout {
        grid-template-columns: 1fr;
    }

    .viewer-card,
    .details-card {
        position: static;
    }

    .header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 14px 0;
    }

    .nav-search {
        width: 100%;
        margin-left: 0;
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .header {
        position: static;
    }

    .header-inner {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        align-items: center;
        gap: 10px;
        padding: 14px 0;
    }

    .brand-block {
        grid-column: 1;
        grid-row: 1;
        justify-content: flex-start;
    }

    .header h1 {
        margin: 0;
        font-size: 24px;
    }

    .header-actions {
        grid-column: 2;
        grid-row: 1;
        margin-left: 0;
        margin-top: 0;
        justify-self: end;
    }

    .nav-search {
        grid-column: 1 / -1;
        grid-row: 2;
        display: grid;
        grid-template-columns: 1fr auto auto;
        align-items: center;
        gap: 8px;
        width: 100%;
        margin-left: 0;
    }

    .nav-search input {
        width: 100%;
        min-width: 0;
        height: 44px;
        padding: 0 14px;
        font-size: 16px;
    }

    .nav-search-btn,
    .filter-toggle-btn {
        height: 44px;
        padding: 0 16px;
        font-size: 15px;
    }

    .filter-toggle-btn {
        width: 44px;
        padding: 0;
    }

    .page-title,
    .listing-title {
        font-size: 28px;
    }

    .page-title {
        margin-bottom: 16px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .card {
        border-radius: 18px;
    }

    .card-body {
        padding: 18px 16px 16px;
    }

    .card h3 {
        font-size: 20px;
    }

    .card .price {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .card-mini-specs {
        gap: 6px;
        margin-bottom: 12px;
    }

    .card-mini-specs span {
        min-height: 28px;
        padding: 0 9px;
        font-size: 12px;
    }

    .card .risk-pill {
        margin-bottom: 12px;
    }

    .card .desc {
        font-size: 15px;
    }

    .empty-state {
        padding: 26px 18px;
        border-radius: 18px;
    }

    .empty-state h3 {
        font-size: 24px;
    }

    .empty-state p {
        font-size: 15px;
    }

    .search-panel {
        padding: 16px;
    }

    .filter-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .filter-actions {
        gap: 10px;
    }

    .checkbox-row {
        margin-top: 12px;
    }

    .site-footer {
        margin-top: 28px;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 22px 0 16px;
    }

    .footer-col h3 {
        margin-bottom: 8px;
        font-size: 17px;
    }

    .footer-col p {
        margin-bottom: 6px;
        font-size: 15px;
    }

    .footer-bottom {
        padding: 12px 0 18px;
    }

    .footer-bottom p {
        font-size: 13px;
        line-height: 1.4;
    }

    .legal-page h1 {
        font-size: 28px;
    }

    .legal-card {
        padding: 18px;
        border-radius: 18px;
    }

    .notfound-page {
        padding: 34px 0;
    }

    .notfound-card {
        padding: 28px 18px;
        border-radius: 18px;
    }

    .notfound-card h1 {
        font-size: 56px;
    }

    .notfound-card h2 {
        font-size: 22px;
    }
}

@media (max-width: 720px) {
    .thumb-btn {
        width: 78px;
        height: 62px;
    }

    .lightbox {
        padding: 14px;
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
        font-size: 24px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 640px) {
    .nav-search {
        gap: 8px;
    }

    .nav-search-btn {
        padding: 0 14px;
    }
}

.archived-banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(183, 138, 82, 0.25);
    background: rgba(183, 138, 82, 0.12);
    color: var(--medium);
    font-size: 14px;
    font-weight: 600;
}

.demo-banner {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(183, 138, 82, 0.25);
    background: rgba(183, 138, 82, 0.12);
    color: var(--medium);
    font-size: 14px;
    font-weight: 600;
}

.demo-ribbon {
    position: absolute;
    top: 18px;
    left: -40px;
    width: 140px;
    background: linear-gradient(135deg, #c9a66b 0%, #a08050 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 6px 0;
    text-align: center;
    transform: rotate(-45deg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 5;
}
