/*
 * Premium header Cart Widget — canonical presentation source.
 * Theme publishes semantic colors and the restricted raised-edge DNA.
 * Commerce owns widget geometry, WooCommerce fragment rows and interaction; only the outer panel and widget heading consume raised depth.
 */
.site-header,
.site-header .hdf-header-main,
.site-header .hdf-header-main__inner,
.hdf-header-main__actions,
.hdf-header-main__actions > *,
.hdf-header-action--cart,
.hdc-cart-widget {
    overflow: visible;
}

.site-header .hdf-header-main {
    --hdf-header-cart-control-width: clamp(132px, calc(var(--hdf-header-main-control-render-size, 43px) + 64px), 156px);
}

.hdf-header-action--cart {
    position: relative;
    z-index: 2147482500;
    min-width: var(--hdf-header-cart-control-width);
}

.hdc-cart-widget {
    --hdc-cart-widget-surface: var(--hdc-flat-surface);
    --hdc-cart-widget-heading: color-mix(in srgb, var(--hdc-cart-widget-primary) 3%, var(--hdc-flat-surface));
    --hdc-cart-widget-hover: var(--hdc-flat-hover);
    --hdc-cart-widget-accent: color-mix(in srgb, var(--hdc-cart-widget-primary) 8%, var(--hdc-flat-surface));
    --hdc-cart-widget-text: var(--hdc-text);
    --hdc-cart-widget-border: var(--hdc-flat-border);
    --hdc-cart-widget-muted: var(--hdf-color-muted, var(--hdc-muted-text));
    --hdc-cart-widget-danger: var(--hdf-color-error, var(--hdc-danger));
    --hdc-cart-widget-primary: var(--hdf-color-primary, var(--hdc-primary));
    --hdc-cart-widget-primary-hover: var(--hdf-color-primary-hover, var(--hdc-primary-hover));
    --hdc-cart-widget-on-primary: var(--hdf-color-on-primary, var(--hdc-button-text));
    position: relative;
    z-index: 2147482501;
    display: flex;
    width: 100%;
    min-width: var(--hdf-header-cart-control-width);
    height: var(--hdf-header-main-control-render-size, 43px);
    align-items: center;
    justify-content: center;
    color: var(--hdc-cart-widget-text);
    font-family: var(--hdc-font-ui);
}

.hdf-header-action--cart .hdf-header-action__control,
.hdc-cart-widget > .hdf-header-action__control--cart {
    position: relative;
    box-sizing: border-box;
    display: flex;
    width: var(--hdf-header-cart-control-width);
    min-width: var(--hdf-header-cart-control-width);
    max-width: var(--hdf-header-cart-control-width);
    height: var(--hdf-header-main-control-render-size, 43px);
    min-height: var(--hdf-header-main-control-render-size, 43px);
    align-items: center;
    justify-content: center;
    gap: 0;
    margin: 0;
    padding: 0;
    transform: none;
    translate: none;
}

.hdf-header-action--cart .hdf-header-action__icon,
.hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__icon {
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    display: grid;
    width: 31px;
    height: 100%;
    margin: 0;
    place-items: center;
    border: 0;
    background: transparent;
    box-shadow:none;
    font-size: 1px;
    transform: none;
    translate: none;
}

.hdf-header-action--cart .hdf-header-action__icon .hdc-icon,
.hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__icon .hdc-icon {
    display: block;
    width: var(--hdc-cart-icon-width, 19px);
    height: var(--hdc-cart-icon-height, 18px);
    min-width: var(--hdc-cart-icon-width, 19px);
    min-height: var(--hdc-cart-icon-height, 18px);
    color: currentColor;
    fill: currentColor;
    stroke: none;
}

.hdf-header-action--cart .hdf-header-action__meta,
.hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__meta {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 31px;
    inset-inline-end: 4px;
    display: block;
    width: auto;
    min-width: 0;
    max-width: none;
    overflow: hidden;
    margin: 0;
    padding: 0;
    color: var(--hdf-header-action-color, var(--hdc-cart-widget-text));
    font-size: clamp(9px, calc(var(--hdf-header-main-control-render-size, 43px) * .205), 10px);
    font-weight: 700;
    letter-spacing: -.015em;
    line-height: 1;
    text-align: center;
    text-overflow: clip;
    white-space: nowrap;
    transform: translateY(-50%);
    translate: none;
}

/* Header Cart geometry is immutable across hover/focus/active states.
 * Opening the dropdown may change color/state, never the trigger coordinates. */
.hdf-header-action--cart .hdf-header-action__control:hover,
.hdf-header-action--cart .hdf-header-action__control:focus-visible,
.hdf-header-action--cart .hdf-header-action__control:active,
.hdc-cart-widget > .hdf-header-action__control--cart:hover,
.hdc-cart-widget > .hdf-header-action__control--cart:focus-visible,
.hdc-cart-widget > .hdf-header-action__control--cart:active {
    width: var(--hdf-header-cart-control-width);
    min-width: var(--hdf-header-cart-control-width);
    max-width: var(--hdf-header-cart-control-width);
    height: var(--hdf-header-main-control-render-size, 43px);
    min-height: var(--hdf-header-main-control-render-size, 43px);
    margin: 0;
    padding: 0;
    transform: none;
    translate: none;
}

.hdf-header-action--cart .hdf-header-action__control:hover .hdf-header-action__icon,
.hdf-header-action--cart .hdf-header-action__control:focus-visible .hdf-header-action__icon,
.hdf-header-action--cart .hdf-header-action__control:active .hdf-header-action__icon,
.hdc-cart-widget > .hdf-header-action__control--cart:hover .hdf-header-action__icon,
.hdc-cart-widget > .hdf-header-action__control--cart:focus-visible .hdf-header-action__icon,
.hdc-cart-widget > .hdf-header-action__control--cart:active .hdf-header-action__icon {
    inset-block: 0;
    inset-inline-start: 0;
    width: 31px;
    height: 100%;
    margin: 0;
    border: 0;
    background: transparent;
    box-shadow:none;
    transform: none;
    translate: none;
}

.hdc-cart-widget::after {
    position: absolute;
    top: 100%;
    inset-inline-end: 0;
    width: min(var(--hdc-selection-dropdown-width, 320px), calc(100vw - 18px));
    height: 12px;
    display: none;
    content: "";
    pointer-events: auto;
}

.hdc-cart-widget:hover::after,
.hdc-cart-widget:focus-within::after,
.hdc-cart-widget[data-hdc-open="true"]::after {
    display: block;
}

.hdc-cart-widget__panel {
    outline: 0;
    z-index: 2147482502;
    top: calc(100% + 10px);
    inset-inline-end: 0;
    width: min(var(--hdc-selection-dropdown-width, 320px), calc(100vw - 18px));
    padding: 0;
    overflow: visible;
    border: 1px solid color-mix(in srgb, var(--hdc-cart-widget-primary) 18%, var(--hdc-cart-widget-border));
    border-radius: 14px;
    background: var(--hdc-cart-widget-surface);
    color: var(--hdc-cart-widget-text);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(5px);
    transition: opacity 140ms ease, visibility 140ms ease, transform 140ms ease;
}

.hdc-cart-widget__panel::after { display: none; content: none; }

.hdc-cart-widget__panel::before {
    position: absolute;
    top: -6px;
    inset-inline-end: 22px;
    width: 11px;
    height: 11px;
    border-top: 1px solid var(--hdc-cart-widget-border);
    border-inline-start: 1px solid var(--hdc-cart-widget-border);
    background: var(--hdc-cart-widget-heading);
    content: "";
    transform: rotate(45deg);
}

.hdc-cart-widget:hover > .hdc-cart-widget__panel,
.hdc-cart-widget:focus-within > .hdc-cart-widget__panel,
.hdc-cart-widget[data-hdc-open="true"] > .hdc-cart-widget__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.hdc-cart-widget__header,
.hdc-cart-widget__body,
.hdc-cart-widget__summary,
.hdc-cart-widget__secure,
.hdc-cart-widget__footer {
    position: relative;
    z-index: 1;
}

.hdc-cart-widget__header {
    outline: 0;
    display: grid;
    min-height: 62px;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--hdc-cart-widget-border);
    border-radius: 13px 13px 0 0;
    background: var(--hdc-cart-widget-heading);
}

.hdc-cart-widget__header-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: 50%;
    background: var(--hdc-cart-widget-hover);
    color: var(--hdc-cart-widget-primary-hover);
}

.hdc-cart-widget__header-icon .hdc-icon {
    width: 17px;
    height: 17px;
}

.hdc-cart-widget__header-copy {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.hdc-cart-widget__header-copy strong {
    overflow: hidden;
    color: var(--hdc-header-widget-heading-color);
    font-family: var(--hdc-font-heading);
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hdc-cart-widget__header-copy span {
    color: var(--hdc-cart-widget-muted);
    font-size: .72rem;
    line-height: 1.3;
}

.hdc-cart-widget__clear {
    display: inline-flex;
    min-height: 30px;
    align-items: center;
    padding: 4px 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--hdc-header-widget-clear-color);
    font-size: .68rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: none;
}

.hdc-cart-widget__clear:hover,
.hdc-cart-widget__clear:focus-visible {
    background: transparent;
    color: var(--hdc-header-widget-clear-color);
    text-decoration: underline;
    text-underline-offset: 3px;
    box-shadow: none;
}

.hdc-cart-widget__body {
    max-height: 228px;
    padding: 12px 10px 2px;
    overflow-y: auto;
    background: var(--hdc-cart-widget-surface);
    overscroll-behavior: contain;
    scrollbar-color: var(--hdf-color-border-strong, var(--hdc-muted-text)) transparent;
    scrollbar-width: thin;
}

.hdc-cart-widget--visible-1 .hdc-cart-widget__body { max-height: 76px; }
.hdc-cart-widget--visible-2 .hdc-cart-widget__body { max-height: 152px; }
.hdc-cart-widget--visible-3 .hdc-cart-widget__body { max-height: 228px; }
.hdc-cart-widget--visible-4 .hdc-cart-widget__body { max-height: 304px; }
.hdc-cart-widget--visible-5 .hdc-cart-widget__body { max-height: 380px; }

.hdc-cart-widget__item {
    position: relative;
    display: grid;
    min-height: 68px;
    grid-template-columns: 48px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 9px;
    margin: 0 0 8px;
    padding: 7px 8px;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: var(--hdc-compact-radius, 8px);
    background: var(--hdc-cart-widget-surface);
}

.hdc-cart-widget__item:hover,
.hdc-cart-widget__item:focus-within {
    background: var(--hdc-cart-widget-hover);
}

.hdc-cart-widget__thumb {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: 7px;
    background: var(--hdc-cart-widget-surface);
}

.hdc-cart-widget__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.hdc-cart-widget__item-main {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.hdc-cart-widget__item .hdc-cart-widget__item-title {
    display: -webkit-box;
    min-height: 2.4em;
    max-height: 2.4em;
    overflow: hidden;
    color: var(--hdc-cart-widget-text);
    font-size: .75rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.hdc-cart-widget__item-title:hover,
.hdc-cart-widget__item-title:focus-visible {
    color: var(--hdc-cart-widget-primary-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hdc-cart-widget__item-data {
    max-width: 100%;
    overflow: hidden;
    color: var(--hdc-cart-widget-muted);
    font-size: .6rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hdc-cart-widget__item-data dl,
.hdc-cart-widget__item-data p,
.hdc-cart-widget__item-data dt,
.hdc-cart-widget__item-data dd {
    display: inline;
    margin: 0;
}

.hdc-cart-widget__item-meta {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 7px;
    color: var(--hdc-cart-widget-muted);
    font-size: .68rem;
    line-height: 1.1;
}

.hdc-cart-widget__item-meta span,
.hdc-cart-widget__item-meta strong {
    white-space: nowrap;
}

.hdc-cart-widget__item-meta strong {
    min-width: 0;
    overflow: hidden;
    color: var(--hdc-cart-widget-text);
    font-size: .73rem;
    font-weight: 700;
    text-overflow: ellipsis;
}

.hdc-cart-widget__remove {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--hdc-cart-widget-danger);
}

.hdc-cart-widget__remove:hover,
.hdc-cart-widget__remove:focus-visible {
    background: color-mix(in srgb, var(--hdc-cart-widget-danger) 8%, var(--hdc-cart-widget-surface));
    color: var(--hdc-cart-widget-danger);
}

.hdc-cart-widget__remove .hdc-icon {
    width: 13px;
    height: 13px;
}

.hdc-cart-widget__summary {
    display: flex;
    min-height: 38px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px 5px;
    border-block-start: 1px solid var(--hdc-cart-widget-border);
    background: var(--hdc-cart-widget-surface);
    color: var(--hdc-cart-widget-muted);
    font-size: .8rem;
}

.hdc-cart-widget__summary strong {
    color: var(--hdc-cart-widget-text);
    font-size: .9rem;
    font-weight: 700;
}

.hdc-cart-widget__secure {
    display: flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin: 0 14px 10px;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: var(--hdc-compact-radius, 8px);
    background: var(--hdc-cart-widget-accent);
    color: var(--hdc-cart-widget-text);
    font-size: .72rem;
    font-weight: 700;
}

.hdc-cart-widget__secure-icon {
    display: grid;
    place-items: center;
    color: var(--hdc-cart-widget-muted);
}

.hdc-cart-widget__secure-icon .hdc-icon {
    width: 15px;
    height: 15px;
}

.hdc-cart-widget__empty {
    display: grid;
    min-height: 180px;
    place-items: center;
    align-content: center;
    gap: 8px;
    padding: 22px 18px;
    text-align: center;
}

.hdc-cart-widget__empty-icon {
    display: grid;
    width: 54px;
    height: 54px;
    place-items: center;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: 50%;
    background: var(--hdc-cart-widget-hover);
    color: var(--hdc-cart-widget-primary-hover);
}

.hdc-cart-widget__empty-icon .hdc-icon {
    width: 27px;
    height: 27px;
}

.hdc-cart-widget__empty strong {
    color: var(--hdc-cart-widget-text);
    font-family: var(--hdc-font-heading);
    font-size: .94rem;
}

.hdc-cart-widget__empty p {
    max-width: 255px;
    margin: 0;
    color: var(--hdc-cart-widget-muted);
    font-size: .74rem;
    line-height: 1.4;
}

.hdc-cart-widget__footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 0 14px 14px;
    background: var(--hdc-cart-widget-surface);
    border-radius: 0 0 var(--hdc-radius) var(--hdc-radius);
}

.hdc-cart-widget__button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 10px;
    border: 1px solid var(--hdc-cart-widget-border);
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.hdc-cart-widget__button--secondary {
    background: var(--hdc-cart-widget-surface);
    color: var(--hdc-cart-widget-text);
}

.hdc-cart-widget__button-icon {
    display: inline-flex;
    width: var(--hdc-cart-icon-width, 19px);
    height: var(--hdc-cart-icon-height, 18px);
    flex: 0 0 var(--hdc-cart-icon-width, 19px);
    align-items: center;
    justify-content: center;
}

.hdc-cart-widget__button-icon .hdc-icon {
    display: block;
    width: 100%;
    height: 100%;
    color: currentColor;
    fill: currentColor;
    stroke: none;
}

.hdc-cart-widget__button--secondary:hover,
.hdc-cart-widget__button--secondary:focus-visible {
    border-color: var(--hdc-cart-widget-primary);
    background: var(--hdc-cart-widget-hover);
    color: var(--hdc-cart-widget-primary-hover);
}

.hdc-cart-widget__button--primary {
    border-color: var(--hdc-cart-widget-primary-hover);
    background: var(--hdc-cart-widget-primary);
    color: var(--hdc-cart-widget-on-primary);
}

.hdc-cart-widget__button--primary:hover,
.hdc-cart-widget__button--primary:focus-visible {
    border-color: var(--hdc-cart-widget-primary-hover);
    background: var(--hdc-cart-widget-primary-hover);
    color: var(--hdc-cart-widget-on-primary);
}

/* Cart visibility uses the Cart Experience hover/focus/data-state contract,
 * while the generic dropdown controller restores hidden for other widgets. */
.hdc-cart-widget > .hdc-cart-widget__panel[hidden] {
    display: block;
}

/* Compact tablet/mobile cart trigger is quantity-only and remains a 1:1 control. */
@media (max-width: 1140px) {
    .site-header .hdf-header-main {
        --hdf-header-cart-control-width: var(--hdf-header-main-control-render-size, 34px);
    }

    .hdf-header-action--cart,
    .hdc-cart-widget {
        width: var(--hdf-header-main-control-render-size, 34px);
        min-width: var(--hdf-header-main-control-render-size, 34px);
        max-width: var(--hdf-header-main-control-render-size, 34px);
    }

    .hdf-header-action--cart .hdf-header-action__control,
    .hdc-cart-widget > .hdf-header-action__control--cart {
        width: var(--hdf-header-main-control-render-size, 34px);
        min-width: var(--hdf-header-main-control-render-size, 34px);
        max-width: var(--hdf-header-main-control-render-size, 34px);
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0;
    }

    .hdf-header-action--cart .hdf-header-action__icon,
    .hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__icon {
        position: static;
        width: auto;
        height: auto;
        margin: auto;
        transform: none;
    }

    .hdf-header-action--cart .hdf-header-action__meta,
    .hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__meta,
    .hdf-header-action--cart .hdf-header-action__label,
    .hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__label,
    .hdf-header-action--cart .woocommerce-Price-amount,
    .hdc-cart-widget > .hdf-header-action__control--cart .woocommerce-Price-amount {
        display: none;
    }

    .hdf-header-action--cart .hdf-header-action__badge,
    .hdc-cart-widget > .hdf-header-action__control--cart .hdf-header-action__badge {
        display: grid;
    }
}

@media (max-width: 782px) {
    .site-header .hdf-header-main {
        --hdf-header-cart-control-width: var(--hdf-header-main-control-render-size, 30px);
    }

    .hdf-header-action--cart {
        z-index: 2147482600;
    }

    .hdc-cart-widget::after {
        display: none;
    }

    .hdc-cart-widget__panel {
        position: fixed;
        z-index: 2147482601;
        top: max(76px, calc(var(--wp-admin--admin-bar--height, 0px) + 70px));
        inset-inline: var(--hdc-space-3);
        width: auto;
        max-height: calc(100vh - 92px);
    }

    .hdc-cart-widget__body {
        max-height: min(228px, calc(100vh - 245px));
    }
}

@media (max-width: 480px) {
    .hdc-cart-widget__header {
        grid-template-columns: 32px minmax(0, 1fr) auto;
        padding-inline: 11px;
    }

    .hdc-cart-widget__body {
        padding-inline: 8px;
    }

    .hdc-cart-widget__footer {
        gap: 7px;
        padding-inline: 10px;
    }

    .hdc-cart-widget__button {
        padding-inline: 7px;
        font-size: .71rem;
    }
}
