/**
 * The Keepers Gift Wrapping — product page option and the cart / checkout
 * panel. Colours and radius from the theme presets, with fallbacks.
 *
 * @package The_Keepers_Gift_Wrapping
 */

.tkgw-product,
.tkgw-panel {
    --tkgw-accent: var(--wp--preset--color--custom-primary, #1f3d2b);
    --tkgw-line: color-mix(in srgb, currentColor 18%, transparent);
    --tkgw-soft: color-mix(in srgb, var(--tkgw-accent) 6%, transparent);
    --tkgw-radius: var(--border-radius-md, 8px);
}

/* ── Product page ───────────────────────────────────────── */

.tkgw-product {
    margin: 1em 0;
    padding: .75em 1em;
    border: 1px solid var(--tkgw-line);
    border-radius: var(--tkgw-radius);
}
.tkgw-product.is-wrapped {
    border-color: var(--tkgw-accent);
    background: var(--tkgw-soft);
}
.tkgw-product__toggle,
.tkgw-item__toggle {
    display: flex;
    align-items: flex-start;
    gap: .6em;
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
}
.tkgw-product__toggle input,
.tkgw-item__toggle input {
    flex: 0 0 auto;
    width: 1.1em;
    height: 1.1em;
    margin: .15em 0 0;
    accent-color: var(--tkgw-accent);
}
.tkgw-product__fee {
    display: inline-block;
    margin-left: .35em;
    font-weight: 400;
    opacity: .75;
}
.tkgw-product__desc,
.tkgw-product__note,
.tkgw-panel__desc {
    margin: .5em 0 0;
    font-size: .875em;
    opacity: .8;
}
.tkgw-product__options[hidden] {
    display: none;
}

/* ── Papers (swatches) ──────────────────────────────────── */

.tkgw-papers {
    display: flex;
    flex-wrap: wrap;
    gap: .5em;
    margin: .75em 0 0;
    padding: 0;
    border: 0;
}
.tkgw-paper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: .3em;
    width: 4.25em;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: .75em;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
}
.tkgw-paper__swatch {
    display: block;
    width: 3.25em;
    height: 3.25em;
    border-radius: 50%;
    background: var(--tkgw-soft) center / cover no-repeat;
    box-shadow: inset 0 0 0 1px var(--tkgw-line);
    transition: box-shadow .15s;
}
.tkgw-paper:hover .tkgw-paper__swatch {
    box-shadow: inset 0 0 0 1px var(--tkgw-line), 0 0 0 2px color-mix(in srgb, currentColor 15%, transparent);
}
.tkgw-paper.is-selected .tkgw-paper__swatch,
.tkgw-paper:has(input:checked) .tkgw-paper__swatch {
    box-shadow: 0 0 0 2px var(--wp--preset--color--base, #fff), 0 0 0 4px var(--tkgw-accent);
}
.tkgw-paper:has(input:focus-visible) .tkgw-paper__swatch,
.tkgw-paper:focus-visible .tkgw-paper__swatch {
    outline: 2px solid var(--tkgw-accent);
    outline-offset: 4px;
}
.tkgw-paper:focus-visible {
    outline: none;
}
.tkgw-paper[disabled] {
    cursor: progress;
}

/* ── Message ────────────────────────────────────────────── */

.tkgw-message {
    display: grid;
    gap: .25em;
    margin: .75em 0 0;
}
.tkgw-message__label {
    font-size: .875em;
}
.tkgw-message__input {
    width: 100%;
    box-sizing: border-box;
    min-height: 3.5em;
    padding: .5em .65em;
    border: 1px solid var(--tkgw-line);
    border-radius: calc(var(--tkgw-radius) / 2);
    background: var(--wp--preset--color--base, #fff);
    color: inherit;
    font: inherit;
    font-size: .875em;
    resize: vertical;
}
.tkgw-message__input:focus {
    outline: 2px solid var(--tkgw-accent);
    outline-offset: 0;
    border-color: transparent;
}
.tkgw-message__count {
    justify-self: end;
    font-size: .75em;
    opacity: .6;
}

/* ── Cart / checkout / mini cart card ───────────────────── */

.tkgw-panel-wrap {
    padding: 16px 0;
}
.tkgw-panel {
    --tkgw-card: var(--wp--preset--color--custom-primary-10, #e8edeb);
    --tkgw-white: var(--wp--preset--color--custom-white, #fff);
    --tkgw-pad: 20px;
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-lg, calc(var(--tkgw-radius) * 1.5));
    background: var(--tkgw-card);
    color: var(--tkgw-accent);
    font-size: 15px;
}
.tkgw-panel.is-plain {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--tkgw-line);
}
.tkgw-panel__body {
    padding: var(--tkgw-pad);
}
.tkgw-panel__head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.tkgw-panel__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tkgw-white);
    color: var(--tkgw-accent);
}
.tkgw-panel__icon svg {
    display: block;
}
.tkgw-panel__title {
    margin: 0;
    font-size: 1.0625em;
    font-weight: 600;
    line-height: 1.35;
}
.tkgw-panel .tkgw-panel__desc {
    margin: .2em 0 0;
    font-size: .875em;
    line-height: 1.45;
    opacity: .8;
}
.tkgw-items {
    display: grid;
    gap: 8px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}
.tkgw-item {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--tkgw-radius);
    background: var(--tkgw-white);
    box-shadow: 0 0 0 1px transparent;
    transition: box-shadow .15s;
}
.tkgw-item.is-wrapped {
    box-shadow: 0 0 0 1.5px var(--tkgw-accent);
}
.tkgw-item.is-busy {
    opacity: .6;
}
.tkgw-panel .tkgw-item__toggle {
    align-items: center;
    margin: 0;
    font-weight: 400;
    font-size: .9375em;
}
.tkgw-panel .tkgw-item__toggle input {
    margin: 0;
}
.tkgw-item__name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
}
.tkgw-item__fee {
    flex: 0 0 auto;
    font-size: .875em;
    white-space: nowrap;
    opacity: .75;
}
/* Themes give labels a bottom margin (.woocommerce-page label: .7em). */
.tkgw-panel label.tkgw-item__toggle {
    margin: 0;
}
/* Papers in the card: "Select wrapping paper:", then swatches only; the
   name shows in a bubble on hover / keyboard focus. */
.tkgw-papers__label {
    margin: 12px 0 0 1.7em;
    font-size: .8125em;
    line-height: 1.3;
    opacity: .75;
}
.tkgw-panel .tkgw-papers {
    gap: 10px;
    margin: 8px 0 2px 1.7em;
}
.tkgw-panel .tkgw-paper {
    position: relative;
    width: auto;
    font-size: 1em;
}
.tkgw-panel .tkgw-paper__swatch {
    width: 40px;
    height: 40px;
}
.tkgw-panel .tkgw-paper.is-selected .tkgw-paper__swatch {
    box-shadow: 0 0 0 2px var(--tkgw-white), 0 0 0 4px var(--tkgw-accent);
}
.tkgw-panel .tkgw-paper__name {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 3;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--tkgw-accent);
    color: var(--tkgw-white);
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 3px);
    transition: opacity .12s ease, transform .12s ease;
}
.tkgw-panel .tkgw-paper:hover .tkgw-paper__name,
.tkgw-panel .tkgw-paper:focus-visible .tkgw-paper__name {
    opacity: 1;
    transform: translate(-50%, 0);
}
/* One message for the whole order, below the items. */
.tkgw-panel .tkgw-message--order {
    margin: 16px 0 0;
}
.tkgw-panel .tkgw-message__input {
    border-color: transparent;
    background: var(--tkgw-white);
}
.tkgw-panel__photo {
    margin: 0;
    line-height: 0;
}
.tkgw-panel__photo img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}
.tkgw-order-message p {
    white-space: normal;
}
/* The checkout's order summary indents its rows by 16px. */
.wc-block-checkout__sidebar .tkgw-panel-wrap,
.wp-block-woocommerce-checkout-order-summary-block .tkgw-panel-wrap {
    padding-right: 16px;
    padding-left: 16px;
}
/* Mini cart: below the products, inside the scrolling list. */
.tkgw-mini {
    padding: 0; /* The drawer has its own padding. */
    margin-bottom: 20px; /* Space to the totals and buttons below. */
}
/* While the cart is read: the last known card greyed with a spinner, or a placeholder */
.tkgw-panel.is-stale {
    position: relative;
}
.tkgw-panel.is-stale > .tkgw-panel__body {
    opacity: .55;
    transition: opacity .2s ease;
}
.tkgw-panel.is-stale > .tkgw-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
}
.tkgw-spinner {
    display: inline-block;
    flex: none;
    box-sizing: border-box;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: tkgw-spin .8s linear infinite;
}
.tkgw-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tkgw-skeleton {
    height: 52px;
    margin-top: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255,255,255,.55) 25%, rgba(255,255,255,.95) 50%, rgba(255,255,255,.55) 75%);
    background-size: 200% 100%;
    animation: tkgw-shimmer 1.4s ease-in-out infinite;
}
@keyframes tkgw-spin {
    to { transform: rotate(360deg); }
}
@keyframes tkgw-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .tkgw-spinner,
    .tkgw-skeleton {
        animation-duration: 3s;
    }
}
.tkgw-mini .tkgw-panel {
    --tkgw-pad: 16px;
    font-size: 14px;
}
.tkgw-mini .tkgw-panel__photo img {
    aspect-ratio: 2 / 1;
}
/* Checkout: the card's own box (narrow: before payment; wide: below the
   order summary in the sidebar). */
.tkgw-checkout-card[data-spot="main"] .tkgw-panel-wrap {
    padding: 0 0 24px;
    border: 0;
}
.wc-block-checkout__sidebar .tkgw-checkout-card .tkgw-panel-wrap {
    padding: 16px 0;
    border: 0;
}
.tkgw-checkout-card[data-spot="main"] .tkgw-panel__photo img {
    aspect-ratio: 2 / 1;
}
