/* Gallery module — a masonry wall of full-shape photos (no cropping, no stretching) and a
   full-screen album viewer you swipe through, with a physical photo-album page-turn. */

/* ---- The wall: photos keep their own shape, packed into columns (masonry). ---- */
.gallery-grid { list-style: none; margin: 0; padding: 0; column-count: 3; column-gap: 14px; }
.gallery-item {
  display: block; break-inside: avoid; margin: 0 0 14px; position: relative;
  border-radius: var(--radius); overflow: hidden; background: var(--surface);
  cursor: zoom-in; -webkit-tap-highlight-color: transparent;
}
.gallery-item img { width: 100%; height: auto; display: block; object-fit: contain; transition: transform 0.45s ease; }
.gallery-item:hover img, .gallery-item:focus-visible img { transform: scale(1.03); }
.gallery-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* A video item gets a play badge over its poster frame. */
.gallery-item.is-video::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 999px; background: rgba(12, 15, 20, 0.62) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='white'/%3E%3C/svg%3E") center/26px no-repeat;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35); pointer-events: none;
}
@media (max-width: 1100px) { .gallery-grid { column-count: 2; } }
@media (max-width: 560px) { .gallery-grid { column-count: 1; } }

/* ---- An even grid (a "photo-mix" from the site editor's albums): full rows at every width,
   3 across then 2 across. Tiles are 3:2, so a landscape photo fills its tile exactly and a portrait
   one sits whole on the tile — nothing is cropped. */
.gallery-grid--even { column-count: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.gallery-grid--even .gallery-item { margin: 0; aspect-ratio: 3 / 2; }
.gallery-grid--even .gallery-item picture { display: block; width: 100%; height: 100%; }
.gallery-grid--even .gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-grid--even .gallery-item.is-portrait img { object-fit: contain; }
@media (max-width: 760px) { .gallery-grid--even { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }

/* Album sections: a heading above its own grid of photos. */
.gallery-album { font-family: var(--font-head, inherit); font-weight: var(--head-weight, 700); font-size: clamp(1.3rem, 1rem + 1.1vw, 2rem); margin: clamp(30px, 4vw, 48px) 0 clamp(12px, 1.6vw, 18px); line-height: 1.1; }
.gallery-album:first-of-type { margin-top: 0; }

/* Album covers: a stacked "pile of photos" you click to open the album in the viewer.
   With JS, gallery.js hides the full grids (.album-photos) and the stacks open the viewer; without
   JS the stacks are jump-links to the grids below, which stay visible so every photo is reachable. */
.album-stacks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: clamp(26px, 4vw, 48px); }
.album-stack { appearance: none; -webkit-appearance: none; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; text-align: left; color: inherit; text-decoration: none; font: inherit; display: flex; flex-direction: column; gap: 14px; -webkit-tap-highlight-color: transparent; }
.album-stack__pile { position: relative; aspect-ratio: 4 / 3; margin-bottom: 4px; }
.album-stack__pile::before, .album-stack__pile::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,0.16); transition: transform 0.35s ease; }
.album-stack__pile::before { transform: rotate(-3.5deg) translateY(3px); }
.album-stack__pile::after { transform: rotate(2.5deg) translateY(2px); }
.album-stack__pile > picture, .album-stack__pile > img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
.album-stack__pile img { position: relative; display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,0.28); transition: transform 0.35s ease; }
.album-stack:hover .album-stack__pile img, .album-stack:focus-visible .album-stack__pile img { transform: translateY(-4px); }
.album-stack:hover .album-stack__pile::before { transform: rotate(-5deg) translateY(5px); }
.album-stack:hover .album-stack__pile::after { transform: rotate(4deg) translateY(4px); }
.album-stack:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.album-stack__meta { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.album-stack__name { font-family: var(--font-head, inherit); font-weight: var(--head-weight, 700); font-size: clamp(1.2rem, 1rem + 0.7vw, 1.6rem); line-height: 1.1; }
.album-stack__count { color: var(--text-soft, #667); font-size: 0.9rem; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .album-stack__pile::before, .album-stack__pile::after, .album-stack__pile img { transition: none; } }

/* ---- The album viewer (a full-screen <dialog>). ---- */
.lightbox { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; padding: 0; margin: 0; border: 0; background: transparent; color: #fff; overflow: hidden; }
.lightbox::backdrop { background: rgba(8, 10, 14, 0.94); }
.lightbox-figure { margin: 0; height: 100vh; display: grid; grid-template-rows: 1fr auto; }

/* The stage holds two "leaves" (the current page and the one underneath it) in 3D. */
.album-stage { position: relative; min-height: 0; perspective: 2400px; display: grid; }
.album-leaf { grid-area: 1 / 1; display: grid; place-items: center; padding: clamp(40px, 6vh, 64px) clamp(16px, 6vw, 80px) 12px; transform-style: preserve-3d; backface-visibility: hidden; }
.album-leaf img, .album-leaf video { max-width: 100%; max-height: 72vh; width: auto; height: auto; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); background: #0c0f14; }
.album-leaf--under { z-index: 1; }
.album-leaf--turning { z-index: 2; transform-origin: left center; will-change: transform; }
/* A soft shadow that sweeps across the turning page to sell the curl. */
.album-leaf--turning::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; background: linear-gradient(90deg, rgba(0,0,0,0.45), rgba(0,0,0,0) 32%); }

/* Flip to the NEXT photo: the top page swings away to the left around its spine. */
.album-stage.turn-next .album-leaf--turning { animation: leaf-next var(--turn, 620ms) cubic-bezier(.33,.0,.2,1) forwards; }
.album-stage.turn-next .album-leaf--turning::after { animation: leaf-shade var(--turn, 620ms) ease-in forwards; }
@keyframes leaf-next { from { transform: rotateY(0deg); } to { transform: rotateY(-168deg); } }
/* Flip to the PREVIOUS photo: the page swings back in from the left. */
.album-stage.turn-prev .album-leaf--turning { animation: leaf-prev var(--turn, 620ms) cubic-bezier(.33,.0,.2,1) forwards; }
.album-stage.turn-prev .album-leaf--turning::after { animation: leaf-shade-rev var(--turn, 620ms) ease-out forwards; }
@keyframes leaf-prev { from { transform: rotateY(168deg); } to { transform: rotateY(0deg); } }
@keyframes leaf-shade { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }
@keyframes leaf-shade-rev { 0% { opacity: 0; } 60% { opacity: 1; } 100% { opacity: 0; } }

.lightbox-caption { grid-row: 2; text-align: center; font-size: 0.95rem; color: #e6e9ef; padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.lightbox-btn { position: absolute; display: grid; place-items: center; width: 50px; height: 50px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.25); background: rgba(20,24,31,0.72); color: #fff; cursor: pointer; z-index: 5; }
.lightbox-btn:hover { background: rgba(40,46,58,0.92); }
.lightbox-prev { left: max(10px, env(safe-area-inset-left, 0px)); top: 50%; transform: translateY(-50%); }
.lightbox-next { right: max(10px, env(safe-area-inset-right, 0px)); top: 50%; transform: translateY(-50%); }
.lightbox-close { right: max(10px, env(safe-area-inset-right, 0px)); top: max(10px, env(safe-area-inset-top, 0px)); transform: none; }
.lightbox-share { right: calc(max(10px, env(safe-area-inset-right, 0px)) + 60px); top: max(10px, env(safe-area-inset-top, 0px)); transform: none; }
.lightbox-figure { grid-template-rows: 1fr auto auto; }
.lightbox-album { justify-self: center; margin: -6px 0 calc(14px + env(safe-area-inset-bottom, 0px)); color: #fff; font-weight: 600; font-size: 0.95rem; text-decoration: underline; text-underline-offset: 3px; }
.lightbox-album:hover { text-decoration-thickness: 2px; }
.lightbox-count { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); top: max(18px, env(safe-area-inset-top, 0px)); margin: 0; font-size: 0.9rem; color: #c9ced8; z-index: 5; }

@media (prefers-reduced-motion: reduce) {
  .gallery-item img { transition: none; }
  .album-stage.turn-next .album-leaf--turning, .album-stage.turn-prev .album-leaf--turning { animation-duration: 1ms; }
  .album-stage.turn-next .album-leaf--turning::after, .album-stage.turn-prev .album-leaf--turning::after { animation: none; }
}

/* ---- Share options: the site's own networks, WhatsApp, Copy link and the phone's menu. ---- */
.share-sheet { position: fixed; z-index: 1000; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); box-sizing: border-box; padding: 18px 18px 16px; border-radius: 16px; background: #14161c; color: #f4f5f7; border: 1px solid rgba(255,255,255,0.14); box-shadow: 0 24px 60px rgba(0,0,0,0.5); }
.share-sheet__title { margin: 0 0 12px; font-weight: 700; font-size: 1rem; }
.share-sheet__list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.share-sheet__btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; color: #fff; background: #23262f; }
.share-sheet__btn:hover { background: #2d313c; }
.share-sheet__btn .socials__icon { width: 30px; height: 30px; }
.share-sheet__btn .socials__icon svg { width: 16px; height: 16px; }
.share-sheet__btn .socials__icon img { width: 18px; height: 18px; }
.share-sheet__btn--facebook:not(.socials__link--facebook) { background: #0866ff; border-color: transparent; }
.share-sheet__btn--x:not(.socials__link--x) { background: #000; }
.share-sheet__btn--whatsapp:not(.socials__link--whatsapp) { background: #25d366; color: #062e16; border-color: transparent; }
.share-sheet__note { margin: 12px 0 0; font-size: 0.88rem; line-height: 1.45; color: #c9ced8; overflow-wrap: anywhere; }
.share-sheet__note:empty { display: none; }
.share-sheet__btn:focus-visible, .share-sheet__close:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.share-sheet__close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: #c9ced8; font-size: 1.6rem; line-height: 1; cursor: pointer; }

/* ---- Portfolio page jump links, and an album page's actions (share, all albums). ---- */
.portfolio-jump { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.portfolio-jump a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; }
.portfolio-jump a:hover, .portfolio-jump a:focus-visible { border-color: var(--accent); color: var(--accent); }
.album-page__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }
.album-page__share { display: inline-flex; align-items: center; gap: 8px; }
#gallery, #recent, #albums { scroll-margin-top: 90px; }

/* Video tiles: a play badge over the poster frame (the viewer plays the video). */
.gallery-item.is-video { position: relative; }
.gallery-play { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(10, 10, 14, 0.62); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85); pointer-events: none; }
.gallery-play::after { content: ""; position: absolute; left: 22px; top: 17px; border-style: solid; border-width: 11px 0 11px 18px; border-color: transparent transparent transparent #fff; }
