/* ════════════════════════════════════════════════════════════════
   onlinesiparisler — v2 · COMMERCE STYLES
   Product detail modal (.pm-…) + checkout overlay (.co-…).
   Reuses draft.css tokens, double-bezel shells, .btn patterns, and the
   cart-drawer scrim/spring-slide language. Namespaced to avoid collisions.
   ════════════════════════════════════════════════════════════════ */

/* ─────────────── shared overlay scaffolding ─────────────── */
.pm-overlay, .co-overlay { position: fixed; inset: 0; z-index: 160; visibility: hidden; }
.pm-overlay.open, .co-overlay.open { visibility: visible; }

.pm-scrim, .co-scrim {
  position: fixed; inset: 0;
  background: rgba(12, 29, 20, 0.5);
  -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
  opacity: 0;
  transition: opacity 0.5s var(--soft-out);
}
.pm-scrim.show, .co-scrim.show { opacity: 1; }

/* centered dialogs — spring up + fade */
.pm-dialog, .co-dialog {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -46%) scale(0.97);
  width: min(940px, calc(100vw - 2.4rem));
  max-height: calc(100dvh - 2.4rem);
  opacity: 0;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-hover);
  transition: opacity 0.5s var(--soft-out), transform 0.6s var(--spring);
}
.co-dialog { width: min(560px, calc(100vw - 2.4rem)); }
.pm-overlay.open .pm-dialog, .co-overlay.open .co-dialog {
  opacity: 1; transform: translate(-50%, -50%) scale(1);
}
.pm-core, .co-core {
  display: flex; flex-direction: column;
  max-height: calc(100dvh - 2.4rem);
  overflow: hidden;
}

/* close button (shared) */
.pm-x, .co-x {
  display: grid; place-items: center; flex: none;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(252, 250, 244, 0.85);
  color: var(--ink);
  transition: transform 0.45s var(--spring), background-color 0.45s var(--spring), color 0.45s var(--spring), border-color 0.45s var(--spring);
}
.pm-x:hover, .co-x:hover { background: var(--ink-deep); color: var(--cream-on-dark); border-color: var(--ink-deep); transform: rotate(90deg); }

/* payment method selector (step 2) */
.co-paymethods { display: flex; flex-direction: column; gap: 0.55rem; margin: 1.1rem 0 0.3rem; }
.co-pm-title {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 0.2rem;
}
.co-pm {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--paper); cursor: pointer;
  transition: border-color 0.4s var(--spring), box-shadow 0.4s var(--spring), background-color 0.4s var(--spring);
}
.co-pm:hover { border-color: var(--line-strong); }
.co-pm:has(input:checked) { border-color: var(--ink-deep); box-shadow: 0 0 0 1px var(--ink-deep); }
.co-pm input { margin-top: 0.2rem; accent-color: var(--leaf); }
.co-pm-body { display: flex; flex-direction: column; gap: 0.1rem; }
.co-pm-body strong { font-size: 0.92rem; font-weight: 600; }
.co-pm-body em { font-style: normal; font-size: 0.76rem; color: var(--ink-soft); }

/* ════════════════════════════════════════════════════════════════
   PRODUCT MODAL
   ════════════════════════════════════════════════════════════════ */
.pm-x { position: absolute; top: 1rem; right: 1rem; z-index: 3; }

.pm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  min-height: 0;
}

/* media column — fills the full height of the (taller) info column so tall
   bottles use all the vertical space instead of floating small in the middle */
.pm-media-wrap {
  position: relative;
  background: radial-gradient(28rem 20rem at 50% 30%, #FFFFFF, var(--porcelain-2));
  display: flex;
  padding: clamp(1.5rem, 3vw, 2.6rem);
  min-height: clamp(380px, 48vh, 560px);
}
.pm-media {
  flex: 1; align-self: stretch; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(0.8rem, 2vw, 1.4rem);
  overflow: hidden;
}
.pm-media img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(17, 39, 28, 0.16));
  transition: transform 0.7s var(--spring);
}
.pm-media:hover img { transform: scale(1.03); }
.pm-media .p-svg { width: 100%; height: 100%; display: block; }
.pm-media .p-svg svg { width: 100%; height: 100%; display: block; }

/* info column */
.pm-info {
  padding: clamp(1.8rem, 3vw, 2.6rem);
  padding-right: clamp(1.8rem, 3vw, 2.6rem);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.pm-tag {
  align-self: flex-start;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase;
  background: rgba(12, 29, 20, 0.82); color: var(--cream-on-dark);
  padding: 0.32rem 0.7rem; border-radius: 999px;
  margin-bottom: 0.3rem;
}
.pm-tag.tag-clay { background: var(--clay); }
.pm-name { font-family: var(--serif); font-weight: 400; font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.05; }
.pm-sub { font-size: 0.86rem; color: var(--ink-soft); letter-spacing: 0.02em; }

.pm-rating { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; margin-top: 0.2rem; }
.pm-stars { display: inline-flex; letter-spacing: 0.04em; }
.pm-stars span { color: var(--line-strong); font-size: 0.95rem; line-height: 1; }
.pm-stars span.on { color: var(--clay); }
.pm-rating b { font-weight: 700; }
.pm-reviews { color: var(--ink-soft); font-weight: 400; }

.pm-price { font-family: var(--serif); font-size: clamp(1.8rem, 3vw, 2.3rem); margin-top: 0.4rem; }
.pm-desc { font-size: 0.96rem; color: var(--ink-soft); line-height: 1.7; margin-top: 0.2rem; }

/* variant picker */
.pm-variants { margin-top: 0.9rem; }
.pm-label, .pm-nutri-head, .co-ship-head {
  display: block;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 0.7rem;
}
.pm-variant-pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pm-pill {
  font-size: 0.82rem; font-weight: 500;
  padding: 0.5rem 1rem; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--ink);
  transition: all 0.4s var(--spring);
}
.pm-pill:hover { border-color: var(--ink); transform: translateY(-1px); }
.pm-pill.selected {
  background: var(--ink-deep); color: var(--cream-on-dark); border-color: var(--ink-deep);
  box-shadow: var(--shadow-soft);
}

/* buy row: stepper + add */
.pm-buy { display: flex; align-items: center; gap: 0.8rem; margin-top: 1.3rem; flex-wrap: wrap; }
.pm-stepper {
  display: inline-flex; align-items: center; gap: 0.2rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 0.25rem;
}
.pm-stepper button {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.1rem; line-height: 1; color: var(--ink);
  transition: background-color 0.3s var(--soft-out);
}
.pm-stepper button:hover { background: var(--porcelain-2); }
.pm-stepper b { font-size: 0.95rem; min-width: 2rem; text-align: center; font-weight: 600; }
.pm-add { flex: 1; min-width: 180px; justify-content: space-between; padding-left: 1.4rem; }

/* nutrition */
.pm-nutri { margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.pm-nutri-table { display: grid; grid-template-columns: 1fr 1fr; gap: 0.1rem 1.4rem; }
.pm-nutri-table > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--line);
}
.pm-nutri-table dt { font-size: 0.84rem; color: var(--ink-soft); }
.pm-nutri-table dd { font-size: 0.88rem; font-weight: 600; text-align: right; }
.pm-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; }
.pm-chips span {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
  color: var(--leaf);
  background: rgba(30, 91, 60, 0.08);
  border: 1px solid rgba(30, 91, 60, 0.16);
  padding: 0.34rem 0.7rem; border-radius: 999px;
}

/* ════════════════════════════════════════════════════════════════
   CHECKOUT OVERLAY
   ════════════════════════════════════════════════════════════════ */
.co-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.5rem 1.6rem 0.6rem;
}
.co-head .eyebrow { margin-bottom: 0.8rem; }
.co-title { font-family: var(--serif); font-weight: 400; font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1; }

/* step indicator */
.co-steps {
  list-style: none; margin: 0; padding: 0.4rem 1.6rem 1rem;
  display: flex; align-items: center; gap: 0.7rem;
}
.co-stepdot { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink-soft); }
.co-stepdot b {
  display: grid; place-items: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%;
  font-size: 0.78rem; font-weight: 700;
  background: var(--porcelain-2); color: var(--ink-soft);
  border: 1px solid var(--line);
  transition: background-color 0.4s var(--spring), color 0.4s var(--spring), border-color 0.4s var(--spring);
}
.co-stepdot span { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; }
.co-stepdot.active b, .co-stepdot.done b { background: var(--ink-deep); color: var(--cream-on-dark); border-color: var(--ink-deep); }
.co-stepdot.active span { color: var(--ink); }
.co-stepline { flex: 1; height: 1px; background: var(--line-strong); }

.co-body { overflow-y: auto; padding: 0.4rem 1.6rem 1.6rem; }

/* form */
.co-form { display: flex; flex-direction: column; gap: 0.95rem; }
.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.co-field { display: flex; flex-direction: column; gap: 0.4rem; }
.co-field label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; color: var(--ink); }
.co-field label i { color: var(--clay); font-style: normal; }
.co-opt, .co-field .co-opt { color: var(--ink-soft); font-weight: 400; }
.co-field input, .co-field textarea {
  font-family: var(--sans); font-size: 0.95rem; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 0.7rem 0.85rem;
  transition: border-color 0.35s var(--soft-out), box-shadow 0.35s var(--soft-out);
  width: 100%;
}
.co-field textarea { resize: vertical; line-height: 1.5; }
.co-field input::placeholder, .co-field textarea::placeholder { color: var(--ink-soft); opacity: 0.7; }
.co-field input:focus-visible, .co-field textarea:focus-visible {
  outline: none; border-color: var(--herbalife); box-shadow: var(--focus);
}
.co-field input[aria-invalid="true"], .co-field textarea[aria-invalid="true"] {
  border-color: var(--clay); box-shadow: 0 0 0 3px rgba(201, 104, 63, 0.16);
}
.co-err { font-size: 0.74rem; color: var(--clay); font-weight: 500; }
.co-next { margin-top: 0.6rem; }

/* review step */
.co-review { display: flex; flex-direction: column; gap: 1rem; }
.co-summary {
  background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.1rem 1.2rem;
}
.co-lines { display: flex; flex-direction: column; gap: 0.7rem; }
.co-li { display: grid; grid-template-columns: 48px 1fr auto; gap: 0.8rem; align-items: center; }
.co-li-img {
  width: 48px; height: 48px; object-fit: contain;
  background: radial-gradient(4rem 3rem at 50% 30%, #fff, var(--porcelain-2));
  border-radius: 0.6rem;
}
.co-li-fallback { display: grid; place-items: center; font-family: var(--serif); font-size: 1.15rem; color: var(--paper); background: var(--pc, #1E5B3C); }
.co-li-info { min-width: 0; }
.co-li-name { font-family: var(--serif); font-size: 1.02rem; line-height: 1.15; }
.co-li-variant { font-size: 0.72rem; color: var(--leaf); font-weight: 600; margin-top: 0.05rem; }
.co-li-qty { font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.1rem; }
.co-li-total { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }

.co-totals { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.4rem; }
.co-totals > div { display: flex; align-items: baseline; justify-content: space-between; }
.co-totals dt { font-size: 0.86rem; color: var(--ink-soft); }
.co-totals dd { font-size: 0.92rem; font-weight: 600; }
.co-est { font-size: 0.68rem; color: var(--ink-soft); font-weight: 500; font-style: italic; }
.co-grand { margin-top: 0.3rem; padding-top: 0.55rem; border-top: 1px solid var(--line); }
.co-grand dt { color: var(--ink); font-weight: 600; }
.co-grand dd { font-family: var(--serif); font-size: 1.5rem; font-weight: 400; }

/* ship-to recap */
.co-ship-to {
  background: rgba(17, 39, 28, 0.03);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0.9rem 1.1rem;
}
.co-ship-to p { font-size: 0.84rem; color: var(--ink-soft); line-height: 1.5; }
.co-ship-to strong { color: var(--ink); font-weight: 600; }
.co-ship-note { margin-top: 0.3rem; font-style: italic; }

/* consent */
.co-consent {
  display: flex; align-items: flex-start; gap: 0.7rem;
  font-size: 0.84rem; line-height: 1.55; color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 0.85rem 1rem;
  cursor: pointer;
}
.co-consent input {
  flex: none; margin-top: 0.15rem;
  width: 1.15rem; height: 1.15rem;
  accent-color: var(--herbalife); cursor: pointer;
}
.co-consent a { color: var(--leaf); border-bottom: 1px solid currentColor; }
.co-consent a:hover { opacity: 0.7; }

/* error banner */
.co-error {
  font-size: 0.85rem; line-height: 1.5; color: var(--clay); font-weight: 500;
  background: rgba(201, 104, 63, 0.08);
  border: 1px solid rgba(201, 104, 63, 0.2); border-radius: var(--r-md);
  padding: 0.75rem 0.95rem;
}

/* pay button + loading state */
.co-pay { justify-content: space-between; padding-left: 1.4rem; }
.co-pay[disabled] { opacity: 0.5; cursor: not-allowed; }
.co-pay.loading { opacity: 0.85; cursor: progress; }
.co-pay.loading .btn-orb {
  animation: co-spin 0.7s linear infinite;
  border: 2px solid rgba(242, 237, 224, 0.3);
  border-top-color: var(--cream-on-dark);
  background: transparent;
}
.co-pay.loading .btn-orb svg { display: none; }
@keyframes co-spin { to { transform: rotate(360deg); } }

.co-back {
  align-self: center;
  font-size: 0.82rem; color: var(--ink-soft); font-weight: 500;
  padding: 0.3rem 0.6rem;
  transition: color 0.3s var(--soft-out);
}
.co-back:hover { color: var(--ink); }
.co-back[disabled] { opacity: 0.4; cursor: not-allowed; }

.co-fallback { font-size: 0.82rem; color: var(--ink-soft); text-align: center; }
.co-fallback a { color: var(--leaf); border-bottom: 1px solid currentColor; }
.co-fallback a:hover { opacity: 0.7; }
.co-fineprint { font-size: 0.72rem; color: var(--ink-soft); text-align: center; line-height: 1.5; opacity: 0.85; }

/* ─────────────── responsive: bottom-sheet under 560px ─────────────── */
@media (max-width: 760px) {
  .pm-dialog { width: min(560px, calc(100vw - 1.6rem)); }
  .pm-grid { grid-template-columns: 1fr; }
  /* stacked: keep the image COMPACT so name/price/variants/add-to-cart are
     visible without scrolling — details below may scroll, the CTA must not */
  .pm-media-wrap { padding: 0.7rem; min-height: 0; justify-content: center; }
  .pm-media { padding: 0.4rem; height: clamp(120px, 19vh, 165px); flex: none; width: 100%; }
  .pm-media img { filter: drop-shadow(0 8px 18px rgba(17, 39, 28, 0.14)); }
  .pm-info { padding: 1rem 1.25rem 1.2rem; }
  .pm-name { font-size: 1.55rem; }
  .pm-price { font-size: 1.6rem; margin-top: 0.25rem; }
  /* long copy can scroll later — clamp it above the fold */
  .pm-desc {
    font-size: 0.9rem; line-height: 1.55;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .pm-variants { margin-top: 0.6rem; }
}

@media (max-width: 560px) {
  /* bottom-sheet like the cart drawer */
  .pm-dialog, .co-dialog {
    left: 0; right: 0; top: auto; bottom: 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(105%);
    transition: transform 0.6s var(--spring);
  }
  .pm-overlay.open .pm-dialog, .co-overlay.open .co-dialog {
    transform: translateY(0);
  }
  .pm-core, .co-core { max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .co-row { grid-template-columns: 1fr; gap: 0.95rem; }
  .pm-buy { flex-direction: column; align-items: stretch; }
  .pm-stepper { align-self: flex-start; }
  .pm-add { width: 100%; }
  .pm-nutri-table { grid-template-columns: 1fr; }
}

/* ─────────────── reduced motion ─────────────── */
@media (prefers-reduced-motion: reduce) {
  .pm-dialog, .co-dialog { transition: opacity 0.01ms; transform: translate(-50%, -50%) scale(1); }
  .pm-overlay.open .pm-dialog, .co-overlay.open .co-dialog { transform: translate(-50%, -50%) scale(1); }
  .co-pay.loading .btn-orb { animation-duration: 0.01ms; }
}
@media (prefers-reduced-motion: reduce) and (max-width: 560px) {
  .pm-dialog, .co-dialog { transform: translateY(0); }
}
