/* ============================================================
   Section 7 — instagram (brief/instagram.md)
   Figma: desktop 3441:2356 (1440 x 340) · mobile 3441:2036 (375 x 168.67)
   Template: marquee (css/templates/marquee.css + js/marquee.js are the scaffold's).
   Only scoped overrides live here: neutralise the template demo values (FD-71),
   the 16px gap on track + seam (FD-AX, D-IG6), tile / overlay / motion control.
   ============================================================ */

/* Section box: no own bg, 0 block padding, no gutter (container--bleed, D-IG2).
   Section height = tile height. */
.instagram {
  /* Tile height (= section height). Mobile 0-767: 168.67 @375 (§2). */
  --ig-tile-h: clamp(144px, calc(168.67px + (var(--max-vw) - 375px) * 0.015), 340px);
  --ig-gap: 16px; /* FIXED on every layer — never clamp a marquee gap (ADAPT) */
}

/* Pseudo-tablet 768-1023: desktop-compressed — desktop proportion 340/1440 (D-IG5). */
@media (min-width: 768px) {
  .instagram {
    --ig-tile-h: clamp(175px, calc(340px * (var(--max-vw) / var(--vw-base))), 242px);
  }
}

/* Desktop 1024+: 340 @1440, D-min 242, D-max 453. */
@media (min-width: 1024px) {
  .instagram {
    --ig-tile-h: clamp(242px, calc(340px * (var(--max-vw) / var(--vw-base))), 453px);
  }
}

/* ---- marquee: neutralise demo values + seam gap ---- */
.instagram .instagram__marquee {
  width: 100%;
  height: auto;            /* demo: 30px */
  padding: 0;              /* demo: 5px 0 */
  background: transparent; /* demo: #f9f9f9 */
  column-gap: var(--ig-gap); /* seam between the two tickers (demo 50px) */
}

/* FD-AX defensive: seam between copies inside ONE ticker (multiplier > 1). */
.instagram .marquee-ticker {
  column-gap: var(--ig-gap);
}

/* Layout on .slider-track ONLY — clones keep just this class. */
.instagram .slider-track {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  column-gap: var(--ig-gap); /* demo 50px */
  white-space: nowrap;
}

/* ---- tile (link) ---- */
.instagram__tile {
  display: block;
  position: relative;
  flex: none;
  height: var(--ig-tile-h);
  width: calc(var(--ig-tile-h) * 416 / 340); /* 416 x 340 on both layers (ratio 1.22353) */
  border-radius: var(--radius);
  cursor: pointer;
}

/* Focus ring inside the tile: the marquee clips at its edges (overflow: hidden),
   so the page's outset ring would be cut off top and bottom. */
.instagram__tile:focus-visible {
  outline-offset: -2px;
}

.instagram__photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hover state (Figma 3441:2360 / 3441:2042): #000 at layer opacity 0.5 + centred glyph. */
.instagram__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-overlay);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.instagram__icon {
  display: block;
  width: calc(var(--ig-tile-h) * 48 / 340); /* 48 @340 desktop, ~24 @168.67 mobile */
  height: auto;
}

@media (hover: hover) {
  .instagram__tile:hover .instagram__overlay {
    opacity: 1;
  }
}

.instagram__tile:focus-visible .instagram__overlay {
  opacity: 1;
}

/* ---- motion control (BA-IG3) ---- */
/* A keyboard-focused tile must not move (WCAG 2.2.2). js/instagram.js sets .is-kbd-focus only
   for :focus-visible focus (a mouse click must not freeze the strip — IG-A2) and parks the ticker
   at phase 0, so the browser's focus scroll-into-view stays inside the two tracks and the strip is
   never emptied (IG-A1); it resets scrollLeft when focus leaves. */
.instagram .instagram__marquee.is-kbd-focus .marquee-ticker {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .instagram .marquee-ticker {
    animation-play-state: paused;
  }
  .instagram__overlay {
    transition: none;
  }
}

/* ---- lightbox (user request 2026-10-09: a tile click opens the photo in a popup) ---- */
.instagram__lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  /* the dialog itself covers the viewport, so the dim lives on it (not only on ::backdrop) */
  background: rgba(0, 0, 0, 0.94);
  color: var(--color-text);
  overflow: hidden;
}
.instagram__lightbox::backdrop {
  background: transparent;
}
.instagram__lightbox[open] {
  display: grid;
  place-items: center;
}
.instagram__lightbox-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 64px var(--gutter);
}
.instagram__lightbox-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 100%;
  max-height: 100%;
}
.instagram__lightbox-img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 1800px);
  max-height: calc(100dvh - 128px - 36px);
  object-fit: contain;
}
.instagram__lightbox-count {
  font-size: var(--text-small);
  line-height: var(--lh-body);
  opacity: 0.8;
}
.instagram__lightbox-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius);
  cursor: pointer;
}
.instagram__lightbox-btn::before,
.instagram__lightbox-btn::after {
  content: "";
  position: absolute;
  background: currentColor;
}
/* close: two 1.5px bars crossed */
.instagram__lightbox-btn--close { top: 8px; right: 8px; }
.instagram__lightbox-btn--close::before,
.instagram__lightbox-btn--close::after { width: 22px; height: 1.5px; }
.instagram__lightbox-btn--close::before { transform: rotate(45deg); }
.instagram__lightbox-btn--close::after { transform: rotate(-45deg); }
/* prev / next: a chevron drawn with two borders */
.instagram__lightbox-btn--prev,
.instagram__lightbox-btn--next { top: 50%; transform: translateY(-50%); }
.instagram__lightbox-btn--prev { left: 8px; }
.instagram__lightbox-btn--next { right: 8px; }
.instagram__lightbox-btn--prev::before,
.instagram__lightbox-btn--next::before {
  width: 12px;
  height: 12px;
  background: none;
  border-top: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
}
.instagram__lightbox-btn--prev::before { transform: translateX(2px) rotate(-45deg); }
.instagram__lightbox-btn--next::before { transform: translateX(-2px) rotate(135deg); }
.instagram__lightbox-btn::after { display: none; }
.instagram__lightbox-btn--close::after { display: block; }
.instagram__lightbox-btn:focus-visible { outline-offset: -2px; }
@media (hover: hover) {
  .instagram__lightbox-btn:hover { background: rgba(255, 255, 255, 0.16); }
}
@media (min-width: 1024px) {
  .instagram__lightbox-btn--close { top: 24px; right: 24px; }
  .instagram__lightbox-btn--prev { left: 24px; }
  .instagram__lightbox-btn--next { right: 24px; }
  .instagram__lightbox-inner { padding: 80px 96px; }
  .instagram__lightbox-img { max-height: calc(100dvh - 160px - 36px); }
}
/* the strip stands still behind an open viewer */
.instagram.is-lightbox-open .marquee-ticker { animation-play-state: paused; }
