/* Chợ Cũ Bắc Ninh - giao diện xanh dương và trắng, ưu tiên điện thoại.
   Mô-típ riêng: "tem giá" (tag có lỗ xỏ dây) dùng cho từ khóa tìm nhiều và giá tiền. */

:root {
    --ink: #0d1b3e;
    --ink-soft: #4a5878;
    --cobalt: #1747d1;
    --cobalt-dark: #0f34a0;
    --cobalt-night: #0a2470;
    --sky: #e8f0ff;
    --bg: #f5f8fe;
    --line: #d8e2f5;
    --white: #ffffff;
    --tag: #ffd23f;
    --tag-soft: #fff1b8;
    --price: #b42318;
    --ok: #12805c;
    --focus: #7aa2ff;

    --radius-card: 12px;
    --radius-field: 10px;
    --radius-pill: 999px;

    --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --header-h: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
}

img,
svg {
    max-width: 100%;
    display: block;
}

a {
    color: var(--cobalt);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    color: var(--cobalt-dark);
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
    color: var(--ink);
}

p {
    margin: 0;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: 16px;
}

.container-narrow {
    max-width: 760px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    background: var(--ink);
    color: var(--white);
    padding: 8px 14px;
    border-radius: var(--radius-field);
}

.skip-link:focus {
    top: 12px;
    color: var(--white);
}

.muted {
    color: var(--ink-soft);
}

.icon {
    flex: none;
}

/* ---------- Nút ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius-field);
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-primary {
    background: var(--cobalt);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--cobalt-dark);
    color: var(--white);
}

.btn-accent {
    background: var(--tag);
    color: var(--ink);
}

.btn-accent:hover {
    background: #ffc400;
    color: var(--ink);
}

.btn-ghost {
    background: var(--white);
    color: var(--cobalt);
    box-shadow: inset 0 0 0 1.5px var(--line);
}

.btn-ghost:hover {
    background: var(--sky);
    color: var(--cobalt-dark);
}

.btn-small {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.9rem;
}

.btn-large {
    min-height: 52px;
    padding: 0 28px;
    font-size: 1.05rem;
}

/* ---------- Header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding-top: env(safe-area-inset-top, 0px);
}

.header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding-block: 10px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
}

.brand:hover {
    color: var(--ink);
}

.brand-mark {
    border-radius: 10px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--cobalt);
}

.brand-place {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--ink);
}

.header-search {
    order: 3;
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 4px 4px 4px 14px;
    background: var(--bg);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--ink-soft);
}

.header-search:focus-within {
    border-color: var(--cobalt);
    background: var(--white);
}

.header-search input {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    outline: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    text-decoration: none;
    color: var(--ink);
}

.header-link:hover {
    color: var(--cobalt);
}

.header-link-register,
.btn-post {
    display: none;
}

.cat-nav {
    display: none;
    border-top: 1px solid var(--line);
    background: var(--white);
}

.cat-nav-list {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.cat-nav-list::-webkit-scrollbar {
    display: none;
}

.cat-nav-list a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-soft);
    text-decoration: none;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
}

.cat-nav-list a:hover {
    color: var(--cobalt);
    border-bottom-color: var(--cobalt);
}

/* ---------- Thông báo ---------- */

.flash-wrap {
    padding-top: 16px;
}

.flash {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-field);
    border: 1px solid var(--line);
    background: var(--white);
}

.flash-success {
    background: #e6f6ef;
    border-color: #9fd8c0;
    color: #0b5d42;
}

.flash-error {
    background: #fdeceb;
    border-color: #f2b4af;
    color: #8e1d14;
}

.flash-close {
    border: 0;
    background: transparent;
    font-size: 1.4rem;
    line-height: 1;
    color: inherit;
    cursor: pointer;
}

/* ---------- Hero ---------- */

.hero {
    background: var(--cobalt);
    color: var(--white);
    padding: 28px 0 32px;
}

.hero-grid {
    display: grid;
    gap: 24px;
}

.hero h1 {
    color: var(--white);
    font-size: clamp(1.85rem, 6vw, 3.1rem);
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1.12;
    max-width: 20ch;
}

.hero-sub {
    margin-top: 14px;
    max-width: 52ch;
    font-size: 1.02rem;
    color: #dbe6ff;
}

.search-box {
    display: grid;
    gap: 8px;
    margin-top: 22px;
    padding: 10px;
    background: var(--white);
    border-radius: 14px;
    color: var(--ink);
}

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 12px;
    background: var(--bg);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-field);
    color: var(--ink-soft);
}

.search-field:focus-within {
    border-color: var(--cobalt);
    background: var(--white);
}

.search-field input,
.search-field select {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: 44px;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.97rem;
    color: var(--ink);
    outline: none;
}

.search-submit {
    min-height: 48px;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

/* Tem giá: cạnh trái nhọn, lỗ xỏ dây */
.tag-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px 0 26px;
    background: var(--white);
    color: var(--ink);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
    border-radius: 0 6px 6px 0;
}

.tag-chip::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 7px;
    height: 7px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--cobalt);
}

.tag-chip:hover {
    background: var(--tag);
    color: var(--ink);
}

.hero-art {
    display: none;
}

/* ---------- Dải lưu ý ---------- */

.trust-strip {
    background: var(--tag-soft);
    border-bottom: 1px solid #f0dc8a;
}

.trust-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 16px;
    padding-block: 10px;
    font-size: 0.9rem;
}

.trust-row p {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.trust-row p .icon {
    margin-top: 2px;
    color: #8a5a00;
}

.trust-row a {
    font-weight: 600;
    color: var(--ink);
}

/* ---------- Khối nội dung ---------- */

.section {
    padding-block: 36px;
}

.section-tint {
    background: var(--sky);
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head h2 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.section-link {
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.section-link:hover {
    text-decoration: underline;
}

/* ---------- Danh mục ---------- */

.cat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.cat-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    height: 100%;
    padding: 14px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    color: var(--ink);
    text-decoration: none;
}

.cat-tile:hover {
    border-color: var(--cobalt);
    color: var(--ink);
}

.cat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    border-radius: 50%;
    background: var(--sky);
    color: var(--cobalt);
}

.cat-name {
    font-weight: 700;
}

.cat-count {
    font-size: 0.85rem;
    color: var(--ink-soft);
}

/* ---------- Tin đăng ---------- */

.listing-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    overflow: hidden;
}

.card:hover {
    border-color: var(--cobalt);
}

.card-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--sky);
    overflow: hidden;
}

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

.card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #8fa9e6;
}

.badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: var(--radius-pill);
}

.badge-featured {
    background: var(--tag);
    color: var(--ink);
}

.card-body {
    padding: 10px 12px 12px;
}

.card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
}

/* Giá tiền dạng tem giá */
.price-tag {
    position: relative;
    display: inline-block;
    margin-top: 8px;
    padding: 3px 12px 3px 24px;
    background: var(--tag-soft);
    color: var(--price);
    font-size: 1.02rem;
    font-weight: 800;
    clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
    border-radius: 0 6px 6px 0;
}

.price-tag::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--white);
}

.card-cond {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--ok);
    font-weight: 600;
}

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--ink-soft);
}

.card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 20px;
    text-align: center;
    background: var(--white);
    border: 1.5px dashed #b6c8ee;
    border-radius: var(--radius-card);
}

.empty h3 {
    font-size: 1.15rem;
}

.empty p {
    max-width: 44ch;
    color: var(--ink-soft);
}

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--sky);
    color: var(--cobalt);
}

/* ---------- Khu vực ---------- */

.area-group + .area-group {
    margin-top: 18px;
}

.area-group-title {
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink-soft);
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 16px;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    color: var(--ink);
    font-size: 0.93rem;
    font-weight: 500;
    text-decoration: none;
}

.chip:hover {
    border-color: var(--cobalt);
    color: var(--cobalt);
}

/* ---------- Mua bán an toàn ---------- */

.safe-grid {
    display: grid;
    gap: 14px;
}

.safe-grid li {
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--line);
    border-left: 4px solid var(--cobalt);
    border-radius: var(--radius-card);
}

.safe-icon {
    display: inline-flex;
    margin-bottom: 8px;
    color: var(--cobalt);
}

.safe-grid h3 {
    margin-bottom: 6px;
    font-size: 1.05rem;
}

.safe-grid p {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

/* ---------- Dải kêu gọi đăng tin ---------- */

.cta-band {
    background: var(--cobalt-night);
    color: var(--white);
}

.cta-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-block: 32px;
}

.cta-band h2 {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 800;
}

.cta-band p {
    margin-top: 6px;
    color: #c9d6f5;
}

/* ---------- Trang nội dung ---------- */

.page-article {
    background: var(--white);
}

.breadcrumb {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.breadcrumb a {
    text-decoration: none;
}

.page-title {
    font-size: clamp(1.6rem, 4.5vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 18px;
}

.prose {
    max-width: 68ch;
    font-size: 1.02rem;
    line-height: 1.75;
}

.prose h2 {
    margin: 30px 0 10px;
    font-size: 1.25rem;
    font-weight: 800;
}

.prose p {
    margin-bottom: 14px;
}

.prose ul,
.prose ol {
    margin: 0 0 16px;
    padding-left: 22px;
}

.prose ul {
    list-style: disc;
}

.prose li {
    margin-bottom: 6px;
}

.prose .notice {
    margin: 18px 0;
    padding: 14px 16px;
    background: var(--tag-soft);
    border-left: 4px solid var(--tag);
    border-radius: 0 var(--radius-field) var(--radius-field) 0;
}

.contact-card {
    margin-top: 28px;
    padding: 20px;
    background: var(--sky);
    border-radius: var(--radius-card);
}

.contact-card h2 {
    margin-bottom: 12px;
    font-size: 1.15rem;
}

.contact-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.contact-list .icon {
    color: var(--cobalt);
}

.state-page {
    text-align: center;
}

.state-page .empty-icon {
    margin-bottom: 14px;
}

.state-text {
    max-width: 52ch;
    margin: 0 auto;
    color: var(--ink-soft);
}

.state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 22px;
}

.plain-state {
    padding-bottom: 0;
}

.plain-state .state-page {
    padding: 12vh 0;
}

.debug-box {
    margin-top: 24px;
    padding: 12px;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-word;
    background: #fdeceb;
    border: 1px solid #f2b4af;
    border-radius: var(--radius-field);
    font-size: 0.85rem;
}

/* ---------- Footer ---------- */

.site-footer {
    background: #0b1633;
    color: #c9d6f5;
}

.footer-grid {
    display: grid;
    gap: 28px;
    padding-block: 36px;
}

.footer-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--white);
}

.footer-slogan {
    margin-top: 4px;
    color: var(--tag);
    font-weight: 600;
}

.footer-note {
    margin-top: 12px;
    max-width: 46ch;
    font-size: 0.93rem;
}

.footer-heading {
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--white);
}

.footer-col li {
    padding: 4px 0;
    font-size: 0.93rem;
}

.site-footer a {
    color: #c9d6f5;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--white);
    text-decoration: underline;
}

.footer-contact li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.footer-contact .icon {
    margin-top: 4px;
    color: var(--tag);
}

.footer-bottom {
    border-top: 1px solid #22305c;
    font-size: 0.85rem;
}

.footer-bottom-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-block: 16px;
}

/* ---------- Thanh điều hướng điện thoại ---------- */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--white);
    border-top: 1px solid var(--line);
}

.tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 2px 0;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
}

.tabbar a[aria-current="page"] {
    color: var(--cobalt);
}

.tabbar-post-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-top: -22px;
    border-radius: 50%;
    background: var(--tag);
    color: var(--ink);
    border: 3px solid var(--white);
}

/* ---------- Máy tính bảng và máy tính ---------- */

@media (min-width: 640px) {
    .search-box {
        grid-template-columns: 1fr 1fr;
    }

    .search-field-q,
    .search-submit {
        grid-column: 1 / -1;
    }

    .cat-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .listing-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .safe-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .cta-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .footer-bottom-row {
        flex-direction: row;
        justify-content: space-between;
    }
}

@media (min-width: 900px) {
    body {
        padding-bottom: 0;
    }

    .tabbar {
        display: none;
    }

    .container {
        padding-inline: 24px;
    }

    .header-row {
        flex-wrap: nowrap;
    }

    .header-search {
        order: 0;
        flex: 1 1 auto;
        max-width: 520px;
    }

    .header-link-register,
    .btn-post {
        display: inline-flex;
    }

    .cat-nav {
        display: block;
    }

    .hero {
        padding: 56px 0 60px;
    }

    .hero-grid {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: center;
        gap: 48px;
    }

    .hero-art {
        display: block;
        justify-self: center;
        overflow: visible;
    }

    .section {
        padding-block: 52px;
    }

    .cat-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 14px;
    }

    .listing-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .footer-grid {
        grid-template-columns: 1.6fr 1fr 1fr 1.3fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .btn {
        transition: none;
    }
}
