/* ==========================================================================
   Brand layer over product photos (includes/media-brand.php, docs/UX-PLAN.md "Branded imagery").
   HTML/CSS only: the photo files stay clean. Uses the theme tokens (mf-child main.css);
   the values after the commas are only fallbacks when the theme is not active.
   Sizes follow the photo frame's own width (container queries), so the same layer works on a
   160px phone card, a 280px desktop card and the 600px product photo. The frames have fixed
   aspect ratios and the layer is absolutely positioned: nothing shifts while it loads.
   ========================================================================== */

/* Frames: cream, like the approved mock-up; the photo is contained inside. */
.mf-bl-on .mf-card__media,
.mf-bl-on .woocommerce-product-gallery__image:has(> .mf-bl--pdp) a > img,
.mf-bl-on .mf-bl-rv {
  background: radial-gradient(120% 90% at 50% 20%, #fff 0%, var(--cream, #fbf6e9) 55%, #efe6cf 100%);
}
.mf-bl-on .mf-card__media { container-type: inline-size; container-name: mf-frame; }
.mf-bl-on ul.products li.product .mf-card__media > img { padding: 17% 7% 19% !important; object-fit: contain !important; }
@container mf-frame (max-width: 299px) { .mf-bl-on ul.products li.product .mf-card__media > img { padding: 16% 4% 18% !important; } }
/* An "Out of stock" chip takes the logo's corner. */
.mf-bl-on ul.products li.product.outofstock .mf-bl__logo { display: none; }
.mf-bl-on .mf-card__media .mf-card__alt { background: transparent; }
.mf-bl-on .mf-card__media:has(.mf-card__alt) .mf-card__alt { background: radial-gradient(120% 90% at 50% 20%, #fff 0%, var(--cream, #fbf6e9) 55%, #efe6cf 100%); }

.woocommerce-product-gallery__image { position: relative; container-type: inline-size; container-name: mf-frame; }
.mf-bl-on .woocommerce-product-gallery__image:has(> .mf-bl--pdp) a > img { padding: 9% 6% 11%; }

/* The layer */
.mf-bl {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  font-family: var(--f-body, system-ui, sans-serif); color: var(--ink, #0e0e10);
  --u: clamp(10px, 1.25cqi + 7.5px, 15px);    /* chip text size */
  --pad: clamp(6px, 3.2cqi, 18px);          /* distance from the frame edge */
  transition: opacity var(--t, 240ms) var(--ease, ease);
}
.mf-bl__chip {
  position: absolute; display: inline-flex; align-items: center; white-space: nowrap;
  min-height: calc(var(--u) * 2); padding: 0 calc(var(--u) * .8);
  border-radius: var(--r-pill, 999px);
  font-size: var(--u); font-weight: 600; line-height: 1;
  background: var(--glass-bg-strong, rgba(251, 246, 233, .84));
  -webkit-backdrop-filter: var(--glass-blur, blur(14px) saturate(160%)); backdrop-filter: var(--glass-blur, blur(14px) saturate(160%));
  box-shadow: var(--glass-edge, inset 0 1px 0 rgba(255, 255, 255, .7), 0 0 0 1px rgba(14, 14, 16, .06)), 0 6px 16px rgba(14, 14, 16, .08);
}
.mf-bl__logo { top: var(--pad); left: var(--pad); padding: 0 calc(var(--u) * .7); height: calc(var(--u) * 2.4); }
.mf-bl__logo img { display: block; width: auto !important; height: calc(var(--u) * 1.5) !important; max-width: none; padding: 0 !important; position: static !important; background: none !important; opacity: 1 !important; }

.mf-bl__foot { position: absolute; left: var(--pad); bottom: var(--pad); right: calc(var(--pad) + var(--seal, 0px) + 6px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.mf-bl__foot .mf-bl__chip { position: static; max-width: 100%; }
.mf-bl__pill { background: rgba(14, 14, 16, .88); color: var(--cream, #fbf6e9); -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: 0 6px 16px rgba(14, 14, 16, .18); overflow: hidden; }
.mf-bl__pill b { color: var(--gold, #c9a23a); font-weight: 700; }
.mf-bl__more { overflow: hidden; text-overflow: ellipsis; }

/* Gallery caption: "Actual phone" / "Representative image" */
.mf-bl__cap {
  display: inline-flex; align-items: center; min-height: calc(var(--u) * 1.9); padding: 0 calc(var(--u) * .75);
  border-radius: var(--r-pill, 999px); background: var(--glass-bg-strong, rgba(251, 246, 233, .84));
  -webkit-backdrop-filter: var(--glass-blur, blur(14px) saturate(160%)); backdrop-filter: var(--glass-blur, blur(14px) saturate(160%));
  box-shadow: var(--glass-edge, inset 0 1px 0 rgba(255, 255, 255, .7), 0 0 0 1px rgba(14, 14, 16, .06));
  font-family: var(--f-body, system-ui, sans-serif); font-size: calc(var(--u) * .86); font-weight: 600; line-height: 1; color: var(--ink, #0e0e10); white-space: nowrap;
}
.mf-bl__cap::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--success, #1f7a4d); }
.mf-bl__cap.is-stock::before { background: var(--steel, #8a8d94); }
.mf-bl--caponly .mf-bl__foot { right: var(--pad); }
/* Credit of a free-licence representative image (author, licence, source): a second, smaller line in the caption. */
.mf-bl__cap.has-credit { flex-wrap: wrap; row-gap: 2px; max-width: 100%; white-space: normal; padding-top: 4px; padding-bottom: 4px; border-radius: calc(var(--u) * .9); }
.mf-bl__credit { flex-basis: 100%; font-size: 10px; font-weight: 400; line-height: 1.35; letter-spacing: 0; text-transform: none; overflow-wrap: anywhere; }
.mf-bl__credit a { color: inherit; text-decoration: underline; pointer-events: auto; }

/* Warranty seal */
.mf-bl { --seal: calc(var(--u) * 5.6); }
.mf-bl__seal {
  position: absolute; right: var(--pad); bottom: var(--pad);
  width: var(--seal); height: var(--seal); border-radius: 50%;
  display: grid; place-content: center; justify-items: center; text-align: center;
  background: var(--cream, #fbf6e9); /* solid, like a stamp: the gold number keeps 4.6:1 */
  box-shadow: 0 0 0 1px rgba(201, 162, 58, .7), inset 0 0 0 calc(var(--u) * .3) rgba(255, 255, 255, .7), 0 6px 16px rgba(14, 14, 16, .1);
}
.mf-bl__n { font-family: var(--f-head, system-ui, sans-serif); font-stretch: 110%; font-weight: 800; font-size: calc(var(--u) * 1.9); line-height: 1; color: var(--gold-ink, #8c6a12); }
.mf-bl__t { width: 9ch; margin-top: 2px; font-family: var(--f-mono, ui-monospace, monospace); font-size: max(8px, calc(var(--u) * .56)); line-height: 1.15; letter-spacing: .06em; text-transform: uppercase; color: var(--graphite, #2a2b2f); }
.mf-bl:not(:has(.mf-bl__seal)) .mf-bl__foot { right: var(--pad); }

/* Narrow frames (2-up phone cards): condition word only, smaller seal. */
@container mf-frame (max-width: 299px) {
  .mf-bl--card .mf-bl__more { display: none; }
  .mf-bl { --seal: calc(var(--u) * 4.6); }
  .mf-bl__t { font-size: 7px; width: 8ch; letter-spacing: .02em; }
}
@container mf-frame (max-width: 199px) {
  .mf-bl { --u: 9px; --pad: 6px; --seal: 46px; }
  .mf-bl__logo img { height: 11px !important; }
  .mf-bl__n { font-size: 16px; }
  .mf-bl__t { font-size: 7px; letter-spacing: 0; }
}
/* Cards: the full pill text only on wide cards. */
@container mf-frame (max-width: 339px) { .mf-bl--card .mf-bl__more { display: none; } }

/* Product page: the layer steps aside while zooming (zoom shows the clean photo). */
@media (hover: hover) {
  .woocommerce-product-gallery__image:hover .mf-bl--pdp { opacity: 0; }
}

/* Recently viewed row (decorated by assets/media-brand.js): minimal layer. */
.mf-bl-rv { position: relative; display: block; container-type: inline-size; container-name: mf-frame; border-radius: var(--r-sm, 12px); overflow: hidden; }
.mf-bl-rv img { display: block; background: transparent !important; padding: 18% 8% 20%; }
.mf-bl--rv { --u: 9px; --pad: 5px; --seal: 34px; }
.mf-bl--rv .mf-bl__logo { display: none; }
.mf-bl--rv .mf-bl__n { font-size: 13px; }
.mf-bl--rv .mf-bl__t { display: none; }

/* Glass fallbacks: no blur support, reduced transparency, low-end devices -> solid cream. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mf-bl__chip:not(.mf-bl__pill), .mf-bl__cap { background: var(--glass-solid, rgba(251, 246, 233, .96)); }
}
@media (prefers-reduced-transparency: reduce) {
  .mf-bl__chip:not(.mf-bl__pill), .mf-bl__cap { background: var(--glass-solid, rgba(251, 246, 233, .96)); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .mf-bl__pill { background: var(--ink, #0e0e10); }
}
html.mf-lowfx .mf-bl__chip:not(.mf-bl__pill), html.mf-lowfx .mf-bl__cap { background: var(--glass-solid, rgba(251, 246, 233, .96)); -webkit-backdrop-filter: none; backdrop-filter: none; }
html.mf-lowfx .mf-bl__pill { background: var(--ink, #0e0e10); }

@media (prefers-reduced-motion: reduce) { .mf-bl { transition: none; } }
@media print { .mf-bl { display: none; } }
