/*
 * HOME-FULL-PRODUCT-MODAL-20 — the full product / pack detail modal shell (partials/v3/full-detail-modal.php,
 * v3-full-detail.js). Only the shell is styled here: the mounted detail is the real product / pack body with its own
 * component stylesheets (v3-c-pdp.css, v3-c-pdp-buy.css, v3-pdp-ingredients.css …), unchanged.
 *
 * Desktop (data-fd-layout="edged", set by the script once the existing 1180px detail container + the shell edges + the
 * detail's own scrollbar + 2 × 12px fit the available width): a centred window around that container, so the detail keeps
 * its 1124px content width; a lower viewport keeps the window and scrolls inside it. Narrower: fullscreen with the dynamic
 * viewport height and the safe areas. The bar sits outside the detail scroller; only the detail scrolls.
 * No transform / filter / contain on the shell: the stacked Ingredients dialog inside the detail stays a viewport overlay.
 */
.fd-modal {
  --fd-container: 1180px;
  --fd-edge: 1px;
  --fd-gap: 12px;
  --fd-gap-y: clamp(12px, 2.6vh, 28px);
  --fd-scrollbar: 0px;
  --fd-bar-h: 60px;
  --fd-line: #e2e7dd;
  /* DG-STOREFRONT-FINISH-CART-21 A1 (Mark): a dark neutral anthracite bar with white controls, recognisable on any detail */
  --fd-bar-bg: linear-gradient(180deg, #323c43 0%, #252d33 100%);
  --fd-bar-ink: #fff;
  --fd-ink: var(--ink, #171d18);
  position: fixed;
  inset: 0;
  z-index: 85; /* above the sticky header (70/71) and the consent bar (80); below drawers (90/95) and dialogs (100+) */
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(20, 25, 21, 0.46);
  color: inherit; /* not the dialog's own CanvasText: the page's ink, as on the ordinary page */
  overflow: hidden;
  overscroll-behavior: contain;
}
.fd-modal:not([open]) {
  display: none;
}
.fd-modal[open] {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  /* DG-STOREFRONT-FINISH-CART-21 B2 (Mark): a calm fade of the whole layer (backdrop + window), opacity only (no transform /
     filter / clip on the shell: the nested Ingredients dialog stays a viewport overlay); in 190ms ease-out, out 150ms ease-in */
  transition: opacity 190ms ease-out;
}
.fd-modal[open].is-entering {
  opacity: 0;
}
.fd-modal[open].is-leaving {
  opacity: 0;
  transition: opacity 150ms ease-in;
}
@media (prefers-reduced-motion: reduce) {
  .fd-modal[open],
  .fd-modal[open].is-leaving {
    transition: none;
  }
}

.fd-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  overflow: hidden;
}
.fd-modal[data-fd-layout="edged"] .fd-shell {
  width: calc(var(--fd-container) + 2 * var(--fd-edge) + var(--fd-scrollbar));
  height: calc(100vh - 2 * var(--fd-gap-y));
  height: calc(100dvh - 2 * var(--fd-gap-y));
  border: var(--fd-edge) solid #d9e0d4;
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(20, 25, 21, 0.24), 0 6px 18px rgba(20, 25, 21, 0.10);
}

/* ---- the bar: back | title | close ---- */
.fd-bar {
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: var(--fd-bar-h);
  padding: 8px 14px;
  background: #252d33;
  background: var(--fd-bar-bg);
  border-bottom: 1px solid #1b2126;
  color: var(--fd-bar-ink);
}
.fd-modal[data-fd-layout="full"] .fd-bar {
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
}
.fd-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--fd-bar-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fd-bar-back {
  padding-left: 10px;
}
.fd-bar-close {
  padding-right: 10px;
}
.fd-bar-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.fd-bar-btn:active {
  background: rgba(255, 255, 255, 0.2);
}
.fd-bar-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.fd-bar-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 22px;
  height: 22px;
}
.fd-bar-ico svg {
  display: block;
  width: 20px;
  height: 20px;
}
.fd-bar-ico--back svg {
  transform: scaleX(-1);
}
.fd-bar-label {
  display: inline-block;
  padding-top: 1px;
}
.fd-bar-title {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--fd-bar-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- the detail scroller (the only vertical scroll while the modal is open) ---- */
.fd-scroller {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  /* the detail's sticky offsets (section navigation, gallery, order summary) start at the top of this scroller */
  --v2-anchor-offset: 14px;
}
.fd-scroller:focus {
  outline: none;
}
.fd-modal[data-fd-layout="full"] .fd-scroller {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.fd-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* loading: a calm placeholder of the hero (no animation) */
.fd-loading[hidden],
.fd-error[hidden] {
  display: none;
}
.fd-skel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 43px;
  padding-top: 32px;
  padding-bottom: 48px;
}
.fd-skel-media {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  background: #f1f3ee;
}
.fd-skel-copy {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
}
.fd-skel-line {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: #eef1ea;
}
.fd-skel-line--title {
  width: 72%;
  height: 30px;
  border-radius: 10px;
}
.fd-skel-line--short {
  width: 46%;
}
.fd-skel-line--block {
  height: 150px;
  margin-top: 12px;
  border-radius: 16px;
}

/* error: calm text and the real page link */
.fd-error-inner {
  max-width: 640px;
  padding-top: 56px;
  padding-bottom: 64px;
  text-align: center;
}
.fd-error-heading {
  margin: 0 0 10px;
  color: var(--fd-ink);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
}
.fd-error-heading:focus {
  outline: none;
}
.fd-error-body {
  margin: 0 0 22px;
  color: #4b564d;
  font-size: 16px;
  line-height: 1.5;
}

/* the mounted detail: the page's own presentation (without its breadcrumb: a calm top space under the bar instead) */
.fd-mount {
  padding-top: 24px;
}
/* only what the page family hook gives the ordinary page is restated */
body.v3-storefront .fd-modal .fd-detail[data-detail-kind="product"] .d-prow-media {
  background-color: #fff;
}

/* phones / narrow: icon-only actions (44 × 44, accessible names unchanged), the title keeps the middle */
@media (max-width: 600px) {
  .fd-modal {
    --fd-bar-h: 56px;
  }
  .fd-bar {
    gap: 6px;
  }
  .fd-bar-btn {
    padding: 0;
    width: 44px;
  }
  .fd-bar-label {
    display: none;
  }
  .fd-bar-title {
    font-size: 14.5px;
  }
  .fd-mount {
    padding-top: 14px;
  }
  .fd-skel {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-top: 16px;
  }
  .fd-skel-media {
    aspect-ratio: 4 / 3;
  }
}
@media (max-width: 720px) {
  /* the pack page hides its "Other Nutrition Packs" band on phones by its page anchor; the fragment's id is prefixed */
  body.v3-storefront .fd-modal .fd-detail[data-detail-kind="pack"] [id$="-pkg-more-packs"] {
    display: none;
  }
}
