/* ============================================================
   Book Checkout — Stripe Custom Checkout Elements
   ABC Gabig, LLC
   ============================================================ */

.checkout-page {
  min-height: 100vh;
  padding: 88px 24px 48px;
  background: transparent;
}

.checkout-page__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 40px;
  align-items: start;
}

.checkout-summary {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
  border-radius: var(--radius);
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.checkout-summary__cover {
  width: min(220px, 70%);
  margin: 0 auto;
  border-radius: var(--radius);
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.45),
    4px 4px 0 rgba(213, 190, 118, 0.15);
}

.checkout-summary__book-title .product-name__title {
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  color: var(--cream-light);
}

.checkout-summary__book-title .product-name__arm.product-name__subtitle {
  font-size: clamp(0.95rem, 2vw, 1.05rem);
  color: var(--cream);
}

.checkout-summary__meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(226, 209, 182, 0.12);
}

.checkout-summary__quantity {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkout-summary__quantity-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.checkout-quantity {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0;
  border-radius: 10px;
  border: 1px solid rgba(226, 209, 182, 0.2);
  background: rgba(226, 209, 182, 0.06);
  overflow: hidden;
}

.checkout-quantity__btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.checkout-quantity__btn:hover:not(:disabled) {
  background: rgba(213, 190, 118, 0.12);
}

.checkout-quantity__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.checkout-quantity__input {
  width: 52px;
  height: 40px;
  border: none;
  border-left: 1px solid rgba(226, 209, 182, 0.12);
  border-right: 1px solid rgba(226, 209, 182, 0.12);
  background: transparent;
  color: var(--cream-light);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
}

.checkout-quantity__input::-webkit-outer-spin-button,
.checkout-quantity__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.checkout-quantity__input:focus {
  outline: none;
  background: rgba(213, 190, 118, 0.08);
}

.checkout-quantity__hint {
  min-height: 1.1rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: rgba(226, 209, 182, 0.72);
}

.checkout-quantity__error {
  min-height: 1.1rem;
  margin: 0;
  font-size: 0.85rem;
  color: #ffb4b4;
}

/* Collapse the hint/error rows entirely when they have no message, so they
   don't reserve space (and flex gap) inside the cart box. */
.checkout-quantity__hint:empty,
.checkout-quantity__error:empty {
  display: none;
}

.checkout-summary__row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.92rem;
  color: var(--cream);
}

.checkout-summary__row--total {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold);
  padding-top: 8px;
  border-top: 1px solid rgba(226, 209, 182, 0.12);
}

/* While the cart is syncing with the backend, prices/totals show a neutral
   placeholder that gently pulses, so the optimistic quantity is visible but no
   contradictory (stale) price is ever presented as final. */
.checkout-summary__value--pending,
.cart-item__price--pending {
  color: rgba(226, 209, 182, 0.5);
  animation: checkout-price-pulse 1s ease-in-out infinite;
}

@keyframes checkout-price-pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .checkout-summary__value--pending,
  .cart-item__price--pending {
    animation: none;
  }
}

.checkout-panel {
  padding: 28px;
  border-radius: var(--radius);
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.checkout-panel__title {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 2rem);
  color: var(--cream-light);
  margin-bottom: 8px;
}

.checkout-panel__intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.checkout-notice {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--cream);
  padding: 12px 16px;
  margin: 0 0 24px;
  border-radius: var(--radius);
  border: 1px solid rgba(213, 190, 118, 0.35);
  background: rgba(213, 190, 118, 0.08);
  border-left: 4px solid var(--gold);
}

.checkout-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* On desktop the groups are transparent pass-throughs so the panel looks
   unchanged; on mobile they become separate cards (see media query). */
.checkout-group {
  display: contents;
}

.checkout-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkout-section__label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.checkout-element {
  min-height: 12px;
}

.checkout-shipping-form,
.checkout-shipping-display,
.checkout-shipping-rates,
.checkout-promo {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkout-promo__entry {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.checkout-promo__input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(226, 209, 182, 0.2);
  background: rgba(10, 22, 40, 0.45);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

.checkout-promo__input::placeholder {
  color: rgba(226, 209, 182, 0.45);
}

.checkout-promo__input:focus {
  outline: 2px solid rgba(201, 162, 39, 0.45);
  outline-offset: 1px;
}

.checkout-promo__entry .btn {
  flex-shrink: 0;
  align-self: stretch;
}

.checkout-promo__applied {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(226, 209, 182, 0.06);
  border: 1px solid rgba(226, 209, 182, 0.12);
}

.checkout-promo__applied-label {
  font-size: 0.9rem;
  color: rgba(226, 209, 182, 0.75);
}

.checkout-promo__applied-code {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cream);
}

.checkout-promo__remove {
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}

.checkout-promo__remove:hover {
  color: var(--cream);
}

.checkout-promo__error {
  min-height: 0;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #ff7a7a;
}

.checkout-promo__error:empty {
  display: none;
}

.checkout-promo__input--invalid {
  border-color: rgba(255, 122, 122, 0.55);
}

.checkout-summary__row--discount span:last-child {
  color: var(--gold);
}

.checkout-shipping-display {
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(226, 209, 182, 0.06);
  border: 1px solid rgba(226, 209, 182, 0.12);
}

.checkout-shipping-display__text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--cream);
}

.checkout-shipping-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkout-shipping-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(226, 209, 182, 0.06);
  border: 1px solid rgba(226, 209, 182, 0.12);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.checkout-shipping-option:hover {
  border-color: rgba(213, 190, 118, 0.35);
}

.checkout-shipping-option:has(input:checked) {
  border-color: rgba(213, 190, 118, 0.55);
  background: rgba(213, 190, 118, 0.08);
}

.checkout-shipping-option input {
  margin-top: 3px;
  accent-color: var(--gold);
}

.checkout-consent {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(226, 209, 182, 0.06);
  border: 1px solid rgba(226, 209, 182, 0.12);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.45;
  color: rgba(226, 209, 182, 0.88);
}

.checkout-consent input {
  margin-top: 3px;
  accent-color: var(--gold);
  flex-shrink: 0;
}

.checkout-consent__text {
  display: block;
}

.checkout-shipping-option__label {
  display: flex;
  flex: 1;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  font-size: 0.95rem;
  color: var(--cream);
}

.checkout-shipping-option__main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.checkout-shipping-option__name {
  line-height: 1.45;
}

.checkout-shipping-option__delivery {
  font-size: 0.82rem;
  line-height: 1.4;
  color: rgba(226, 209, 182, 0.72);
}

.checkout-shipping-expand {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  font-size: 0.88rem;
  color: var(--gold);
  text-decoration: underline;
  cursor: pointer;
}

.checkout-shipping-expand:hover {
  color: var(--cream);
}

.checkout-shipping-option__amount {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--gold);
}

.checkout-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkout-actions .btn {
  min-width: 120px;
}

.checkout-actions .btn:disabled,
#submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

#submit.checkout-submit--blocked,
#submit[aria-disabled="true"]:not(:disabled) {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

#submit {
  width: 100%;
  margin-top: 4px;
}

.checkout-message {
  min-height: 1.25rem;
  font-size: 0.92rem;
  color: #ffb4b4;
}

.checkout-message--success {
  color: #9fd89f;
}

.checkout-message--status {
  color: rgba(226, 209, 182, 0.75);
}

.checkout-loading,
.checkout-error-state {
  max-width: 640px;
  margin: 120px auto 0;
  padding: 32px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
}

.checkout-loading__spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border: 3px solid rgba(213, 190, 118, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: checkout-spin 0.8s linear infinite;
}

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

.checkout-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

.checkout-back-link:hover {
  color: var(--gold);
}

.checkout-return {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 24px 48px;
  background: transparent;
}

.checkout-return__card {
  width: min(100%, 560px);
  padding: 40px 32px;
  text-align: center;
  border-radius: var(--radius);
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.checkout-return__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  font-weight: 700;
}

.checkout-return__icon--success {
  background: rgba(48, 177, 48, 0.15);
  color: #9fd89f;
}

.checkout-return__icon--error {
  background: rgba(223, 27, 65, 0.15);
  color: #ffb4b4;
}

.checkout-return__title {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  color: var(--cream-light);
  margin-bottom: 12px;
}

.checkout-return__text {
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 24px;
}

.checkout-return__details {
  text-align: left;
  margin: 0 auto 24px;
  padding: 16px 18px;
  border-radius: 10px;
  background: rgba(226, 209, 182, 0.06);
  border: 1px solid rgba(226, 209, 182, 0.1);
  font-size: 0.92rem;
  color: var(--cream);
}

.checkout-return__details p + p {
  margin-top: 8px;
}

.checkout-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .checkout-page__inner {
    grid-template-columns: 1fr;
  }

  .checkout-summary {
    position: static;
  }

  /* Panel becomes a transparent wrapper; its inner form groups become the
     cards, so the flow reads: Cart -> Shipping & Details -> Totals -> Payment. */
  .checkout-panel {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  /* Header sits in its own block at the top; the grid gap handles the spacing. */
  .checkout-panel__intro {
    margin-bottom: 0;
  }

  .checkout-group {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px 18px;
    border-radius: var(--radius);
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  }

  /* Totals are moved between the details and payment groups (see
     book-checkout-layout.js) and styled as their own card. */
  .checkout-form > .checkout-summary__meta {
    padding: 22px 18px;
    border-top: none;
    border-radius: var(--radius);
    background: var(--panel-surface);
    border: 1px solid var(--panel-border);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  }
}

@media (max-width: 600px) {
  .checkout-page,
  .checkout-return {
    padding-top: 84px;
  }

  /* The panel is a transparent wrapper on mobile (padding handled by the inner
     cards), so keep it padding-free here so all boxes are the same width. */
  .checkout-summary {
    padding: 22px 18px;
  }
}

/* ---------- Cross-sell add-ons ---------- */
.cart-cross-sell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}

.cart-cross-sell[hidden] {
  display: none;
}

.cross-sell-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(213, 190, 118, 0.08);
  border: 1px dashed rgba(213, 190, 118, 0.35);
}

.cross-sell-item__cover {
  width: 56px;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.cross-sell-item__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cross-sell-item__title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.25;
  color: var(--cream-light);
}

.cross-sell-item__desc {
  font-size: 0.82rem;
  color: var(--cream);
  opacity: 0.85;
}

.cross-sell-item__add {
  justify-self: end;
  padding: 9px 16px;
  border: none;
  border-radius: 999px;
  background: var(--gold);
  color: var(--darker);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.cross-sell-item__add:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.cross-sell-item__add:active {
  transform: translateY(0);
}

@media (max-width: 600px) {
  .cross-sell-item {
    grid-template-columns: 48px minmax(0, 1fr);
    grid-template-areas:
      "cover body"
      "add add";
  }

  .cross-sell-item__cover {
    grid-area: cover;
    width: 48px;
  }

  .cross-sell-item__body {
    grid-area: body;
  }

  .cross-sell-item__add {
    grid-area: add;
    justify-self: stretch;
    text-align: center;
  }
}

/* ---------- Cross-sell group row ---------- */
.cross-sell-item--group .cross-sell-item__cover--group {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 72px;
  border-radius: 6px;
  background: rgba(213, 190, 118, 0.12);
}

.cross-sell-item__group-icon {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.cross-sell-item__from {
  font-size: 0.8rem;
  color: var(--gold);
  margin-top: 2px;
}

/* ---------- Bookmark picker modal ---------- */
body.cross-sell-modal-open {
  overflow: hidden;
}

.cross-sell-modal[hidden] {
  display: none;
}

.cross-sell-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.cross-sell-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 9, 20, 0.92);
}

.cross-sell-modal__panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  padding: 24px;
  border-radius: var(--radius);
  background: #0f2138;
  border: 1px solid rgba(226, 209, 182, 0.22);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.cross-sell-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.cross-sell-modal__title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  color: var(--cream-light);
  margin: 0;
}

.cross-sell-modal__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(226, 209, 182, 0.1);
  color: var(--cream);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.cross-sell-modal__grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cross-sell-modal__card {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: #1a2f4f;
  border: 1px solid rgba(226, 209, 182, 0.18);
}

.cross-sell-modal__cover {
  width: 100px;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.cross-sell-modal__card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--cream-light);
  margin: 0 0 4px;
}

.cross-sell-modal__card-subtitle {
  font-size: 0.85rem;
  color: var(--gold);
  margin: 0 0 8px;
}

.cross-sell-modal__card-desc {
  font-size: 0.82rem;
  color: var(--cream);
  margin: 0 0 10px;
  line-height: 1.45;
}

.cross-sell-modal__price {
  font-weight: 700;
  color: var(--cream-light);
  margin: 0 0 10px;
}

.cross-sell-modal__in-cart {
  font-size: 0.85rem;
  color: var(--gold);
  margin: 0;
}

.cross-sell-modal__add {
  width: 100%;
  max-width: 200px;
}

.cross-sell-modal__footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .cross-sell-modal__card {
    grid-template-columns: 1fr;
  }

  .cross-sell-modal__cover {
    width: 80px;
  }
}
