.cart-trigger,
.product-buy,
.shop-cart button {
  min-height: 44px;
  border: 0;
  color: inherit;
  background: transparent;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.cart-trigger {
  display: inline-flex;
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-items: center;
  gap: 6px;
  padding: 0;
}

.site-header:has(.cart-trigger) .site-address { margin-inline-end: 6.25rem; }
.cart-trigger:hover, .cart-close:hover, .cart-remove:hover, .cart-back:hover { text-decoration: underline; }

.product-buy {
  position: absolute;
  z-index: 2;
  top: 8px;
  right: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--paper);
}

.product-buy:hover { background: var(--photo-mat); }

#catalog { isolation: isolate; }

.shop-cart {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 520px);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: var(--paper);
}

.shop-cart::backdrop { background: rgb(0 0 0 / 52%); }
body:has(.shop-cart[open]) { overflow: hidden; }

.cart-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.cart-heading,
.cart-content,
.cart-summary {
  padding: 18px clamp(16px, 4vw, 28px);
}

.cart-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.cart-heading h2 { font-size: 1.25em; }
.cart-heading button, .cart-back, .cart-remove { padding: 0; }
.cart-stage:not([hidden]) { display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.cart-stage.cart-confirmation:not([hidden]) { display: flex; }
.cart-content { overflow-y: auto; }
.cart-items { margin: 0; padding: 0; list-style: none; }
.cart-empty p { margin-bottom: 12px; }

.cart-line {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding-block: 12px;
}

.cart-thumbnail {
  width: 64px;
  height: 64px;
  object-fit: contain;
  background: var(--photo-mat);
}

.cart-item-copy strong { font-weight: 500; }

.cart-quantity {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-quantity button {
  width: 44px;
  padding: 0;
  background: var(--photo-mat);
}

.cart-summary { background: var(--photo-mat); }
.cart-summary p { display: flex; justify-content: space-between; margin-bottom: 12px; }

.shop-cart .cart-action {
  width: 100%;
  padding: 0 14px;
  color: var(--paper);
  background: var(--ink);
}

.shop-cart .cart-action:hover { background: #292929; }

.checkout-fields { display: grid; align-content: start; gap: 16px; }
.checkout-fields label { display: grid; gap: 4px; }
.checkout-fields input {
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  font-size: max(16px, 1rem);
  background: var(--photo-mat);
}

.cart-back { justify-self: start; }

.cart-confirmation {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 28px;
  text-align: center;
}

.cart-confirmation img { width: 100px; height: auto; }
.cart-confirmation .cart-action { max-width: 280px; }

@media (prefers-reduced-motion: no-preference) {
  .shop-cart[open] { animation: cart-enter 220ms ease-out; }
}

@keyframes cart-enter {
  from { transform: translateX(100%); }
}

@media (max-width: 1366px) {
  .product:not([hidden]):has(> .product-buy) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 2px;
  }

  .product:has(> .product-buy) > .product-media,
  .product:has(> .product-buy) > .product-caption { grid-area: 1 / 1; }

  .product:has(> .product-buy) > .product-caption {
    position: relative;
    inset: auto;
    align-self: end;
  }

  .product-buy {
    position: static;
    z-index: auto;
    grid-area: 2 / 1;
    background: var(--photo-mat);
  }

  .product-buy:hover { text-decoration: underline; }
}

@media (max-width: 700px) {
  .site-header:has(.cart-trigger) .site-address { margin-inline-end: 0; }
}
