﻿/* ============================================================
   FeedGrid — Storefront Widget Styles
   4 layouts: Grid, Collage, Highlight, Slider
   CSS custom properties set by feedgrid.js:
     --gf-cols-desktop, --gf-cols-tablet, --gf-cols-mobile
     --gf-gap, --gf-radius, --gf-i (item index for stagger)
   ============================================================ */

/* === BASE STYLES === */

/* Outer wrapper — padding is applied here (not on .feedgrid-container) so
   the top/bottom space sits ABOVE the heading and BELOW the grid, instead
   of just above the grid. CSS variables are set inline by the Liquid
   template (no JS round-trip), so values bake in at first paint.
   Defaults to 0 padding so existing block instances render unchanged.

   Shopify wraps every app block in <div class="shopify-app-block"> at
   render time, and our .feedgrid-wrapper is its direct child. When the
   theme drops that shopify-app-block into a flex container with
   align-items:flex-start (e.g. Coconut White's .layout-panel-flex--column),
   the shopify-app-block shrinks to its content width — so anything we put
   on the wrapper alone resolves against an already-narrow parent (~221px
   on a 2189px row, observed on babyandcar.com.au 2026-05-18). The
   `.shopify-app-block:has(> .feedgrid-wrapper)` rule below stretches the
   real constraint point. The wrapper rule is a defensive backstop for any
   future theme that uses a different wrapper structure or omits
   shopify-app-block (e.g. inline content edits). */
.shopify-app-block:has(> .feedgrid-wrapper) {
  width: 100%;
  align-self: stretch;
}

.feedgrid-wrapper {
  width: 100%;
  align-self: stretch;
  box-sizing: border-box;
  padding-top: var(--gf-pad-top-d, 0);
  padding-bottom: var(--gf-pad-bot-d, 0);
}

.feedgrid-container {
  position: relative; /* Required for slider arrow absolute positioning */
  /* Resolve gap/radius from desktop vars by default; mobile media query overrides below */
  --gf-gap: var(--gf-gap-desktop, 8px);
  --gf-radius: var(--gf-radius-desktop, 4px);
}

.feedgrid-heading {
  font: inherit;
  margin: 0 0 12px;
}

.feedgrid-grid {
  position: relative;
  width: 100%;
}

.feedgrid-item {
  display: block; /* <a> defaults to inline — must blockify for aspect-ratio + absolute children */
  position: relative;
  overflow: visible; /* tooltips must escape item bounds */
  border-radius: var(--gf-radius, 4px);
  background: #f0f0f0;
  /* --gf-aspect is set by feedgrid.js from the block's image_aspect setting.
     Defaults to 1/1 (square). Other options: 4/5 portrait, 16/9 landscape. */
  aspect-ratio: var(--gf-aspect, 1);
}

/* Inner media wrapper clips the image zoom without clipping tooltips */
.feedgrid-item-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.feedgrid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: var(--gf-aspect, 1);
  display: block;
  opacity: 0;
  transition: opacity 420ms ease-out, transform 200ms ease;
}

.feedgrid-item img.gf-loaded {
  opacity: 1;
}

/* === SCREEN READER UTILITY === */

.feedgrid-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === PLATFORM BADGES === */

.feedgrid-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedgrid-badge--ig {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.feedgrid-badge--tt {
  background: #010101;
}

.feedgrid-badge svg {
  width: 10px;
  height: 10px;
  display: block;
  margin: auto;
}

/* === GRID LAYOUT === */

.feedgrid-grid[data-fg-layout="grid"] {
  display: grid;
  grid-template-columns: repeat(var(--gf-cols-desktop, 5), 1fr);
  gap: var(--gf-gap, 8px);
}

/* === COLLAGE LAYOUT === */

.feedgrid-grid[data-fg-layout="collage"] {
  display: flex;
  gap: var(--gf-gap, 8px);
}

.feedgrid-grid[data-fg-layout="collage"] .feedgrid-featured {
  flex: 0 0 calc((100% - var(--gf-gap, 8px)) * 0.4);
  overflow: hidden;
  border-radius: var(--gf-radius, 4px);
}

.feedgrid-grid[data-fg-layout="collage"] .feedgrid-featured .feedgrid-item {
  aspect-ratio: var(--gf-aspect, 1);
}

.feedgrid-grid[data-fg-layout="collage"] .feedgrid-featured .feedgrid-item img {
  aspect-ratio: var(--gf-aspect, 1);
}

.feedgrid-grid[data-fg-layout="collage"] .feedgrid-small-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: var(--gf-gap, 8px);
}

/* === HIGHLIGHT LAYOUT === */

.feedgrid-grid[data-fg-layout="highlight"] {
  display: flex;
  gap: var(--gf-gap, 8px);
  align-items: stretch;
}

.feedgrid-grid[data-fg-layout="highlight"] .feedgrid-featured {
  flex: 1;
  overflow: hidden;
  border-radius: var(--gf-radius, 4px);
}

.feedgrid-grid[data-fg-layout="highlight"] .feedgrid-featured .feedgrid-item {
  aspect-ratio: var(--gf-aspect, 1);
}

.feedgrid-grid[data-fg-layout="highlight"] .feedgrid-featured .feedgrid-item img {
  aspect-ratio: var(--gf-aspect, 1);
}

.feedgrid-grid[data-fg-layout="highlight"] .feedgrid-side-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
}

.feedgrid-grid[data-fg-layout="highlight"] .feedgrid-side-grid .feedgrid-item {
  aspect-ratio: var(--gf-aspect, 1);
  border-radius: 2px;
}

/* === SLIDER LAYOUT === */

.feedgrid-grid[data-fg-layout="slider"] {
  display: flex;
  gap: var(--gf-gap, 8px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.feedgrid-grid[data-fg-layout="slider"]::-webkit-scrollbar {
  display: none;
}

.feedgrid-grid[data-fg-layout="slider"] .feedgrid-item {
  flex: 0 0 var(--gf-slider-item-desktop, calc((100% - 8px * 4) / 5));
  min-width: 0;
}

/* === HOVER OVERLAY (desktop only) === */

.feedgrid-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.6));
  padding: 8px;
  opacity: 0;
  transition: opacity 200ms ease;
}

.feedgrid-overlay-caption {
  font-size: 12px;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* === SHOPPABLE TOOLTIPS === */

.feedgrid-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  border-radius: 6px;
  padding: 6px 10px;
  white-space: normal;
  max-width: 140px;
  width: max-content;
  pointer-events: none; /* hidden by default — shown on hover */
  display: block;
  text-decoration: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

/* Desktop: CSS sibling hover — pin:hover shows its adjacent tooltip.
   The ::before pseudo-element bridges the 6px gap between pin and tooltip
   so the cursor can travel between them without the tooltip flashing off.
   Mobile: JS adds .is-active on tap. */
.feedgrid-hotspot:hover ~ .feedgrid-tooltip,
.feedgrid-tooltip:hover,
.feedgrid-hotspot-wrapper.is-active .feedgrid-tooltip {
  opacity: 1;
  pointer-events: auto;
}

.feedgrid-tooltip::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -8px;
  height: 8px;
}

/* Edge-aware positioning */
.feedgrid-tooltip--left {
  left: -4px;
  transform: none;
}

.feedgrid-tooltip--right {
  left: auto;
  right: -4px;
  transform: none;
}

.feedgrid-tooltip--below {
  bottom: auto;
  top: calc(100% + 6px);
}

.feedgrid-tooltip-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.feedgrid-tooltip-variant {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 1px;
}

.feedgrid-tooltip-cta {
  display: block;
  font-size: 11px;
  color: white;
  text-decoration: none;
  opacity: 0.8;
  margin-top: 3px;
}

.feedgrid-tooltip-cta:hover {
  opacity: 1;
}

@media (hover: hover) {
  .feedgrid-item:hover .feedgrid-overlay {
    opacity: 1;
  }

  .feedgrid-item:hover img.gf-loaded {
    transform: scale(1.04);
  }
}

/* === ENTRANCE ANIMATION === */

@keyframes gf-fadein-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedgrid-item {
  animation: gf-fadein-up 420ms ease-out both;
  animation-delay: calc(var(--gf-i, 0) * 55ms);
}

@media (prefers-reduced-motion: reduce) {
  .feedgrid-item {
    animation: none;
    opacity: 1;
  }

  .feedgrid-item img {
    transition: none;
  }

  .feedgrid-overlay {
    transition: none;
  }

  .feedgrid-lightbox {
    transition: none;
  }

  .feedgrid-lightbox-card {
    transition: none;
  }

  .feedgrid-arrow {
    transition: none;
  }
}

/* === RESPONSIVE BREAKPOINTS === */

@media (max-width: 1199px) {
  .feedgrid-grid[data-fg-layout="grid"] {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 749px) {
  .feedgrid-wrapper {
    padding-top: var(--gf-pad-top-m, var(--gf-pad-top-d, 0));
    padding-bottom: var(--gf-pad-bot-m, var(--gf-pad-bot-d, 0));
  }

  .feedgrid-container {
    --gf-gap: var(--gf-gap-mobile, 4px);
    --gf-radius: var(--gf-radius-mobile, 4px);
  }

  .feedgrid-grid[data-fg-layout="grid"] {
    grid-template-columns: repeat(var(--gf-cols-mobile, 2), 1fr);
  }

  .feedgrid-grid[data-fg-layout="slider"] .feedgrid-item {
    flex: 0 0 var(--gf-slider-item-mobile, calc((100% - 4px) / 2));
  }

  .feedgrid-grid[data-fg-layout="collage"] {
    flex-direction: column;
  }

  .feedgrid-grid[data-fg-layout="collage"] .feedgrid-featured {
    flex: none;
    width: 100%;
  }

  .feedgrid-grid[data-fg-layout="collage"] .feedgrid-small-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .feedgrid-grid[data-fg-layout="highlight"] {
    flex-direction: column;
  }

  .feedgrid-grid[data-fg-layout="highlight"] .feedgrid-featured {
    flex: none;
    width: 100%;
  }
}

/* === SLIDER ARROWS === */

.feedgrid-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: white;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #333;
  z-index: 3;
  opacity: 1;
  transition: opacity 200ms ease;
}

.feedgrid-arrow--prev {
  left: -14px;
}

.feedgrid-arrow--next {
  right: -14px;
}

.feedgrid-arrow[disabled] {
  opacity: 0;
  pointer-events: none;
}

.feedgrid-arrow:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

.feedgrid-item:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}

/* === POWERED-BY BADGE === */

.feedgrid-powered {
  text-align: center;
  margin-top: 12px;
  font-size: 11px;
  color: #999;
}

.feedgrid-powered a {
  color: #999;
  text-decoration: none;
}

.feedgrid-powered a:hover {
  color: #666;
}

/* === SHOPPABLE HOTSPOTS === */

/* Wrapper: zero-size anchor point; overflow:visible lets tooltip escape item's
   overflow:hidden; pointer-events:auto so hover/touch work per-pin.
   Clicks in empty space fall through because the wrapper has no dimensions —
   only the visible pin dot and tooltip capture events. */
.feedgrid-hotspot-wrapper {
  position: absolute;
  width: 0;
  height: 0;
  overflow: visible;
  z-index: 10;
  pointer-events: auto;
}

/* Pin: pointer-events:auto so CSS :hover fires reliably.
   Clicks bubble up to the item's lightbox handler. */
.feedgrid-hotspot {
  position: absolute;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.feedgrid-hotspot-dot {
  width: 7px;
  height: 7px;
  background: #4f46e5;
  border-radius: 50%;
}

@keyframes gf-pulse {
  0%, 100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.feedgrid-hotspot {
  animation: gf-pulse 2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .feedgrid-hotspot {
    animation: none;
  }
}

/* ── Lightbox ── */
.feedgrid-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 200ms ease;
  pointer-events: none;
}
.feedgrid-lightbox.gf-open {
  opacity: 1; pointer-events: auto;
}
.feedgrid-lightbox-card {
  position: relative;
  background: white; border-radius: 12px;
  max-width: 420px; width: 90%; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transform: translateY(20px); transition: transform 200ms ease;
}
.feedgrid-lightbox.gf-open .feedgrid-lightbox-card {
  transform: translateY(0);
}
.feedgrid-lightbox-image {
  position: relative; width: 100%;
}
.feedgrid-lightbox-image img {
  width: 100%; display: block; border-radius: 12px 12px 0 0;
}
.feedgrid-lightbox-image video {
  width: 100%; display: block; border-radius: 12px 12px 0 0;
}
.feedgrid-tiktok-embed {
  width: 100%; min-height: 560px; display: block;
  border: none; border-radius: 12px 12px 0 0; background: #000;
}
.feedgrid-lightbox-close {
  position: absolute; top: 10px; right: 10px; z-index: 10;
  width: 32px; height: 32px; background: rgba(0,0,0,0.5);
  border-radius: 50%; border: none; cursor: pointer;
  color: white; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.feedgrid-lightbox-body { padding: 16px; }
.feedgrid-lightbox-profile {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.feedgrid-lightbox-avatar {
  width: 28px; height: 28px; border-radius: 50%;
}
.feedgrid-lightbox-username {
  font-size: 13px; font-weight: 600; color: #333;
}
.feedgrid-lightbox-time {
  font-size: 11px; color: #999; margin-left: auto;
}
.feedgrid-lightbox-caption {
  font-size: 13px; color: #555; line-height: 1.5; margin-bottom: 12px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.feedgrid-lightbox-caption.gf-expanded {
  -webkit-line-clamp: unset;
}
.feedgrid-lightbox-products {
  border-top: 1px solid #f0f0f0; padding-top: 12px;
}
.feedgrid-lightbox-products-label {
  font-size: 10px; font-weight: 600; color: #999;
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}
.feedgrid-lightbox-product {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; background: #f9f9f9; border-radius: 8px;
  cursor: pointer; text-decoration: none; color: inherit;
  margin-bottom: 6px;
}
.feedgrid-lightbox-product:hover { background: #f0f0ff; }
.feedgrid-lightbox-product-thumb {
  width: 44px; height: 44px; border-radius: 6px;
  object-fit: cover; flex-shrink: 0;
}
.feedgrid-lightbox-product-title {
  font-size: 13px; font-weight: 600; color: #333;
}
.feedgrid-lightbox-product-variant {
  font-size: 12px; color: #4f46e5; font-weight: 500;
}
.feedgrid-lightbox-source {
  display: block; text-align: center; margin-top: 12px;
  font-size: 12px; color: #999; text-decoration: none;
}
.feedgrid-lightbox-source:hover { color: #666; }
/* Navigation arrows */
.feedgrid-lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; background: rgba(255,255,255,0.9);
  border-radius: 50%; border: none; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #333;
}
.feedgrid-lightbox-nav--prev { left: -50px; }
.feedgrid-lightbox-nav--next { right: -50px; }
.feedgrid-lightbox-nav[disabled] {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.feedgrid-lightbox-nav:focus-visible {
  outline: 2px solid #4f46e5;
  outline-offset: 2px;
}
.feedgrid-lightbox-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
/* Mobile full-screen */
@media (max-width: 749px) {
  .feedgrid-lightbox-card {
    max-width: 100%; width: 100%; height: 100%;
    max-height: 100vh; border-radius: 0;
  }
  .feedgrid-lightbox-image img,
  .feedgrid-lightbox-image video,
  .feedgrid-tiktok-embed { border-radius: 0; }
  .feedgrid-lightbox-nav--prev { left: 8px; }
  .feedgrid-lightbox-nav--next { right: 8px; }

  .feedgrid-tooltip {
    max-width: 110px;
    padding: 5px 8px;
  }
  .feedgrid-tooltip-title {
    font-size: 10px;
  }
  .feedgrid-tooltip-cta {
    font-size: 10px;
  }
}
