/* ==========================================================================
   home.css — the mosaic grid. See MOSAIC-FIDELITY-NOTES.md for the honesty
   note on how closely this can be expected to match the reference.
   ========================================================================== */

.mosaic {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 300px;
  grid-auto-flow: dense;
  gap: 0;
}

.tile {
  position: relative;
  overflow: hidden;
  grid-column: span 1;
  grid-row: span 1;
  background: #eaeaea; /* shows briefly if an image is slow to load */
}

.tile--wide {
  grid-column: span 2;
}

.tile--tall {
  grid-row: span 2;
}

.tile--large {
  grid-column: span 2;
  grid-row: span 2;
}

.tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Broken-image fallback: JS adds this class instead of leaving a broken
   <img>, so the grid cell stays a solid neutral block instead of collapsing
   or showing a broken-image glyph. */
.tile--broken .tile__img {
  display: none;
}

.tile__placeholder {
  display: none;
  position: absolute;
  inset: 0;
  background: #d8d8d8;
  align-items: center;
  justify-content: center;
  color: #999;
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tile--broken .tile__placeholder {
  display: flex;
}

.tile__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  background: var(--tile-hover-color, #333);
}

.tile__overlay-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 24px;
  color: var(--color-overlay-text);
  margin: 0;
}

.tile__overlay-view {
  background: #000;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 12px 30px;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

/* Desktop: plain CSS hover. */
@media (hover: hover) and (pointer: fine) {
  .tile:hover .tile__overlay {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Any device: JS also toggles this class for the mobile tap flow (and as a
   hover fallback on touch-with-mouse hybrid devices). */
.tile.is-active .tile__overlay {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .mosaic {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }
  .tile,
  .tile--wide,
  .tile--large {
    grid-column: span 1;
    grid-row: span 1;
    aspect-ratio: 4 / 3;
  }
  .tile--tall {
    aspect-ratio: 3 / 4;
  }
}
