/**
 * Mosaic Gallery v2 — unified portfolio grid (Phase 1)
 * Replaces per-project containerN classes with layout presets + data-cols spans.
 */

.gallery-v2 {
  padding-top: clamp(80px, 9vw, 104px);
  padding-bottom: 32px;
}

@media (max-width: 992px) {
  .gallery-v2 {
    padding-top: 85px;
  }
}

/* Intro panel — full width above mosaic */
.gallery-v2 .proj-intro {
  margin: 40px;
  margin-bottom: 12px;
  background: var(--project-accent, #333);
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
}

.gallery-v2 .proj-intro .proj {
  background: #333;
  margin-top: 0;
}

.gallery-v2 .proj-intro.box--intro .proj {
  background: #333;
}

/* Mosaic grid */
.gallery-mosaic {
  --gallery-cols: 6;
  display: grid;
  grid-template-columns: repeat(var(--gallery-cols), minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(180px, 28vw, 320px), auto);
  grid-auto-flow: dense;
  gap: 12px;
  margin: 40px;
  margin-top: 12px;
}

@media (max-width: 767.98px) {
  .gallery-v2 .proj-intro,
  .gallery-mosaic {
    margin-left: 20px;
    margin-right: 20px;
  }
}

.gallery-tile {
  --tile-cols: 2;
  --tile-rows: 1;
  --tile-fit: cover;
  grid-column: span var(--tile-cols);
  grid-row: span var(--tile-rows);
  margin: 0;
  background: #333;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto clamp(180px, 28vw, 320px);
}

.gallery-tile[data-cols="1"] { --tile-cols: 1; }
.gallery-tile[data-cols="2"] { --tile-cols: 2; }
.gallery-tile[data-cols="3"] { --tile-cols: 3; }
.gallery-tile[data-cols="4"] { --tile-cols: 4; }
.gallery-tile[data-cols="5"] { --tile-cols: 5; }
.gallery-tile[data-cols="6"] { --tile-cols: 6; }

.gallery-tile[data-rows="2"] { --tile-rows: 2; }

.gallery-v2[data-fit="contain"] .gallery-tile {
  --tile-fit: contain;
}

.gallery-v2[data-fit="contain"] .gallery-tile img,
.gallery-tile[data-fit="contain"] img {
  height: auto;
}

.gallery-tile[data-fit="contain"] {
  --tile-fit: contain;
}

.gallery-tile[data-fit="cover"] {
  --tile-fit: cover;
}

.gallery-tile__link {
  display: block;
  width: 100%;
  height: 100%;
  min-height: clamp(180px, 28vw, 320px);
  line-height: 0;
  position: relative;
  cursor: zoom-in;
}

.gallery-tile__link::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  transition: background 0.25s ease;
  pointer-events: none;
}

@media (hover: hover) {
  .gallery-tile__link:hover::after {
    background: rgba(0, 0, 0, 0.12);
  }

  .gallery-tile__link:hover img {
    transform: scale(1.055);
  }
}

.gallery-tile img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: clamp(180px, 28vw, 320px);
  object-fit: var(--tile-fit);
  object-position: center;
  transform: scale(1);
  transition: transform 0.5s cubic-bezier(0.77, 0, 0.175, 1);
}

.gallery-tile--audio .gallery-tile__link {
  cursor: default;
}

.gallery-audio-card {
  background: #151515;
  color: #fff;
  isolation: isolate;
}

.gallery-audio-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.15) 58%, rgba(0, 0, 0, 0.05));
  pointer-events: none;
}

.gallery-audio-card img {
  filter: grayscale(1);
}

.gallery-audio-card__panel {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 2;
  display: grid;
  gap: 0.55rem;
  line-height: 1.2;
}

.gallery-audio-card__label {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-family: "Montserrat", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.gallery-audio-card__panel h2 {
  margin: 0;
  color: #fff;
  font-family: "Montserrat", sans-serif;
  font-size: clamp(1.2rem, 2.1vw, 1.8rem);
  line-height: 1.05;
}

.gallery-audio-card audio {
  width: 100%;
  max-width: 100%;
  height: 38px;
  display: block;
}

.gallery-tile__link[data-vbtype="video"]::before {
  content: "\25B6";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 3.5rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.18rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 1.05rem;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

/* Layout presets — 6-column rows must sum to 6 (e.g. 3+3 or 2+2+2) */
.gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(5n + 1),
.gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(5n + 2) {
  --tile-cols: 3;
}

.gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(5n + 3),
.gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(5n + 4),
.gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(5n) {
  --tile-cols: 2;
}

.gallery-v2[data-layout="pub-spread"] .gallery-tile {
  --tile-fit: contain;
  --tile-cols: 3;
}

.gallery-v2[data-layout="pub-spread"] .gallery-tile:nth-child(2n + 1) {
  --tile-cols: 3;
}

.gallery-v2[data-layout="pub-spread"] .gallery-tile:nth-child(2n) {
  --tile-cols: 3;
}

.gallery-v2[data-layout="pub-spread"] .gallery-tile__link,
.gallery-v2[data-layout="pub-spread"] .gallery-tile img {
  min-height: clamp(220px, 30vw, 400px);
  height: auto;
}

.gallery-v2[data-layout="web-screen"] .gallery-tile {
  --tile-fit: contain;
  --tile-cols: 6;
  min-height: clamp(240px, 50vh, 560px);
}

.gallery-v2[data-layout="web-screen"] .gallery-tile__link,
.gallery-v2[data-layout="web-screen"] .gallery-tile img {
  min-height: clamp(240px, 50vh, 560px);
}

/* Mobile */
@media (max-width: 991px) {
  .gallery-mosaic {
    --gallery-cols: 2;
    grid-auto-rows: minmax(160px, auto);
  }

  .gallery-tile,
  .gallery-tile[data-cols],
  .gallery-v2[data-layout="brand-wide"] .gallery-tile,
  .gallery-v2[data-layout="pub-spread"] .gallery-tile,
  .gallery-v2[data-layout="web-screen"] .gallery-tile {
    --tile-cols: 2;
    --tile-rows: 1;
  }

  .gallery-v2[data-layout="pub-spread"] .gallery-tile:nth-child(3n + 1),
  .gallery-v2[data-layout="brand-wide"] .gallery-tile:nth-child(6n + 1) {
    --tile-cols: 2;
  }

  .gallery-v2 .proj-intro {
    margin-bottom: 0.5rem;
  }
}

@media (max-width: 480px) {
  .gallery-mosaic {
    --gallery-cols: 1;
  }

  .gallery-tile,
  .gallery-tile[data-cols] {
    --tile-cols: 1;
  }
}

/* Larger prev/next tap targets on v2 intro */
.gallery-v2 .controls button {
  width: 2.75rem;
  height: 2.75rem;
  min-width: 44px;
  min-height: 44px;
}

/* Expand hint — first tile on touch devices */
@media (hover: none) {
  .gallery-v2 .gallery-tile:first-child .gallery-tile__link::before {
    content: "Tap to enlarge";
    position: absolute;
    right: 0.65rem;
    bottom: 0.65rem;
    z-index: 2;
    padding: 0.35rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 2px;
    line-height: 1.2;
    pointer-events: none;
  }
}
