/* Cart, checkout and order pages. */

.cart-items {
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.cart-item {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.5rem 1rem;
  padding: 1rem 0;
  border-bottom: var(--border-width) solid var(--color-border);
}

@media (min-width: 768px) {
  .cart-item {
    grid-template-columns: 8rem 1fr auto 7rem;
    align-items: start;
  }
}

.cart-item__image img {
  display: block;
  width: 100%;
}

.cart-item__title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.2em;
  font-style: italic;
  text-transform: none;
}

.cart-item__title a {
  text-decoration: none;
}

.cart-item__options {
  margin: 0.3rem 0;
  font-size: 0.85em;
  font-style: italic;
}

.cart-item__options dt,
.cart-item__options dd {
  display: inline;
  margin: 0;
}

.cart-item__unit {
  font-size: 0.85em;
  color: var(--color-muted);
}

.cart-item__quantity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cart-item__quantity input {
  width: 3.5em;
  margin-left: 0.3em;
}

.cart-item__remove-form {
  display: inline;
}

.cart-item__remove {
  padding: 0;
  font: inherit;
  font-size: 0.85em;
  color: var(--color-accent);
  background: none;
  border: 0;
  cursor: pointer;
}

.cart-item__total {
  margin: 0;
  font-size: 1.3em;
  text-align: right;
}

.cart-totals {
  max-width: 32rem;
  margin: 2rem 0 0 auto;
}

.cart-totals table {
  width: 100%;
  border-collapse: collapse;
}

.cart-totals :is(th, td) {
  padding: 0.4em 0;
  vertical-align: baseline;
  border-bottom: 1px solid var(--color-panel);
}

.cart-totals th {
  width: 40%;
  padding-right: 1em;
  font-family: var(--font-title);
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 400;
  text-align: right;
  color: var(--color-brown);
}

.cart-totals small {
  display: block;
  font-size: 0.75em;
  font-style: italic;
  color: var(--color-muted);
}

.cart-totals__total td {
  font-size: 1.2rem;
  font-weight: 700;
}

.cart-totals__checkout,
.cart__continue {
  margin-top: 1rem;
  text-align: center;
}

/* ---- Checkout ---------------------------------------------------------------- */

.checkout {
  display: grid;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (min-width: 900px) {
  .checkout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }

  .checkout__summary {
    position: sticky;
    top: 1rem;
  }
}

.checkout__section + .checkout__section {
  margin-top: 2rem;
}

.checkout__section h2,
.checkout__summary h2 {
  margin: 0 0 1rem;
  font-size: 1.4rem;
}

.checkout__summary {
  padding: 1.25rem;
  background: var(--color-panel);
}

.checkout__form:has([data-ship-to-billing]:checked) [data-shipping-fields] {
  display: none;
}

.checkout__note,
.checkout__tax-note,
.checkout__terms {
  margin: 0.75rem 0;
  font-size: 0.85em;
  font-style: italic;
  color: var(--color-muted);
}

/* Checkout steps (checkout.js shows one at a time): each ends with one big
   button to the next step. The confirm step (checkout/_address_check) asks
   about the ship-to address; payment starts with a summary of the details. */
.checkout__form :is([data-step], section) {
  scroll-margin-top: 1rem; /* checkout.js scrolls to steps and sections */
}

.checkout__next {
  display: block;
  width: 100%;
  max-width: 32rem;
  min-height: 48px;
  margin-top: 1.5rem;
}

.checkout__next + .button--quiet {
  margin-top: 0.75rem;
}

.address-check h2 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}

.address-check p {
  max-width: 32rem;
  margin: 0 0 1rem;
}

.address-check mark {
  background: #ffe9a8;
}

.address-card {
  max-width: 32rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
}

.details-summary {
  padding: 1rem 1.25rem;
  border: 2px solid var(--color-border);
  border-radius: 6px;
}

.details-summary dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.6rem 1.25rem;
  margin: 0 0 0.75rem;
}

.details-summary dt {
  font-family: var(--font-title);
  font-style: normal;
  font-size: 0.8em;
  color: var(--color-brown);
}

.details-summary dd {
  margin: 0;
}

/* Choices: big radio options joined into one block, like a toggle (shared
   borders overlap, and the chosen option's border sits on top). For the ways
   to pay, where the chosen one opens its details and .payment-submit shows its
   pay button (see checkout.js), and the addresses to pick between when USPS
   suggests a change. */
.choices {
  max-width: 32rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice {
  position: relative;
  border: 2px solid var(--color-border);
  background: #fff;
}

.choice:not([hidden]) ~ .choice {
  margin-top: -2px;
}

.choice:has(:checked) {
  z-index: 1;
  border-color: var(--color-accent);
}

/* Round the outer corners of the first and last options shown. */
.choice:not([hidden]):not(.choice:not([hidden]) ~ *) {
  border-radius: 6px 6px 0 0;
}

.choice:not([hidden]):not(:has(~ .choice:not([hidden]))) {
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.choice__label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
}

.choice__label input {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  accent-color: var(--color-accent);
}

.choice__name {
  font-family: var(--font-heading);
  font-style: normal;
  font-size: 1.1rem;
}

.choice__aside {
  margin-left: auto;
}

.choice__details {
  margin: 0;
  padding: 0 1rem 1rem;
  font-size: 0.9em;
  color: var(--color-muted);
}

.choice:not(:has(:checked)) .choice__details {
  display: none;
}

.card-fields__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.payment-submit {
  max-width: 32rem;
  margin-top: 1.25rem;
}

.payment-submit__button {
  width: 100%;
  min-height: 48px; /* the PayPal and Apple Pay buttons' height */
}

.apple-pay-button {
  display: block;
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  -webkit-appearance: -apple-pay-button;
  -apple-pay-button-type: buy;
  -apple-pay-button-style: black;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.75rem 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 0.2rem;
  font-family: var(--font-title);
  font-style: normal;
  font-size: 0.8em;
  color: var(--color-brown);
}

.field :is(input, select, textarea) {
  width: 100%;
}

.field [aria-invalid=true] {
  border-color: var(--color-accent);
}

.field__error {
  margin: 0.3rem 0 0;
  font-size: 0.9em;
  color: var(--color-accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Order summary, confirmation and status --------------------------------- */

.order-summary {
  width: 100%;
  border-collapse: collapse;
}

.order-summary :is(td, th) {
  padding: 0.5em 0;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.order-summary th {
  font-family: var(--font-title);
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-brown);
}

.order-summary__qty {
  color: var(--color-muted);
}

.order-summary__options {
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8em;
  font-style: italic;
}

.order-summary__amount {
  text-align: right !important;
  white-space: nowrap;
  padding-left: 1rem !important;
}

.order-summary__total :is(th, td) {
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: 0;
}

.order-received {
  margin: 1rem 0 1.5rem;
  font-size: 1.2em;
}

.order-details__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  margin: 0 0 1.5rem;
}

.order-details__facts dt {
  font-family: var(--font-title);
  font-style: normal;
  font-size: 0.8rem;
  color: var(--color-brown);
}

.order-details__facts dd {
  margin: 0;
  font-weight: 700;
}

.order-details__addresses {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem 2rem;
  margin-top: 1.5rem;
}

.order-details__addresses h2 {
  font-size: 1.2rem;
}

.order-details__addresses address {
  font-style: normal;
}

.order-details__packages h2 {
  font-size: 1.2rem;
}

.order-details__packages ul {
  list-style: none;
  padding: 0;
}

.order-details__packages li + li {
  margin-top: 0.75rem;
}

.order-details__package-items {
  color: var(--color-muted);
}

.order-status__form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 1rem;
  margin: 1.5rem 0;
}

.order-status__help {
  margin-top: 2rem;
}

/* While an order is being placed (checkout.js): a spinner beside the label. */
.payment-submit__button[aria-busy=true] {
  cursor: progress;
  filter: none;
}

.payment-submit__button[aria-busy=true]::before {
  content: "";
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.5em;
  vertical-align: -0.1em;
  border: 0.15em solid rgb(255 255 255 / 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .payment-submit__button[aria-busy=true]::before {
    animation-duration: 2.4s;
  }
}
