/**
 * PAESE — unified WooCommerce price presentation.
 *
 * This file is the final source of truth for promotional-price color.
 * Component styles may still control layout and font size, but every actual
 * reduced price must use --theme-palette-color-6.
 */

:root {
    --paese-regular-price-color: var(--theme-palette-color-5, var(--theme-text-color));
    --paese-regular-price-font-size: clamp(17px, 1.5vw, 20px);
    --paese-regular-price-font-weight: 600;
    --paese-old-price-color: #9a9a9a;
    --paese-old-price-font-size: 0.85rem;
    --paese-sale-price-color: var(--theme-palette-color-6);
    --paese-sale-price-font-size: clamp(17px, 1.5vw, 20px);
    --paese-sale-price-font-weight: 600;
}

/*
 * Safety fallback while the legacy iWorks Omnibus plugin is being removed.
 * The PAESE renderer is the only notice that should remain visible.
 */
.iworks-omnibus {
    display: none !important;
}

/* Native WooCommerce and Paese price HTML. */
:where(
    .woocommerce,
    .woocommerce-page,
    .wc-block-cart,
    .wp-block-woocommerce-cart,
    .fc-price,
    .fc-summary-price,
    .fc-mobile-summary-bar
) :where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price
) ins,
:where(
    .woocommerce,
    .woocommerce-page,
    .wc-block-cart,
    .wp-block-woocommerce-cart,
    .fc-price,
    .fc-summary-price,
    .fc-mobile-summary-bar
) :where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price
) ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
    text-decoration: none;
}

/* Paese markup can use .sale-price as the promotional value wrapper. */
:where(
    .woocommerce,
    .woocommerce-page,
    .fc-price,
    .fc-summary-price,
    .fc-mobile-summary-bar
) .sale-price:not(:has(del)),
:where(
    .woocommerce,
    .woocommerce-page,
    .fc-price,
    .fc-summary-price,
    .fc-mobile-summary-bar
) .sale-price:not(:has(del)) :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
}

/*
 * Dynamic-pricing fallback.
 *
 * Some YITH rules return:
 * <del>regular price</del> <span class="amount">current price</span>
 * instead of the native WooCommerce <del>...</del><ins>...</ins> structure.
 * Only a direct amount following del is selected, so Omnibus amounts nested
 * in their own notices remain untouched.
 */
.fc-price-main > del ~ .woocommerce-Price-amount,
.fc-price-main > del ~ .woocommerce-Price-amount .woocommerce-Price-currencySymbol,
.fc-price-main > del ~ .amount,
.fc-price-main > del ~ .amount .woocommerce-Price-currencySymbol,
.price > del ~ .woocommerce-Price-amount,
.price > del ~ .woocommerce-Price-amount .woocommerce-Price-currencySymbol,
.price > del ~ .amount,
.price > del ~ .amount .woocommerce-Price-currencySymbol {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
}

/* Woo and YITH sale markup share the same baseline layout. */
.price:has(> del) {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35em;
}

.price > del,
.price > del :where(.amount, .woocommerce-Price-amount, .woocommerce-Price-currencySymbol) {
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    line-height: 1.2;
}

/* WooCommerce Cart and Checkout blocks. */
.wc-block-components-product-price__value.is-discounted,
.wc-block-components-product-price__value.is-discounted :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
),
.wc-block-grid__product-price ins,
.wc-block-grid__product-price ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
}

.wc-block-components-sale-badge {
    color: var(--paese-sale-price-color) !important;
}

/* Legacy cart markup generated by the child theme. */
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal,
    .product-price,
    .product-subtotal
) .sale-price ins,
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal,
    .product-price,
    .product-subtotal
) .sale-price ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
}

/* Direct sale markup in the classic cart amount column. */
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal,
    .product-price,
    .product-subtotal
) ins,
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal,
    .product-price,
    .product-subtotal
) ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
    text-decoration: none;
}

/* A regular or old price remains neutral. */
:where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price
) del,
:where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price
) del :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--theme-text-color, #777);
}

/* Preserve semantic formatting consistently. */
:where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price,
    .wc-block-grid__product-price
) ins {
    font-style: normal;
    text-decoration: none;
}

:where(
    .price,
    .sale-price,
    .fc-price-main,
    .woocommerce-variation-price,
    .wc-block-components-product-price,
    .wc-block-grid__product-price
) del {
    opacity: 0.72;
    text-decoration-line: line-through;
    text-decoration-thickness: 1px;
}


/* =========================================================
 * MINI CART, CART DRAWER AND BLOCKSY ADDED-TO-CART POPUP
 * One visual language shared with product-card prices.
 * ========================================================= */
:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(.price, .quantity) .sale-price {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35em;
    line-height: 1.25;
}

:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(.price, .quantity) .sale-price ins,
:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(.price, .quantity) .sale-price ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-sale-price-color) !important;
    font-size: var(--paese-sale-price-font-size) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
    font-style: normal;
    line-height: 1.2;
    text-decoration: none;
}

:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(.price, .quantity) .sale-price del,
:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(.price, .quantity) .sale-price del :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: #9a9a9a !important;
    font-size: 0.85rem !important;
    font-weight: 400 !important;
    line-height: 1.2;
    opacity: 0.72;
    text-decoration-line: line-through;
    text-decoration-thickness: 1px;
}

:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) .price:not(:has(del)) > :where(.amount, .woocommerce-Price-amount),
:where(
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) .price:not(:has(del)) > :where(
    .amount,
    .woocommerce-Price-amount
) .woocommerce-Price-currencySymbol {
    color: var(--theme-palette-color-5) !important;
    font-size: 1.3rem !important;
    font-weight: 600 !important;
}

/* Final layout contract: every promotional price stays on one line. */
:where(
    .woocommerce,
    .woocommerce-page,
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product,
    .fc-price,
    .fc-summary-price,
    .fc-mobile-summary-bar
) :where(
    .price:has(> del),
    .sale-price:has(del),
    .fc-price-main:has(> del)
) {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: baseline !important;
    gap: 0.35em !important;
    white-space: nowrap !important;
}

/* Stable visual order: regular price left, promotional price right. */
:where(
    .price:has(del),
    .sale-price:has(del),
    .fc-price-main:has(del),
    .woocommerce-variation-price:has(del),
    .wc-block-components-product-price:has(del)
) > del {
    order: 1 !important;
}

:where(
    .price:has(del),
    .sale-price:has(del),
    .fc-price-main:has(del),
    .woocommerce-variation-price:has(del),
    .wc-block-components-product-price:has(del)
) > :where(ins, .amount, .woocommerce-Price-amount) {
    order: 2 !important;
}

/* =========================================================
 * FINAL PRODUCT-PRICE CONTRACT
 * Regular and promotional prices use one system everywhere.
 * ========================================================= */
:where(
    .woocommerce,
    .woocommerce-page,
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product,
    .wc-block-cart,
    .wp-block-woocommerce-cart
) :where(
    .price:not(:has(del)),
    .fc-price-main:not(:has(del)),
    .wc-block-components-product-price:not(:has(.wc-block-components-product-price__regular))
) :where(.amount, .woocommerce-Price-amount),
:where(
    .woocommerce,
    .woocommerce-page,
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product
) :where(
    .price:not(:has(del)),
    .fc-price-main:not(:has(del))
) > :where(.amount, .woocommerce-Price-amount) {
    color: var(--paese-regular-price-color) !important;
    font-size: var(--paese-regular-price-font-size) !important;
    font-weight: var(--paese-regular-price-font-weight) !important;
    line-height: 1.2;
}

:where(
    .woocommerce,
    .woocommerce-page,
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product,
    .wc-block-cart
) :where(.price, .sale-price, .fc-price-main, .wc-block-components-product-price) del,
:where(
    .woocommerce,
    .woocommerce-page,
    .widget_shopping_cart,
    #woo-cart-panel,
    .ct-added-to-cart-product,
    .wc-block-cart
) :where(.price, .sale-price, .fc-price-main, .wc-block-components-product-price) del :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-old-price-color) !important;
    font-size: var(--paese-old-price-font-size) !important;
    font-weight: 400 !important;
    line-height: 1.2;
    opacity: 0.72;
}

/* Blocksy places the unit price natively inside the product-name cell. */
.woocommerce-cart .woocommerce-cart-form__cart-item .product-name > .price {
    display: flex !important;
    width: 100% !important;
    max-width: 100%;
    margin-block: 0.45rem 0 !important;
    white-space: nowrap !important;
}

/* Mini-cart: title, metadata and quantity/price remain separate rows. */
:where(.widget_shopping_cart, #woo-cart-panel) .product-data {
    min-width: 0;
}

:where(.widget_shopping_cart, #woo-cart-panel) .product-title {
    display: block;
}

:where(.widget_shopping_cart, #woo-cart-panel) .product-data > .quantity {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 0.25em;
    width: 100%;
    margin-top: 0.4rem;
    white-space: nowrap;
}

/* Classic checkout: regular and promotional line prices. */
.paese-classic-checkout .product-total .sale-price {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35em;
    white-space: nowrap;
}

.paese-classic-checkout .product-total .sale-price ins {
    color: var(--paese-sale-price-color) !important;
    font-weight: var(--paese-sale-price-font-weight) !important;
    text-decoration: none;
}

.paese-classic-checkout .product-total .sale-price del {
    color: var(--paese-old-price-color, #9a9a9a) !important;
    font-size: 0.85em;
    font-weight: 400 !important;
    opacity: 0.8;
}

/*
 * Cart and checkout keep the product-card price hierarchy at a compact size.
 * The mini-cart is intentionally excluded.
 */
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal
) .sale-price ins,
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal
) .sale-price ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
),
.paese-classic-checkout .product-total .sale-price ins,
.paese-classic-checkout .product-total .sale-price ins :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    font-size: 0.95rem !important;
}

.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal
) .sale-price del,
.woocommerce-cart :where(
    td.product-price,
    td.product-subtotal
) .sale-price del :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
),
.paese-classic-checkout .product-total .sale-price del,
.paese-classic-checkout .product-total .sale-price del :where(
    .amount,
    .woocommerce-Price-amount,
    .woocommerce-Price-currencySymbol
) {
    color: var(--paese-old-price-color, #9a9a9a) !important;
    font-size: 0.78rem !important;
    font-weight: 400 !important;
}
