/* Staffords — Instagram feed section ("From our feed to your kitchen").
   Self-contained: relies only on the tokens in styles.css (:root). Behaviour: instagram-feed.js */

.insta { --insta-bg: var(--cream); --insta-card: var(--paper); background: var(--insta-bg); overflow: hidden; }
/* On the home page it sits on paper (section--paper) to separate it from the cream Brands section above */
.insta.section--paper { --insta-bg: var(--paper); --insta-card: var(--cream); }

/* ---------- Head ---------- */
.insta__head { margin-bottom: clamp(32px, 4vw, 48px); }
.insta__head h2 em { font-style: italic; color: var(--gold-ink); }
.insta__head p { color: var(--muted); max-width: 34em; margin: 16px 0 0; }
/* Desktop: heading and line beneath it each stay on one line */
@media (min-width: 961px) {
  .insta__head h2, .insta__head p { white-space: nowrap; max-width: none; }
}

/* Highlights on the left, the profile card on the right, sharing one row.
   The card's bottom edge lines up with the bottom of the filter row (above its 8px scroll padding). */
.insta__bar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px;
  margin-bottom: clamp(28px, 3vw, 40px);
}
.insta__bar .insta__highlights { flex: 1 1 auto; min-width: 0; margin: 0; padding-inline: 0; }
/* Soft edge where the rings scroll under the card on mid-size screens */
@media (min-width: 961px) and (max-width: 1240px) {
  .insta__bar .insta__highlights { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}
/* Resting: just the profile picture and Follow. On hover/focus the handle and stats slide open
   between them, so the card grows to the left from its fixed right edge. */
.insta__profile {
  flex-shrink: 0; display: flex; align-items: center; gap: 0;
  margin-bottom: 8px; padding: 8px; border-radius: 999px;
  background: var(--insta-card); box-shadow: 0 0 0 1px var(--rule), 0 10px 26px -18px rgba(14, 33, 96, 0.45);
  text-decoration: none; color: var(--ink);
  transition: box-shadow 0.35s var(--ease), transform 0.35s var(--ease);
}
.insta__profile:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(20, 49, 130, 0.28), 0 16px 30px -18px rgba(14, 33, 96, 0.55); }
.insta__profile:hover .insta__follow { background: var(--navy-deep); }
.insta__who {
  display: block; overflow: hidden; white-space: nowrap;
  max-width: 0; opacity: 0; margin-inline: 10px 0;
  transition: max-width 0.5s var(--ease), opacity 0.3s var(--ease), margin 0.5s var(--ease);
}
.insta__profile:hover .insta__who,
.insta__profile:focus-visible .insta__who { max-width: 240px; opacity: 1; margin-inline: 14px 18px; transition-delay: 0s, 0.12s, 0s; }
.insta__handle, .insta__stats { display: flex; }
.insta__profile .insta__avatar { width: 56px; height: 56px; }
.insta__profile .insta__follow { min-height: 48px; padding: 0 24px; }
.insta__avatar {
  width: 64px; height: 64px; border-radius: 50%; padding: 3px; flex-shrink: 0;
  background: conic-gradient(from 200deg, var(--gold), var(--navy), var(--gold-soft), var(--gold));
}
.insta__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: contain; background: var(--paper); border: 3px solid var(--cream); padding: 6px; }
.insta__handle { font-weight: 600; color: var(--navy); line-height: 1.2; }
.insta__stats { display: flex; gap: 14px; font-size: 0.88rem; color: var(--muted); margin-top: 2px; }
.insta__stats b { color: var(--ink); font-weight: 600; }
.insta__follow svg { width: 18px; height: 18px; }
.insta__follow:hover svg { transform: none; }

/* ---------- Highlights (story rings that filter the grid) ---------- */
.insta__highlights {
  display: flex; gap: clamp(14px, 2.4vw, 28px);
  margin: 0 calc(-1 * var(--gutter)) clamp(28px, 3vw, 40px); padding: 4px var(--gutter) 8px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.insta__highlights::-webkit-scrollbar { display: none; }
.insta-hl {
  flex-shrink: 0; scroll-snap-align: start;
  display: grid; justify-items: center; gap: 8px;
  background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink);
  font-size: 0.86rem; font-weight: 500;
}
.insta-hl__ring {
  width: clamp(68px, 7vw, 84px); aspect-ratio: 1; border-radius: 50%; padding: 3px;
  background: var(--rule);
  transition: background 0.35s var(--ease), transform 0.35s var(--ease);
}
.insta-hl__ring img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; border: 3px solid var(--insta-bg); }
.insta-hl__ring--all { display: grid; place-items: center; }
.insta-hl__ring--all span {
  width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--insta-bg);
  display: grid; place-items: center; background: var(--navy); color: var(--cream);
}
.insta-hl__ring--all svg { width: 40%; height: 40%; }
.insta-hl:hover .insta-hl__ring { transform: translateY(-3px); }
.insta-hl[aria-pressed="true"] .insta-hl__ring { background: conic-gradient(from 200deg, var(--gold), var(--navy), var(--gold-soft), var(--gold)); }
.insta-hl[aria-pressed="true"] { color: var(--navy); font-weight: 600; }

/* ---------- Grid ---------- */
.insta__grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 1.2vw, 16px);
  grid-auto-flow: dense;
}
.insta-post {
  position: relative; aspect-ratio: 1; overflow: hidden; border-radius: var(--radius);
  background: var(--cream-deep); cursor: pointer; border: 0; padding: 0; display: block; width: 100%;
  animation: insta-in 0.6s var(--ease) both;
}
.insta-post--feature { grid-column: span 2; grid-row: span 2; }
.insta-post img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease); }
.insta-post:hover img, .insta-post:focus-visible img { transform: scale(1.06); }
.insta-post--feature img { animation: insta-drift 18s ease-in-out infinite alternate; }
@keyframes insta-drift { to { transform: scale(1.1) translate(-2%, -1%); } }
@keyframes insta-in { from { opacity: 0; transform: translateY(16px); } }

.insta-post__type {
  position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45));
}
.insta-post__recipe {
  position: absolute; top: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 253, 248, 0.92); color: var(--navy);
  font-size: 0.74rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
}
.insta-post__recipe svg { width: 13px; height: 13px; }
.insta-post__veil {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  padding: clamp(12px, 1.6vw, 22px); text-align: left; color: var(--cream);
  background: linear-gradient(180deg, rgba(14, 33, 96, 0) 30%, rgba(14, 33, 96, 0.88) 100%);
  opacity: 0; transition: opacity 0.4s var(--ease);
}
.insta-post:hover .insta-post__veil, .insta-post:focus-visible .insta-post__veil { opacity: 1; }
.insta-post__caption {
  font-size: 0.9rem; line-height: 1.45; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.insta-post:not(.insta-post--feature) .insta-post__caption { -webkit-line-clamp: 2; font-size: 0.84rem; }
.insta-post--feature .insta-post__caption { font-family: var(--serif); font-size: clamp(1.1rem, 1.6vw, 1.4rem); line-height: 1.3; }
.insta-post__meta { display: flex; gap: 14px; align-items: center; font-size: 0.82rem; font-weight: 500; }
.insta-post__meta span { display: inline-flex; align-items: center; gap: 5px; }
.insta-post__meta svg { width: 15px; height: 15px; }
.insta-post__cook { margin-left: auto; color: var(--gold); }
/* Feature tile keeps its caption visible: it's the "now cooking" post */
.insta-post--feature .insta-post__veil { opacity: 1; background: linear-gradient(180deg, rgba(14, 33, 96, 0) 45%, rgba(14, 33, 96, 0.85) 100%); }

.insta__more { display: flex; justify-content: center; margin-top: clamp(28px, 3vw, 40px); }

/* ---------- Community wall: #BakedWithStaffords ---------- */
.insta-community {
  margin-top: clamp(64px, 8vw, 110px);
  display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr); gap: clamp(24px, 4vw, 64px); align-items: center;
}
.insta-community h3 { font-size: clamp(1.8rem, 3vw, 2.6rem); }
.insta-community h3 span { color: var(--gold-ink); }
.insta-community p { color: var(--muted); margin: 14px 0 22px; }
.insta-community__tag {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1px dashed var(--navy); background: var(--paper); color: var(--navy);
  border-radius: 999px; padding: 10px 18px; font-weight: 600;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.insta-community__tag:hover { background: var(--navy); color: var(--cream); }
.insta-community__tag svg { width: 16px; height: 16px; }
.insta-community__tag[data-copied]::after { content: "Copied"; font-weight: 500; font-size: 0.8rem; opacity: 0.75; }

.insta-wall {
  position: relative; overflow: hidden; padding-block: 24px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.insta-wall__track { display: flex; gap: 22px; width: max-content; animation: insta-marquee 48s linear infinite; }
.insta-wall:hover .insta-wall__track { animation-play-state: paused; }
@keyframes insta-marquee { to { transform: translateX(-50%); } }
.insta-polaroid {
  flex-shrink: 0; width: 190px; margin: 0;
  background: var(--paper); padding: 10px 10px 14px; border-radius: 3px;
  box-shadow: 0 10px 28px -12px rgba(14, 33, 96, 0.35), 0 1px 0 rgba(14, 33, 96, 0.06);
  transform: rotate(var(--tilt, -2deg));
  transition: transform 0.4s var(--ease);
}
.insta-polaroid:nth-child(even) { --tilt: 2.2deg; margin-top: 18px; }
.insta-polaroid:nth-child(3n) { --tilt: -1deg; }
.insta-polaroid:hover { transform: rotate(0) scale(1.05); }
.insta-polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.insta-polaroid figcaption { font-size: 0.8rem; color: var(--muted); padding-top: 9px; line-height: 1.35; }
.insta-polaroid figcaption b { display: block; color: var(--navy); font-weight: 600; }

/* ---------- Post viewer (dialog) ---------- */
.insta-modal {
  width: min(1040px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: 10px; background: var(--paper); color: var(--ink);
  overflow: hidden;
}
.insta-modal::backdrop { background: rgba(14, 33, 96, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.insta-modal[open] { animation: insta-pop 0.35s var(--ease); }
@keyframes insta-pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.insta-modal__inner { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); max-height: calc(100dvh - 48px); }
.insta-modal__media { position: relative; background: #111; user-select: none; }
.insta-modal__media img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1; }
.insta-modal__heart {
  position: absolute; left: 50%; top: 50%; width: 110px; height: 110px; margin: -55px 0 0 -55px;
  color: #fff; opacity: 0; pointer-events: none; filter: drop-shadow(0 6px 20px rgba(0, 0, 0, 0.35));
}
.insta-modal__heart.is-pop { animation: insta-heart 0.9s var(--ease); }
@keyframes insta-heart {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.12); }
  45% { transform: scale(0.95); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1) translateY(-20px); }
}
.insta-modal__body { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.insta-modal__top { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--rule); }
.insta-modal__top .insta__avatar { width: 40px; height: 40px; padding: 2px; }
.insta-modal__top .insta__avatar img { border-width: 2px; padding: 3px; }
.insta-modal__top small { display: block; color: var(--muted); font-size: 0.8rem; }
.insta-modal__close {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--cream); color: var(--navy); font-size: 1.5rem; line-height: 1;
}
.insta-modal__close:hover { background: var(--cream-deep); }
.insta-modal__text { padding: 20px 22px 4px; }
.insta-modal__text p { white-space: pre-line; font-size: 0.97rem; }
.insta-modal__tags { color: var(--navy); font-size: 0.9rem; }
.insta-modal__actions { display: flex; align-items: center; gap: 18px; padding: 4px 22px 16px; color: var(--muted); font-size: 0.9rem; }
.insta-modal__like {
  display: inline-flex; align-items: center; gap: 7px; border: 0; background: none; cursor: pointer;
  color: var(--ink); font-weight: 600; padding: 0;
}
.insta-modal__like svg { width: 24px; height: 24px; transition: transform 0.3s var(--ease); }
.insta-modal__like[aria-pressed="true"] { color: #d6304a; }
.insta-modal__like[aria-pressed="true"] svg { fill: currentColor; transform: scale(1.12); }

.insta-cook { margin: auto 22px 22px; padding: 18px; background: var(--cream); border-radius: 8px; }
.insta-cook--plain { background: none; padding: 0; } /* a post with no recipe: just "View on Instagram" */
/* Hidden until the feed loads, and the wall hides when there are no community photos */
.insta[hidden], .insta-community[hidden] { display: none; }
.insta-cook h4 { font-size: 1.25rem; margin-bottom: 4px; }
.insta-cook > p { font-size: 0.9rem; color: var(--muted); margin: 0 0 14px; }
.insta-cook__products { display: grid; gap: 8px; margin-bottom: 16px; }
.insta-cook__product {
  display: flex; align-items: center; gap: 12px; text-decoration: none;
  background: var(--paper); border-radius: 6px; padding: 8px 12px 8px 8px;
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}
.insta-cook__product:hover { box-shadow: 0 6px 18px -10px rgba(14, 33, 96, 0.45); transform: translateX(2px); }
.insta-cook__product img { width: 44px; height: 44px; object-fit: contain; }
.insta-cook__product span { font-size: 0.9rem; font-weight: 500; color: var(--navy); line-height: 1.25; }
.insta-cook__product small { display: block; color: var(--muted); font-weight: 400; }
.insta-cook__product i { margin-left: auto; color: var(--gold-ink); font-style: normal; }
.insta-cook__cta { display: flex; flex-wrap: wrap; gap: 10px; }
.insta-cook__cta .btn { min-height: 44px; padding: 0 20px; font-size: 0.92rem; }

.insta-modal__nav {
  position: absolute; top: 50%; translate: 0 -50%; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 253, 248, 0.9); color: var(--navy);
  display: grid; place-items: center;
}
.insta-modal__nav svg { width: 18px; height: 18px; }
.insta-modal__nav--prev { left: 12px; }
.insta-modal__nav--next { right: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .insta__bar { flex-direction: column; align-items: stretch; gap: 22px; }
  .insta__bar .insta__highlights { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
  .insta__profile { order: -1; margin-bottom: 0; align-self: flex-start; }
  .insta__grid { grid-template-columns: repeat(3, 1fr); }
  .insta-community { grid-template-columns: 1fr; }
  .insta-modal__inner { grid-template-columns: 1fr; overflow-y: auto; }
  .insta-modal__body { overflow: visible; }
  .insta-modal__media img { max-height: 56dvh; }
}
@media (max-width: 600px) {
  .insta__grid { grid-template-columns: repeat(2, 1fr); }
  .insta-post__veil { opacity: 1; background: linear-gradient(180deg, rgba(14, 33, 96, 0) 55%, rgba(14, 33, 96, 0.8) 100%); }
  .insta-post:not(.insta-post--feature) .insta-post__caption { display: none; }
  .insta-post:not(.insta-post--feature) .insta-post__meta .insta-post__cook { display: none; }
  .insta-polaroid { width: 150px; }
  .insta__profile { align-self: stretch; gap: 12px; }
  .insta__profile .insta__avatar { width: 48px; height: 48px; }
  .insta__profile .insta__follow { margin-left: auto; min-height: 44px; padding: 0 18px; }
  .insta__stats { gap: 10px; font-size: 0.8rem; }
}
@media (hover: none) {
  .insta-post__veil { opacity: 1; }
  /* Touch screens can't hover, so the handle and stats are always shown */
  .insta__who { max-width: 240px; opacity: 1; margin-inline: 12px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .insta-post, .insta-post--feature img, .insta-modal[open], .insta-modal__heart.is-pop { animation: none; }
  .insta-wall { overflow-x: auto; }
  .insta-wall__track { animation: none; }
}
