/* =========================================================
   Product Card (spec §28)
   ========================================================= */
.ds-product-card {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    overflow: hidden;
    transition: box-shadow var(--ds-transition), transform var(--ds-transition), border-color var(--ds-transition);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.ds-product-card:hover {
    box-shadow: var(--ds-shadow-md);
    border-color: transparent;
    transform: translateY(-3px);
}

/* "بیشترین تخفیف‌ها" homepage section (template-parts/home/product-slider-discounts.php,
   .ds-discounts-section on the <section>) — a subtle warm/red tint on the card
   and its image area, just enough to visually set discounted products apart
   from the plain white cards used everywhere else on the site. */
.ds-discounts-section .ds-product-card {
    background: color-mix(in srgb, var(--ds-danger) 6%, var(--ds-white));
    border-color: color-mix(in srgb, var(--ds-danger) 22%, var(--ds-border));
}

.ds-discounts-section .ds-product-card-media {
    background: color-mix(in srgb, var(--ds-danger) 12%, var(--ds-primary-light));
}

.ds-product-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--ds-primary-light);
    overflow: hidden;
}

.ds-product-card-image-link {
    display: block;
    width: 100%;
    height: 100%;
}

.ds-product-card-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ds-product-card:hover .ds-product-card-image-link img {
    transform: scale(1.05);
}

.ds-badge {
    position: absolute;
    top: 10px;
    z-index: 2;
    font-size: var(--ds-fs-xs);
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: var(--ds-radius-sm);
}

.ds-badge-sale {
    right: 10px;
    background: var(--ds-accent);
    color: var(--ds-text);
}

.ds-badge-outofstock {
    right: 10px;
    background: var(--ds-muted);
    color: var(--ds-white);
}

.ds-wishlist-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ds-text);
    transition: color var(--ds-transition), background-color var(--ds-transition);
}

.ds-wishlist-btn:hover,
.ds-wishlist-btn[aria-pressed="true"] {
    color: var(--ds-danger);
}

/* Filled heart once favorited, not just a colored outline — the icon's own path
   already carries stroke="currentColor" fill="none" (inc/helpers.php), so this only
   needs to add the fill on top once active. */
.ds-wishlist-btn[aria-pressed="true"] svg path {
    fill: currentColor;
}

.ds-wishlist-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Static (non-card) placement — single product page, next to Add to Cart. */
.ds-wishlist-btn-static {
    position: static;
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    flex-shrink: 0;
}

.ds-wishlist-btn-static:hover {
    border-color: var(--ds-danger);
}

.ds-product-card-overlay {
    position: absolute;
    inset: 0;
    /* background: rgba(32, 40, 32, 0.45); */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ds-white);
    font-weight: 700;
    z-index: 1;
}

.ds-product-card-overlay span {
    background: #00000045;
    padding: 10px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 11px;
}

.ds-quickview-btn {
    position: absolute;
    bottom: -40px;
    right: 10px;
    left: 10px;
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    padding: 0.5rem;
    font-size: var(--ds-fs-xs);
    font-weight: 600;
    opacity: 0;
    transition: bottom var(--ds-transition), opacity var(--ds-transition);
    z-index: 2;
}

.ds-product-card:hover .ds-quickview-btn,
.ds-product-card:focus-within .ds-quickview-btn {
    bottom: 10px;
    opacity: 1;
}

.ds-product-card-body {
    padding: 0.5rem;
    flex-grow: 1;
}

/*
 * Product card title (site-owner request): always a single line — it must
 * never wrap onto a second line, however narrow the card is. At rest it
 * truncates with an ellipsis ("…") once the card doesn't have room for the
 * full name; on hover/focus the full title auto-scrolls into view instead of
 * staying cut off, then snaps back to the truncated state once the pointer
 * leaves the card again. The card's own width is what decides how much text
 * shows — a wide card shows the whole name, a narrow one clips more of it.
 *
 * The scrolling itself needs a plain-text run whose natural (unclamped)
 * width can be measured and slid within a clipped viewport — the ellipsis
 * shorthand alone (-webkit-line-clamp / text-overflow on the h2 itself)
 * can't do that, so initProductTitleScroll() in assets/js/theme.js wraps the
 * title text in an inner .ds-title-scroll-inner span once on page load and
 * toggles the .is-title-scrolling class on hover/focus; see the rules below.
 * If JS is ever unavailable the inner span is simply missing and the plain
 * text-overflow: ellipsis on the h2 itself still truncates it cleanly to one
 * line (no scroll animation in that case, but no wrapping/overflow either).
 */
.ds-product-card-body .woocommerce-loop-product__title {
    font-size: var(--ds-fs-sm);
    font-weight: 600;
    margin-bottom: 0.35rem;
    line-height: 1.5;
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ds-product-card-body .woocommerce-loop-product__title .ds-title-scroll-inner {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    transform: translateX(0);
    transition: transform 0.25s ease-out;
}

.ds-product-card-body .woocommerce-loop-product__title.is-title-scrolling .ds-title-scroll-inner {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    transition: transform var(--ds-title-scroll-duration, 2.2s) linear;
    transform: translateX(var(--ds-title-scroll-shift, 0px));
}

@media (max-width: 768px) {
    .ds-product-card-body .woocommerce-loop-product__title {
        font-size: var(--ds-fs-xs);
    }
}


.ds-product-card-rating {
    margin-bottom: 0.35rem;
}

.ds-product-card-body .price {
    font-size: var(--ds-fs-sm);
    font-weight: 700;
    color: var(--ds-primary-dark);
    /* Reserves the same vertical space whether the price is a single line (a
       plain price, or the "تماس بگیرید" call-to-order label on an out-of-stock
       product) or the two-line "قیمت قبل / قیمت جدید" before-after comparison
       (see .price.ds-price-compare below). Without this, cards with a
       one-line price end up noticeably shorter than their neighbors in the
       same row/slide, so the "اطلاعات بیشتر"/"افزودن به سبد خرید" buttons
       don't line up. 3.7em ~= the two-line block's real height at this
       font-size; align-items:center keeps a one-line price looking
       intentionally centered rather than stuck to the top of the extra space. */
    display: flex;
    align-items: center;
    min-height: 3.5em;
}

.ds-product-card-body .price del {
    color: var(--ds-muted);
    font-weight: 400;
    font-size: var(--ds-fs-sm);
    margin-inline-end: 0.4rem;
}

.ds-product-card-body .price ins {
    text-decoration: none;
}

/* Third-party "before/after" price comparison markup (a plugin on this site
   hooks woocommerce_get_price_html to print "قیمت قبل: X, قیمت جدید: Y" —
   see dairy_shop_restructure_before_after_price_html() in inc/woocommerce.php)
   restructured here so it wraps cleanly on narrow screens instead of running
   both prices together as one plain-text line that falls apart when space is
   tight. Used on both the product card (.ds-product-card-body .price) and the
   single-product summary (.single-product .summary .price) — those existing
   selectors still control font-size/color, this only adds the layout. */
.price.ds-price-compare {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    /* gap: 0.25rem 0.75rem; */
}

.ds-price-old,
.ds-price-new {
    display: inline-flex;
    align-items: baseline;
    gap: 0.3rem;
    white-space: nowrap;
    width: 100%;
}

.ds-price-old {
    color: var(--ds-muted);
    font-weight: 400;
    text-decoration: line-through;
    width: 100%;
}

.ds-price-label {
    font-size: var(--ds-fs-xs);
    font-weight: 400;
    opacity: 0.8;
}

@media (max-width: 480px) {
    .price.ds-price-compare {
        flex-direction: column;
        align-items: flex-start;
        gap: 0rem;
    }
}

.ds-product-card-footer {
    padding: 0.75rem;
}

.ds-product-card-footer .button,
.ds-add-to-cart-btn {
    display: block;
    width: 100%;
    text-align: center;
    background-color: var(--ds-primary);
    color: var(--ds-white) !important;
    border: 1px solid var(--ds-primary);
    border-radius: var(--ds-radius-sm);
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: var(--ds-fs-sm);
    transition: background-color var(--ds-transition);
}

@media (max-width: 768px) {

    .ds-product-card-footer .button,
    .ds-add-to-cart-btn {
        font-size: var(--ds-fs-xs);
    }
}

.ds-product-card-footer .button:hover,
.ds-add-to-cart-btn:hover {
    background-color: var(--ds-primary-dark);
    border-color: var(--ds-primary-dark);
}

.ds-product-card-footer .button.loading {
    opacity: 0.7;
    pointer-events: none;
}

/*
 * "اطلاعات بیشتر" (Read more) button — shown instead of "افزودن به سبد خرید"
 * for an out-of-stock / not-purchasable product (see the
 * woocommerce_loop_add_to_cart_args filter in inc/woocommerce.php, which is
 * what puts .ds-read-more-btn on it instead of .ds-add-to-cart-btn). Deliberately
 * NOT the solid brand-green add-to-cart color — a neutral outline style so the
 * two actions never look identical/interchangeable to a shopper (site-owner
 * request). Same size/shape as the add-to-cart button via the shared
 * ".ds-product-card-footer .button" rule above; only the colors are overridden.
 */
.ds-product-card-footer .ds-read-more-btn {
    background-color: var(--ds-white);
    color: var(--ds-text) !important;
    border-color: var(--ds-border);
}

.ds-product-card-footer .ds-read-more-btn:hover {
    background-color: var(--ds-text);
    color: var(--ds-white) !important;
    border-color: var(--ds-text);
}

/* WooCommerce loop grid (used everywhere content-product.php is looped) */
ul.products {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    list-style: none;
    padding: 0;
    margin: 0 0 2rem;
}

@media (min-width: 768px) {
    ul.products {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 992px) {
    ul.products {
        grid-template-columns: repeat(3, 1fr);
    }
}

ul.products li.product {
    margin: 0 !important;
}

/* =========================================================
   Blog cards
   ========================================================= */
.ds-blog-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .ds-blog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .ds-blog-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.ds-blog-card {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    overflow: hidden;
    box-shadow: var(--ds-shadow-sm);
    transition: box-shadow var(--ds-transition), transform var(--ds-transition), border-color var(--ds-transition);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ds-blog-card:hover {
    box-shadow: var(--ds-shadow-lg);
    border-color: transparent;
    transform: translateY(-4px);
}

.ds-blog-card-image-link {
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--ds-primary-light);
}

.ds-blog-card-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.ds-blog-card:hover .ds-blog-card-image-link img {
    transform: scale(1.06);
}

.ds-blog-card-body {
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.ds-blog-card-category {
    display: inline-block;
    align-self: flex-start;
    font-size: var(--ds-fs-xs);
    font-weight: 700;
    color: var(--ds-primary-dark);
    background: var(--ds-primary-light);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

.ds-blog-card-title {
    font-size: var(--ds-fs-lg);
    margin-bottom: 0.6rem;
    line-height: 1.5;
    transition: color var(--ds-transition);
}

.ds-blog-card:hover .ds-blog-card-title {
    color: var(--ds-primary);
}

.ds-blog-card-excerpt {
    color: var(--ds-muted);
    font-size: var(--ds-fs-sm);
    margin-bottom: 1.1rem;
    flex-grow: 1;
}

.ds-blog-card-meta {
    font-size: var(--ds-fs-xs);
    color: var(--ds-muted);
    padding-top: 0.9rem;
    border-top: 1px solid var(--ds-border);
}

.ds-blog-card-readmore {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--ds-primary);
    font-weight: 600;
    transition: gap var(--ds-transition);
}

.ds-blog-card-readmore::after {
    content: "";
    width: 6px;
    height: 6px;
    border-style: solid;
    border-color: currentColor;
    border-width: 0 1.4px 1.4px 0;
    transform: rotate(135deg);
    flex-shrink: 0;
}

.ds-blog-card:hover .ds-blog-card-readmore {
    gap: 0.55rem;
}

/* =========================================================
   Shop toolbar / filters / child categories
   ========================================================= */
.ds-shop-header {
    margin-bottom: 1rem;
}

.ds-shop-header-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-bottom: 0.35rem;
}

.ds-archive-title {
    font-size: var(--ds-fs-2xl);
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.35;
}

.ds-archive-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    padding: 0.45rem 0.95rem;
    background: #527D5E;
    color: #fff;
    border: 1px solid #527D5E;
    border-radius: 999px;
    font-size: var(--ds-fs-sm);
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--ds-transition), border-color var(--ds-transition), color var(--ds-transition), transform var(--ds-transition);
}

.ds-archive-back-btn:hover,
.ds-archive-back-btn:focus-visible {
    background: var(--ds-primary-dark);
    border-color: var(--ds-primary-dark);
    color: #fff;
    text-decoration: none;
}

.ds-archive-back-btn:focus{
    color: #fff;
    border-color: var(--ds-primary-dark);
}

.ds-archive-back-btn:active {
    transform: translateY(1px);
}

.ds-archive-back-btn-icon {
    width: 1.1em;
    height: 1.1em;
    flex-shrink: 0;
    /* Flip the left-chevron so it points toward the parent (inline-start in RTL). */
    transform: scaleX(-1);
}

@media (max-width: 575.98px) {
    .ds-shop-header-title-row {
        align-items: flex-start;
    }

    .ds-archive-title {
        font-size: var(--ds-fs-xl);
        flex: 1 1 calc(100% - 7.5rem);
    }

    .ds-archive-back-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8125rem;
    }
}

/* ===== Child Categories - هم‌اندازه و یکدست ===== */
.ds-child-categories {
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

@media (max-width: 768px) {
    .ds-child-categories {
        max-height: 155px;
        overflow-y: scroll;
        padding: 10px 10px;
        border: 1px solid #e6ede8;
        border-radius: 10px;
    }
}

.ds-child-categories .list-unstyled {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ===== دسکتاپ: همه آیتم‌ها هم‌عرض ===== */
.ds-child-categories .list-unstyled li {
    flex: 1 0 auto;
    /* همه به نسبت مساوی فضا می‌گیرند */
    min-width: 120px;
    max-width: 200px;
}

.ds-child-category-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    font-size: var(--ds-fs-sm);
    white-space: nowrap;
    transition: all var(--ds-transition);
    width: 100%;
    height: 100%;
    min-height: 44px;
    text-align: center;
    background: transparent;
    color: var(--ds-text);
    text-decoration: none;
}

.ds-child-category-pill:hover {
    border-color: var(--ds-primary);
    color: var(--ds-primary-dark);
    background: var(--ds-primary-light);
    text-decoration: none;
}

.ds-child-category-svg {
    display: inline-flex;
    width: 18px;
    height: 18px;
    color: var(--ds-primary);
    flex-shrink: 0;
}

.ds-child-category-svg svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ds-child-category-count {
    color: var(--ds-muted);
    font-size: var(--ds-fs-xs);
    flex-shrink: 0;
}

/* ===== پایان بخش child categories ===== */

.ds-shop-toolbar {
    padding-block: 1rem;
    border-bottom: 1px solid var(--ds-border);
    margin-bottom: 1.5rem;
}

.ds-orderby-select {
    max-width: 200px;
}

.ds-mobile-filters-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.ds-mobile-filters-toggle .ds-icon {
    width: 18px;
    height: 18px;
}

/* ===== ریسپانسیو برای موبایل ===== */
@media (max-width: 576px) {
    .ds-child-categories .list-unstyled li {
        flex: 0 0 calc(50% - 0.25rem);
        /* دقیقاً ۲ ستون با احتساب gap */
        min-width: 0;
        max-width: none;
    }

    /* آیتم آخر هم دقیقاً همان اندازه را حفظ می‌کند */
    .ds-child-categories .list-unstyled li:last-child {
        flex: 0 0 calc(50% - 0.25rem);
        min-width: 0;
        max-width: none;
    }

    .ds-child-category-pill {
        font-size: var(--ds-fs-xs);
        padding: 0.4rem 0.5rem;
        min-height: 38px;
    }

    .ds-child-category-svg {
        width: 14px;
        height: 14px;
    }
}

@media (max-width: 400px) {
    .ds-child-categories .list-unstyled li {
        flex: 0 0 calc(50% - 0.25rem);
        min-width: 0;
        max-width: none;
    }

    .ds-child-categories .list-unstyled li:last-child {
        flex: 0 0 calc(50% - 0.25rem);
        min-width: 0;
        max-width: none;
    }

    .ds-child-category-pill {
        font-size: 0.7rem;
        padding: 0.3rem 0.4rem;
        min-height: 34px;
        gap: 0.2rem;
    }

    .ds-child-category-count {
        font-size: 0.6rem;
    }
}

/* =========================================================
   Desktop sidebar filter panel (spec §12) — sticky card, shared with the
   mobile offcanvas via the same .ds-filters-form markup.
   ========================================================= */
.ds-sidebar-filters-card {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    padding: 1.5rem;
    position: sticky;
    /* Must clear BOTH the topbar and the main header row, since they scroll and
       stick together as one unit — using --ds-header-height alone left this card
       sliding in partway under the header while scrolling. */
    top: calc(var(--ds-header-height) + var(--ds-topbar-height) + 1rem);
}

.ds-sidebar-filters-title {
    font-size: var(--ds-fs-base);
    font-weight: 700;
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-filter-group {
    border: none;
    padding: 0 0 1.25rem;
    margin: 0 0 1.25rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-filter-group:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0.5rem;
}

.ds-filter-group summary {
    font-weight: 700;
    font-size: var(--ds-fs-sm);
    color: var(--ds-text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-block: 0.15rem;
}

.ds-filter-group summary::-webkit-details-marker {
    display: none;
}

.ds-filter-group summary::after {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 1.5px solid var(--ds-muted);
    border-bottom: 1.5px solid var(--ds-muted);
    transform: rotate(45deg);
    transition: transform var(--ds-transition);
    flex-shrink: 0;
}

.ds-filter-group[open] summary::after {
    transform: rotate(-135deg);
}

/* ---- Active filter chips ---- */
.ds-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-active-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--ds-primary-light);
    color: var(--ds-primary-dark);
    border-radius: 999px;
    padding: 0.3rem 0.5rem 0.3rem 0.75rem;
    font-size: var(--ds-fs-xs);
    font-weight: 600;
    transition: background-color var(--ds-transition);
}

.ds-active-filter-chip:hover {
    background: var(--ds-border);
    color: var(--ds-text);
}

.ds-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    line-height: 1;
}

.ds-active-filters-clear {
    font-size: var(--ds-fs-xs);
    color: var(--ds-danger);
    font-weight: 600;
    margin-inline-start: 0.25rem;
}

.ds-price-range-inputs input {
    text-align: center;
}

.ds-price-range-sep {
    color: var(--ds-muted);
    flex-shrink: 0;
}

/* Custom checkbox-style toggle (replaces raw browser checkboxes for a premium look) */
.ds-filter-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.65rem;
}

.ds-filter-toggle:last-child {
    margin-bottom: 0;
}

.ds-filter-toggle-input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border: 1.5px solid var(--ds-border);
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    transition: background-color var(--ds-transition), border-color var(--ds-transition);
}

.ds-filter-toggle-input:checked {
    background-color: var(--ds-primary);
    border-color: var(--ds-primary);
}

.ds-filter-toggle-input:checked::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 5px;
    width: 5px;
    height: 9px;
    border: solid var(--ds-white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ds-filter-toggle label {
    font-size: var(--ds-fs-sm);
    color: var(--ds-text);
    cursor: pointer;
    user-select: none;
}

/* ---- Rating filter (star radio options) ---- */
.ds-rating-filter {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ds-rating-filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: var(--ds-fs-sm);
}

.ds-rating-filter-option input[type="radio"] {
    accent-color: var(--ds-primary);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.ds-rating-filter-stars {
    display: inline-flex;
    gap: 1px;
    font-size: 0.85rem;
    letter-spacing: -1px;
    color: var(--ds-border);
}

.ds-rating-star.is-filled {
    color: var(--ds-accent);
}

.ds-rating-filter-label {
    color: var(--ds-muted);
}

.ds-filters-actions .btn-ds-outline {
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .ds-sidebar-filters-card {
        display: none;
    }
}

.ds-widget {
    margin-bottom: 2rem;
}

.ds-widget-title {
    font-size: var(--ds-fs-base);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ds-primary-light);
}

/* =========================================================
   Empty / 404 states (spec §29)
   ========================================================= */
.ds-empty-state {
    max-width: 480px;
    margin-inline: auto;
}

.ds-empty-state-title {
    font-size: var(--ds-fs-lg);
    font-weight: 700;
}

/* Keeps the 404 page from being so short that the footer shows up right under
   the "بازگشت به صفحه اصلی" button — min-height, not a fixed height, so a
   longer viewport is never clipped. */
.ds-404 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 530px;
}

.ds-404-code {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 800;
    color: var(--ds-primary-light);
    -webkit-text-stroke: 2px var(--ds-primary);
    margin-bottom: 0;
}

.ds-404-title {
    font-size: var(--ds-fs-xl);
    font-weight: 700;
    margin-top: 1rem;
}

/* =========================================================
   Pagination
   ========================================================= */
.woocommerce-pagination ul,
.pagination {
    display: flex;
    gap: 0.4rem;
    list-style: none;
    padding: 0;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.woocommerce-pagination ul li a,
.woocommerce-pagination ul li span,
.pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-fs-sm);
    padding-inline: 0.5rem;
}

.woocommerce-pagination ul li .current,
.pagination .page-numbers.current {
    background: var(--ds-primary);
    color: var(--ds-white);
    border-color: var(--ds-primary);
}

/* =========================================================
   Single post / page — wrapped in a card (white/border/shadow) instead of
   sitting bare on the page background, and the_content()'s generic HTML
   (headings, lists, links, quotes, images, tables, code) gets real styling
   instead of inheriting nothing but the site's plain body text.
   ========================================================= */
.ds-single-post {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-sm);
    padding: clamp(1.5rem, 4vw, 3rem);
}

.ds-single-post-header .ds-blog-card-category {
    margin-bottom: 0.85rem;
}

.ds-single-post-title,
.ds-page-title {
    font-size: var(--ds-fs-3xl);
    line-height: 1.4;
}

.ds-single-post-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: var(--ds-fs-sm);
    color: var(--ds-muted);
    margin-bottom: 0;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-meta-sep {
    color: var(--ds-border);
}

.ds-single-post-thumbnail {
    margin-block: 1.75rem;
}

.ds-single-post-thumbnail img,
.ds-page-thumbnail img {
    border-radius: var(--ds-radius-md);
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin-bottom: 0;
}

.ds-single-post-content,
.ds-page-body {
    font-size: var(--ds-fs-base);
    line-height: 1.95;
    color: var(--ds-text);
}

.ds-single-post-content p,
.ds-page-body p {
    margin-bottom: 1.25rem;
}

.ds-single-post-content h2,
.ds-page-body h2 {
    font-size: var(--ds-fs-xl);
    margin-top: 2.25rem;
    margin-bottom: 1rem;
    padding-inline-start: 0.85rem;
    border-inline-start: 4px solid var(--ds-accent);
}

.ds-single-post-content h3,
.ds-page-body h3 {
    font-size: var(--ds-fs-lg);
    margin-top: 1.75rem;
    margin-bottom: 0.85rem;
}

.ds-single-post-content ul,
.ds-single-post-content ol,
.ds-page-body ul,
.ds-page-body ol {
    margin-bottom: 1.25rem;
    padding-inline-start: 1.5rem;
}

.ds-single-post-content li,
.ds-page-body li {
    margin-bottom: 0.5rem;
}

.ds-single-post-content a,
.ds-page-body a {
    color: var(--ds-primary);
    text-decoration: underline;
    text-decoration-color: var(--ds-primary-light);
    text-underline-offset: 3px;
    font-weight: 600;
}

.ds-single-post-content a:hover,
.ds-page-body a:hover {
    text-decoration-color: var(--ds-primary);
}

.ds-single-post-content blockquote,
.ds-page-body blockquote {
    margin: 1.75rem 0;
    padding: 1.1rem 1.5rem;
    background: var(--ds-primary-light);
    border-inline-start: 4px solid var(--ds-primary);
    border-radius: 0 var(--ds-radius-md) var(--ds-radius-md) 0;
    font-style: italic;
    color: var(--ds-primary-dark);
}

.ds-single-post-content blockquote p:last-child,
.ds-page-body blockquote p:last-child {
    margin-bottom: 0;
}

.ds-single-post-content img,
.ds-page-body img {
    border-radius: var(--ds-radius-md);
    margin-block: 0.5rem;
}

.ds-single-post-content table,
.ds-page-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: var(--ds-fs-sm);
}

.ds-single-post-content th,
.ds-single-post-content td,
.ds-page-body th,
.ds-page-body td {
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--ds-border);
    text-align: start;
}

.ds-single-post-content th,
.ds-page-body th {
    background: var(--ds-primary-light);
    font-weight: 700;
}

.ds-single-post-content code,
.ds-page-body code {
    background: var(--ds-primary-light);
    color: var(--ds-primary-dark);
    padding: 0.15rem 0.4rem;
    border-radius: var(--ds-radius-sm);
    font-size: 0.9em;
}

.ds-single-post-content pre,
.ds-page-body pre {
    background: var(--ds-text);
    color: var(--ds-white);
    padding: 1.25rem;
    border-radius: var(--ds-radius-md);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.ds-single-post-content pre code,
.ds-page-body pre code {
    background: none;
    color: inherit;
    padding: 0;
}

.ds-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 2.25rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--ds-border);
}

.ds-tag-badge {
    font-size: var(--ds-fs-xs);
    font-weight: 600;
    border: 1px solid var(--ds-border);
    background: var(--ds-background);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    transition: background-color var(--ds-transition), border-color var(--ds-transition), color var(--ds-transition);
}

.ds-tag-badge:hover {
    background: var(--ds-primary);
    border-color: var(--ds-primary);
    color: var(--ds-white);
}

@media (max-width: 575.98px) {
    .ds-single-post {
        padding: 1.25rem;
        border-radius: var(--ds-radius-md);
    }
}

/* =========================================================
   Comments (single post / page) — comments.php template override + the
   CAPTCHA fields it prints via inc/comments.php's dairy_shop_captcha_field_html().
   Built to match the same card/border/radius/focus language used everywhere
   else in the theme (see the checkout form fields in woocommerce.css) rather
   than WordPress's unstyled default markup.
   ========================================================= */
.ds-comments-section {
    margin-top: 2.5rem;
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-sm);
    padding: clamp(1.5rem, 4vw, 3rem);
}

.ds-comments-title {
    font-size: var(--ds-fs-xl);
    margin-bottom: 1.5rem;
}

.ds-comment-list,
.ds-comment-list .children {
    list-style: none;
    padding-inline-start: 0;
    margin: 0;
}

.ds-comment-list .children {
    padding-inline-start: clamp(1.25rem, 4vw, 2.5rem);
    border-inline-start: 2px solid var(--ds-border);
}

.ds-comment {
    padding-block: 1.5rem;
    border-bottom: 1px solid var(--ds-border);
}

.ds-comment-list > .ds-comment:first-child {
    padding-top: 0;
}

.ds-comment-body {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.ds-comment-avatar img {
    border-radius: 50%;
    display: block;
}

.ds-comment-content {
    flex: 1;
    min-width: 0;
}

.ds-comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.ds-comment-author {
    font-weight: 700;
}

.ds-comment-date {
    font-size: var(--ds-fs-xs);
    color: var(--ds-muted);
}

.ds-comment-awaiting-moderation {
    font-size: var(--ds-fs-sm);
    color: var(--ds-warning);
    background: #FBF3E4;
    border-radius: var(--ds-radius-sm);
    padding: 0.4rem 0.75rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.ds-comment-text p {
    margin-bottom: 0.75rem;
}

.ds-comment-text p:last-child {
    margin-bottom: 0;
}

.ds-comment-reply {
    margin-top: 0.5rem;
}

.ds-comment-reply a {
    font-size: var(--ds-fs-sm);
    font-weight: 600;
    color: var(--ds-primary);
}

/* Comment form */
#respond.comment-respond {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ds-border);
}

.comment-reply-title {
    font-size: var(--ds-fs-xl);
    margin-bottom: 1.25rem;
}

.comment-reply-title small a {
    font-size: var(--ds-fs-sm);
    font-weight: 600;
    color: var(--ds-danger);
    margin-inline-start: 0.5rem;
}

.ds-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.ds-form-row .ds-form-group {
    flex: 1 1 200px;
}

.ds-form-group {
    margin-bottom: 1.1rem;
}

.ds-form-group label {
    display: block;
    font-size: var(--ds-fs-sm);
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.ds-required {
    color: var(--ds-danger);
}

.ds-form-control {
    width: 100%;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    padding: 0.65rem 0.85rem;
    background: var(--ds-white);
    font-family: inherit;
    font-size: var(--ds-fs-base);
    color: var(--ds-text);
}

.ds-form-control:focus {
    border-color: var(--ds-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--ds-primary-light);
}

.ds-captcha-group {
    background: var(--ds-background);
    border: 1px dashed var(--ds-border);
    border-radius: var(--ds-radius-md);
    padding: 1rem 1.1rem;
}

.ds-captcha-input {
    max-width: 140px;
}

.ds-comment-submit {
    margin-top: 0.5rem;
}

/* =========================================================
   Smart "back to top" button — hidden until the user scrolls down (toggled via
   JS in theme.js adding/removing .is-visible), smooth-scrolls to top on click.
   ========================================================= */
.ds-back-to-top {
    position: fixed;
    inset-inline-end: 1.25rem;
    bottom: 1.5rem;
    z-index: 1030;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--ds-primary);
    color: var(--ds-white);
    box-shadow: var(--ds-shadow-lg);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.25s ease, transform 0.25s ease, background-color var(--ds-transition), visibility 0.25s;
}

.ds-back-to-top .ds-icon {
    width: 22px;
    height: 22px;
}

.ds-back-to-top:hover {
    background: var(--ds-primary-dark);
}

.ds-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Clear the fixed mobile bottom nav bar (template-parts/header/mobile-bottom-nav.php,
   all mobile pages) — and, on product pages specifically, ALSO the sticky
   add-to-cart bar (z-index 1040) that sits directly above that nav bar there,
   both of which would otherwise sit on top of / behind this button. */
@media (max-width: 991.98px) {
    .ds-back-to-top {
        bottom: calc(var(--ds-mobile-navbar-height) + 1rem);
        inset-inline-end: 1rem;
        width: 42px;
        height: 42px;
    }

    body.single-product .ds-back-to-top {
        bottom: calc(var(--ds-mobile-navbar-height) + 5.5rem);
    }
}

/* =========================================================
   Sitewide "no image" placeholder (dairy_shop_image_placeholder() in
   inc/helpers.php) — used anywhere an image slot can legitimately be empty:
   blog cards, single post header, static pages, product cards, category
   cards. Sized by whatever wraps it (width:100%; height:100%); wrapping
   containers already establish their own aspect-ratio/height.
   ========================================================= */
.ds-image-placeholder {
    width: 100%;
    height: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--ds-primary-light) 0%, var(--ds-border) 100%);
    color: var(--ds-primary);
    border-radius: inherit;
}

.ds-image-placeholder .ds-icon {
    width: 30%;
    height: 30%;
    max-width: 64px;
    max-height: 64px;
    opacity: 0.55;
}