/*
 * Universal checkout stylesheet, contract v1 (UC-1).
 *
 * The ONE platform-owned checkout stylesheet — the same Shopify-style two-column
 * checkout for every shop, lightly branded per shop via CSS custom properties
 * the page shell (universal-checkout.html) sets in an inline <style>:
 *   --brand-primary      — the shop's primary brand color (theme colorScheme)
 *   --brand-primary-text — readable text ON the primary color
 *   --brand-font-heading — heading font stack (theme headingFont)
 *   --brand-font-body    — body font stack (theme bodyFont)
 * Each has a neutral fallback so the page renders fine when a var is absent.
 *
 * Served at /_platform/checkout-v1.css. Framework-free, no build step.
 */

:root {
  --uc-brand: var(--brand-primary, #1a1a1a);
  --uc-brand-text: var(--brand-primary-text, #ffffff);
  --uc-font-heading: var(--brand-font-heading, Georgia, "Times New Roman", serif);
  --uc-font-body: var(--brand-font-body, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);

  --uc-bg: #ffffff;
  --uc-panel: #fafafa;
  --uc-ink: #1f2326;
  --uc-muted: #6b7177;
  --uc-line: #e3e6e8;
  --uc-line-strong: #c9ced2;
  --uc-radius: 10px;
  --uc-danger: #b42318;
  --uc-danger-bg: #fef3f2;
  --uc-max: 1080px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body.uc-checkout {
  background: var(--uc-bg);
  color: var(--uc-ink);
  font-family: var(--uc-font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.uc-checkout h1,
.uc-checkout h2,
.uc-checkout legend,
.uc-checkout .uc-brandmark-text {
  font-family: var(--uc-font-heading);
}

.uc-wrap {
  max-width: var(--uc-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Header / brand bar -------------------------------------------------- */
.uc-topbar {
  border-bottom: 1px solid var(--uc-line);
}
.uc-topbar .uc-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.uc-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.uc-brand-logo {
  height: 40px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  display: block;
}
.uc-brandmark-text {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.uc-secure {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--uc-muted);
}

/* ---- Layout grid --------------------------------------------------------- */
.uc-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 48px;
  align-items: start;
  padding: 36px 0 80px;
}

.uc-main { min-width: 0; }

.uc-page-head { margin: 0 0 22px; }
.uc-page-head h1 {
  margin: 0 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}
.uc-page-head p {
  margin: 0;
  color: var(--uc-muted);
  font-size: 0.95rem;
}

/* ---- Form ---------------------------------------------------------------- */
.uc-fieldset {
  border: 1px solid var(--uc-line);
  border-radius: var(--uc-radius);
  padding: 20px;
  margin: 0 0 18px;
}
.uc-fieldset legend {
  font-size: 1.02rem;
  font-weight: 600;
  padding: 0 6px;
}
.uc-field { margin-bottom: 14px; }
.uc-field:last-child { margin-bottom: 0; }
.uc-field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--uc-ink);
}
.uc-hint-inline {
  color: var(--uc-muted);
  font-weight: 400;
  font-size: 0.8rem;
}
.uc-input {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--uc-ink);
  background: var(--uc-bg);
  border: 1px solid var(--uc-line-strong);
  border-radius: 8px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.uc-input:focus {
  outline: none;
  border-color: var(--uc-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--uc-brand) 18%, transparent);
}
select.uc-input { appearance: none; background-image: none; cursor: pointer; }

.uc-field-row {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}
.uc-field-row.uc-two { grid-template-columns: 1fr 1fr; }
.uc-field-row .uc-field { margin-bottom: 0; }

/* ---- Payment selector (platform/payment snippet) ------------------------- */
.platform-payment-methods {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.pay-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--uc-line-strong);
  border-radius: 8px;
  padding: 13px 14px;
  cursor: pointer;
  font-size: 0.94rem;
}
.pay-option:has(input:checked) {
  border-color: var(--uc-brand);
  box-shadow: 0 0 0 1px var(--uc-brand) inset;
}
.pay-option input { accent-color: var(--uc-brand); }
.platform-pay-mount { margin-top: 14px; }
.platform-pay-mount[hidden] { display: none; }
.platform-payment-empty .pay-empty-note {
  margin: 0;
  color: var(--uc-muted);
  font-size: 0.9rem;
}

/* ---- Buttons ------------------------------------------------------------- */
.uc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--uc-brand-text);
  background: var(--uc-brand);
  border: 1px solid var(--uc-brand);
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.12s ease;
}
.uc-btn:hover { filter: brightness(0.93); }
.uc-btn:disabled { opacity: 0.55; cursor: not-allowed; filter: none; }

.uc-place {
  margin-top: 6px;
}
.uc-foot-hint {
  margin: 10px 0 0;
  font-size: 0.82rem;
  color: var(--uc-muted);
}

/* ---- Inline error -------------------------------------------------------- */
.uc-error {
  margin: 0 0 16px;
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--uc-danger-bg);
  border: 1px solid color-mix(in srgb, var(--uc-danger) 30%, transparent);
  color: var(--uc-danger);
  font-size: 0.9rem;
}
.uc-error[hidden] { display: none; }

/* ---- Order summary (sticky, right column) -------------------------------- */
.uc-summary {
  position: sticky;
  top: 24px;
  background: var(--uc-panel);
  border: 1px solid var(--uc-line);
  border-radius: var(--uc-radius);
  padding: 22px;
}
.uc-summary-head {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 600;
}
#checkout-summary { display: grid; gap: 14px; }
.summary-line {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  gap: 12px;
}
.summary-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1px solid var(--uc-line);
  background-color: #f0f1f2;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}
.summary-thumb.has-no-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, transparent 46%, var(--uc-line-strong) 46%, var(--uc-line-strong) 54%, transparent 54%);
  opacity: 0.5;
  border-radius: 8px;
}
.summary-qty-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--uc-muted);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.summary-line-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.summary-line-title {
  font-size: 0.9rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
.summary-line-variant { font-size: 0.8rem; color: var(--uc-muted); }
.summary-line-price { font-size: 0.9rem; white-space: nowrap; }

.summary-divider {
  height: 1px;
  background: var(--uc-line);
  margin: 18px 0;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.92rem;
  margin-bottom: 8px;
}
.summary-row.total {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 14px 0 0;
}
.summary-note {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--uc-muted);
}
/* UC-3 — minimum-order-value notice (shown when the bag is below the minimum). */
.uc-min-order-notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #8a4b00;
  background: #fff4e5;
  border: 1px solid #ffd9a8;
  border-radius: 8px;
}
.uc-min-order-notice[hidden] { display: none; }
/* UC-4 — marketing-consent opt-in checkbox (below the email field). */
.uc-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--uc-muted);
  cursor: pointer;
}
.uc-consent-input { margin-top: 2px; flex: 0 0 auto; }
.uc-consent[hidden] { display: none; }
.mono { font-variant-numeric: tabular-nums; }

/* ---- Confirmation (post-201, inline) ------------------------------------- */
.order-confirm[hidden] { display: none; }
.oc-hero { text-align: center; margin: 8px 0 24px; }
.oc-check {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--uc-brand);
  color: var(--uc-brand-text);
  font-size: 1.6rem;
  line-height: 56px;
  text-align: center;
}
.oc-hero h1 { margin: 0 0 8px; font-size: 1.5rem; }
.oc-hero p { margin: 0 auto; max-width: 460px; color: var(--uc-muted); font-size: 0.95rem; }
.oc-card {
  border: 1px solid var(--uc-line);
  border-radius: var(--uc-radius);
  padding: 20px;
  margin: 0 0 16px;
}
.oc-card h2 { margin: 0 0 6px; font-size: 1.05rem; }
.oc-card .hint { margin: 0 0 14px; color: var(--uc-muted); font-size: 0.86rem; }
.oc-info { margin: 0; display: grid; gap: 10px; }
.oc-info-row { display: flex; justify-content: space-between; gap: 16px; }
.oc-info-row dt { color: var(--uc-muted); font-size: 0.86rem; margin: 0; }
.oc-info-row dd { margin: 0; font-weight: 500; text-align: right; word-break: break-all; }

/* ---- Payment-return failure pane (payment-return-receipt) ---------------- */
.uc-pay-error {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: var(--uc-radius);
  background: var(--uc-danger-bg);
  border: 1px solid color-mix(in srgb, var(--uc-danger) 35%, transparent);
  color: var(--uc-danger);
}
.uc-pay-error[hidden] { display: none; }
.uc-pay-error-head { display: block; font-size: 1rem; }
.uc-pay-error-body { margin: 4px 0 0; font-size: 0.9rem; }

/* ---- Receipt (post-payment success, payment-return-receipt) -------------- */
.oc-receipt[hidden] { display: none; }
.oc-receipt h2 { margin: 0 0 14px; }
.oc-receipt-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.oc-receipt-item { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.oc-receipt-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.oc-receipt-item-title { font-size: 0.92rem; font-weight: 500; }
.oc-receipt-item-variant { font-size: 0.82rem; color: var(--uc-muted); }
.oc-receipt-item-qty { font-size: 0.82rem; color: var(--uc-muted); }
.oc-receipt-item-total { font-size: 0.9rem; white-space: nowrap; }
.oc-receipt-ship { margin: 18px 0 0; }
.oc-receipt-ship h3 { margin: 0 0 6px; font-size: 0.95rem; }
.oc-receipt-ship-addr { margin: 0; font-size: 0.9rem; color: var(--uc-ink); white-space: pre-line; }
.uc-print { margin-top: 18px; }

/* ---- Print / Save-as-PDF (payment-return-receipt) ------------------------ */
/* Browser print of the rendered receipt → "Save as PDF" (no server PDF). Strip
   all checkout chrome and print ONLY the confirmation/receipt pane, black on
   white. The print button hides itself. */
@media print {
  .uc-topbar,
  .uc-summary,
  [data-checkout-summary-wrap],
  #checkout-form,
  .uc-page-head,
  .uc-print,
  [data-receipt-print] {
    display: none !important;
  }
  html, body.uc-checkout {
    background: #fff !important;
    color: #000 !important;
  }
  .uc-grid { display: block; padding: 0; }
  .order-confirm { display: block !important; }
  .oc-check { background: #000 !important; color: #fff !important; }
  .oc-card { border-color: #999 !important; break-inside: avoid; }
  .uc-btn { display: none !important; }
}

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .uc-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-bottom: 56px;
  }
  /* On mobile the summary sits ABOVE the form (Shopify pattern) and is not
     sticky — order matters: the template marks it order-first via a class. */
  .uc-summary { position: static; order: -1; }
  .uc-field-row.uc-two { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .uc-wrap { padding: 0 16px; }
}
