/* ═══════════════════════════════════════════════════════════════
   PUBLIC LAYOUT — top nav + editorial work area
   ═══════════════════════════════════════════════════════════════ */

body.public {
    background: var(--surface);
    /* off-canvas drawer (.drawer, position:fixed; transform:translateX(100%))
       и его sticky-дети контрибутят в document scrollWidth → горизонтальный
       скролл на узких viewport. clip отрезает без создания скролл-контекста;
       hidden — фолбэк для Safari <16. */
    overflow-x: hidden;
    overflow-x: clip;
}

/* ══════════════ TOP NAV ══════════════ */
.p-top {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.9);
    border-bottom: 1px solid var(--line);
}
/* Frosted glass — только на десктопе. На <=960px backdrop-filter
   создаёт containing block для position:fixed потомков и ломает
   полноэкранное бургер-меню (.p-nav.is-open). */
@media (min-width: 961px) {
    .p-top {
        backdrop-filter: saturate(180%) blur(12px);
        -webkit-backdrop-filter: saturate(180%) blur(12px);
    }
}
.p-top-inner {
    max-width: var(--container);
    margin: 0 auto;
    height: var(--topbar-h);
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.p-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 800; font-size: 14px; letter-spacing: 0.06em;
    color: var(--ink);
}
.p-brand-mark {
    width: 32px; height: 32px;
    border-radius: 6px;
    overflow: hidden;
    display: grid; place-content: center;
}
.p-brand-mark img { width:100%; height:100%; object-fit:contain; }

.p-nav {
    display: flex;
    gap: 24px;
    margin-left: 12px;
    font-size: 14px;
    flex-wrap: nowrap;
}
.p-nav a { color: var(--graphite); font-weight: 500; position: relative; padding: 2px 0; white-space: nowrap; }
.p-nav a:hover { color: var(--ink); }
.p-nav a.is-active { color: var(--ink); font-weight: 600; }
.p-nav a.is-active::after {
    content: "";
    position: absolute; left: 0; right: 0; bottom: -22px;
    height: 2px; background: var(--ink);
}

.p-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.p-top-phone {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--ink);
    font-weight: 500;
    padding-right: 12px;
    margin-right: 4px;
    border-right: 1px solid var(--line);
    white-space: nowrap;
}

@media (max-width: 1100px) {
    .p-nav { gap: 18px; font-size: 13px; }
    .p-top-phone { display: none; }
}
@media (max-width: 960px) {
    /* .p-nav скрывается базовым inline-CSS в base.html и
       раскрывается через .p-nav.is-open (бургер). Здесь только
       компактная типографика бренда — список ссылок виден
       целиком в раскрытом меню. */
    .p-top-inner { padding: 0 16px; gap: 12px; }
    .p-brand { font-size: 13px; gap: 8px; }
}
@media (max-width: 480px) {
    .p-top-inner { padding: 0 12px; gap: 8px; }
    .p-top-actions { gap: 4px; }
    .p-top-actions .btn-sm { height: 36px; padding: 0 8px; font-size: 11px; }
    .p-brand-mark { width: 30px; height: 30px; }
    .p-brand { font-size: 12px; letter-spacing: 0.04em; }
}
@media (max-width: 339px) {
    /* Только на iPhone SE 1-го поколения (320px) бренд-текст скрываем,
       чтобы Войти/Регистрация поместились без переноса. На современных
       phones 360px+ (Galaxy S25, Pixel) бренд остаётся виден. */
    .p-brand > span { display: none; }
}

/* Footer */
.p-footer {
    border-top: 1px solid var(--line);
    margin-top: 80px;
    padding: 64px 0 32px;
    color: var(--graphite);
    font-size: 13px;
}
.p-footer-grid {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 48px;
}
.p-footer h5 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--ink); margin-bottom: 16px;
}
.p-footer a { display: block; padding: 4px 0; color: var(--graphite); }
.p-footer a:hover { color: var(--ink); }
.p-footer-legal {
    max-width: var(--container);
    margin: 48px auto 0;
    padding: 24px 24px 0;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--stone);
}

@media (max-width: 640px) {
    .p-footer { margin-top: 48px; padding: 40px 0 24px; }
    .p-footer-grid { grid-template-columns: 1fr; gap: 28px; }
    .p-footer h5 { margin-bottom: 10px; }
    .p-footer a { padding: 10px 0; min-height: 40px; display: inline-flex; align-items: center; }
    .p-footer-legal {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        margin-top: 32px;
    }
    .p-footer-legal > div:last-child { gap: 16px; flex-wrap: wrap; }
    .p-footer-legal a { padding: 8px 0; min-height: 40px; display: inline-flex; align-items: center; }
}

/* ══════════════ CATALOG PAGE ══════════════ */
.cat-head {
    border-bottom: 1px solid var(--line);
    padding: 40px 0 32px;
}
.cat-head-inner {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px 32px;
    flex-wrap: wrap;
}
.cat-head-inner > div:first-child { flex: 1 1 420px; min-width: 0; }
@media (max-width: 640px) {
    .cat-head-inner > div:first-child { flex: 0 0 auto; }
}
.cat-head h1 {
    font-size: clamp(2rem, 3vw + 1rem, 3rem);
    line-height: 1;
    letter-spacing: -0.03em;
}
.cat-head .eyebrow { margin-bottom: 8px; }
.cat-head-sub {
    color: var(--graphite);
    margin-top: 12px;
    max-width: 52ch;
    font-size: 15px;
}

.cat-head-sort {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    color: var(--stone);
    flex-shrink: 0;
}
.cat-head-sort select {
    border: 0;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    padding-right: 20px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%230a0a0a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right center;
    appearance: none;
}

/* ══════════════ CATALOG LAYOUT ══════════════ */
.cat-body {
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 24px 0;
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 40px;
    align-items: start;
}

/* Filter sidebar */
.f-side {
    position: sticky;
    top: calc(var(--topbar-h) + 20px);
    font-size: 13px;
}
.f-group {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}
.f-group:first-child { padding-top: 0; }
.f-group h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    color: var(--ink);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.f-group h4 .ct { font-family: var(--font-mono); color: var(--stone); font-weight: 400; letter-spacing: 0; }

.f-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    cursor: pointer;
    color: var(--graphite);
}
.f-check:hover { color: var(--ink); }
.f-check .ct { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--stone); }
.f-check input { margin: 0; }

.f-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.f-range input {
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 0 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    width: 100%;
}
.f-range input:focus { outline: none; border-color: var(--ink); }

.f-clear {
    margin-top: 4px;
    font-size: 12px;
    color: var(--stone);
    cursor: pointer;
}
.f-clear:hover { color: var(--ink); text-decoration: underline; }

/* Active filter pills row */
.cat-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
    align-items: center;
    font-size: 13px;
}
.cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 6px 0 12px;
    background: var(--paper);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
}
.cat-pill .x {
    width: 16px; height: 16px;
    border-radius: 50%;
    display: grid; place-content: center;
    color: var(--stone);
    cursor: pointer;
}
.cat-pill .x:hover { color: var(--ink); background: var(--line); }
.cat-pills .clear { color: var(--graphite); font-size: 12px; margin-left: 4px; cursor: pointer; }

.cat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 13px;
    color: var(--stone);
}
.cat-toolbar .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ══════════════ CAR GRID ══════════════ */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px 16px;
}

.p-car {
    background: var(--surface);
    transition: transform var(--dur-base) var(--ease);
    cursor: pointer;
}
.p-car:hover { transform: translateY(-2px); }

.p-car-img {
    aspect-ratio: 4/3;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}
.p-car-img::before {
    /* Placeholder silhouette shown behind real images */
    content: "";
    position: absolute; inset: 0; z-index: 0;
    background:
        radial-gradient(ellipse 60% 40% at 50% 70%, rgba(255,255,255,0.08), transparent 60%),
        linear-gradient(180deg, #2a2a2a 0%, #0e0e0e 100%);
}
.p-car-img img {
    position: relative; z-index: 1;
}
.p-car-img svg {
    position: absolute;
    left: 50%; top: 52%; transform: translate(-50%, -50%);
    width: 60%; max-width: 220px; opacity: 0.22;
}
.p-car-img .chip-flag svg {
    width: 16px; height: 12px;
    position: static; transform: none; opacity: 1; max-width: none;
}
.p-car-img .tl {
    position: absolute; top: 12px; left: 12px;
    display: flex; gap: 6px;
}
.p-car-img .tr {
    position: absolute; top: 12px; right: 12px;
}
.p-car-img .chip {
    height: 22px;
    padding: 0 8px;
    background: rgba(255,255,255,0.92);
    color: var(--ink);
    border-radius: 999px;
    font-size: 10px; font-weight: 700;
    letter-spacing: 0.06em; text-transform: uppercase;
    display: inline-flex; align-items: center;
}
.p-car-img .chip.is-accent { background: var(--accent); color: #fff; }
.p-car-img .fav {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    display: grid; place-content: center;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--dur-fast), transform var(--dur-fast);
}
.p-car-img .fav:hover { background: #fff; }
.p-car-img .fav:active { transform: scale(0.92); }
.p-car-img .fav.is-active { color: var(--fav); }
.p-car-img .fav svg {
    width: 16px; height: 16px; stroke-width: 2;
    position: static; transform: none; opacity: 1; max-width: none;
}
@media (max-width: 640px) {
    .p-car-img .fav { width: 40px; height: 40px; }
    .p-car-img .fav svg { width: 18px; height: 18px; }
}
.p-car-img .count {
    position: absolute; bottom: 12px; right: 12px;
    height: 22px; padding: 0 8px;
    background: rgba(0,0,0,0.65);
    color: #fff; border-radius: 999px;
    font-size: 11px; font-family: var(--font-mono);
    display: inline-flex; align-items: center; gap: 4px;
}

.p-car-body { padding: 12px 2px 0; }
.p-car-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    display: flex; justify-content: space-between; gap: 8px;
}
.p-car-title .year {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--stone);
    font-weight: 400;
    flex-shrink: 0;
}
.p-car-meta {
    font-size: 13px;
    color: var(--stone);
    margin-top: 4px;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}
.p-car-price-row {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line-2);
    display: flex; justify-content: space-between; align-items: baseline;
}
.p-car-price {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}
.p-car-loc {
    font-size: 12px;
    color: var(--stone);
}

/* ══════════════ PAGINATION ══════════════ */
.p-pager {
    margin: 40px 0 0;
    padding: 24px 0;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}
.p-pager-pages { display: flex; gap: 4px; }
.p-pager-pages a, .p-pager-pages button {
    min-width: 32px; height: 32px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; font-family: var(--font-mono); font-size: 13px;
    color: var(--graphite); cursor: pointer;
    transition: background var(--dur-fast), color var(--dur-fast);
}
.p-pager-pages a:hover, .p-pager-pages button:hover { background: var(--paper); color: var(--ink); }
.p-pager-pages .is-on { background: var(--ink); color: #fff; }
.p-pager-pages .dots { color: var(--stone); padding: 0 4px; }
