@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #fffaf7;
    --primary: #8f5662;
    --secondary: #2f493f;
    --border: #eaded8;
    --text: #2a2927;
    --muted: #6b625c;
    --radius: 12px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    min-height: 100%;
    background: linear-gradient(
        180deg,
        #eef2ef 0%,
        #e6ebe8 100%
    );
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    font-family: "Vazirmatn", Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(
            circle at top right,
            rgba(143, 86, 98, .10),
            transparent 30%
        ),
        linear-gradient(
            180deg,
            #eef2ef 0%,
            #e6ebe8 100%
        );
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
    border: none;
}

img {
    max-width: 100%;
    display: block;
}

.phone-shell {
    width: min(100vw, 420px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    box-shadow: 0 24px 70px rgba(38, 45, 41, .16);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255, 250, 247, .92);
    box-shadow: 0 10px 24px rgba(66, 56, 48, .10);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 21px;
    line-height: 1.4;
}

.eyebrow {
    margin: 0;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

.socials {
    display: flex;
    align-items: center;
    gap: 8px;
}

.socials a,
.icon-btn {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: #4c4845;
    text-decoration: none;
}

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#cartBadge {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.category-strip {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.category-strip::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 4px 8px;
    font-size: 1rem;
    border: 1px solid #e8dcd5;
    border-radius: 999px;
    background: #fff;
    color: #615b56;
    white-space: nowrap;
    transition: .2s;
}

.chip.is-active {
    background: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.products {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
    padding: 6px 6px 20px;
    scrollbar-width: thin;
    scrollbar-color: #d8c8bf transparent;
}

.products::-webkit-scrollbar {
    width: 6px;
}

.products::-webkit-scrollbar-thumb {
    background: #d8c8bf;
    border-radius: 999px;
}

.product-card {
    display: flex;
    flex-direction: column;
    height: 450px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    transition: transform .2s, border-color .2s, box-shadow .2s;
}

.product-card:hover {
    transform: translateY(-2px);
    border-color: rgba(143, 86, 98, .25);
    box-shadow: 0 10px 20px rgba(66, 56, 48, .10);
}

.image-button {
    width: 100%;
    aspect-ratio: 9 / 16;
    padding: 0;
    overflow: hidden;
    background: none;
    display: block;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: #f3ece7;
    transition: .3s;
    display: block;
}

.product-card:hover .product-image {
    transform: scale(1.03);
}

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    min-height: 0;
}

.product-name {
    margin: -15px -5px 0 0;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text);
    min-height: 50px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    text-align: right;
    width: 100%;
}

.product-meta {
    display: flex;
    justify-content: flex-end;
    margin-top: -15px;
}

.price {
    color: var(--secondary);
    font-size: 13.5px;
    font-weight: 700;
    white-space: nowrap;
}

.controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
}

.qty-stepper {
    flex: 1;
    height: 36px;
    display: flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid #e2d5cc;
    border-radius: 8px;
    background: #fffaf7;
}

.qty-step {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    background: none;
    font-size: 15px;
    font-weight: 700;
    color: #4c4845;
    transition: .15s;
}

.qty-step:hover {
    background: rgba(143, 86, 98, .06);
}

.qty-step:active {
    transform: scale(.95);
}

.qty-value {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.add-btn {
    width: 38px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 14px rgba(143, 86, 98, .22);
    transition: .2s transform, .2s background;
}

.add-btn:hover {
    transform: translateY(-1px);
}

.add-btn:active {
    transform: scale(.95);
}

.add-btn.is-added {
    background: var(--secondary);
}

.add-btn svg {
    width: 16px;
    height: 16px;
}

.image-button:focus-visible,
.product-name:focus-visible,
.qty-step:focus-visible,
.add-btn:focus-visible,
.primary:focus-visible,
.chip:focus-visible,
.icon-btn:focus-visible,
.socials a:focus-visible {
    outline: 2px solid rgba(47, 73, 63, .45);
    outline-offset: 2px;
}

.sheet {
    width: min(calc(100vw - 32px), 360px);
    max-height: calc(100vh - 40px);
    padding: 0;
    border: none;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
}

#productDialog {
    width: min(calc(100vw - 32px), 300px);
}

.sheet::backdrop {
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(3px);
}

.sheet-body {
    padding: 14px;
    background: var(--bg);
    max-height: calc(100vh - 68px);
    overflow-y: auto;
}

.terms-content {
    display: grid;
    gap: 10px;
    margin: 0 0 16px;
}

.terms-content p {
    margin: 0;
    line-height: 1.7;
    color: #5e5852;
    font-size: 13px;
}

#closeTermsBottom {
    width: 100%;
    padding: 14px 0;
    margin-top: 8px;
    font-size: 16px;
    border-radius: 12px;
}

.sheet-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sheet-title h2,
.detail-view h2 {
    margin: 0;
    font-size: 19px;
}

.detail-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.detail-view img {
    width: 110px;
    aspect-ratio: 9/16;
    object-fit: cover;
    object-position: center;
    border-radius: 12px;
    background: #f3ece7;
    flex-shrink: 0;
}

.detail-view strong {
    color: var(--secondary);
    font-size: 15px;
}

.detail-view p:last-of-type {
    margin: 0;
    line-height: 1.9;
    color: #5e5852;
}

.detail-view #detailDescription {
    white-space: pre-wrap;
    word-break: break-word;
    text-align: center;
}

.cart-items {
    display: grid;
    gap: 10px;
    margin: 16px 0;
    max-height: 50vh;
    overflow-y: auto;
}

.cart-row {
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 126px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
}

.cart-row img {
    width: 60px;
    height: 106px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    background: #f3ece7;
}

.cart-row h3 {
    margin: 0 0 4px;
    font-size: 12px;
    line-height: 1.6;
}

.cart-row span {
    color: #666;
    font-size: 11px;
}

.remove {
    width: 36px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff7f5;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    transition: .2s;
}

.remove:hover {
    background: #fcecea;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.cart-total strong {
    color: var(--secondary);
}

.primary {
    width: 100%;
    min-height: 42px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    transition: .2s;
}

.primary:hover {
    opacity: .92;
}

.primary:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.empty {
    padding: 22px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed #d9cbc2;
    border-radius: 10px;
}

@media (max-width:360px) {
    .product-card {
        height: 440px;
    }

    .product-name {
        font-size: 12.5px;
        min-height: 46px;
    }
}