/*
 * m2dijital shared media styles: photo gallery sections (gallery/mosaic, gallery/band),
 * the /iletisim photo strip, the lightbox (js/m2-gallery.js) and customer service photos
 * inside service variants and the detail-page sidebar. Loaded by the shared layout for
 * every theme; colours come from the page (currentColor) and the tenant variables, so the
 * same rules read correctly on light and dark themes.
 */

/* ---------- Gallery: common tile ---------- */
.m2-gal-list { list-style: none; margin: 0; padding: 0; }
.m2-gal-item {
    display: block; position: relative; height: 100%; overflow: hidden; border-radius: 12px;
    background: rgba(127, 127, 127, .14); color: inherit;
}
.m2-gal-item img {
    display: block; width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover;
    transition: transform .35s ease;
}
.m2-gal-item:hover img, .m2-gal-item:focus-visible img { transform: scale(1.04); }
.m2-gal-item:focus-visible { outline: 3px solid var(--m2-primary, #2f55d4); outline-offset: 3px; }
.m2-gal-cap {
    position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 28px 12px 10px;
    font-size: .875rem; line-height: 1.35; color: #fff;
    /* solid enough under the text for any photo (white: >= 6:1), the fade only in the top padding */
    background: linear-gradient(to top, rgba(0, 0, 0, .78), rgba(0, 0, 0, .66) calc(100% - 28px), rgba(0, 0, 0, 0));
    overflow-wrap: anywhere;
}

/* ---------- gallery/mosaic (light and most themes) ---------- */
.m2-gal-mosaic .m2-gal-list { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) {
    .m2-gal-mosaic .m2-gal-list { gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .m2-gal-mosaic .m2-gal-list > li:first-child:not(:only-child) { grid-column: span 2; grid-row: span 2; }
    .m2-gal-mosaic .m2-gal-list > li:first-child:not(:only-child) img { aspect-ratio: auto; }
}
@media (min-width: 1200px) {
    .m2-gal-mosaic .m2-gal-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- gallery/band (dark / photo-heavy themes): horizontal scroll strip in the container ---------- */
.m2-gal-band .m2-gal-list {
    display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    padding: 4px 0 14px; scrollbar-width: thin;
}
.m2-gal-band .m2-gal-list > li { flex: 0 0 78%; scroll-snap-align: start; }
@media (min-width: 576px) { .m2-gal-band .m2-gal-list > li { flex-basis: 46%; } }
@media (min-width: 992px) { .m2-gal-band .m2-gal-list > li { flex-basis: 380px; } }
.m2-gal-band .m2-gal-item { border-radius: 4px; }
.m2-gal-hint { font-size: .875rem; opacity: .75; }

/* ---------- /iletisim photo strip ---------- */
.m2-photo-strip .m2-gal-list { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 768px) { .m2-photo-strip .m2-gal-list { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.m2-photo-strip .m2-gal-item { border-radius: 8px; }

/* ---------- Lightbox ---------- */
html.m2-lb-open { overflow: hidden; }
.m2-lb {
    width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
    background: rgba(8, 10, 16, .94); color: #fff;
}
.m2-lb::backdrop { background: rgba(8, 10, 16, .6); }
.m2-lb-figure {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
    width: 100%; height: 100%; margin: 0; padding: 56px 16px 40px;
}
.m2-lb-img { max-width: 100%; max-height: calc(100vh - 140px); width: auto; height: auto; object-fit: contain; border-radius: 4px; }
.m2-lb-caption { max-width: 720px; text-align: center; font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere; }
.m2-lb-counter { position: absolute; top: 18px; left: 18px; font-size: .875rem; opacity: .8; }
.m2-lb-btn {
    position: absolute; display: flex; align-items: center; justify-content: center;
    width: 48px; height: 48px; border: 0; border-radius: 50%; font-size: 2rem; line-height: 1;
    color: #fff; background: rgba(255, 255, 255, .12); cursor: pointer;
}
.m2-lb-btn:hover { background: rgba(255, 255, 255, .24); }
.m2-lb-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.m2-lb-close { top: 8px; right: 8px; }
.m2-lb-prev, .m2-lb-next { top: 50%; transform: translateY(-50%); }
.m2-lb-prev { left: 8px; }
.m2-lb-next { right: 8px; }
.m2-lb-btn[hidden], .m2-lb-caption[hidden] { display: none; }

/* ---------- Service photos (only when the customer added one) ---------- */
body .m2-has-photo { position: relative; overflow: hidden; }
.m2-photo-fill { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* services/g1-media-cards, services/g4-vitrin-cards: the photo fills the media area; the
   theme's colour surface stays underneath as the loading placeholder. */

/* services/g2-tiles: photo behind the text. Customers upload white studio shots as well as
   dark scenes, so the shade is built for the worst case without dimming the whole photo:
   - tile ::before: a light shade, a little stronger at the top for the icon;
   - the text block: a scrim from 56px above the title down to the tile's bottom edge, drawn
     with border-image outset (no layout change; the block stays unpositioned so the title's
     stretched-link still covers the whole tile; the tile's overflow clips it). Under the text
     it is >= 62% black: white text >= 6:1 even on a pure white photo.
   - white text that wins over the themes' own muted / hover tile colours. */
body .g2-tile.m2-has-photo { isolation: isolate; min-height: 240px; }
body .g2-tile.m2-has-photo .m2-photo-fill { z-index: -2; transition: transform .35s ease; }
body .g2-tile.m2-has-photo::before {
    content: ""; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .45) 0, rgba(0, 0, 0, .12) 45%, rgba(0, 0, 0, .12) 100%);
}
body .g2-tile.m2-has-photo .g2-tile-body {
    border-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .62) 56px, rgba(0, 0, 0, .72)) fill 0 / 0 / 56px 100vmax 100vmax;
}
body .g2-tile.m2-has-photo:hover .m2-photo-fill, body .g2-tile.m2-has-photo:focus-within .m2-photo-fill { transform: scale(1.04); }
body .g2-tiles .g2-tile.m2-has-photo :is(a, p, .g2-tile-icon) { color: #fff; }

/* services/g1-menu: small square photo beside the entry */
body .g1-menu-item.m2-has-photo { display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 16px; align-items: start; overflow: visible; }
.g1-menu-item.m2-has-photo > .m2-menu-thumb { grid-row: span 2; width: 64px; height: 64px; border-radius: 12px; object-fit: cover; }

/* Detail-page sidebar: thumbnail instead of the icon */
.m2-sidebar-thumb { width: 40px; height: 30px; margin-right: .5rem; border-radius: 4px; object-fit: cover; vertical-align: middle; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
    .m2-gal-item img, body .g2-tile.m2-has-photo .m2-photo-fill { transition: none; }
    .m2-gal-item:hover img, body .g2-tile.m2-has-photo:hover .m2-photo-fill { transform: none; }
}
