/* ==========================================================================
   APF_MOSAICO_UNICO_V10_LAB — CANDIDATA 2026-11-01 (non pubblicata)
   Un solo criterio di mosaico per: feed centrale (#feed), pagine locali
   (.apf-v3-shop-view), card community (stesso markup) e pagine personali
   (.apf-customer-post-media).
   - Disposizione determinata SOLO dal numero di foto, in CSS (:has), quindi
     identica al primo disegno, a cache fredda o calda, e non dipende dai download.
   - Anteprime con object-fit:cover (celle piene); il viewer completo non e' toccato.
   - Una foto sola: V10 riserva un riquadro quadrato stabile, con cover.
   - Da caricare DOPO feed-armonia.css e dopo lo <style id="apf-four-compact-v8">.
   Rapporti (larghezza/altezza del riquadro):
     2 foto 1.5  (ipotesi, nessun riferimento Facebook fornito)
     3 foto 1    (misurato dall'esempio 05: 706x704)
     4 foto 1    (2x2, caso base da confrontare; nessun esempio fornito)
     5+ foto 1.2 (misurato dagli esempi 01/02: 706x587)
   ========================================================================== */

/* ---- FEED + PAGINE LOCALI + CARD COMMUNITY: base comune per 2+ foto ---- */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)){--apf-mosaic-maxh:min(80dvh,720px);display:grid!important;gap:2px!important;padding:0!important;margin-inline:auto!important;width:min(100%,680px,calc(var(--apf-mosaic-maxh) * var(--apf-mosaic-ratio,1)))!important;height:auto!important;max-height:var(--apf-mosaic-maxh)!important;aspect-ratio:var(--apf-mosaic-ratio,1)!important;min-width:0!important;min-height:0!important;overflow:hidden!important;background:#e3e8ef!important;border-radius:0!important;grid-auto-rows:minmax(0,1fr)!important;}
@media(max-width:767px){html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)){--apf-mosaic-maxh:min(70dvh,600px);}}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)) > button{display:block!important;position:relative!important;min-width:0!important;min-height:0!important;width:100%!important;height:100%!important;max-height:none!important;aspect-ratio:auto!important;padding:0!important;margin:0!important;border:0!important;border-radius:0!important;overflow:hidden!important;background:#d5dce7!important;grid-row:auto!important;grid-column:auto!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)) > button > img{position:absolute!important;inset:0!important;display:block!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;object-fit:cover!important;object-position:center!important;border-radius:0!important;background:transparent!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)) > button:nth-child(n+6){display:none!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)) > button:focus-visible{outline:3px solid #1768e5!important;outline-offset:-3px!important;}
/* ---- FEED + PAGINE LOCALI + CARD COMMUNITY: 2 foto, affiancate ---- */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(2)):not(:has(>button:nth-child(3))){--apf-mosaic-ratio:1.5;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-template-rows:minmax(0,1fr)!important;}
/* ---- FEED + PAGINE LOCALI + CARD COMMUNITY: 3 foto, una grande a sinistra e due a destra ---- */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))){--apf-mosaic-ratio:1;grid-template-columns:minmax(0,2fr) minmax(0,1fr)!important;grid-template-rows:repeat(2,minmax(0,1fr))!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(1){grid-column:1!important;grid-row:1 / 3!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(2){grid-column:2!important;grid-row:1!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(3){grid-column:2!important;grid-row:2!important;}
/* ---- FEED + PAGINE LOCALI + CARD COMMUNITY: 4 foto, 2x2 ---- */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(4)):not(:has(>button:nth-child(5))){--apf-mosaic-ratio:1;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-template-rows:repeat(2,minmax(0,1fr))!important;}
/* ---- FEED + PAGINE LOCALI + CARD COMMUNITY: 5 o piu' foto, due sopra e tre sotto (la quinta porta il +N) ---- */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)){--apf-mosaic-ratio:1.2;grid-template-columns:repeat(6,minmax(0,1fr))!important;grid-template-rows:minmax(0,3fr) minmax(0,2fr)!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)) > button:nth-child(1){grid-column:1 / 4!important;grid-row:1!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)) > button:nth-child(2){grid-column:4 / 7!important;grid-row:1!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)) > button:nth-child(3){grid-column:1 / 3!important;grid-row:2!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)) > button:nth-child(4){grid-column:3 / 5!important;grid-row:2!important;}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button:nth-child(5)) > button:nth-child(5){grid-column:5 / 7!important;grid-row:2!important;}

/* ---- PAGINE PERSONALI (max 4 foto): base comune per 2+ foto ---- */
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)){--apf-mosaic-maxh:min(80dvh,720px);display:grid!important;gap:2px!important;padding:0!important;margin-inline:auto!important;width:min(100%,680px,calc(var(--apf-mosaic-maxh) * var(--apf-mosaic-ratio,1)))!important;height:auto!important;max-height:var(--apf-mosaic-maxh)!important;aspect-ratio:var(--apf-mosaic-ratio,1)!important;min-width:0!important;min-height:0!important;overflow:hidden!important;background:#e3e8ef!important;border-radius:0!important;grid-auto-rows:minmax(0,1fr)!important;}
@media(max-width:767px){html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)){--apf-mosaic-maxh:min(70dvh,600px);}}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)) > button{display:block!important;position:relative!important;min-width:0!important;min-height:0!important;width:100%!important;height:100%!important;max-height:none!important;aspect-ratio:auto!important;padding:0!important;margin:0!important;border:0!important;border-radius:0!important;overflow:hidden!important;background:#d5dce7!important;grid-row:auto!important;grid-column:auto!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)) > button > img{position:absolute!important;inset:0!important;display:block!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;object-fit:cover!important;object-position:center!important;border-radius:0!important;background:transparent!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)) > button:nth-child(n+6){display:none!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)) > button:focus-visible{outline:3px solid #1768e5!important;outline-offset:-3px!important;}
/* ---- PAGINE PERSONALI (max 4 foto): 2 foto, affiancate ---- */
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(2)):not(:has(>button:nth-child(3))){--apf-mosaic-ratio:1.5;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-template-rows:minmax(0,1fr)!important;}
/* ---- PAGINE PERSONALI (max 4 foto): 3 foto, una grande a sinistra e due a destra ---- */
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))){--apf-mosaic-ratio:1;grid-template-columns:minmax(0,2fr) minmax(0,1fr)!important;grid-template-rows:repeat(2,minmax(0,1fr))!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(1){grid-column:1!important;grid-row:1 / 3!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(2){grid-column:2!important;grid-row:1!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(3)):not(:has(>button:nth-child(4))) > button:nth-child(3){grid-column:2!important;grid-row:2!important;}
/* ---- PAGINE PERSONALI (max 4 foto): 4 foto, 2x2 ---- */
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(4)):not(:has(>button:nth-child(5))){--apf-mosaic-ratio:1;grid-template-columns:repeat(2,minmax(0,1fr))!important;grid-template-rows:repeat(2,minmax(0,1fr))!important;}
/* ---- PAGINE PERSONALI (max 4 foto): 5 o piu' foto, due sopra e tre sotto (la quinta porta il +N) ---- */
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)){--apf-mosaic-ratio:1.2;grid-template-columns:repeat(6,minmax(0,1fr))!important;grid-template-rows:minmax(0,3fr) minmax(0,2fr)!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)) > button:nth-child(1){grid-column:1 / 4!important;grid-row:1!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)) > button:nth-child(2){grid-column:4 / 7!important;grid-row:1!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)) > button:nth-child(3){grid-column:1 / 3!important;grid-row:2!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)) > button:nth-child(4){grid-column:3 / 5!important;grid-row:2!important;}
html body .apf-customer-post-media.apf-customer-post-media:has(>button:nth-child(5)) > button:nth-child(5){grid-column:5 / 7!important;grid-row:2!important;}

/* ---- Indicatore +N: la regola esistente in feed-armonia.css (button[data-apf-gallery-more]::after)
   resta valida; qui si garantisce solo che sia sopra l'immagine posizionata in assoluto. ---- */
.business-post-media > button[data-apf-gallery-more]::after{z-index:2;}

/* V10: one photograph, same deterministic preview in all four contexts.
   A square fallback is a deliberate LAB choice, NOT a measured Facebook rule.
   Only image buttons; do not match video, stories, or the post viewer stage. */
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button > img):not(:has(>button:nth-child(2))),
html body .apf-customer-post-media.apf-customer-post-media:has(>button > img):not(:has(>button:nth-child(2))){
 --apf-mosaic-maxh:min(80dvh,720px);--apf-mosaic-ratio:1;
 display:grid!important;grid-template-columns:minmax(0,1fr)!important;grid-template-rows:minmax(0,1fr)!important;
 width:min(100%,680px,var(--apf-mosaic-maxh))!important;height:auto!important;
 aspect-ratio:1!important;max-height:none!important;min-height:0!important;min-width:0!important;
 padding:0!important;margin-inline:auto!important;gap:0!important;overflow:hidden!important;
}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button > img):not(:has(>button:nth-child(2))) > button,
html body .apf-customer-post-media.apf-customer-post-media:has(>button > img):not(:has(>button:nth-child(2))) > button{
 display:block!important;position:relative!important;width:100%!important;height:100%!important;min-height:0!important;min-width:0!important;
 grid-row:1!important;grid-column:1!important;padding:0!important;margin:0!important;border:0!important;border-radius:0!important;overflow:hidden!important;
}
html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button > img):not(:has(>button:nth-child(2))) > button > img,
html body .apf-customer-post-media.apf-customer-post-media:has(>button > img):not(:has(>button:nth-child(2))) > button > img{
 position:absolute!important;inset:0!important;width:100%!important;height:100%!important;max-height:none!important;max-width:none!important;
 object-fit:cover!important;object-position:center!important;display:block!important;border-radius:0!important;
}
@media(max-width:767px){
 html body.apf-feed-armonia :is(#feed,.apf-v3-shop-view) .business-feed-card.business-feed-card:not(.apf-business-kind-story) > .business-post-media.business-post-media:has(>button > img):not(:has(>button:nth-child(2))),
 html body .apf-customer-post-media.apf-customer-post-media:has(>button > img):not(:has(>button:nth-child(2))){--apf-mosaic-maxh:min(70dvh,600px);}
}
/* V10: close remains above the scrolling post and image (including zoom).
   Preserve overlay > shell > existing content. No nested scroll rewrite. */
html body .social-post-dialog.apf-complete-post > .social-post-dialog-close{
 position:absolute!important;float:none!important;
 top:max(8px,env(safe-area-inset-top))!important;right:max(8px,env(safe-area-inset-right))!important;
 width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important;
 margin:0!important;padding:0!important;z-index:100!important;display:grid!important;place-items:center!important;
 visibility:visible!important;opacity:1!important;pointer-events:auto!important;
 background:#fff!important;color:#152033!important;border:1px solid #cbd5e1!important;border-radius:50%!important;
 box-shadow:0 2px 10px #0004!important;font-size:28px!important;line-height:1!important;
}
html body .social-post-dialog.apf-complete-post > .social-post-dialog-close:focus-visible{outline:3px solid #1768e5!important;outline-offset:2px!important;}
html body .social-photo-viewer > button[aria-label="Chiudi"]{z-index:5;top:max(8px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));}
