/* ==========================================================================
   Collection Tiles — interactive "tiles in action" demo (marketing site only)
   --------------------------------------------------------------------------
   Styles the fake storefront/collection grid, the placeholder product cards,
   the scroll-reveal callouts that point at each injected tile, and the
   self-contained faux-video tile. The TILES themselves are rendered by the
   real app code in /assets/demo/collection-tiles.{js,css} — this file only
   styles the surrounding demo and the callouts.
   ========================================================================== */

/* ---- Storefront frame ---------------------------------------------------- */
.ct-demo { max-width: 1080px; margin: 40px auto 0; padding: 0 24px; }
.ct-demo__frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ct-demo__chrome {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: #fbfcfe;
}
.ct-demo__dots { display: flex; gap: 6px; }
.ct-demo__dots i { width: 11px; height: 11px; border-radius: 50%; background: #d3dae6; display: block; }
.ct-demo__url {
  flex: 1; font-size: .82rem; color: var(--text-faint);
  background: #eef2f9; border-radius: 7px; padding: 6px 12px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ct-demo__store { padding: 22px 22px 6px; }
.ct-demo__store-name { font-weight: 800; letter-spacing: .14em; color: var(--ink); font-size: 1.05rem; }
.ct-demo__store-sub { color: var(--text-faint); font-size: .85rem; margin-top: 2px; }

/* ---- Product grid (mimics a Shopify collection) -------------------------- */
.ct-demo__grid {
  list-style: none; margin: 0; padding: 18px 22px 28px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 16px;
}
@media (max-width: 720px) {
  .ct-demo__grid { grid-template-columns: repeat(2, 1fr); }
  /* Trim the leftover product tail after the wide tile on the 2-col layout. */
  .ct-demo__grid .ct-demo__product--xtra { display: none; }
}

.ct-demo__product { display: flex; flex-direction: column; }
.ct-demo__thumb {
  display: block; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: #eef2f9;
}
.ct-demo__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ct-demo__title { margin: 10px 0 2px; font-size: .92rem; color: var(--text); font-weight: 500; }
.ct-demo__title:hover { text-decoration: none; color: var(--ink); }
.ct-demo__price { font-size: .9rem; color: var(--text-soft); }

/* The injected tile wrapper becomes the anchor for its callout. */
.ct-demo .collection-tile-wrapper { position: relative; }

/* Keep demo links from navigating (handled in JS too). */
.ct-demo a { cursor: pointer; }

/* ---- Video tile (self-contained auto-playing placeholder) ---------------- */
/* The video tile renders (via the real app) as an image-only tile using a dark
   "poster". We overlay a continuously-animating "now playing" scene so it reads
   as a silent looping clip — no media file, no play button. Swap in a real clip
   by giving the tile type:"video" + video_url (see README); the overlay then
   steps aside (JS skips it when a real <video> is present). */
.ct-demo .collection-tile-wrapper[data-tile-id="video"] .collection-tile { position: relative; }

.ct-demo-video-overlay {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: inherit; z-index: 1;
  background:
    radial-gradient(120% 80% at 28% 18%, rgba(109,91,208,.55), transparent 60%),
    radial-gradient(120% 80% at 82% 88%, rgba(45,127,249,.50), transparent 55%),
    #0a1428;
}
.ct-demo-video-overlay::before { /* drifting light blobs → ambient motion */
  content: ""; position: absolute; inset: -25%;
  background:
    radial-gradient(closest-side, rgba(255,255,255,.16), transparent),
    radial-gradient(closest-side, rgba(255,255,255,.10), transparent);
  background-size: 55% 55%, 42% 42%; background-repeat: no-repeat;
  background-position: 8% 18%, 78% 72%;
  animation: ctDrift 7s ease-in-out infinite alternate;
}
.ct-demo-video-overlay::after { /* slow sheen sweep → suggests playback */
  content: ""; position: absolute; top: 0; bottom: 0; width: 55%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.18), transparent);
  transform: translateX(-170%); animation: ctSheen 3.8s ease-in-out infinite;
}
/* Looping progress bar — the strongest "this is playing" signal. */
.ct-demo-video-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; z-index: 3; background: rgba(255,255,255,.20); }
.ct-demo-video-bar i { display: block; height: 100%; width: 0; background: #fff; animation: ctProgress 6s linear infinite; }
.ct-demo-video-badge {
  position: absolute; left: 10px; bottom: 12px; z-index: 3;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(10,20,40,.62); color: #fff; font-size: .72rem; font-weight: 600;
  padding: 5px 10px; border-radius: 999px; backdrop-filter: blur(3px);
}
.ct-demo-video-badge svg { width: 13px; height: 13px; }

@keyframes ctDrift { from { background-position: 8% 18%, 78% 72%; } to { background-position: 24% 32%, 62% 58%; } }
@keyframes ctSheen { 0% { transform: translateX(-170%); } 55%,100% { transform: translateX(320%); } }
@keyframes ctProgress { from { width: 0; } to { width: 100%; } }

/* ---- Callouts (point at each tile, reveal on scroll) --------------------- */
.ct-demo-callout {
  position: absolute; top: 50%; z-index: 30; width: 230px;
  background: var(--ink); color: #eaf0fb;
  border-radius: 14px; padding: 15px 17px; box-shadow: 0 16px 40px rgba(10,20,40,.30);
  opacity: 0; transition: opacity .45s ease, transform .45s ease; pointer-events: none;
}
.ct-demo-callout__title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #fff; font-size: .98rem; margin-bottom: 5px; }
.ct-demo-callout__title svg { width: 16px; height: 16px; color: var(--accent-light); flex: none; }
.ct-demo-callout__body { font-size: .86rem; line-height: 1.5; color: #aebbd4; }
.ct-demo-callout__arrow { position: absolute; top: 50%; width: 0; height: 0; border-style: solid; }

/* Right-side bubble (points left toward the tile) */
.ct-demo-callout.side-right { left: calc(100% + 20px); transform: translate(14px, -50%); }
.ct-demo-callout.side-right .ct-demo-callout__arrow {
  left: -9px; transform: translateY(-50%);
  border-width: 9px 9px 9px 0; border-color: transparent var(--ink) transparent transparent;
}
/* Left-side bubble (points right toward the tile) */
.ct-demo-callout.side-left { right: calc(100% + 20px); transform: translate(-14px, -50%); }
.ct-demo-callout.side-left .ct-demo-callout__arrow {
  right: -9px; transform: translateY(-50%);
  border-width: 9px 0 9px 9px; border-color: transparent transparent transparent var(--ink);
}
.ct-demo-callout.is-visible { opacity: 1; transform: translate(0, -50%); }

/* Mobile / narrow: callout drops below the tile, full width, pointing up. */
@media (max-width: 720px) {
  .ct-demo-callout,
  .ct-demo-callout.side-left,
  .ct-demo-callout.side-right {
    position: absolute; top: calc(100% + 12px); left: 0; right: auto;
    width: 100%; transform: translateY(10px);
  }
  .ct-demo-callout.is-visible { transform: translateY(0); }
  .ct-demo-callout__arrow,
  .ct-demo-callout.side-left .ct-demo-callout__arrow,
  .ct-demo-callout.side-right .ct-demo-callout__arrow {
    top: -9px; left: 24px; right: auto; transform: none;
    border-width: 0 9px 9px 9px; border-color: transparent transparent var(--ink) transparent;
  }
}

/* Respect reduced-motion: no slide/fade, no faux-video animation. */
@media (prefers-reduced-motion: reduce) {
  .ct-demo-callout { transition: none; }
  .ct-demo-callout,
  .ct-demo-callout.side-left,
  .ct-demo-callout.side-right { transform: translateY(-50%); }
  @media (max-width: 720px) {
    .ct-demo-callout, .ct-demo-callout.side-left, .ct-demo-callout.side-right { transform: none; }
  }
  .ct-demo-video-overlay::before,
  .ct-demo-video-overlay::after,
  .ct-demo-video-bar i { animation: none; }
  .ct-demo-video-bar i { width: 45%; } /* static fill instead of looping */
}
