@import url("fonts.css");

/* ==========================================================================
   Bellariva menyusi — avval mobil.
   Ranglar va tipografika bellariva.uz bilan bir xil.
   ========================================================================== */

:root {
    --paper:       #fbf7f1;
    --paper-alt:   #f3ebe0;
    --white:       #ffffff;
    --ink:         #171310;
    --body:        #574a40;
    --muted:       #8b7b6d;
    --line:        #e6dccf;
    --line-strong: #d4c6b4;
    --accent:      #9c4722;
    --accent-dark: #7d3617;
    --accent-soft: #f0e1d7;
    --forest:      #1e2922;

    --font-display: "Cormorant Garamond", Georgia, serif;
    --font-sans:    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --radius:    10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(23, 19, 16, .06), 0 2px 8px rgba(23, 19, 16, .04);
    --shadow:    0 6px 18px rgba(23, 19, 16, .10);
    --shadow-lg: 0 -8px 40px rgba(23, 19, 16, .22);

    --gutter: 1rem;
    --header-h: 3.5rem;
    /* .tabs__list ning taxminiy balandligi: .5 + 2.4 + .65 rem + satr bo‘shlig‘i. */
    --tabs-h: 3.8rem;
    --ease: cubic-bezier(.22, .61, .36, 1);

    /* Pastdagi qo‘ng‘iroq paneli balandligi — kontent uning tagida qolmasligi uchun. */
    --bar-h: calc(3.5rem + env(safe-area-inset-bottom, 0px));
}

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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /*
     * Kategoriyaga o‘tganda sarlavha yopishqoq panel tagida qolmasin.
     * JS yuklangach bu qiymat o‘lchangan haqiqiy balandlik bilan almashadi —
     * bu yerdagisi JS ishlamagan holat uchun.
     */
    scroll-padding-top: calc(var(--header-h) + var(--tabs-h));
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--body);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-wrap: break-word;
}

body.is-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); color: var(--ink); font-weight: 600; line-height: 1.15; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
li { list-style: none; }
img { max-width: 100%; display: block; }
a { color: inherit; }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Klaviatura bilan yuruvchilar uchun: fokus tushgandagina ko‘rinadi. */
.skip {
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 100;
    padding: .5rem .9rem;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: .85rem;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip:focus { transform: none; }

/* 1. Yuqori panel ---------------------------------------------------------- */

.top {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(251, 247, 241, .94);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}

.top__inner {
    height: var(--header-h);
    padding: 0 var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}

.brand { text-decoration: none; display: flex; flex-direction: column; min-width: 0; }

.brand__name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: .01em;
    line-height: 1.1;
}

.brand__tagline {
    font-size: .66rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top__actions { display: flex; align-items: center; gap: .4rem; flex: none; }

.iconbtn, .langbtn {
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: var(--white);
    color: var(--ink);
    text-decoration: none;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .06em;
    transition: background .2s var(--ease), border-color .2s var(--ease);
}

.iconbtn:active, .langbtn:active { background: var(--accent-soft); border-color: var(--accent); }
.iconbtn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--white); }

/* 2. Qidiruv --------------------------------------------------------------- */

.search { padding: 0 var(--gutter) .65rem; }

.search__field {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem .8rem;
    background: var(--white);
    border: 1px solid var(--line-strong);
    border-radius: 999px;
}

.search__field svg { color: var(--muted); flex: none; }

.search__field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: none;
    font: inherit;
    /* 16px dan kichik bo‘lsa iOS sahifani kattalashtirib yuboradi. */
    font-size: 1rem;
    color: var(--ink);
}

.search__field input::-webkit-search-cancel-button { display: none; }

.search__clear[hidden] { display: none; }

.search__clear {
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    background: var(--paper-alt);
    color: var(--body);
    font-size: 1.1rem;
    line-height: 1;
    display: grid;
    place-items: center;
}

/* 3. Kategoriya yorliqlari -------------------------------------------------- */

.tabs {
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs__list {
    display: flex;
    gap: .45rem;
    /* Tepadagi joy nom bilan yorliqlarni bir-biridan ajratib turadi. */
    padding: .5rem var(--gutter) .65rem;
    width: max-content;
    min-width: 100%;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    height: 2.4rem;
    padding: 0 .95rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--white);
    color: var(--body);
    font-size: .9rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}

.tab__emoji { font-size: .95rem; line-height: 1; }

/*
 * Kategoriya ikonkasi. Fayl — shaffof niqob, rangni matn beradi: shuning
 * uchun faol yorliqning to'q fonida ikonka o'zi ocharib ketadi.
 */
.catico {
    flex: none;
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    background: currentColor;
    -webkit-mask: var(--ico) center / contain no-repeat;
    mask: var(--ico) center / contain no-repeat;
}

.tab.is-active {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

/* 4. Filtrlar --------------------------------------------------------------- */

.filters {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding: .9rem var(--gutter) .2rem;
}

.filters::-webkit-scrollbar { display: none; }

.chip {
    flex: none;
    height: 2rem;
    padding: 0 .8rem;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--body);
    font-size: .8rem;
    white-space: nowrap;
    transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}

.chip.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-dark);
    font-weight: 500;
}

/* 5. Bo‘limlar va kartochkalar ---------------------------------------------- */

main { padding-bottom: 1rem; }

.cat { padding: 1.4rem var(--gutter) 0; }
.cat[hidden] { display: none; }

.cat__title {
    display: flex;
    align-items: center;
    gap: .45rem;
    font-size: 1.6rem;
    margin-bottom: .85rem;
}

.cat__title span { font-size: 1.25rem; }
.cat__title .catico { width: 1.4rem; height: 1.4rem; color: var(--accent); }

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
}

.card[hidden] { display: none; }

.card__open {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    text-align: left;
    padding: 0;
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}

.card__open:active { transform: scale(.975); box-shadow: var(--shadow); }

.card__media {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    background: var(--paper-alt);
}

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

.card__nophoto {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 2rem;
    opacity: .35;
}

.card__flag {
    position: absolute;
    top: .4rem;
    left: .4rem;
    padding: .18rem .45rem;
    border-radius: 999px;
    background: rgba(23, 19, 16, .82);
    color: var(--paper);
    font-size: .6rem;
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}

.card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .6rem .7rem .7rem;
}

.card__name {
    font-family: var(--font-display);
    font-size: 1.08rem;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
}

.card__desc {
    font-size: .76rem;
    line-height: 1.35;
    color: var(--muted);
    /* Ikki qatordan oshsa uchta nuqta bilan kesiladi. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card__foot {
    margin-top: auto;
    padding-top: .35rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .4rem;
}

.card__price {
    font-size: .95rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}

.card__price i { font-style: normal; font-size: .7rem; font-weight: 400; color: var(--muted); }
.card__weight { font-size: .7rem; color: var(--muted); white-space: nowrap; }

/* 6. Bo‘sh natija ----------------------------------------------------------- */

.empty[hidden] { display: none; }

.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: 4rem var(--gutter);
    text-align: center;
}

.empty strong { font-family: var(--font-display); font-size: 1.4rem; color: var(--ink); font-weight: 600; }
.empty span { font-size: .88rem; color: var(--muted); }
.empty .btn { margin-top: .75rem; }

/* 7. Tugmalar --------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    height: 2.75rem;
    padding: 0 1.15rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: .88rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s var(--ease), border-color .2s var(--ease);
}

.btn svg { width: 1.05rem; height: 1.05rem; }
.btn--primary { background: var(--accent); color: var(--white); }
.btn--primary:active { background: var(--accent-dark); }
.btn--ghost { border-color: var(--line-strong); background: var(--white); color: var(--ink); }
.btn--ghost:active { background: var(--paper-alt); }

/* 8. Pastki panel ----------------------------------------------------------- */

.bottombar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    gap: .5rem;
    padding: .5rem var(--gutter) calc(.5rem + env(safe-area-inset-bottom, 0px));
    background: rgba(251, 247, 241, .94);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line);
}

.bottombar .btn { flex: 1; min-width: 0; }

.totop {
    position: fixed;
    right: var(--gutter);
    bottom: calc(var(--bar-h) + .75rem);
    z-index: 24;
    width: 2.6rem;
    height: 2.6rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--ink);
    color: var(--paper);
    box-shadow: var(--shadow);
}

.totop[hidden] { display: none; }

/* 9. Pastdan ochiladigan oyna ------------------------------------------------ */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }

.sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(23, 19, 16, .55);
    animation: fade .25s var(--ease);
}

.sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    animation: rise .3s var(--ease);
    /* Barmoq bilan pastga surish uchun JS translateY ni shu yerga yozadi. */
    will-change: transform;
}

.sheet__grip {
    position: absolute;
    top: .5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2.25rem;
    height: .25rem;
    border-radius: 999px;
    background: var(--line-strong);
    z-index: 2;
}

.sheet__close {
    position: absolute;
    top: .75rem;
    right: .75rem;
    z-index: 2;
    width: 2.1rem;
    height: 2.1rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(251, 247, 241, .9);
    color: var(--ink);
    font-size: 1.5rem;
    line-height: 1;
    backdrop-filter: blur(6px);
}

.sheet__scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.sheet__media { background: var(--paper-alt); }
.sheet__media img { width: 100%; max-height: 45dvh; object-fit: cover; }
.sheet__media:empty { display: none; }

.sheet__body { padding: 1.1rem var(--gutter) 1.25rem; }

.sheet__cat {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    margin-bottom: .3rem;
}

.sheet__cat:empty { display: none; }

.sheet__title { font-size: 1.75rem; margin-bottom: .5rem; }

.sheet__desc { font-size: .95rem; line-height: 1.6; }
.sheet__desc:empty { display: none; }

.sheet__badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .85rem; }
.sheet__badges:empty { display: none; }

.sheet__badges li {
    padding: .25rem .6rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: .74rem;
    font-weight: 500;
}

.sheet__facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
    gap: .6rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.sheet__facts:empty { display: none; border: 0; padding: 0; margin: 0; }
.sheet__facts dt { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.sheet__facts dd { font-size: .95rem; font-weight: 500; color: var(--ink); }

.sheet__allergens { margin-top: 1rem; font-size: .8rem; color: var(--muted); }
.sheet__allergens:empty { display: none; }

.sheet__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem var(--gutter) calc(.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--white);
}

.sheet__price { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.sheet__price i { font-style: normal; font-size: .8rem; font-family: var(--font-sans); color: var(--muted); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }

/* 10. Pastki ma'lumot ------------------------------------------------------- */

.foot {
    margin-top: 2.5rem;
    /* Pastki qo'ng'iroq paneli footer oxirini yopib qo'ymasligi uchun. */
    padding: 2rem var(--gutter) calc(2.5rem + var(--bar-h));
    background: var(--forest);
    color: rgba(251, 247, 241, .72);
    font-size: .85rem;
}

.foot__brand {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--paper);
    margin-bottom: 1.1rem;
}

.foot__list { display: grid; gap: .85rem; }
.foot__list dt { font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; opacity: .6; }
.foot__list dd { color: var(--paper); }
.foot__list a { color: var(--paper); text-decoration: none; border-bottom: 1px solid rgba(251, 247, 241, .3); }

.foot__links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1.4rem; }
.foot__links a { color: var(--paper); text-decoration: none; border-bottom: 1px solid rgba(251, 247, 241, .3); }

.foot__note, .foot__copy { margin-top: 1.4rem; font-size: .74rem; opacity: .6; }
.foot__copy { margin-top: .4rem; }

/* 11. Kattaroq ekranlar ------------------------------------------------------ */

@media (min-width: 30rem) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); }
}

@media (min-width: 46rem) {
    :root { --gutter: 1.5rem; --header-h: 4rem; }

    /*
     * Lentaning o'zi cheklanadi, ichidagi ro'yxat emas: ro'yxatda
     * "min-width: 100%" bor va u "max-width" ni bosib, qatorni butun
     * ekran bo'ylab cho'zib yuborardi.
     */
    .top__inner, .search, .tabs, .filters, .cat, .foot__inner {
        max-width: 60rem;
        margin-inline: auto;
    }

    /*
     * Kompyuterda yorliqlar yangi qatorga o'tadi, surilmaydi.
     * Barmoq bilan surish mumkin bo'lmagan joyda yashirin gorizontal lenta
     * kategoriyalarni qo'lga tushmaydigan qilib qo'yardi.
     */
    .tabs { overflow: visible; }

    .tabs__list {
        flex-wrap: wrap;
        width: auto;
        min-width: 0;
        row-gap: .45rem;
    }

    .brand__name { font-size: 1.7rem; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 1rem; }
    .cat__title { font-size: 1.9rem; }
    .foot__list { grid-template-columns: repeat(3, 1fr); }

    /* Katta ekranda pastki panel kerak emas — kontakt pastda ko‘rinib turadi. */
    .bottombar { display: none; }
    :root { --bar-h: 0px; }
    .totop { bottom: 1.25rem; }

    .sheet__panel {
        left: 50%;
        bottom: 50%;
        transform: translate(-50%, 50%);
        width: min(34rem, calc(100vw - 3rem));
        max-height: 88dvh;
        border-radius: var(--radius-lg);
        animation: pop .25s var(--ease);
    }

    @keyframes pop { from { opacity: 0; transform: translate(-50%, 52%) scale(.97); } }
}

/* 12. Imkoniyatlar ----------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    .top, .bottombar, .totop, .sheet, .filters, .foot__links { display: none !important; }
    body { background: #fff; }
    .card__open { break-inside: avoid; box-shadow: none; }
}
