/**
 * WooCommerce Blocks — Cart & Checkout
 *
 * The cart and checkout are rendered by WooCommerce's React blocks, which ship
 * their own stylesheet and ignore the classic WooCommerce templates the rest of
 * the theme overrides. Untouched, they are the most obviously "default
 * WooCommerce" surface on the site — and they are the last two screens before
 * the money, so they are exactly where the store must look most deliberate.
 *
 * Everything below is presentational only: no block markup is altered, so a
 * WooCommerce update cannot break checkout because of this file.
 *
 * @package Etches
 * @since 1.1.15
 */

/* ==========================================================================
   Shared shell
   ========================================================================== */

.wc-block-checkout,
.wp-block-woocommerce-cart {
    font-family: var(--font-body);
    color: var(--color-text);
}

/* Block headings follow the brand serif, like every other heading on the site */
.wc-block-components-title,
.wc-block-components-checkout-step__title,
.wc-block-cart__totals-title,
.wc-block-components-checkout-order-summary__title-text,
.wc-block-components-order-summary__title,
.wc-block-components-express-payment__title {
    font-family: var(--font-heading) !important;
    font-weight: 500 !important;
    color: var(--color-text) !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

.wc-block-components-checkout-step__title {
    font-size: 1.5rem !important;
}

.wc-block-components-checkout-step__description {
    color: var(--color-text-light);
    font-size: 0.9375rem;
}

/* Section labels ("PRODUKT", "ŁĄCZNIE", totals title) — small caps, not shouty */
.wc-block-cart-items__header,
.wc-block-cart-items__header th,
.wc-block-cart__totals-title {
    font-size: 0.75rem !important;
    letter-spacing: 0.12em !important;
    text-transform: uppercase !important;
    color: var(--color-text-muted) !important;
    font-family: var(--font-body) !important;
    font-weight: 500 !important;
    border-bottom: 1px solid var(--color-border) !important;
    padding-bottom: var(--spacing-sm) !important;
}

/* ==========================================================================
   Buttons — the single ink CTA, everywhere
   ========================================================================== */

.wc-block-components-button:not(.is-link),
.wc-block-cart__submit-button,
.wc-block-components-checkout-place-order-button {
    background-color: var(--color-ink) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--border-radius) !important;
    font-family: var(--font-body) !important;
    font-size: 0.9375rem !important;
    font-weight: 500 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    min-height: 3.5rem !important;
    padding: 1rem 2rem !important;
    box-shadow: none !important;
    transition: background-color var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base) !important;
}

.wc-block-components-button:not(.is-link):hover,
.wc-block-cart__submit-button:hover,
.wc-block-components-checkout-place-order-button:hover {
    background-color: var(--color-ink-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 24px -8px rgba(38, 32, 25, 0.45) !important;
}

.wc-block-components-button:not(.is-link):focus-visible,
.wc-block-components-checkout-place-order-button:focus-visible {
    outline: 2px solid var(--color-ink) !important;
    outline-offset: 3px !important;
}

/* Text buttons ("Wróć do koszyka", "Usuń", "Edytuj") */
.wc-block-components-button.is-link,
.wc-block-cart-item__remove-link,
.wc-block-components-address-card__edit,
.wc-block-components-checkout-return-to-cart-button {
    color: var(--color-primary-text) !important;
    font-size: 0.875rem !important;
    text-underline-offset: 3px;
    transition: color var(--transition-fast);
}

.wc-block-components-button.is-link:hover,
.wc-block-cart-item__remove-link:hover,
.wc-block-components-address-card__edit:hover,
.wc-block-components-checkout-return-to-cart-button:hover {
    color: var(--color-primary-text-dark) !important;
}

/* ==========================================================================
   Form fields — warm borders and a gold focus ring instead of the stock blue
   ========================================================================== */

.wc-block-components-text-input input[type="text"],
.wc-block-components-text-input input[type="email"],
.wc-block-components-text-input input[type="tel"],
.wc-block-components-text-input input[type="number"],
.wc-block-components-textarea,
.wc-block-components-combobox-control input.components-combobox-control__input,
.wc-blocks-components-select .wc-blocks-components-select__select {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius) !important;
    background-color: #fff !important;
    font-family: var(--font-body) !important;
    color: var(--color-text) !important;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.wc-block-components-text-input.is-active input,
.wc-block-components-text-input input:focus,
.wc-block-components-textarea:focus,
.wc-block-components-combobox-control input.components-combobox-control__input:focus,
.wc-blocks-components-select .wc-blocks-components-select__select:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(196, 164, 132, 0.25) !important;
    outline: none !important;
}

.wc-block-components-text-input label,
.wc-blocks-components-select__label {
    color: var(--color-text-light) !important;
    font-family: var(--font-body) !important;
}

/* Validation stays in the warm palette rather than stock alert red */
.wc-block-components-validation-error,
.wc-block-components-validation-error p {
    color: var(--color-error) !important;
    font-size: 0.8125rem !important;
}

.has-error input,
.wc-block-components-text-input.has-error input {
    border-color: var(--color-error) !important;
}

/* Checkbox + radio */
.wc-block-components-checkbox__input[type="checkbox"] {
    border: 1px solid var(--color-border) !important;
    border-radius: 3px !important;
}

.wc-block-components-checkbox__input[type="checkbox"]:checked {
    background-color: var(--color-ink) !important;
    border-color: var(--color-ink) !important;
}

/* The tick is a separate SVG layered over the box — it has to be light once
   the box is ink, otherwise the control reads as an empty black square. */
.wc-block-components-checkbox__mark {
    fill: #fff !important;
}

.wc-block-components-radio-control__option {
    border-radius: var(--border-radius);
}

.wc-block-components-radio-control-accordion-option,
.wc-block-components-radio-control__option {
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.wc-block-components-radio-control__option--checked-option-highlighted,
.wc-block-components-radio-control-accordion-option:has(.wc-block-components-radio-control__input:checked) {
    border-color: var(--color-primary) !important;
    background-color: var(--color-background-warm) !important;
}

.wc-block-components-radio-control__input:checked {
    accent-color: var(--color-ink);
}

/* ==========================================================================
   Cart
   ========================================================================== */

.wc-block-cart-items td,
.wc-block-cart-item__wrap {
    border-color: var(--color-border-light) !important;
}

.wc-block-cart-item__image img {
    border-radius: var(--border-radius);
    background-color: var(--color-background-warm);
}

.wc-block-components-product-name {
    font-family: var(--font-heading) !important;
    font-size: 1.0625rem !important;
    color: var(--color-text) !important;
    text-decoration: none !important;
}

.wc-block-components-product-name:hover {
    color: var(--color-primary-text) !important;
}

.wc-block-components-product-price__value,
.wc-block-components-product-price {
    color: var(--color-text) !important;
    font-weight: 500;
}

.wc-block-components-product-metadata {
    color: var(--color-text-light);
    font-size: 0.875rem;
}

/* Quantity stepper */
.wc-block-components-quantity-selector {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius) !important;
    background-color: #fff;
}

.wc-block-components-quantity-selector__button {
    color: var(--color-text-light) !important;
    transition: color var(--transition-fast), background-color var(--transition-fast);
}

.wc-block-components-quantity-selector__button:hover {
    color: var(--color-text) !important;
    background-color: var(--color-background-warm) !important;
}

.wc-block-components-quantity-selector__input {
    font-family: var(--font-body) !important;
    color: var(--color-text) !important;
}

/* Totals card in the sidebar (the sidebar element carries both classes) */
.wc-block-cart__sidebar.wc-block-components-sidebar,
.wc-block-checkout__sidebar.wc-block-components-sidebar {
    background-color: var(--color-background-warm);
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
}

.wc-block-components-totals-item {
    font-size: 0.9375rem;
    color: var(--color-text-light);
}

.wc-block-components-totals-item__label {
    color: var(--color-text-light);
}

.wc-block-components-totals-item__value {
    color: var(--color-text);
    font-weight: 500;
}

/* Grand total gets the serif — it is the number the buyer is deciding on.
   The label wraps and the amount never does, so a long label like
   "Szacowana łączna kwota" cannot push the price out of the card. */
.wc-block-components-totals-footer-item,
.wc-block-components-totals-footer-item .wc-block-components-totals-item__label,
.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    font-family: var(--font-heading) !important;
    font-size: 1.25rem !important;
    color: var(--color-text) !important;
    font-weight: 500 !important;
}

.wc-block-components-totals-footer-item {
    border-top: 1px solid var(--color-border) !important;
    padding-top: var(--spacing-md) !important;
    gap: var(--spacing-sm);
    align-items: baseline;
}

.wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
    min-width: 0;
    line-height: 1.3;
}

.wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Green only when the rate really is free — a shipping charge is a cost, not a win */
.wc-block-checkout__shipping-option--free .wc-block-components-radio-control__option-layout {
    color: var(--color-success) !important;
}

/* Coupon panel */
.wc-block-components-panel__button {
    font-family: var(--font-body) !important;
    font-size: 0.9375rem !important;
    color: var(--color-text-light) !important;
}

.wc-block-components-panel__button:hover {
    color: var(--color-text) !important;
}

/* ==========================================================================
   Checkout
   ========================================================================== */

.wc-block-components-checkout-step {
    border: none;
}

.wc-block-components-checkout-step__heading {
    margin-bottom: var(--spacing-xs);
}

.wc-block-components-address-card {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--border-radius) !important;
    background-color: var(--color-background-warm);
}

/* Express-payment area: when no wallet is available the block still renders its
   "Ekspresowa kasa / Lub kontynuuj poniżej" frame around an empty box, which
   reads as a broken widget at the top of checkout. Collapse it when empty.
   Emptiness is measured by the __event-buttons list, never by :has(button) —
   Stripe paints Google Pay and Link inside iframes, so a fully working express
   checkout contains zero <button> elements in this document and that test hid
   it outright. */
.wc-block-components-express-payment--checkout:not(:has(.wc-block-components-express-payment__event-buttons > *)) {
    display: none;
}

.wc-block-components-express-payment--checkout:not(:has(.wc-block-components-express-payment__event-buttons > *)) + .wc-block-components-express-payment-continue-rule {
    display: none;
}

.wc-block-components-express-payment__title-container::before,
.wc-block-components-express-payment__title-container::after,
.wc-block-components-express-payment-continue-rule::before,
.wc-block-components-express-payment-continue-rule::after {
    border-color: var(--color-border) !important;
}

/* Order summary */
.wc-block-components-order-summary-item__description .wc-block-components-product-name {
    font-size: 1rem !important;
}

.wc-block-components-order-summary-item__image img {
    border-radius: var(--border-radius);
}

.wc-block-components-order-summary-item__quantity {
    background-color: var(--color-ink) !important;
    border-color: var(--color-ink) !important;
    color: #fff !important;
}

/* Terms line */
.wc-block-checkout__terms {
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.wc-block-checkout__terms a {
    color: var(--color-primary-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Actions row keeps the primary button dominant */
.wc-block-checkout__actions_row {
    align-items: center;
}

/* ==========================================================================
   Reassurance strip (rendered by inc/woocommerce-blocks.php)
   ========================================================================== */

.etches-checkout-trust {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
    padding: var(--spacing-lg);
    background-color: var(--color-background-warm);
    border: 1px solid var(--color-border-light);
    border-radius: var(--border-radius-lg);
}

.etches-checkout-trust__item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-text-light);
}

.etches-checkout-trust__item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    color: var(--color-primary);
}

.etches-checkout-trust__item strong {
    display: block;
    color: var(--color-text);
    font-weight: 500;
}

/* ==========================================================================
   Empty cart
   ========================================================================== */

.wp-block-woocommerce-empty-cart-block h2,
.wc-block-cart__empty-cart__title {
    font-family: var(--font-heading) !important;
    font-weight: 400 !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .wc-block-cart__sidebar .wc-block-components-sidebar,
    .wc-block-checkout__sidebar .wc-block-components-sidebar {
        padding: var(--spacing-md);
    }

    .wc-block-components-checkout-step__title {
        font-size: 1.25rem !important;
    }

    .wc-block-components-totals-footer-item,
    .wc-block-components-totals-footer-item .wc-block-components-totals-item__label,
    .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
        font-size: 1.1875rem !important;
    }

    .etches-checkout-trust {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }
}
