/* "See it in action": grouped grid of short, silent, looping product clips.
   Videos lazy-load near the viewport, play only while visible, and fall back to
   posters under prefers-reduced-motion or Save-Data. Loaded by index.html. */

.demos {
  background: var(--ink-900);
  color: var(--paper);
  padding: var(--s-9, 96px) 0;
  overflow: hidden;
}

.demos .eyebrow { display: inline-block; color: var(--brand-300); }

.demos__head {
  max-width: 720px;
  margin: 0 auto var(--s-7, 48px);
  text-align: center;
}

.demos__head h2 {
  margin-top: 12px;
  color: var(--paper);
}

.demos__head h2 em { color: var(--brand-300); }

.demos__head p {
  margin: 16px auto 0;
  max-width: 58ch;
  color: var(--ink-300);
}

.demos__toggle {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-300);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}

.demos__toggle:hover,
.demos__toggle:focus-visible { color: var(--paper); border-color: rgba(255, 255, 255, 0.4); }
.demos__toggle[hidden] { display: none; }

.demos__toggle-icon {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
}

.demos__toggle[aria-pressed="true"] .demos__toggle-icon {
  border-right: 0;
  border-left: 0;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 9px solid currentColor;
}

/* ---- Groups ---- */
.demo-group + .demo-group { margin-top: var(--s-7, 48px); }

.demo-group__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.demo-group__title {
  margin: 0;
  font: 700 20px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--paper);
}

.demo-group__line {
  margin: 0;
  font-size: var(--fs-small, 15px);
  color: var(--ink-300);
}

.demo-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.demo-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Single-clip group: clip on the left, copy on the right */
.demo-grid--1 { grid-template-columns: minmax(0, 1fr); }
.demo-grid--1 .demo-tile {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
}
.demo-grid--1 .demo-tile__body { padding: 24px 28px; }
.demo-grid--1 .demo-tile__title { font-size: 22px; }

/* ---- Tile ---- */
.demo-tile {
  position: relative;
  margin: 0;
  border-radius: 16px;
  overflow: hidden;
  background: #0F2436;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  transition: transform .35s var(--ease, ease), border-color .35s ease, box-shadow .35s ease;
}

.demo-tile:hover,
.demo-tile:focus-within {
  transform: translateY(-3px);
  border-color: rgba(77, 155, 208, 0.55);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}

.demo-tile__media {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  background: #F4F6F9;
  cursor: zoom-in;
  aspect-ratio: 1280 / 618;
  overflow: hidden;
  line-height: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.demo-tile__media:focus-visible {
  outline: 2px solid var(--brand-300);
  outline-offset: -2px;
}

.demo-tile__media video,
.demo-tile__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top left;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Transparent layer above the video: right-click / long-press hits this, not the media */
.demo-tile__guard,
.demo-lightbox__guard {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: transparent;
  -webkit-touch-callout: none;
}

.demo-tile__expand {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(10, 27, 42, 0.72);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.demo-tile:hover .demo-tile__expand,
.demo-tile__media:focus-visible .demo-tile__expand { opacity: 1; transform: none; }

.demo-tile__expand svg { width: 16px; height: 16px; }

.demo-tile__body { padding: 16px 18px 18px; }

.demo-tile__title {
  margin: 0;
  font: 700 17px/1.3 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--paper);
}

.demo-tile__cap {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-300);
}

/* Fade the clip in once it has a frame to show */
.demo-tile__media video { transition: opacity .5s ease; }
.demo-tile__media.is-loading video { opacity: .85; }

/* ---- Lightbox ---- */
.demo-lightbox {
  width: min(1180px, 94vw);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  background: #0F2436;
  color: var(--paper);
  overflow: hidden;
}

.demo-lightbox::backdrop {
  background: rgba(6, 16, 26, 0.82);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.demo-lightbox__media {
  position: relative;
  background: #F4F6F9;
  line-height: 0;
  aspect-ratio: 1280 / 618;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.demo-lightbox__media video {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.demo-lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
}

.demo-lightbox__title { margin: 0; font: 700 18px/1.3 var(--font-display); color: var(--paper); }
.demo-lightbox__cap { margin: 4px 0 0; font-size: 14px; color: var(--ink-300); }

.demo-lightbox__btns { display: flex; gap: 8px; flex: 0 0 auto; }

.demo-lightbox__btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--paper);
  font: 600 13px/1 var(--font-sans);
  cursor: pointer;
}

.demo-lightbox__btn:hover,
.demo-lightbox__btn:focus-visible { background: rgba(255, 255, 255, 0.1); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .demo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .demos { padding: var(--s-8, 64px) 0; }
  /* Phones: each group becomes a swipeable row to keep the section short */
  .demo-grid,
  .demo-grid--2 {
    display: flex;
    gap: 12px;
    margin: 0 -24px;
    padding: 0 24px 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 24px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .demo-grid::-webkit-scrollbar { display: none; }
  .demo-grid .demo-tile { flex: 0 0 86%; scroll-snap-align: start; }
  .demo-grid--1 .demo-tile { flex-basis: 100%; display: block; }
  .demo-tile:hover,
  .demo-tile:focus-within { transform: none; }
  .demo-grid--1 .demo-tile__body { padding: 16px 18px 18px; }
  .demo-grid--1 .demo-tile__title { font-size: 17px; }
  .demo-lightbox__bar { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-tile,
  .demo-tile__expand,
  .demo-tile__media video { transition: none; }
  .demo-tile:hover,
  .demo-tile:focus-within { transform: none; }
}
