/* =========================================================
   Boutique do Papel — Portfolio Engine V1.6.1
   Canonical gallery/layout stylesheet.
   Masonry uses metadata-first adaptive sections in assets/js/masonry.js.
   Editorial and Lookbook keep strict administrative order.
   ========================================================= */

/* Shared gallery shell */
.gallery{
  max-width:1440px;
  margin:0 auto;
  padding:0 22px 110px;
}
.gallery-item{
  position:relative;
  min-width:0;
  margin:0;
  background:#fff;
  break-inside:auto;
  column-span:none;
  max-width:none;
}
.gallery-media{
  position:relative;
  width:100%;
  min-width:0;
  overflow:hidden;
  background:#f4f1eb;
}
.gallery-image-button{
  display:block;
  width:100%;
  height:auto;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  cursor:zoom-in;
  overflow:hidden;
  -webkit-appearance:none;
  appearance:none;
  -webkit-tap-highlight-color:transparent;
}
.gallery-image-button img{
  display:block;
  width:100%;
  height:auto;
  max-width:none;
  background:#f4f1eb;
  transition:transform .45s cubic-bezier(.2,.6,.2,1),filter .35s ease;
}
@media(hover:hover){
  .gallery-image-button:hover img{transform:scale(1.008);filter:brightness(.985)}
}

/* Selection action is always anchored to the media box, never to
   the card/grid fragment. This avoids Safari orphaned circles. */
.gallery-media>.select-item{
  position:absolute;
  top:9px;
  right:9px;
  z-index:5;
  display:inline-flex!important;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-width:40px;
  min-height:40px;
  margin:0;
  padding:8px 12px;
  border:1px solid rgba(53,78,60,.14);
  border-radius:999px;
  background:rgba(255,255,255,.94);
  color:#354e3c;
  box-shadow:0 5px 18px rgba(26,40,31,.10);
  backdrop-filter:blur(7px);
  -webkit-backdrop-filter:blur(7px);
  font:inherit;
  font-size:.76rem;
  cursor:pointer;
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  -webkit-appearance:none;
  appearance:none;
  -webkit-tap-highlight-color:transparent;
}
.gallery-media>.select-item.is-selected{
  background:#354e3c;
  color:#fff;
  border-color:#354e3c;
}

/* Copy belongs to card height, therefore the Masonry engine measures it. */
.gallery-copy{
  display:grid;
  gap:10px;
  padding:12px 3px 14px;
  background:#fff;
}
.gallery-copy-main{min-width:0}
.gallery-copy h2{
  margin:0 0 5px;
  font-family:Georgia,"Times New Roman",serif;
  font-size:1.18rem;
  line-height:1.08;
  font-weight:400;
  color:#354e3c;
}
.gallery-copy p{
  margin:0;
  color:#6c746e;
  font-size:.88rem;
  line-height:1.5;
}
.gallery-price{margin-top:1px}
.gallery-price strong,.gallery-price span{display:block}
.gallery-price strong{
  color:#354e3c;
  font-family:Georgia,"Times New Roman",serif;
  font-size:1.08rem;
  line-height:1.15;
  font-weight:400;
}
.gallery-price span{margin-top:2px;color:#907152;font-size:.77rem}

/* =========================================================
   MASONRY V4 — adaptive sectional compositor
   - Compose immediately from metadata; photographs load independently.
   - No absolute positioning and no reactive ResizeObserver loop.
   - featured / wide / automatic landscape are full-width anchors.
   - Later normal/tall items may move before an anchor to balance columns.
   - Normal cards may be promoted to full width when that closes a section.
   - Only an eligible normal card without copy may receive a small thumbnail
     crop as a final fallback. Full media remains intact in the lightbox.
   ========================================================= */
.gallery--masonry{
  --masonry-gap:12px;
  display:block!important;
  columns:auto!important;
  column-gap:0!important;
  min-height:0;
}
/* The real gallery is always visible, including before JS and on failure. */
.gallery--masonry[data-masonry-ready="true"]{visibility:visible}
/* Only disposable text-measurement clones are clipped, never the portfolio. */
.masonry-measure-host{
  position:fixed!important;
  left:0;
  top:0;
  width:0;
  height:0;
  min-height:0;
  padding:0;
  margin:0;
  overflow:hidden;
  visibility:hidden;
  pointer-events:none;
  contain:layout style paint;
}
.gallery--masonry .masonry-section{
  display:grid;
  grid-template-columns:repeat(var(--masonry-columns,2),minmax(0,1fr));
  gap:var(--masonry-gap);
  align-items:start;
  margin:0 0 var(--masonry-gap);
}
.gallery--masonry .masonry-column{
  display:flex;
  flex-direction:column;
  gap:var(--masonry-gap);
  min-width:0;
}
.gallery--masonry .masonry-anchor{
  display:block;
  width:100%;
  margin:0 0 var(--masonry-gap);
}
.gallery--masonry .gallery-item{
  position:relative;
  left:auto;
  top:auto;
  width:100%;
  max-width:none!important;
  margin:0!important;
  grid-column:auto!important;
  grid-row:auto!important;
  break-inside:auto!important;
  column-span:none!important;
  -webkit-column-span:none!important;
}
.gallery--masonry .gallery-media,
.gallery--masonry .gallery-image-button,
.gallery--masonry .gallery-image-button img{
  width:100%;
}
.gallery--masonry .gallery-media{
  height:auto;
  aspect-ratio:var(--masonry-media-ratio,1 / 1);
}
.gallery--masonry .gallery-image-button{
  display:block;
  height:100%;
  max-height:none;
}
.gallery--masonry .gallery-image-button img{
  height:100%;
  max-height:none!important;
  object-fit:contain!important;
  object-position:center;
}
/* Explicit Alta is the only persistent crop ordered by the administrator. */
.gallery--masonry .gallery-item--tall .gallery-media{aspect-ratio:3/4;height:auto}
.gallery--masonry .gallery-item--tall .gallery-image-button,
.gallery--masonry .gallery-item--tall .gallery-image-button img{height:100%}
.gallery--masonry .gallery-item--tall .gallery-image-button img{object-fit:cover!important}
/* Anchors keep the complete photograph and reserve its height before download. */
.gallery--masonry .masonry-anchor .gallery-media{
  height:auto;
  aspect-ratio:var(--masonry-media-ratio,1 / 1);
}
.gallery--masonry .masonry-anchor .gallery-image-button,
.gallery--masonry .masonry-anchor .gallery-image-button img{
  height:100%;
  max-height:none;
  object-fit:contain!important;
}
/* A promoted Normal is intentionally enlarged by the compositor, but not cropped. */
.gallery--masonry .is-masonry-promoted .gallery-image-button img{object-fit:contain!important}
/* Last-resort section filler. It is restricted by JS to Normal/no-copy and a
   small extension, so no commercial text or explicit style is altered. */
.gallery--masonry .gallery-item.is-masonry-filler .gallery-media{
  height:var(--masonry-filler-media-height)!important;
  aspect-ratio:auto!important;
}
.gallery--masonry .gallery-item.is-masonry-filler .gallery-image-button,
.gallery--masonry .gallery-item.is-masonry-filler .gallery-image-button img{height:100%!important}
.gallery--masonry .gallery-item.is-masonry-filler .gallery-image-button img{
  object-fit:cover!important;
  object-position:center!important;
}
.gallery--masonry .gallery-item--featured .gallery-copy{padding-top:15px}
.gallery--masonry .gallery-item--featured .gallery-copy h2{font-size:clamp(1.35rem,2vw,2rem)}

/* =========================================================
   EDITORIAL — strict administrative order.
   ========================================================= */
.gallery--editorial{
  columns:auto!important;
  display:grid!important;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:18px;
  align-items:start;
}
.gallery--editorial .gallery-item{grid-column:span 4;margin:0!important}
.gallery--editorial .gallery-image-button img{width:100%;height:auto;max-height:none;object-fit:contain}
.gallery--editorial .gallery-item--wide{grid-column:span 8}
.gallery--editorial .gallery-item--featured{grid-column:span 8;margin:0!important;max-width:none!important}
.gallery--editorial .gallery-item--tall{grid-column:span 4}
.gallery--editorial .gallery-item--tall .gallery-media{aspect-ratio:3/4}
.gallery--editorial .gallery-item--featured .gallery-media{aspect-ratio:4/3}
.gallery--editorial .gallery-item--tall img,
.gallery--editorial .gallery-item--featured img{width:100%;height:100%;object-fit:cover}
.gallery--editorial .gallery-copy{padding-left:2px;padding-right:2px}

/* =========================================================
   LOOKBOOK — strict administrative order.
   ========================================================= */
.gallery--lookbook{
  columns:auto!important;
  display:grid!important;
  grid-template-columns:1fr;
  gap:68px;
  max-width:1120px;
  padding-left:28px;
  padding-right:28px;
}
.gallery--lookbook .gallery-item{margin:0 auto!important;width:100%}
.gallery--lookbook .gallery-item--normal{max-width:900px}
.gallery--lookbook .gallery-item--featured,
.gallery--lookbook .gallery-item--wide{max-width:1120px}
.gallery--lookbook .gallery-item--tall{max-width:680px}
.gallery--lookbook .gallery-item--tall .gallery-media{aspect-ratio:3/4}
.gallery--lookbook .gallery-item--tall img{width:100%;height:100%;object-fit:cover}

@media(max-width:1100px) and (min-width:761px){
  .gallery--masonry{--masonry-gap:10px}
}

@media(max-width:760px){
  .gallery{padding:0 9px 88px}
  .gallery--masonry{--masonry-gap:8px}
  .gallery-copy{padding:8px 2px 11px;gap:7px}
  .gallery-copy h2{font-size:1rem;margin-bottom:3px}
  .gallery-copy p{font-size:.74rem;line-height:1.42}
  .gallery-price strong{font-size:1rem}
  .gallery-price span{font-size:.7rem}
  .gallery-media>.select-item{
    top:6px;
    right:6px;
    width:36px;
    height:36px;
    min-width:36px;
    min-height:36px;
    padding:0;
    border-radius:50%;
  }
  .gallery-media>.select-item .select-label{display:none}

  .gallery--editorial{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding-left:9px;padding-right:9px}
  .gallery--editorial .gallery-item,
  .gallery--editorial .gallery-item--tall{grid-column:span 1}
  .gallery--editorial .gallery-item--featured,
  .gallery--editorial .gallery-item--wide{grid-column:span 2}

  .gallery--lookbook{gap:34px;padding-left:12px;padding-right:12px}
  .gallery--lookbook .gallery-media>.select-item{
    width:auto;
    height:auto;
    min-width:0;
    min-height:36px;
    padding:8px 10px;
    border-radius:999px;
  }
  .gallery--lookbook .gallery-media>.select-item .select-label{display:inline}
}

/* Progressive fallback only: direct cards remain usable if JS is slow/absent.
   As soon as composition is ready, the SAME V1.6 sections/anchors take over. */
.gallery--masonry[data-gallery]:not([data-masonry-ready="true"]),
.gallery--masonry.masonry-fallback{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:var(--masonry-gap);
  align-items:start;
  visibility:visible;
}
.gallery--masonry[data-gallery]:not([data-masonry-ready="true"])>.gallery-item--featured,
.gallery--masonry[data-gallery]:not([data-masonry-ready="true"])>.gallery-item--wide,
.gallery--masonry.masonry-fallback>.gallery-item--featured,
.gallery--masonry.masonry-fallback>.gallery-item--wide{
  grid-column:1 / -1!important;
}
@media(min-width:1180px){
  .gallery--masonry[data-gallery]:not([data-masonry-ready="true"]),
  .gallery--masonry.masonry-fallback{grid-template-columns:repeat(3,minmax(0,1fr))}
}

/* ===== Fase 9 / V1.0.11 — densidade e resolução desktop ===== */
@media(min-width:1180px){
  .gallery{max-width:1200px;padding-left:14px;padding-right:14px;padding-bottom:78px}
  .gallery--masonry{--masonry-gap:10px}
  .gallery--masonry .masonry-anchor{margin-bottom:14px}
  .gallery--masonry .masonry-anchor .gallery-media{display:flex;justify-content:center;align-items:center;height:auto;max-height:760px;aspect-ratio:auto;background:#f7f5f0}
  .gallery--masonry .masonry-anchor .gallery-image-button{display:grid;place-items:center;width:100%;height:auto;max-height:760px}
  .gallery--masonry .masonry-anchor .gallery-image-button img{display:block;width:auto;max-width:100%;height:auto;max-height:760px!important;object-fit:contain!important;margin:0 auto}
  .gallery--editorial{gap:14px}
  .gallery--lookbook{max-width:1040px;gap:44px;padding-left:14px;padding-right:14px}
  .gallery--lookbook .gallery-item--normal{max-width:820px}
  .gallery--lookbook .gallery-item--featured,.gallery--lookbook .gallery-item--wide{max-width:1040px}
  .gallery--lookbook .gallery-item--tall{max-width:620px}
  .gallery--lookbook .gallery-item--featured .gallery-image-button,.gallery--lookbook .gallery-item--wide .gallery-image-button{display:grid;place-items:center;max-height:760px}
  .gallery--lookbook .gallery-item--featured .gallery-image-button img,.gallery--lookbook .gallery-item--wide .gallery-image-button img{width:auto;max-width:100%;height:auto;max-height:760px;object-fit:contain}
}

/* ===== Fase 9 / V1.0.13 — densidade desktop refinada ===== */
@media(min-width:1180px){
  .gallery--masonry .masonry-anchor .gallery-media,
  .gallery--masonry .masonry-anchor .gallery-image-button{max-height:660px}
  .gallery--masonry .masonry-anchor .gallery-image-button img{max-height:660px!important}
  .gallery--lookbook .gallery-item--featured,.gallery--lookbook .gallery-item--wide{max-width:940px}
  .gallery--lookbook .gallery-item--tall{max-width:500px}
  .gallery--lookbook .gallery-item--featured .gallery-image-button,.gallery--lookbook .gallery-item--wide .gallery-image-button{max-height:660px}
  .gallery--lookbook .gallery-item--featured .gallery-image-button img,.gallery--lookbook .gallery-item--wide .gallery-image-button img{max-height:660px}
}
