/* ---------------------------------------------------------------------------
   購物車頁（/cart/）
--------------------------------------------------------------------------- */

.storefront-cart {
  max-width: 1080px;
  margin-inline: auto;
  padding-block: var(--space-8) var(--space-16);
}

.storefront-cart__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  margin-bottom: var(--space-6);
}

.storefront-cart__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: var(--space-6);
  align-items: start;
}

@media (max-width: 900px) {
  .storefront-cart__layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- 全選 -------------------------------------------------------------- */

.storefront-cart__select-all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin-bottom: var(--space-3);
  cursor: pointer;
}

/* --- 品項卡 ------------------------------------------------------------ */

.storefront-cart__card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
}

.storefront-cart__lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.storefront-cart__line {
  display: grid;
  grid-template-columns: auto 72px minmax(0, 1fr) 84px auto auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-5) var(--space-5);
}

.storefront-cart__line + .storefront-cart__line {
  border-top: 1px solid var(--color-border);
}

.storefront-cart__line--disabled {
  opacity: 0.55;
}

/* 綠底白勾的自訂 checkbox（全選＋品項共用） */
.storefront-cart__select-all input,
.storefront-cart__line-check {
  appearance: none;
  -webkit-appearance: none;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  cursor: pointer;
  position: relative;
  flex: none;
}

.storefront-cart__select-all input:checked,
.storefront-cart__line-check:checked {
  background: var(--color-brand);
  border-color: var(--color-brand);
}

.storefront-cart__select-all input:checked::after,
.storefront-cart__line-check:checked::after {
  content: "";
  position: absolute;
  left: 0.32rem;
  top: 0.12rem;
  width: 0.28rem;
  height: 0.55rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.storefront-cart__select-all input:focus-visible,
.storefront-cart__line-check:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.storefront-cart__line-check:disabled {
  background: var(--color-surface-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
}

.storefront-cart__line-image {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-1);
  overflow: hidden;
  background: var(--color-surface-muted);
}

.storefront-cart__line-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.storefront-cart__line-image-placeholder {
  display: block;
  width: 100%;
  height: 100%;
}

.storefront-cart__line-title {
  color: var(--color-text);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.storefront-cart__line-title:hover {
  color: var(--color-accent);
}

.storefront-cart__line-variants,
.storefront-cart__line-availability {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin: var(--space-1) 0 0;
}

.storefront-cart__line-reasons {
  color: var(--color-danger);
  font-size: var(--text-sm);
  margin: var(--space-1) 0 0;
}

.storefront-cart__line-qty input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  font-size: var(--text-base);
  text-align: center;
}

.storefront-cart__line-price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 92px;
}

.storefront-cart__line-compare-price {
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  text-decoration: line-through;
}

.storefront-cart__line-current-price {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.storefront-cart__line-delete button {
  background: none;
  border: none;
  color: var(--color-text-subtle);
  font-size: var(--text-lg);
  line-height: 1;
  padding: var(--space-1);
  cursor: pointer;
}

.storefront-cart__line-delete button:hover {
  color: var(--color-text);
}

@media (max-width: 640px) {
  .storefront-cart__line {
    grid-template-columns: auto 56px minmax(0, 1fr) auto;
    grid-template-areas:
      "check image info delete"
      "check image qtyprice delete";
  }
  .storefront-cart__line-check { grid-area: check; }
  .storefront-cart__line-image { grid-area: image; width: 56px; height: 56px; }
  .storefront-cart__line-info { grid-area: info; }
  .storefront-cart__line-qty { grid-area: qtyprice; width: 72px; }
  .storefront-cart__line-price { grid-area: qtyprice; justify-self: end; }
  .storefront-cart__line-delete { grid-area: delete; }
}

/* --- 收件地與運送方式 --------------------------------------------------- */

.storefront-cart__shipping {
  border-top: 1px solid var(--color-border);
  padding: var(--space-5);
}

.storefront-cart__shipping-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  margin: 0 0 var(--space-4);
}

.storefront-cart__shipping-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 320px;
}

.storefront-cart__select {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  font-size: var(--text-base);
  color: var(--color-text);
}

.storefront-cart__select:disabled {
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
}

.storefront-cart__shipping-note {
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  margin: var(--space-3) 0 0;
}

/* --- 訂單摘要 ----------------------------------------------------------- */

.storefront-cart__summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
}

.storefront-cart__summary-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  margin: 0;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-2) var(--radius-2) 0 0;
}

.storefront-cart__summary-rows {
  margin: 0;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.storefront-cart__summary-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-base);
}

.storefront-cart__summary-row dt {
  color: var(--color-text);
}

.storefront-cart__summary-row dd {
  margin: 0;
  font-weight: var(--weight-medium);
}

.storefront-cart__free-shipping-hint {
  color: var(--color-danger);
  font-size: var(--text-sm);
  margin: calc(var(--space-2) * -1) 0 0;
  text-align: right;
}

.storefront-cart__summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-base);
}

.storefront-cart__summary-total strong {
  font-size: var(--text-lg);
}

.storefront-cart__checkout {
  display: block;
  width: calc(100% - var(--space-5) * 2);
  margin: 0 var(--space-5) var(--space-5);
  text-align: center;
}

.storefront-cart__checkout:disabled {
  background: var(--color-surface-muted);
  color: var(--color-text-subtle);
  cursor: not-allowed;
}

/* --- 通知條 -------------------------------------------------------------- */

.storefront-cart__notice {
  border-radius: var(--radius-1);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.storefront-cart__notice--success {
  background: color-mix(in srgb, var(--color-success) 14%, var(--color-surface));
  color: var(--color-text);
}

.storefront-cart__notice--error {
  background: color-mix(in srgb, var(--color-danger) 10%, var(--color-surface));
  color: var(--color-danger);
}

/* --- Email 驗證 modal ----------------------------------------------------- */

.storefront-cart__modal-backdrop[hidden] {
  display: none;
}

.storefront-cart__modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(33 37 41 / 45%);
  padding: var(--space-5);
}

.storefront-cart__modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: var(--radius-2);
  box-shadow: 0 16px 48px -12px var(--color-shadow);
  padding: var(--space-8) var(--space-6) var(--space-6);
  text-align: center;
}

.storefront-cart__modal-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background: none;
  border: none;
  color: var(--color-text-subtle);
  font-size: var(--text-lg);
  line-height: 1;
  padding: var(--space-1);
  cursor: pointer;
}

.storefront-cart__modal-close:hover {
  color: var(--color-text);
}

.storefront-cart__modal-title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  margin: 0 0 var(--space-3);
}

.storefront-cart__modal-text {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  margin: 0 0 var(--space-5);
  overflow-wrap: anywhere;
}

.storefront-cart__modal-send {
  width: 100%;
}

/* --- 空購物車 ----------------------------------------------------------- */

.storefront-cart__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-16) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  color: var(--color-text-muted);
}
