/*
 * MediBloom store integration.
 *
 * Store-wide pieces the design never had: helpers the storefront views share,
 * the cart-link bump, the product page's JS-driven widgets, CMS output and the
 * iOS focus-zoom guard. Cart, checkout and thank-you live in commerce.css.
 * Tokens come from base.css; the aliases below keep the product page widgets
 * (written against the previous theme's names) on the MediBloom palette.
 */

:root {
  --mb-ink-2: var(--mb-night);
  --mb-ink-3: var(--mb-deep);
  --mb-text-2: var(--mb-grey);
  --mb-surface: #f7f5f2;
  --mb-chip: #e6e1da;
  --mb-line: #e6e1da;
  --mb-line-2: #e6e1da;
  --mb-line-strong: #cfc8be;
  --mb-pill: 999px;
  --mb-tap: 44px;
  --mb-ease: cubic-bezier(.2, .7, .2, 1);
  --mb-font-ui: var(--mb-font);
  --mb-mist: var(--mb-soft);
  --mb-on-dark: var(--mb-white);
}

/* ------------------------------------------------------------------ helpers */

.mb-alert { margin: 0; padding: 12px 16px; border-radius: var(--mb-radius); font-size: 14px; line-height: 1.4; }
.mb-alert[hidden] { display: none; }
.mb-alert--bad { background: #fdecea; color: var(--mb-danger); }
.mb-alert--ok { background: #e8f2ea; color: var(--mb-success); }

.mb-field-note { margin: 0; font-size: 12px; line-height: 1.4; color: var(--mb-muted); }

.mb-page-crumbs { margin-bottom: 16px; }
.mb-crumbs [aria-current="page"] { color: var(--mb-text); }

/* Category chips on the catalog are links to /shop/{slug}; the current one
   carries aria-current rather than aria-pressed. */
.mb-chip { text-decoration: none; }
.mb-chip[aria-current="page"] { color: var(--mb-text); font-weight: 700; border-bottom-color: var(--mb-text); }

.mb-products-count { margin: 0; font-size: 14px; color: var(--mb-muted); }
.mb-products-empty[hidden] { display: none; }

/* ------------------------------------------------------------------ cart link bump */
/* theme.js bumps the header's cart link when an item is added. */
@keyframes mb-bag-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  70% { transform: scale(.97); }
  100% { transform: scale(1); }
}
.is-bumping { animation: mb-bag-bump .5s var(--mb-ease); }
.is-bumping .mb-cart-count { animation: mb-bag-bump .5s var(--mb-ease) .06s; }
@media (prefers-reduced-motion: reduce) {
  .is-bumping, .is-bumping .mb-cart-count { animation: none; }
}

/* ------------------------------------------------------------------ product page */

.mb-pd-legend {
  float: none;
  width: auto;
  margin: 0 0 4px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--mb-muted);
}
.mb-pd-lede > :last-child { margin-bottom: 0; }
.mb-pd-lede p { margin: 0 0 12px; }
.mb-plan-badge[hidden] { display: none; }

/* Subscribe & Save switch: one row shaped like the option cards above it,
   the offer on the left and the toggle pinned right. The whole row is the
   label, so a tap anywhere flips it. */
.mb-subscribe {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 16px;
  border: 1px solid var(--mb-line-strong);
  border-radius: 12px;
  background: var(--mb-white);
  cursor: pointer;
  transition: border-color .2s var(--mb-ease), box-shadow .2s var(--mb-ease);
}
.mb-subscribe:hover { border-color: var(--mb-text); }
.mb-subscribe:has(.mb-subscribe__input:checked) { border-color: var(--mb-ink-2); box-shadow: inset 0 0 0 1px var(--mb-ink-2); }
.mb-subscribe__input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.mb-switch {
  flex: none;
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 28px;
  padding: 3px;
  border-radius: var(--mb-pill);
  background: var(--mb-line-strong);
  transition: background-color .2s var(--mb-ease);
}
.mb-switch__thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mb-white);
  box-shadow: 0 1px 2px rgba(22, 22, 22, .2);
  transition: transform .2s var(--mb-ease);
}
.mb-subscribe:has(.mb-subscribe__input:checked) .mb-switch { background: var(--mb-ink-2); }
.mb-subscribe:has(.mb-subscribe__input:checked) .mb-switch__thumb { transform: translateX(20px); }
.mb-subscribe:has(.mb-subscribe__input:focus-visible) { outline: 2px solid var(--mb-ink-2); outline-offset: 3px; }
.mb-subscribe:has(.mb-subscribe__input:disabled) { cursor: not-allowed; }

/* The stepper cart.js reads: buttons with data-act and a .qty-value span. */
.mb-qty-value {
  min-width: var(--mb-tap);
  text-align: center;
  font: 600 16px/1 var(--mb-font-ui);
  color: var(--mb-ink-2);
}

.mb-pd-prose ul, .mb-pd-prose ol { padding-left: 18px; font-size: 14px; line-height: 1.6; color: var(--mb-text-2); }

.mb-pd-main img[role="button"]:focus-visible { outline-offset: -4px; }

/* Photo lightbox (theme.js). */
body.mb-lightbox-open { overflow: hidden; }
.mb-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mb-lightbox[hidden] { display: none; }
.mb-lightbox__backdrop { position: absolute; inset: 0; background: rgba(22, 22, 22, .92); }
.mb-lightbox__stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 72px 24px;
  /* The stage handles pinch and drag itself, so the browser must not also
     scroll or zoom the page under it. */
  touch-action: none;
}
.mb-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  transform-origin: center center;
  transition: transform .18s ease-out;
  user-select: none;
  -webkit-user-drag: none;
}
.mb-lightbox__img.is-zoomed { cursor: grab; transition: none; }
.mb-lightbox__img.is-zoomed:active { cursor: grabbing; }
.mb-lightbox__close,
.mb-lightbox__nav,
.mb-lightbox__zoom {
  appearance: none;
  border: 0;
  border-radius: var(--mb-pill);
  background: rgba(255, 255, 255, .12);
  color: var(--mb-white);
  line-height: 1;
  cursor: pointer;
}
.mb-lightbox__close:hover,
.mb-lightbox__nav:hover,
.mb-lightbox__zoom:hover { background: rgba(255, 255, 255, .24); }
.mb-lightbox__close { position: absolute; top: 20px; right: 24px; z-index: 2; width: var(--mb-tap); height: var(--mb-tap); font-size: 28px; }
.mb-lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 48px; height: 48px; font-size: 30px; }
.mb-lightbox__nav--prev { left: 24px; }
.mb-lightbox__nav--next { right: 24px; }
.mb-lightbox__nav[hidden] { display: none; }
.mb-lightbox__toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: var(--mb-pill);
  background: rgba(255, 255, 255, .12);
}
.mb-lightbox__zoom { width: 34px; height: 34px; background: transparent; font-size: 20px; }
.mb-lightbox__level { min-width: 56px; text-align: center; font-size: 13px; color: var(--mb-white); }
.mb-lightbox__counter { position: absolute; top: 26px; left: 24px; z-index: 2; margin: 0; font-size: 14px; color: rgba(255, 255, 255, .72); }
.mb-lightbox__counter[hidden] { display: none; }
@media (max-width: 767.98px) {
  .mb-lightbox__stage { padding: 64px 12px; }
  .mb-lightbox__nav--prev { left: 8px; }
  .mb-lightbox__nav--next { right: 8px; }
}


/* ------------------------------------------------------------------ CMS page builder output */

.cms-page__body > .pb-store-block + .pb-store-block { margin-top: 0; }

/* ------------------------------------------------------------------ iOS focus zoom
   Safari on iPhone zooms the page into any field whose text is under 16px
   when it takes focus; on iOS only (-webkit-touch-callout exists nowhere
   else) fields are raised to 16px. */
@supports (-webkit-touch-callout: none) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}
