/**
 * Khaime Storefront — frontend styles.
 *
 * Uses CSS custom properties so merchants can override via their theme:
 *   --khaime-accent, --khaime-hairline, --khaime-radius-md, etc.
 * Inherits font-family from the host theme (no `font-family: ...`
 * declarations on the wrapper) to avoid typography conflicts.
 */

.khaime-storefront {
  --khaime-accent: var(--ks-primary, #111827);
  --khaime-accent-ink: #ffffff;
  --khaime-ink: #1f2937;
  --khaime-muted: #6b7280;
  --khaime-hairline: #e5e7eb;
  --khaime-card-bg: #ffffff;
  --khaime-radius-md: 10px;
  --khaime-radius-sm: 6px;

  box-sizing: border-box;
  color: var(--khaime-ink);
  margin: 2rem 0;
}

.khaime-storefront *,
.khaime-storefront *::before,
.khaime-storefront *::after {
  box-sizing: border-box;
}

.khaime-storefront__header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.khaime-storefront__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.khaime-storefront__controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* Currency switcher lives in class-khaime-storefront-floating-switcher.php
 * as a self-contained fixed-position pill (inlined <style> block), so all
 * of its CSS is intentionally out of this stylesheet. */


/* Grid
 *
 * Flexbox instead of grid: with variable product counts a CSS grid either
 * leaves empty tracks (auto-fill) or stretches cards to ocean-width
 * (auto-fit). Flex wraps naturally — cards have a stable basis, sit
 * left-aligned, and the unused row space goes where it belongs (right
 * edge). The `--khaime-columns` attribute caps the max grid width so a
 * 4-product grid on a 1600px monitor doesn't sprawl edge-to-edge.
 */
.khaime-storefront__grid {
  --khaime-card-basis: 260px;
  --khaime-card-gap: 1.5rem;

  display: flex;
  flex-wrap: wrap;
  gap: var(--khaime-card-gap);

  max-width: calc(
    var(--khaime-columns, 4) * var(--khaime-card-basis) +
    (var(--khaime-columns, 4) - 1) * var(--khaime-card-gap) +
    /* Padding so a single row of max-columns cards has room to breathe. */
    var(--khaime-columns, 4) * 24px
  );
}

.khaime-storefront__grid > * {
  flex: 0 1 var(--khaime-card-basis);
  min-width: 0;
}

@media (max-width: 520px) {
  .khaime-storefront__grid > * {
    flex: 0 1 100%;
  }
}

/* Card */
.khaime-card {
  position: relative;
  background: var(--khaime-card-bg);
  border-radius: var(--khaime-radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 220ms ease, transform 220ms ease;
}

.khaime-card:hover {
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
}

.khaime-card__link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.khaime-card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f3f4f6;
  overflow: hidden;
}

.khaime-card__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 320ms ease;
}

.khaime-card:hover .khaime-card__image {
  transform: scale(1.05);
}

.khaime-card__image-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  color: var(--khaime-muted);
  background: #f3f4f6;
}

/* Sale badge */
.khaime-card__badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ef4444;
  color: #fff;
  border-radius: 6px;
  letter-spacing: 0.02em;
  z-index: 1;
}

/* Quick-add — circular "+" button at the bottom-right of the product
 * image. Always visible (works on touch devices, unlike a hover reveal),
 * compact so it doesn't compete with the product photo. Clicking adds
 * to cart; clicking anywhere else on the card navigates to detail.
 *
 * Defensive scoping: host themes aggressively style buttons (brand-colored
 * fills, scalloped pseudo-elements, auto-injected "Add to cart" text via
 * ::before content). Everything critical is !important'd, pseudo-elements
 * are blanked, and `font-size: 0` ensures any pseudo-element text that
 * does leak through renders invisible while the SVG (which ignores
 * font-size) stays the right size. */
.khaime-card__quick-add {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--khaime-accent, #111827);
  color: var(--khaime-accent-ink, #ffffff);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  user-select: none;
  transition: transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 180ms ease,
              opacity 180ms ease;
}
.khaime-card__quick-add:hover,
.khaime-card__quick-add:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  outline: none;
}
.khaime-card__quick-add:active {
  transform: scale(0.94);
}
.khaime-card__quick-add[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
}
.khaime-card__quick-add svg {
  width: 1.125rem;
  height: 1.125rem;
  display: block;
  color: inherit;
  transition: transform 180ms ease, opacity 120ms ease;
}
/* Loading state — JS adds .is-loading + aria-busy. Spin the plus sign so
 * it reads as an inline spinner during the cart-add request. */
.khaime-card__quick-add.is-loading,
.khaime-card__quick-add[aria-busy="true"] {
  opacity: 0.85;
  cursor: progress;
  pointer-events: none;
}
.khaime-card__quick-add.is-loading svg,
.khaime-card__quick-add[aria-busy="true"] svg {
  animation: khaime-card-quick-add-spin 720ms linear infinite;
}
@keyframes khaime-card-quick-add-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.khaime-card__body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.khaime-card__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.khaime-card__description {
  margin: 0;
  font-size: 0.875rem;
  color: var(--khaime-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.khaime-card__price {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.khaime-card__price-now {
  font-weight: 600;
}

.khaime-card__price-was {
  color: var(--khaime-muted);
  text-decoration: line-through;
  font-size: 0.8125rem;
}

/* Empty + error states */
.khaime-storefront__empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--khaime-muted);
  background: #f9fafb;
  border-radius: var(--khaime-radius-md);
}

.khaime-storefront__empty--error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3.5rem 1.5rem;
  background: #fff;
  border: 1px solid var(--khaime-hairline, #e5e7eb);
}

.khaime-storefront__empty-icon {
  color: var(--khaime-muted, #6b7280);
  margin-bottom: 0.25rem;
}

.khaime-storefront__empty-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--khaime-ink, #111827);
}

.khaime-storefront__empty-text {
  margin: 0;
  max-width: 32rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--khaime-muted, #6b7280);
}

.khaime-storefront__empty-btn {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--khaime-accent-ink, #fff);
  background: var(--khaime-accent, #111827);
  border: 1px solid var(--khaime-accent, #111827);
  border-radius: var(--khaime-radius-sm, 8px);
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.khaime-storefront__empty-btn:hover,
.khaime-storefront__empty-btn:focus {
  opacity: 0.9;
  color: var(--khaime-accent-ink, #fff);
  text-decoration: none;
}

.khaime-storefront__empty-debug {
  margin-top: 1.25rem;
  width: 100%;
  max-width: 32rem;
  text-align: left;
  font-size: 0.8125rem;
}

.khaime-storefront__empty-debug summary {
  cursor: pointer;
  color: var(--khaime-muted, #6b7280);
  user-select: none;
}

.khaime-storefront__empty-debug pre {
  margin: 0.5rem 0 0;
  padding: 0.75rem;
  background: #f6f7f7;
  border: 1px solid #dcdcde;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.75rem;
  color: #374151;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Legacy alert box used elsewhere — kept for backwards compatibility,
 * the storefront grid now uses .khaime-storefront__empty--error instead. */
.khaime-storefront-error {
  padding: 1rem 1.25rem;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  color: #991b1b;
  border-radius: var(--khaime-radius-md);
}

/* Pagination */
.khaime-storefront__pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

.khaime-storefront__page-link {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--khaime-hairline);
  border-radius: var(--khaime-radius-sm);
  text-decoration: none;
  color: inherit;
}

.khaime-storefront__page-indicator {
  color: var(--khaime-muted);
  font-size: 0.9375rem;
}

/* ──────────────────────────────────────────────────────────────────
   Product detail page
   ────────────────────────────────────────────────────────────────── */
.khaime-product {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
  color: var(--khaime-ink, #1f2937);
}

.khaime-product__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem;
}

@media (max-width: 720px) {
  .khaime-product__layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.khaime-product__media {
  position: relative;
}
.khaime-product__image {
  aspect-ratio: 1 / 1;
  width: 100%;
  object-fit: cover;
  border-radius: 12px;
  background: #f3f4f6;
}

/* Thumbnail strip — mirrors the customer app's product-image-mobile
   pattern: small pills floating over the bottom of the hero image.
   On desktop we also support a column layout via media query. */
.khaime-product__thumbs {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.khaime-product__thumbs li {
  list-style: none;
  margin: 0;
  padding: 0;
}
.khaime-product__thumbs li::before { content: none; }
.khaime-product__thumb {
  display: inline-block;
  width: 56px;
  height: 56px;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease;
}
.khaime-product__thumb.is-active { border-color: var(--khaime-accent, #111827); }
.khaime-product__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.khaime-product__thumb:focus-visible {
  outline: 2px solid var(--khaime-accent, #111827);
  outline-offset: 2px;
}

/* Placeholder used when the merchant hasn't uploaded an image. Keeps
   the two-column layout balanced instead of leaving a yawning void. */
.khaime-product__image-placeholder {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 12px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
}
.khaime-product__image-placeholder svg {
  width: 25%;
  height: auto;
  max-width: 96px;
}

.khaime-product__title {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.khaime-product__event-meta {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  color: #4b5563;
  font-size: 0.9rem;
}
.khaime-product__event-meta li {
  list-style: none;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.khaime-product__event-meta li::before { content: none; }

.khaime-product__price {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1rem;
}

.khaime-product__price-was {
  color: #6b7280;
  text-decoration: line-through;
  font-size: 1rem;
}

.khaime-product__description {
  color: #374151;
  line-height: 1.6;
  margin-bottom: 2rem;
}
.khaime-product__description--empty {
  color: #9ca3af;
  font-style: italic;
}

/* Variations.
   - color — circular swatches (hex or image); no text under the swatch
   - size — rectangular pills with the label
   - custom — rectangular pills identical to size
   Sub-variations use the same components, scoped under
   .khaime-product__sub-variations so they can be styled as a second row
   without style-leak.
*/
.khaime-product__variations,
.khaime-product__sub-variations {
  margin: 0 0 1.5rem;
}
.khaime-product__sub-variations { margin-top: 1rem; }
.khaime-product__variations-label {
  font-size: 0.85rem;
  color: #4b5563;
  margin-bottom: 0.5rem;
}
.khaime-product__variations-label .khaime-product__variations-current,
.khaime-product__variations-label [data-khaime-sub-variation-current] {
  font-weight: 600;
  color: var(--khaime-accent, #111827);
  margin-left: 0.25rem;
}
.khaime-product__variation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.khaime-product__variation-btn {
  border: 1.5px solid #d1d5db;
  cursor: pointer;
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.khaime-product__variation-btn.is-selected {
  border-color: var(--khaime-accent, #111827);
  box-shadow: 0 0 0 1px var(--khaime-accent, #111827) inset;
}
.khaime-product__variation-btn:focus-visible {
  outline: 2px solid var(--khaime-accent, #111827);
  outline-offset: 2px;
}
.khaime-product__variation-btn.is-sold-out,
.khaime-product__variation-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: line-through;
}

/* color variant — circular; swatch fills it. Image swatches too. */
.khaime-product__variation-btn--color {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
}
.khaime-product__variation-btn--color .khaime-product__variation-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.khaime-product__variation-btn--color .khaime-product__variation-swatch-label {
  /* hidden — the swatch color is the label */
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.khaime-product__variation-btn--color img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* size + custom variant — pill shape with label */
.khaime-product__variation-btn--size,
.khaime-product__variation-btn--custom {
  min-width: 44px;
  height: 44px;
  padding: 0 0.9rem;
}
.khaime-product__variation-btn--size .khaime-product__variation-label,
.khaime-product__variation-btn--custom .khaime-product__variation-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--khaime-accent, #111827);
}

/* Stock / sold-out notice underneath the variations. */
.khaime-product__stock {
  font-size: 0.85rem;
  color: #4b5563;
  margin: 0.5rem 0 0;
}
.khaime-product__stock.is-sold-out {
  color: #b91c1c;
  font-weight: 600;
}
.khaime-product__cta {
  display: inline-block;
  padding: 0.875rem 1.25rem;
  background: var(--khaime-accent, #111827);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: opacity 120ms ease;
}
.khaime-product__cta:hover,
.khaime-product__cta:focus-visible {
  opacity: 0.9;
  outline: none;
}
.khaime-product__cta:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--khaime-accent, #111827) 25%, transparent);
}
.khaime-product__cta[aria-disabled="true"],
.khaime-product__cta[data-sold-out="1"] {
  background: #9ca3af;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.85;
}

/* Tabs section below the hero. Minimal WC-style underline on the active
   tab. Panels toggle via the `hidden` attribute (zero-JS-friendly when
   JS fails to load — only the first panel shows, rest stay collapsed). */
.khaime-product__tabs {
  margin: 3rem 0 2rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 1.5rem;
}
.khaime-product__tab-nav {
  display: flex;
  gap: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.khaime-product__tab {
  display: inline-block;
  padding: 0.65rem 0;
  margin-bottom: -1px;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  user-select: none;
}
.khaime-product__tab:hover {
  color: var(--khaime-accent, #111827);
}
.khaime-product__tab[aria-selected="true"] {
  color: var(--khaime-accent, #111827);
  border-bottom-color: var(--khaime-accent, #111827);
}
.khaime-product__tab:focus-visible {
  outline: 2px solid var(--khaime-accent, #111827);
  outline-offset: 2px;
  border-radius: 2px;
}
.khaime-product__tab-panel {
  color: #374151;
  line-height: 1.6;
}
.khaime-product__tab-empty {
  color: #9ca3af;
  font-style: italic;
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────────
   Cart page + drawer
   ────────────────────────────────────────────────────────────────── */
.khaime-cart {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.khaime-cart__layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 2rem;
}

@media (max-width: 720px) {
  .khaime-cart__layout { grid-template-columns: 1fr; }
}

.khaime-cart__items {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.75rem !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}
.khaime-cart__items > * { margin: 0 !important; }

.khaime-cart__item {
  display: grid !important;
  grid-template-columns: 64px 1fr auto !important;
  gap: 0.875rem !important;
  align-items: center !important;
  padding: 0.875rem !important;
  border: 1px solid var(--khaime-hairline, #e5e7eb) !important;
  border-radius: 10px !important;
  background: #fff !important;
  margin: 0 !important;
  position: relative;
  transition: opacity 150ms ease;
}

.khaime-cart__item[data-updating="true"] {
  opacity: 0.55;
  pointer-events: none;
}

.khaime-cart__item[data-updating="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid #d1d5db;
  border-top-color: var(--khaime-accent, #111827);
  border-radius: 50%;
  animation: khaime-spin 0.7s linear infinite;
}

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

.khaime-cart__item-img {
  width: 64px !important;
  height: 64px !important;
  object-fit: cover !important;
  border-radius: 8px !important;
  background: #f3f4f6;
  margin: 0 !important;
}

.khaime-cart__item-title {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  line-height: 1.35 !important;
  margin: 0 0 0.25rem !important;
  padding: 0 !important;
  color: var(--khaime-ink, #1f2937) !important;
  text-decoration: none !important;
}
.khaime-cart__item-price {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: var(--khaime-ink, #1f2937) !important;
  /* Some themes strike through elements that look like prices or that
   * contain currency symbols — defend explicitly so our regular line
   * price never renders as a sale old-price. */
  text-decoration: none !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin: 0 !important;
  padding: 0 !important;
}
.khaime-cart__item-meta {
  color: var(--khaime-muted, #6b7280) !important;
  font-size: 0.8125rem !important;
  margin: 0 0 0.25rem !important;
  padding: 0 !important;
  line-height: 1.35 !important;
}

.khaime-cart__qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--khaime-hairline, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
  background: #f9fafb;
}
.khaime-cart__qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--khaime-ink, #1f2937);
  cursor: pointer;
  transition: background-color 120ms ease;
  user-select: none;
}
.khaime-cart__qty-btn:hover,
.khaime-cart__qty-btn:focus-visible {
  background: color-mix(in srgb, var(--khaime-ink, #1f2937) 8%, #f9fafb);
  outline: none;
}
.khaime-cart__qty-btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}
.khaime-cart__qty-btn svg {
  width: 0.875rem;
  height: 0.875rem;
  display: block;
  color: inherit;
}
.khaime-cart__qty-value {
  padding: 0 0.75rem;
  min-width: 2ch;
  text-align: center;
  color: var(--khaime-ink, #1f2937);
  background: #fff;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  border-left: 1px solid var(--khaime-hairline, #e5e7eb);
  border-right: 1px solid var(--khaime-hairline, #e5e7eb);
}

.khaime-cart__remove {
  display: inline-block;
  margin-top: 0.5rem;
  color: #991b1b;
  cursor: pointer;
  font-size: 0.875rem;
}
.khaime-cart__remove:hover,
.khaime-cart__remove:focus-visible {
  text-decoration: underline;
  outline: none;
}
.khaime-cart__remove[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.khaime-cart__summary {
  padding: 1.25rem;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  height: fit-content;
}

.khaime-cart__summary-row {
  display: flex !important;
  justify-content: space-between !important;
  align-items: baseline;
  padding: 0.3125rem 0 !important;
  margin: 0 !important;
  font-size: 0.9375rem !important;
  color: var(--khaime-ink, #111827) !important;
  line-height: 1.4 !important;
}
.khaime-cart__summary-row > span {
  margin: 0 !important;
  padding: 0 !important;
}

.khaime-cart__summary-row--total {
  font-weight: 700 !important;
  font-size: 1.0625rem !important;
  border-top: 1px solid var(--khaime-hairline, #e5e7eb) !important;
  margin: 0.5rem 0 0 !important;
  padding: 0.75rem 0 0 !important;
}
.khaime-cart__summary-row--total > span:last-child {
  color: var(--khaime-accent, #111827) !important;
}

.khaime-cart__summary-note {
  margin: 0.5rem 0 0 !important;
  padding: 0 !important;
  font-size: 0.8125rem !important;
  color: var(--khaime-muted, #6b7280) !important;
  line-height: 1.45 !important;
}

/* Drawer CTAs — primary (Proceed) + secondary (View full cart).
 *
 * Both carry `button wp-element-button` classes in the HTML so themes
 * that style those selectors can lend chrome when it makes sense.
 * We !important the properties themes most commonly zero out on
 * buttons (color, font-size, text-indent, opacity) so the label never
 * silently disappears — that's the failure mode we kept hitting. */
.khaime-cart__checkout-btn,
.khaime-drawer__view-cart {
  display: block !important;
  width: 100% !important;
  padding: 0.75rem 1rem !important;
  text-align: center !important;
  text-decoration: none !important;
  font: inherit !important;
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  text-indent: 0 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  visibility: visible !important;
  opacity: 1 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  cursor: pointer;
  appearance: none !important;
  -webkit-appearance: none !important;
  background-image: none !important;
  clip-path: none !important;
  mask: none !important;
  -webkit-mask: none !important;
  transition: opacity 160ms ease, background-color 160ms ease, border-color 160ms ease;
}
.khaime-cart__checkout-btn::before,
.khaime-cart__checkout-btn::after,
.khaime-drawer__view-cart::before,
.khaime-drawer__view-cart::after {
  content: none !important;
  display: none !important;
  background: none !important;
  border: 0 !important;
}

.khaime-cart__checkout-btn {
  margin-top: 1rem;
  background: var(--khaime-accent, #111827) !important;
  color: var(--khaime-accent-ink, #fff) !important;
  border: 1px solid var(--khaime-accent, #111827) !important;
}
.khaime-cart__checkout-btn:hover { opacity: 0.92 !important; }

.khaime-drawer__view-cart {
  margin-top: 0.5rem;
  background: transparent !important;
  color: var(--khaime-accent, #111827) !important;
  border: 1px solid var(--khaime-accent, #111827) !important;
}
.khaime-drawer__view-cart:hover {
  background: var(--khaime-accent, #111827) !important;
  color: var(--khaime-accent-ink, #fff) !important;
}

/* Drawer */
.khaime-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 999998;
}
.khaime-drawer-overlay[data-open="true"] {
  opacity: 1;
  pointer-events: auto;
}
.khaime-drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: min(420px, 100vw);
  background: #fff;
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 260ms cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 999999;
  display: flex;
  flex-direction: column;
}
.khaime-drawer[data-open="true"] { transform: translateX(0); }
.khaime-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
}
.khaime-drawer__title { font-weight: 600; margin: 0; }
.khaime-drawer__close {
  background: none; border: none; cursor: pointer;
  font-size: 1.25rem; line-height: 1;
  color: #6b7280;
}
.khaime-drawer__body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; }
.khaime-drawer__footer {
  border-top: 1px solid #e5e7eb;
  padding: 1rem 1.25rem;
}


/* ----- Checkout page -----
 * Same lockdown philosophy as order-received: the page must read as a
 * Khaime checkout in any WP theme, while still inheriting the merchant's
 * primary colour via `--khaime-accent`. Every structural rule below uses
 * `!important` against the most common theme/page-builder overrides
 * (Elementor's container `display: flex`, Astra's `max-width` clamps,
 * theme `<label>`/`<form>` resets). Typography is pinned with
 * `font: inherit !important` on inputs so the page font keeps coming
 * through the merchant's brand, but weight/size of our own headings are
 * fixed so themes can't blow them up to display sizes. */
.khaime-checkout {
  max-width: 1100px !important;
  margin: 2.5rem auto !important;
  padding: 0 1rem;
  color: var(--khaime-ink, #111827);
  font-family: inherit;
  line-height: 1.55;
}
.khaime-checkout__error {
  background: #fef2f2 !important;
  color: #991b1b !important;
  padding: 0.875rem 1.125rem !important;
  border-radius: 10px !important;
  margin: 0 0 1.25rem !important;
  border: 1px solid #fecaca !important;
  font-size: 0.9375rem !important;
}
.khaime-checkout__layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr) !important;
  gap: 2rem !important;
  align-items: start !important;
  margin: 0 !important;
}
@media (max-width: 860px) {
  .khaime-checkout__layout { grid-template-columns: 1fr !important; }
}
.khaime-checkout__form {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.875rem !important;
  margin: 0 !important;
  padding: 0 !important;
}
.khaime-checkout__form > * { margin: 0; }
/* Checkout typography + section titles.
 *
 * Specificity bumped to `.khaime-checkout .khaime-checkout__*` (0,2,0+) so
 * theme rules like `h2.my-heading` (0,1,1) can't retitle our section
 * headings into giant display type. Same pattern applied to the "Order
 * summary" title which shares its look with the checkout section headings
 * for visual consistency across the two surfaces. */
.khaime-checkout .khaime-checkout__section-title,
.khaime-checkout .khaime-cart__summary-title,
.khaime-cart__summary .khaime-cart__summary-title {
  font-size: 0.9375rem !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  margin: 1.25rem 0 0.5rem !important;
  padding: 0 !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  color: var(--khaime-ink, #111827) !important;
  font-family: inherit !important;
}
.khaime-checkout .khaime-checkout__section-title:first-child,
.khaime-checkout .khaime-cart__summary-title:first-child {
  margin-top: 0 !important;
}

.khaime-checkout .khaime-checkout__row {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 0.75rem !important;
  margin: 0 !important;
}
@media (max-width: 520px) {
  .khaime-checkout .khaime-checkout__row { grid-template-columns: 1fr !important; }
}
.khaime-checkout .khaime-checkout__field {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.3125rem !important;
  font-size: 0.875rem !important;
  margin: 0 !important;
  padding: 0 !important;
}
.khaime-checkout .khaime-checkout__field > span {
  display: block !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  line-height: 1.3 !important;
  color: var(--khaime-muted, #4b5563) !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  margin: 0 !important;
}

/* Inputs/selects — most themes style `input[type="email"]` etc. at (0,1,1);
 * we match + beat by scoping under two classes (0,2,1) and forcing the
 * handful of properties themes actually override: fill, border, text color. */
.khaime-checkout .khaime-checkout__field input,
.khaime-checkout .khaime-checkout__field select {
  padding: 0.625rem 0.75rem !important;
  border: 1px solid var(--khaime-hairline, #d1d5db) !important;
  border-radius: 8px !important;
  font: inherit !important;
  background: #fff !important;
  color: var(--khaime-ink, #1f2937) !important;
  box-shadow: none !important;
  width: 100%;
  line-height: 1.35;
}
.khaime-checkout .khaime-checkout__field input:focus,
.khaime-checkout .khaime-checkout__field select:focus {
  outline: none !important;
  border-color: var(--khaime-accent, #111827) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--khaime-accent, #111827) 15%, transparent) !important;
}
.khaime-checkout .khaime-checkout__field small {
  color: var(--khaime-muted, #6b7280);
  font-size: 0.75rem;
}

/* Pay button — same treatment as the drawer Proceed button: accent fill,
 * enough specificity + !important to beat theme button[type="submit"]
 * rules. `button wp-element-button` classes are added in the template for
 * themes that do style those selectors properly. */
.khaime-checkout .khaime-checkout__submit {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  margin-top: 1.25rem !important;
  padding: 0.9375rem 1rem !important;
  background: var(--khaime-accent, #111827) !important;
  color: var(--khaime-accent-ink, #fff) !important;
  border: 1px solid var(--khaime-accent, #111827) !important;
  border-radius: 10px !important;
  font: inherit !important;
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  text-decoration: none !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  cursor: pointer;
  box-shadow: none !important;
  transition: opacity 160ms ease;
}
.khaime-checkout .khaime-checkout__submit:hover,
.khaime-checkout .khaime-checkout__submit:focus {
  opacity: 0.92;
  color: var(--khaime-accent-ink, #fff) !important;
  text-decoration: none !important;
}
.khaime-checkout .khaime-checkout__submit[disabled] {
  opacity: 0.55 !important;
  cursor: not-allowed !important;
}

.khaime-checkout .khaime-checkout__summary {
  padding: 1.25rem !important;
  border: 1px solid var(--khaime-hairline, #e5e7eb) !important;
  border-radius: 12px !important;
  background: #f9fafb !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.75rem !important;
}
.khaime-checkout .khaime-checkout__summary-note,
.khaime-checkout__summary-note[data-khaime-preview-note] {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.8125rem !important;
  line-height: 1.45 !important;
  color: var(--khaime-muted, #6b7280) !important;
}

/* ----- Stripe order-pay page ----- */
.khaime-order-pay {
  max-width: 520px;
  margin: 2rem auto;
  padding: 2rem;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}
.khaime-order-pay__title { font-size: 1.25rem; margin: 0 0 0.5rem; }
.khaime-order-pay__amount {
  font-size: 1rem; font-weight: 600; color: #111827; margin: 0 0 1.5rem;
}
.khaime-order-pay__element { margin-bottom: 1rem; }
.khaime-order-pay__error { color: #b91c1c; font-size: 0.875rem; margin-bottom: 0.75rem; min-height: 1.25rem; }
.khaime-order-pay__submit {
  width: 100%; padding: 0.875rem 1rem;
  background: var(--khaime-accent, #111827); color: #fff;
  border: none; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.khaime-order-pay__submit:disabled { opacity: 0.6; cursor: wait; }
.khaime-order-pay__submit:hover:not(:disabled) { background: color-mix(in srgb, var(--khaime-accent, #111827) 85%, #000); }

/* ----- Order received page -----
 * Khaime-branded receipt layout. Two design goals:
 *   1. Lock the visual identity so the page reads as "Khaime" regardless
 *      of which WP theme is active (fonts, weights, spacings carry
 *      !important against the theme's <table>/<dl>/<address> defaults).
 *   2. Pick up the merchant's primary colour from the Khaime settings
 *      page via `--khaime-accent`, so the success ring + buttons inherit
 *      the brand without the merchant having to touch CSS.
 * Visual: a hero banner with an iconographic state mark, a card with a
 * receipt-style meta list, items + totals table, billing address, and a
 * pair of CTAs at the bottom.
 */
.khaime-order-received {
  max-width: 720px;
  margin: 2.5rem auto !important;
  padding: 0;
  color: var(--khaime-ink, #111827);
  font-family: inherit;
  line-height: 1.55;
}

/* ----- Banner ----- */
.khaime-order-received__banner {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center;
  gap: 0.75rem;
  padding: 2.25rem 1.5rem !important;
  margin: 0 0 1.5rem !important;
  background: #fff !important;
  border: 1px solid var(--khaime-hairline, #e5e7eb) !important;
  border-radius: 14px !important;
}
.khaime-order-received__banner--paid {
  /* Subtle tint of the merchant's accent colour, mixed with white. The
     fallback (when --khaime-accent isn't set) keeps the original green. */
  background: color-mix(in srgb, var(--khaime-accent, #16a34a) 6%, #fff) !important;
  border-color: color-mix(in srgb, var(--khaime-accent, #16a34a) 25%, #fff) !important;
}
.khaime-order-received__banner--failed {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
}
.khaime-order-received__banner--processing {
  background: #fffbeb !important;
  border-color: #fde68a !important;
}
.khaime-order-received__banner--missing {
  background: #f9fafb !important;
  border-color: #e5e7eb !important;
}
.khaime-order-received__banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--khaime-hairline, #e5e7eb);
}
.khaime-order-received__banner--paid .khaime-order-received__banner-icon {
  color: var(--khaime-accent, #16a34a);
  border-color: color-mix(in srgb, var(--khaime-accent, #16a34a) 35%, #fff);
}
.khaime-order-received__banner--failed .khaime-order-received__banner-icon {
  color: #dc2626;
  border-color: #fecaca;
}
.khaime-order-received__banner--processing .khaime-order-received__banner-icon,
.khaime-order-received__banner--missing .khaime-order-received__banner-icon {
  color: #6b7280;
}
.khaime-order-received__banner-title {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  color: var(--khaime-ink, #111827) !important;
  letter-spacing: -0.01em;
}
.khaime-order-received__banner-sub {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  color: var(--khaime-muted, #6b7280) !important;
  max-width: 32rem;
}
.khaime-order-received__spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 2.5px solid rgba(17, 24, 39, 0.15);
  border-top-color: var(--khaime-accent, #111827);
  border-radius: 50%;
  animation: khaime-order-received-spin 0.8s linear infinite;
}
@keyframes khaime-order-received-spin {
  to { transform: rotate(360deg); }
}

/* ----- Status / help notes ----- */
.khaime-order-received__note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 0.875rem 1.125rem;
  font-size: 0.875rem;
  color: #78350f;
  margin: 0 0 1.25rem;
}
.khaime-order-received__help {
  font-size: 0.9375rem !important;
  color: var(--khaime-muted, #4b5563) !important;
  margin: 0 0 1.25rem !important;
}

/* ----- Receipt-style meta card ----- */
.khaime-order-received__meta {
  margin: 0 0 1.5rem !important;
  padding: 1rem 1.25rem !important;
  background: #fff;
  border: 1px solid var(--khaime-hairline, #e5e7eb);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}
.khaime-order-received__meta-row {
  display: grid !important;
  grid-template-columns: minmax(120px, 1fr) 2fr;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  padding: 0.625rem 0;
  border-top: 1px dashed var(--khaime-hairline, #e5e7eb);
}
.khaime-order-received__meta-row:first-child {
  border-top: 0;
  padding-top: 0.25rem;
}
.khaime-order-received__meta-row dt {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.8125rem !important;
  font-weight: 500 !important;
  color: var(--khaime-muted, #6b7280) !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}
.khaime-order-received__meta-row dd {
  margin: 0 !important;
  padding: 0 !important;
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: var(--khaime-ink, #111827) !important;
  overflow-wrap: anywhere;
  text-align: right;
}
.khaime-order-received__meta-row--total {
  margin-top: 0.25rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--khaime-hairline, #e5e7eb) !important;
}
.khaime-order-received__meta-row--total dt {
  font-weight: 600 !important;
  color: var(--khaime-ink, #111827) !important;
}
.khaime-order-received__meta-row--total dd {
  font-size: 1.0625rem !important;
  color: var(--khaime-accent, #111827) !important;
}
.khaime-order-received__section-title {
  font-size: 1.0625rem !important;
  font-weight: 700 !important;
  margin: 1.75rem 0 0.75rem !important;
  color: var(--khaime-ink, #111827) !important;
  letter-spacing: -0.01em;
}
.khaime-order-received__table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}
.khaime-order-received__table thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
  padding: 0.75rem 0;
}
.khaime-order-received__table thead th.khaime-order-received__col-total {
  text-align: right;
}
.khaime-order-received__table tbody td {
  padding: 0.75rem 0;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}
.khaime-order-received__table tbody td.khaime-order-received__col-total {
  text-align: right;
  white-space: nowrap;
}
.khaime-order-received__item-title { font-weight: 500; }
.khaime-order-received__item-qty { color: #6b7280; }
.khaime-order-received__item-variant {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 0.15rem;
}
.khaime-order-received__table tfoot th {
  text-align: left;
  font-weight: 500;
  padding: 0.5rem 0;
  color: #4b5563;
}
.khaime-order-received__table tfoot td {
  text-align: right;
  padding: 0.5rem 0;
  color: #111827;
  white-space: nowrap;
}
.khaime-order-received__total-row th,
.khaime-order-received__total-row td {
  border-top: 1px solid #e5e7eb;
  padding-top: 0.75rem !important;
  font-weight: 700;
  font-size: 1.05rem;
  color: #111827;
}
.khaime-order-received__item-summary {
  margin: 0 0 1.25rem;
  padding: 0 0 0 1.25rem;
  color: #4b5563;
}
.khaime-order-received__address {
  font-style: normal;
  line-height: 1.5;
  color: #374151;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
}
.khaime-order-received__actions {
  display: flex !important;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.75rem !important;
}
/* Hide actions while we're polling. Showing "Continue shopping" mid-
 * payment makes it look like an abandon affordance. The polling JS
 * flips `data-state` on the root once the status resolves, which
 * reveals the actions row again. */
.khaime-order-received[data-state="processing"] .khaime-order-received__actions {
  display: none !important;
}
/* Force-override theme link styling — many themes paint <a> with
 * `text-decoration: underline` site-wide, which made the buttons look
 * like raw links in the screenshot. We pin every relevant property. */
.khaime-order-received__continue,
.khaime-order-received__retry {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem !important;
  border-radius: 10px !important;
  font-weight: 600 !important;
  font-size: 0.9375rem !important;
  text-decoration: none !important;
  line-height: 1.2 !important;
  transition: opacity 0.15s ease, background 0.15s ease;
  box-shadow: none !important;
}
.khaime-order-received__continue {
  background: var(--khaime-accent, #111827) !important;
  color: var(--khaime-accent-ink, #fff) !important;
  border: 1px solid var(--khaime-accent, #111827) !important;
}
.khaime-order-received__continue:hover,
.khaime-order-received__continue:focus {
  opacity: 0.92;
  color: var(--khaime-accent-ink, #fff) !important;
  text-decoration: none !important;
}
.khaime-order-received__retry {
  background: #fff !important;
  color: var(--khaime-ink, #111827) !important;
  border: 1px solid var(--khaime-hairline, #d1d5db) !important;
}
.khaime-order-received__retry:hover,
.khaime-order-received__retry:focus {
  background: #f9fafb !important;
  text-decoration: none !important;
}

@media (max-width: 480px) {
  .khaime-order-received { margin: 1.25rem auto !important; padding: 0 1rem; }
  .khaime-order-received__banner { padding: 1.75rem 1rem !important; }
  .khaime-order-received__banner-title { font-size: 1.125rem !important; }
  .khaime-order-received__meta-row {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }
  .khaime-order-received__meta-row dd { text-align: left; }
}
