/* 08 · From the Atelier — spec §4 "08". Tile count per breakpoint is
   achieved by changing each tile's flex-basis formula (N visible items +
   (N-1) gaps = 100% of the track), not by resizing the container — the
   extra tiles simply sit past the edge, needing a scroll, until the <768
   tier switches to a real wrapping grid instead. */
@layer components {
  .instagram {
    background-color: var(--sand-200);
    padding-top: var(--section-pad);
    padding-bottom: 0; /* spec: the button's bottom edge sits flush on the section's own bottom edge */
  }

  .instagram__head {
    margin-bottom: 16px;
  }

  .instagram__eyebrow-link {
    display: inline-block;
    margin-top: 4px;
    text-decoration: none;

    &:hover,
    &:focus-visible {
      color: var(--gold-600);
    }
  }

  .instagram__tiles {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }
  }

  .instagram__tile {
    position: relative;
    display: block;
    flex: 0 0 calc((100% - 6 * 8px) / 7); /* 7 visible: 6 gaps between them */
    aspect-ratio: 4 / 3;
    overflow: hidden;
  }

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

  .instagram__tile-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    color: rgb(255 255 255 / 0.85);
    pointer-events: none;
  }

  .instagram__tile-hover {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: color-mix(in srgb, var(--ink-950) 35%, transparent);
    color: var(--text-on-dark);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
  }

  .instagram__tile:is(:hover, :focus-visible) .instagram__tile-hover {
    opacity: 1;
  }

  /* Zero bottom padding is deliberate: the button's own bottom edge must
     coincide exactly with the section's (padding-bottom:0 above), so it
     sits flush against the footer that follows, per spec. */
  .instagram__cta {
    display: flex;
    justify-content: center;
    padding-top: 8px;
  }

  /* 1024–1279px: 5 visible (4 gaps), rest need a scroll */
  @media (max-width: 1279.98px) {
    .instagram__tile {
      flex-basis: calc((100% - 4 * 8px) / 5);
    }
  }

  /* 768–1023px: 4 visible (3 gaps) */
  @media (min-width: 768px) and (max-width: 1023.98px) {
    .instagram__tile {
      flex-basis: calc((100% - 3 * 8px) / 4);
    }
  }

  /* <768px: a real 3-column wrapping grid, not a scroll track — 6 tiles (7th
     dropped), then the button. */
  @media (max-width: 767.98px) {
    .instagram__tiles {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      overflow: visible;
    }

    .instagram__tile {
      flex-basis: auto;
    }

    .instagram__tile:nth-child(7) {
      display: none;
    }
  }
}
