/* ==========================================================================
   Kintsugi Shop — shared storefront layer (assets/shop/shop.css)
   Class prefix: kg-shop-*   Loaded per-page via {{ asset("shop/shop.css") }}.
   Pairs with assets/shop/shop.js (window.KintsugiShop).
   Uses theme tokens with fallbacks; see scratchpad/foundation-api.md.
   ========================================================================== */

:root {
  --brand-primary-rgb: 122, 155, 118;
  --header-height: 80px;
}

/* --------------------------------------------------------------------------
   Header cart badge (rendered by components/header.jinja on every page;
   populated by shop.js only on pages that load it — stays hidden elsewhere)
   -------------------------------------------------------------------------- */
.kg-shop-cart-link {
  position: relative;
}
.kg-shop-cart-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: var(--kintsugi-gold, #d4af37);
  color: var(--charcoal, #333);
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  pointer-events: none;
}
.kg-shop-cart-badge[hidden] {
  display: none;
}

/* --------------------------------------------------------------------------
   Breadcrumb bar
   -------------------------------------------------------------------------- */
.kg-shop-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 0;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.8125rem;
  color: var(--gray-dark, #666);
}
.kg-shop-breadcrumb a {
  color: var(--gray-dark, #666);
  text-decoration: none;
  transition: color var(--cms-transition-fast, 150ms ease);
}
.kg-shop-breadcrumb a:hover {
  color: var(--forest-primary, #7A9B76);
}
.kg-shop-breadcrumb__sep {
  color: var(--gray-medium, #9ca3af);
  font-size: 0.6875rem;
}
.kg-shop-breadcrumb__current {
  color: var(--charcoal, #333);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Buttons — Kintsugi pill buttons
   -------------------------------------------------------------------------- */
.kg-shop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: 2px solid transparent;
  border-radius: 9999px;
  font-family: var(--font-heading, 'Noto Serif JP', serif);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--cms-transition-normal, 300ms ease);
  -webkit-user-select: none;
  user-select: none;
}
.kg-shop-btn:disabled,
.kg-shop-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.kg-shop-btn--primary {
  background: var(--forest-primary, #7A9B76);
  border-color: var(--forest-primary, #7A9B76);
  color: var(--pure-white, #fff);
}
.kg-shop-btn--primary:hover {
  background: var(--forest-deep, #4A5D47);
  border-color: var(--forest-deep, #4A5D47);
  color: var(--pure-white, #fff);
  transform: translateY(-2px);
  box-shadow: var(--cms-shadow-nature, 0 4px 12px rgba(122, 155, 118, 0.15));
}
.kg-shop-btn--outline {
  background: transparent;
  border-color: var(--forest-primary, #7A9B76);
  color: var(--forest-primary, #7A9B76);
}
.kg-shop-btn--outline:hover {
  background: var(--forest-primary, #7A9B76);
  color: var(--pure-white, #fff);
  transform: translateY(-2px);
}
.kg-shop-btn--danger {
  background: var(--system-error-text, #dc2626);
  border-color: var(--system-error-text, #dc2626);
  color: var(--pure-white, #fff);
}
.kg-shop-btn--danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  transform: translateY(-2px);
}
.kg-shop-btn--ghost {
  background: var(--bg-tertiary, #E8EBE7);
  border-color: transparent;
  color: var(--brand-deep, #4A5D47);
}
.kg-shop-btn--ghost:hover {
  background: var(--sage-light, #B8CDB5);
}
.kg-shop-btn--sm {
  padding: 8px 18px;
  font-size: 0.75rem;
}
.kg-shop-btn--lg {
  padding: 14px 32px;
  font-size: 0.9375rem;
}
.kg-shop-btn--block {
  display: flex;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Generic white panel + product card baseline
   -------------------------------------------------------------------------- */
.kg-shop-panel {
  background: var(--pure-white, #fff);
  border: 1px solid var(--gray-100, #f3f4f6);
  border-radius: 12px;
  box-shadow: var(--cms-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.08));
  padding: 24px;
}

.kg-shop-product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--pure-white, #fff);
  border-top: 4px solid var(--brand-primary, #7A9B76);
  border-radius: 12px;
  box-shadow: var(--cms-shadow-nature, 0 4px 12px rgba(122, 155, 118, 0.15));
  transition: transform var(--cms-transition-normal, 300ms ease),
              box-shadow var(--cms-transition-normal, 300ms ease);
  text-decoration: none;
}
.kg-shop-product-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--cms-shadow-kintsugi, 0 6px 20px rgba(212, 175, 55, 0.25));
}
.kg-shop-product-card__media {
  position: relative;
  overflow: hidden;
  background: var(--gray-100, #f3f4f6);
  aspect-ratio: 1 / 1;
}
.kg-shop-product-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.kg-shop-product-card:hover .kg-shop-product-card__media img {
  transform: scale(1.05);
}
.kg-shop-product-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
  padding: 18px 20px 20px;
}
.kg-shop-product-card__title {
  margin: 0;
  font-family: var(--font-heading, 'Noto Serif JP', serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--charcoal, #333);
  line-height: 1.35;
}

/* Corner pills used on product media (sale / featured / sold-out) */
.kg-shop-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pure-white, #fff);
  background: var(--forest-primary, #7A9B76);
}
.kg-shop-pill--sale {
  background: #ef4444;
}
.kg-shop-pill--soldout {
  background: #ef4444;
}
.kg-shop-pill--featured {
  background: var(--brand-primary, #7A9B76);
}

/* --------------------------------------------------------------------------
   Prices — gold by default; .sale = discounted price in red;
   .kg-shop-price-was = struck-through original price next to a sale price
   -------------------------------------------------------------------------- */
.kg-shop-price {
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--kintsugi-gold, #d4af37);
}
.kg-shop-price.sale {
  color: #ff6b6b;
}
.kg-shop-price-was {
  font-size: 0.9em;
  font-weight: 500;
  color: var(--gray-medium, #9ca3af);
  text-decoration: line-through;
}

/* --------------------------------------------------------------------------
   Order status badges — class is string-concatenated: status-<status>
   (statuses stay lowercase: pending processing shipped delivered completed cancelled)
   -------------------------------------------------------------------------- */
.kg-shop-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 24px;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-dark, #4b5563);
  white-space: nowrap;
}
.kg-shop-status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.kg-shop-status-badge.status-pending {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}
.kg-shop-status-badge.status-processing {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
}
.kg-shop-status-badge.status-shipped {
  background: linear-gradient(135deg, #e9d5ff, #d8b4fe);
  color: #6b21a8;
}
.kg-shop-status-badge.status-delivered,
.kg-shop-status-badge.status-completed {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
}
.kg-shop-status-badge.status-cancelled {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
}

/* --------------------------------------------------------------------------
   Quantity selector
   -------------------------------------------------------------------------- */
.kg-shop-qty {
  display: inline-flex;
  align-items: center;
  background: var(--gray-50, #f9fafb);
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
}
.kg-shop-qty__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--gray-dark, #4b5563);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--cms-transition-fast, 150ms ease),
              color var(--cms-transition-fast, 150ms ease);
}
.kg-shop-qty__btn:hover {
  background: var(--brand-bg, #E8F2EC);
  color: var(--forest-primary, #7A9B76);
}
.kg-shop-qty__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kg-shop-qty__input {
  width: 40px;
  height: 34px;
  border: 0;
  background: transparent;
  text-align: center;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--charcoal, #333);
  -moz-appearance: textfield;
  appearance: textfield;
}
.kg-shop-qty__input::-webkit-outer-spin-button,
.kg-shop-qty__input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.kg-shop-qty__input:focus {
  outline: none;
}

/* --------------------------------------------------------------------------
   Sticky order summary card
   -------------------------------------------------------------------------- */
.kg-shop-summary {
  position: sticky;
  top: calc(var(--header-height, 80px) + 20px);
  background: var(--pure-white, #fff);
  border: 1px solid var(--gray-100, #f3f4f6);
  border-radius: 16px;
  box-shadow: var(--cms-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.08));
  padding: 24px;
}
.kg-shop-summary__title {
  margin: 0 0 18px;
  font-family: var(--font-heading, 'Noto Serif JP', serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--charcoal, #333);
}
.kg-shop-summary__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.9375rem;
  color: var(--gray-dark, #4b5563);
}
.kg-shop-summary__row--discount {
  color: #059669;
}
.kg-shop-summary__total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-200, #e5e7eb);
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--charcoal, #333);
}
.kg-shop-summary__total-amount {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--forest-primary, #7A9B76);
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.kg-shop-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 28px;
  background: var(--pure-white, #fff);
  border: 1px solid var(--gray-100, #f3f4f6);
  border-radius: 24px;
  box-shadow: var(--cms-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.08));
  text-align: center;
}
.kg-shop-empty__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 110px;
  height: 110px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--brand-bg, #E8F2EC);
  color: var(--brand-light, #A8C4B8);
  font-size: 2.75rem;
}
.kg-shop-empty__title {
  margin: 0;
  font-family: var(--font-heading, 'Noto Serif JP', serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--charcoal, #333);
}
.kg-shop-empty__text {
  margin: 0 0 14px;
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.9375rem;
  color: var(--gray-dark, #666);
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Toasts (created by KintsugiShop.toast)
   -------------------------------------------------------------------------- */
.kg-shop-toast-stack {
  position: fixed;
  top: calc(var(--header-height, 80px) + 12px);
  right: 16px;
  z-index: 2400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.kg-shop-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 12px;
  border-left: 4px solid var(--forest-primary, #7A9B76);
  background: var(--pure-white, #fff);
  box-shadow: 0 10px 30px rgba(20, 40, 25, 0.18);
  font-family: var(--font-body, 'Montserrat', sans-serif);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--charcoal, #333);
  line-height: 1.45;
  pointer-events: auto;
  cursor: pointer;
  animation: kgShopToastIn 0.25s ease;
}
.kg-shop-toast i {
  margin-top: 1px;
  font-size: 1rem;
}
.kg-shop-toast--success {
  border-left-color: var(--forest-primary, #7A9B76);
}
.kg-shop-toast--success i {
  color: var(--forest-primary, #7A9B76);
}
.kg-shop-toast--error {
  border-left-color: var(--system-error-text, #dc2626);
}
.kg-shop-toast--error i {
  color: var(--system-error-text, #dc2626);
}
.kg-shop-toast--info {
  border-left-color: var(--kintsugi-gold, #d4af37);
}
.kg-shop-toast--info i {
  color: var(--kintsugi-gold, #d4af37);
}
.kg-shop-toast--leaving {
  animation: kgShopToastOut 0.22s ease forwards;
}
@keyframes kgShopToastIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: none; }
}
@keyframes kgShopToastOut {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translateX(18px); }
}

/* --------------------------------------------------------------------------
   Confirm modal (created by KintsugiShop.confirm) — portal-modal language
   -------------------------------------------------------------------------- */
.kg-shop-confirm[hidden] {
  display: none;
}
.kg-shop-confirm {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.kg-shop-confirm__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 41, 33, 0.55);
  backdrop-filter: blur(3px);
}
.kg-shop-confirm__dialog {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 24rem;
  padding: 2rem 1.9rem 1.6rem;
  background: var(--pure-white, #fff);
  border-radius: 1.25rem;
  box-shadow: 0 30px 70px rgba(20, 40, 25, 0.32);
  font-family: var(--font-body, 'Montserrat', sans-serif);
  text-align: center;
  animation: kgShopModalIn 0.2s ease;
}
.kg-shop-confirm__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--brand-bg, #E8F2EC);
  color: var(--forest-primary, #7A9B76);
  font-size: 1.4rem;
}
.kg-shop-confirm--danger .kg-shop-confirm__icon {
  background: #fee2e2;
  color: var(--system-error-text, #dc2626);
}
.kg-shop-confirm__title {
  margin: 0 0 8px;
  font-family: var(--font-heading, 'Noto Serif JP', serif);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--brand-deep, #4A5D47);
}
.kg-shop-confirm--danger .kg-shop-confirm__title {
  color: var(--charcoal, #333);
}
.kg-shop-confirm__message {
  margin: 0 0 22px;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--gray-dark, #666);
}
.kg-shop-confirm__actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
@keyframes kgShopModalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Loading spinner overlay — add .kg-shop-loading-host to the covered element
   -------------------------------------------------------------------------- */
.kg-shop-loading-host {
  position: relative;
}
.kg-shop-spinner-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  border-radius: inherit;
}
.kg-shop-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--brand-bg, #E8F2EC);
  border-top-color: var(--forest-primary, #7A9B76);
  border-radius: 50%;
  animation: kgShopSpin 0.7s linear infinite;
}
.kg-shop-spinner--lg {
  width: 44px;
  height: 44px;
  border-width: 4px;
}
@keyframes kgShopSpin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .kg-shop-summary {
    position: static;
  }
  .kg-shop-toast-stack {
    top: auto;
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}
