/* ==========================================================================
   Section: instagram-feed  →  assets/section-instagram-feed.css
   Figma 1164-3226: a white 1440×820 frame, 64px below Testimonials. Nine posts (144×144 or
   144×192, #d0d0d0 behind the photo, Figma's Noise effect on top) scattered over the full width,
   around a centred 377px Heading/H1: "Discover More From" in the tertiary grey, "@Instagram" in
   the primary ink, on two 58px lines.
   The section is a scroll track; the frame is sticky and as tall as the room under the header,
   which is 820px — Figma's frame — on a 1440×877 window. The posts layer is centred in the frame
   and the script moves it (assets/js/sections/instagram-feed.js); the CSS on its own is the still
   layout. Posts placed below 820 sit under the frame's lower edge until the scroll brings them in.
   Settings — custom properties on .instagram-feed
     --section-top 64px   --grain-opacity 0.15   --post-bg #d0d0d0
   ========================================================================== */
.instagram-feed {
  --section-top: 64px;
  --sticky-top: calc(var(--header-height) + 1px);
  /* one Figma pixel: 1px at 1440 and wider, scaling down with the section below that */
  --px: clamp(0.5px, calc(100cqw / 1440), 1px);
  --grain-opacity: 0.15;
  --post-bg: #d0d0d0;
  --heading-size: clamp(32px, 3.3334vw, var(--text-display-l-size)); /* 48px at 1440 */

  container-type: inline-size;
  padding-top: var(--section-top);
  background: var(--color-white);
}

.instagram-feed__track {
  display: block;
}

.instagram-feed__frame {
  position: sticky;
  top: var(--sticky-top);
  height: calc(100svh - var(--sticky-top));
  min-height: 480px;
  overflow: clip;
  background: var(--color-white);
}

/* ------------------------------------------------------------------ posts
   One 820-tall design frame, centred in the sticky frame. It is the frame's width, or 1440 design
   px when that is wider (phones, where --px stops shrinking), centred so the sides crop evenly. */
.instagram-feed__posts {
  position: absolute;
  top: calc((100% - 820 * var(--px)) / 2);
  left: calc(50% - max(50%, 720 * var(--px)));
  width: max(100%, 1440 * var(--px));
  height: calc(820 * var(--px));
  will-change: transform;
}

/* x spreads across the layer's width: Figma's posts touch both edges at 1440, so a post's left
   edge is placed at x / (1440 − w) of the free width. Up to 1440 that is exactly x scaled; wider
   screens keep the posts at full size and fill the width instead of leaving empty sides. */
.instagram-feed__post {
  position: absolute;
  top: calc(var(--y) * var(--px));
  left: calc((100% - var(--w) * var(--px)) * var(--x) / (1440 - var(--w)));
  width: calc(var(--w) * var(--px));
  height: calc(var(--h) * var(--px));
  overflow: hidden;
  background: var(--post-bg);
}

.instagram-feed__post img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease-out);
}

@media (hover: hover) {
  .instagram-feed__post:hover img {
    transform: scale(1.05);
  }
}

/* ---------------------------------------------------------------- heading
   Figma centres the 377px text box on (719.5, 409): half a pixel left of the frame's centre and
   one pixel above it. The width is kept in em so the line breaks after "More" at every size. */
.instagram-feed__heading {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7.8542em; /* 377px at 48px */
  max-width: calc(100% - 2 * var(--page-gutter));
  translate: calc(-50% - 0.5px) calc(-50% - 1px);
  color: var(--color-text-primary);
  font-family: var(--font-display);
  font-size: var(--heading-size);
  font-weight: 500;
  line-height: 1.2;
  line-height: round(nearest, var(--heading-size) * 1.2, 1px); /* Figma's whole-pixel 58px lines */
  text-align: center;
  pointer-events: none; /* posts passing under the text stay clickable */
}

.instagram-feed__heading-muted {
  color: var(--color-text-tertiary);
}

.instagram-feed__handle {
  pointer-events: auto;
  text-decoration: underline transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.12em;
  transition: text-decoration-color var(--duration-fast) ease;
}

.instagram-feed__handle:hover {
  text-decoration-color: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .instagram-feed__post img,
  .instagram-feed__handle {
    transition: none;
  }
}
