/* Size selection and the purchase action share the storefront gold. */
#product-dialog #size-options {
  gap: 6px;
}
#product-dialog #size-options .size-option {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 46px;
  min-height: 46px;
  padding: 5px 12px;
  border: 1px solid #514e47;
  border-radius: 5px;
  background: #191918;
  box-shadow: none;
  text-shadow: none;
  color: #f6f2eb;
  font: 600 14px/1 Arial, sans-serif;
}
#product-dialog #size-options .size-option:has(input:checked) {
  background: var(--gold);
  border-color: var(--gold);
  color: #211b12;
}
#product-dialog #size-options .size-option:has(input:disabled) {
  color: #908c84;
  background: transparent;
  border-color: #34322e;
  text-decoration: none;
}
#product-dialog #size-options .size-option:has(.size-status) {
  align-content: center;
  gap: 3px;
  padding-inline: 4px;
}
#product-dialog .size-status {
  color: #d3cbc0;
  font: 600 12px/1.15 Arial, sans-serif;
  white-space: nowrap;
}
#product-dialog #size-options .size-option:has(input:focus-visible),
#product-dialog #buy button:focus-visible {
  outline: 2px solid #f4dba9;
  outline-offset: 2px;
}
#product-dialog #buy .buy-quantity {
  margin-block-start: 6px;
}
#product-dialog #buy .quantity-stepper,
#cart-dialog .quantity-stepper {
  grid-template-columns: 50px minmax(30px, auto) 50px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  gap: 0;
}
#product-dialog #buy .step-btn,
#cart-dialog .quantity-stepper .step-btn {
  height: 44px;
  min-width: 50px;
  border: 1px solid #6c5a40;
  border-radius: 9px;
  background: linear-gradient(180deg, #28251f, #151412);
  box-shadow: inset 0 1px #ffffff0d;
  color: #f1d8a5;
  text-shadow: none;
  font: 400 21px/1 Arial, sans-serif;
}
#product-dialog #buy .step-btn:disabled,
#cart-dialog .quantity-stepper .step-btn:disabled,
#checkout-dialog .checkout-back:disabled,
#checkout-dialog .coupon-entry button:disabled {
  border-color: #332f28;
  background: #141311;
  box-shadow: none;
  color: #887e6e;
  opacity: 1;
}
#product-dialog #buy .step-btn:active:enabled,
#cart-dialog .quantity-stepper .step-btn:active:enabled {
  background: #16130e;
  box-shadow: inset 0 2px 5px #0009;
}
#product-dialog #qty-value,
#cart-dialog .quantity-stepper output {
  border: 0;
  padding: 0;
  background: transparent;
  color: #fff7eb;
  font: 600 16px/1 Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* The primary purchase action uses the same finish through checkout. */
#product-dialog #buy .add,
#cart-dialog .checkout-button,
#checkout-dialog .checkout-button,
#cart-dialog .keep-shopping {
  min-height: 50px;
  padding: 10px 16px;
  border: 1px solid #d8bc86;
  border-radius: 5px;
  background: #ead6ad;
  color: #241c11;
  box-shadow: none;
  text-shadow: none;
  font: 700 15px/1.2 Arial, sans-serif;
}
#product-dialog #buy .add:disabled,
#cart-dialog .checkout-button:disabled,
#checkout-dialog .checkout-button:disabled {
  background: #292724;
  border-color: #45413b;
  color: #b8b2a8;
  opacity: 1;
}
#product-dialog #buy #add-total:not(:empty) { padding-left: 14px; border-left: 1px solid #806b464f; }

#checkout-dialog .checkout-back,
#checkout-dialog .coupon-entry button,
#cart-dialog .cart-actions:has(#checkout-start:not([hidden])) .keep-shopping {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #6c5a40;
  border-radius: 9px;
  background: linear-gradient(180deg, #28251f, #151412);
  box-shadow: inset 0 1px #ffffff0d;
  color: #f1d8a5;
  font: 600 13px/1.2 Arial, sans-serif;
}
#checkout-dialog .transfer-copy { width: auto; min-width: 73px; }
#checkout-dialog .checkout-back:active:enabled,
#checkout-dialog .coupon-entry button:active:enabled,
#cart-dialog .cart-actions:has(#checkout-start:not([hidden])) .keep-shopping:active {
  background: #16130e;
  box-shadow: inset 0 2px 5px #0009;
}

@media (hover:hover) {
  #product-dialog #size-options .size-option:hover:has(input:enabled) { border-color: #d8bc86; }
  #product-dialog #buy .step-btn:hover:enabled,
  #cart-dialog .quantity-stepper .step-btn:hover:enabled,
  #checkout-dialog .checkout-back:hover:enabled,
  #checkout-dialog .coupon-entry button:hover:enabled,
  #cart-dialog .cart-actions:has(#checkout-start:not([hidden])) .keep-shopping:hover {
    border-color: #9f8356;
  }
  #product-dialog #buy .add:hover:enabled,
  #cart-dialog .checkout-button:hover:enabled,
  #checkout-dialog .checkout-button:hover:enabled,
  #cart-dialog .cart-actions:has(#checkout-start[hidden]) .keep-shopping:hover { background: #f5e3bf; }
}

/* Keep the product choices and purchase action on the same alignment. */
#product-dialog .buy-details { gap: 12px; }
#product-dialog .size-field { margin-top: 0; }
#product-dialog #buy .buy-quantity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 5px;
}
#product-dialog #quantity-label,
#product-dialog .size-field legend {
  color: #c7c1b7;
  font: 600 13px/1.2 Arial, sans-serif;
  letter-spacing: normal;
  text-transform: none;
}
#product-dialog .size-field legend {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  margin-bottom: 8px;
}
#product-dialog #size-options::before { content: none; }
#product-dialog #size-options .size-option { flex: 1; }
#product-dialog .stock-note { min-height: 1lh; }

@media (max-width: 650px) and (orientation: portrait) {
  #product-dialog {
    --panel-pad: clamp(16px, 4.5vw, 24px);
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  #product-dialog .dialog-bar { top: max(10px, env(safe-area-inset-top)); right: 12px; }
  #product-dialog #buy { flex: 1; }
  #product-dialog .dialog-body {
    flex: 1;
    grid-template-rows: minmax(160px, 1fr) auto;
    gap: 16px;
    padding: 0 0 6px;
  }
  #product-dialog .gallery { min-height: 0; display: block; }
  #product-dialog .gallery-stage { width: 100%; height: 100%; }
  #product-dialog[data-photo-inset] .gallery-photo { padding: 18px 18px 6px; }
  #product-dialog .buy-details { padding-inline: var(--panel-pad); }
  #product-dialog .buy-details h2 { font-size: clamp(22px, 6vw, 30px); }
  #product-dialog .dialog-actions { padding-top: 8px; }
}

@media (min-width: 651px) and (min-height: 501px) {
  #product-dialog {
    width: min(1120px, calc(100% - 48px));
    --panel-pad: clamp(22px, 3vw, 42px);
  }
  #product-dialog #buy {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: 1fr auto auto 1fr;
    max-height: calc(100dvh - 38px);
    overflow-y: auto;
  }
  #product-dialog .dialog-body { display: contents; }
  #product-dialog .gallery { grid-area: 1 / 1 / 5 / 2; align-self: stretch; }
  #product-dialog .gallery-stage { width: 100%; height: min(78dvh, 780px); }
  #product-dialog .buy-details { grid-area: 2 / 2; padding: 48px var(--panel-pad) 0; }
  #product-dialog .dialog-actions {
    grid-area: 3 / 2;
    display: block;
    padding: 16px var(--panel-pad) 28px;
  }
}

/* Reveal a flat gold face behind the native size label. */
#product-dialog #buy #size-options {
  gap: 4px;
  background: transparent;
}
#product-dialog #buy #size-options .size-option:has(input:enabled) {
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #504c44;
  border-radius: 5px;
  background: #22211f;
  color: var(--purchase-text);
  box-shadow: none;
  transform: none;
  filter: none;
}
#product-dialog #buy #size-options .size-option:has(input:checked:enabled) {
  color: var(--purchase-ink);
  border-color: var(--purchase-cream);
}
#product-dialog #buy #size-options .size-option:has(input:checked:enabled)::before {
  content: '';
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: inherit;
  background: var(--purchase-cream);
  pointer-events: none;
}
#product-dialog #buy #size-options .size-option > span { position: relative; }
@media (prefers-reduced-motion: no-preference) {
  #product-dialog #buy #size-options .size-option:has(input:checked:enabled)::before {
    animation: size-plate-in 320ms cubic-bezier(.2,.75,.22,1);
  }
  #product-dialog #buy #size-options .size-option:has(input:checked:enabled) > span {
    animation: size-ink-in 240ms linear;
  }
}
@keyframes size-plate-in {
  from { clip-path: polygon(-40% 0, -25% 0, -45% 100%, -60% 100%); }
  to { clip-path: polygon(0 0, 125% 0, 105% 100%, 0 100%); }
}
@keyframes size-ink-in {
  0%, 28% { color: var(--purchase-text); }
  45%, 100% { color: var(--purchase-ink); }
}
#product-dialog #buy #size-options .size-option:has(input:focus-visible) {
  outline: 2px solid var(--purchase-cream);
  outline-offset: 1px;
  z-index: 1;
}
@media (forced-colors: active) {
  #product-dialog #buy #size-options .size-option:has(input:checked) { border: 2px solid Highlight; }
}

/* Product and bag share one matte surface for minus, quantity and plus. */
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper[role="group"] {
  display: inline-grid;
  grid-template-columns: 44px minmax(32px, auto) 44px;
  align-items: center;
  gap: 0;
  padding: 0;
  border: 1px solid #393732;
  border-radius: 6px;
  background: #1b1b19;
  box-shadow: none;
}
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn {
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #eeeae1;
  font: 400 20px/1 Arial, sans-serif;
  text-shadow: none;
  box-shadow: none;
  filter: none;
  transform: none;
  transition: background-color 100ms ease-out;
  touch-action: manipulation;
}
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper :is(output, #qty-value) {
  border: 0;
  padding: 0 3px;
  color: #eeeae1;
  font: 600 15px/1 Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
@media (hover: hover) {
  :is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn:enabled:hover {
    background: #2a2926;
  }
}
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn:enabled:active {
  background: #36342f;
  box-shadow: none;
  transform: none;
}
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn:disabled {
  color: #75736d;
  background: transparent;
  opacity: 1;
}
:is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn:focus-visible {
  outline: 2px solid #e8cb97;
  outline-offset: -3px;
}
@media (prefers-reduced-motion: reduce) {
  :is(#product-dialog #buy, #cart-dialog .cart-item-controls) .quantity-stepper .step-btn { transition: none; }
}
