/* Full-height, snap-scrolling video feed for the Gallery's Clips tab. */
.site-main:has(.community-home-reels) {
  width: 100%;
  max-width: none;
  min-height: 0;
  padding: 0;
  display: flex;
}

.community-home-reels {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 0.45rem clamp(0.75rem, 2vw, 1.5rem) 0.75rem;
}

.gallery-reels-heading {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 920px);
  min-height: 3.1rem;
  margin: 0 auto 0.4rem;
}

.gallery-reels-back,
.gallery-reels-library {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.5rem;
  width: fit-content;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: color-mix(in srgb, var(--bg2) 82%, transparent);
  font-size: 0.86rem;
  font-weight: 650;
}

.gallery-reels-back { justify-self: start; }
.gallery-reels-library { justify-self: end; }
.gallery-reels-back:hover,
.gallery-reels-library:hover { border-color: var(--accent); color: var(--ink); }
.gallery-reels-back:first-letter { font-size: 1.3rem; }

.gallery-reels-title { text-align: center; }
.gallery-reels-title h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.15;
}
.gallery-reels-title p {
  margin: 0.12rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.gallery-reels-stage {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
  align-items: stretch;
  gap: 1rem;
  width: min(100%, 1440px);
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
}

.gallery-reels-feed {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 360px;
  max-height: 900px;
  height: calc(100dvh - 190px);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  touch-action: pan-y;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 1.15rem;
  background: #03070d;
  box-shadow: 0 18px 55px rgb(0 0 0 / 32%);
  -webkit-overflow-scrolling: touch;
}
.gallery-reels-feed::-webkit-scrollbar { display: none; }
.gallery-reels-feed:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.gallery-reels-up-next {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
  min-height: 0;
  max-height: 900px;
  height: calc(100dvh - 190px);
  padding: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.15rem;
  background: color-mix(in srgb, var(--bg1) 84%, transparent);
  box-shadow: 0 18px 55px rgb(0 0 0 / 20%);
}
.gallery-reels-up-next-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
}
.gallery-reels-up-next-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.02rem;
}
.gallery-reels-up-next-heading p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.gallery-reels-up-next-count {
  display: grid;
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 50%;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg0));
  font-size: 0.76rem;
  font-weight: 700;
}
.gallery-reels-up-next-list {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  align-content: start;
  gap: 0.7rem;
  min-height: 0;
  padding: 0.1rem 0.15rem 0.1rem 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--line) transparent;
}
.gallery-reels-up-next-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--bg0) 72%, var(--bg2));
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
  -webkit-tap-highlight-color: transparent;
}
.gallery-reels-up-next-item:hover,
.gallery-reels-up-next-item:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg1));
  transform: translateY(-2px);
}
.gallery-reels-up-next-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gallery-reels-up-next-poster {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 9;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: var(--bg0);
}
.gallery-reels-up-next-poster > img { width: 100%; height: 100%; object-fit: cover; }
.gallery-reels-up-next-poster > span:first-child { font-size: 1.8rem; }
.gallery-reels-up-next-play {
  position: absolute;
  right: 0.45rem;
  bottom: 0.45rem;
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 42%);
  border-radius: 50%;
  color: #fff;
  background: rgb(3 8 14 / 65%);
  font-size: 0.72rem;
}
.gallery-reels-up-next-copy {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  min-width: 0;
  padding: 0.65rem 0.7rem 0.75rem;
}
.gallery-reels-up-next-copy strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.gallery-reels-up-next-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-reels-up-next-empty {
  margin: auto 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
}

.gallery-reel {
  position: relative;
  isolation: isolate;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #03070d;
}

.gallery-reel-video {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #03070d;
}
.gallery-reel-landscape .gallery-reel-video { object-fit: contain; }

.gallery-reel-vignette {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgb(0 0 0 / 30%) 0%, transparent 20%, transparent 48%, rgb(0 0 0 / 15%) 62%, rgb(0 0 0 / 82%) 100%);
}

.gallery-reel-source {
  position: absolute;
  top: max(0.85rem, env(safe-area-inset-top));
  left: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: calc(100% - 6rem);
  padding: 0.45rem 0.7rem;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 999px;
  color: #fff;
  background: rgb(3 8 14 / 48%);
  backdrop-filter: blur(10px);
  font-size: 0.78rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-reel-play {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 3.65rem;
  height: 3.65rem;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid rgb(255 255 255 / 48%);
  border-radius: 50%;
  color: #fff;
  background: rgb(3 8 14 / 50%);
  box-shadow: 0 6px 24px rgb(0 0 0 / 28%);
  font-size: 1.35rem;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gallery-reel:hover .gallery-reel-play,
.gallery-reel-play:focus-visible,
.gallery-reel-video[data-paused="true"] + .gallery-reel-vignette + .gallery-reel-source + .gallery-reel-play {
  opacity: 1;
}
.gallery-reel-play:active { transform: translate(-50%, -50%) scale(0.94); }

.gallery-reel-actions {
  position: absolute;
  right: 0.7rem;
  bottom: calc(7.15rem + env(safe-area-inset-bottom));
  display: grid;
  gap: 0.85rem;
}
.gallery-reel-action {
  display: grid;
  justify-items: center;
  gap: 0.13rem;
  min-width: 2.9rem;
  min-height: 3rem;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.7rem;
  color: #fff;
  background: transparent;
  text-shadow: 0 1px 4px rgb(0 0 0 / 75%);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.gallery-reel-action > span { font-size: 1.55rem; line-height: 1; font-weight: 750; }
.gallery-reel-action small { font-size: 0.66rem; font-weight: 650; }
.gallery-reel-action:hover,
.gallery-reel-action:focus-visible { color: #fff; background: rgb(255 255 255 / 13%); }

.gallery-reel-caption {
  position: absolute;
  right: 4.35rem;
  bottom: calc(1.25rem + env(safe-area-inset-bottom));
  left: 1rem;
  color: #fff;
  text-shadow: 0 1px 4px rgb(0 0 0 / 80%);
}
.gallery-reel-author { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.55rem; font-size: 0.83rem; }
.gallery-reel-avatar {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 65%);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, #32d4ff, #6d63ff 52%, #f52d78);
  font-size: 0.75rem;
  font-weight: 800;
}
.gallery-reel-caption h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 1rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.gallery-reel-caption p {
  display: -webkit-box;
  margin: 0.35rem 0 0;
  overflow: hidden;
  color: rgb(255 255 255 / 90%);
  font-size: 0.83rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.gallery-reel-meta { display: flex; gap: 0.35rem; align-items: center; margin-top: 0.5rem; color: rgb(255 255 255 / 76%); font-size: 0.72rem; }

.gallery-reel-progress {
  position: absolute;
  right: 0.7rem;
  bottom: 0.45rem;
  left: 0.7rem;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 35%);
}
.gallery-reel-progress span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: #fff;
}

.gallery-reels-sentinel { flex: 0 0 1px; width: 100%; height: 1px; scroll-snap-align: none; }
.gallery-reels-sentinel[hidden] { display: none; }
.community-home-reels.js-reels-on .gallery-reels-pager { display: none; }
.gallery-reels-pager { justify-content: center; margin: 0.25rem auto 0; font-size: 0.76rem; }

@media (max-width: 860px) {
  .site-main:has(.community-home-reels) { padding: 0; }
  .community-home-reels { padding: 0; }
  .gallery-reels-heading {
    width: 100%;
    min-height: 3rem;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem;
    margin: 0;
  }
  .gallery-reels-back,
  .gallery-reels-library { min-height: 2.25rem; padding: 0.28rem 0.55rem; font-size: 0.76rem; }
  .gallery-reels-title h1 { font-size: 0.98rem; }
  .gallery-reels-title p { font-size: 0.66rem; }
  .gallery-reels-stage {
    display: flex;
    width: 100%;
    margin: 0;
    flex: 1 1 0;
  }
  .gallery-reels-up-next { display: none; }
  .gallery-reels-feed {
    width: 100%;
    height: auto;
    max-height: none;
    min-height: 0;
    margin: 0;
    flex: 1 1 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }
  .gallery-reel-actions { right: 0.45rem; bottom: calc(6.8rem + env(safe-area-inset-bottom)); gap: 0.65rem; }
  .gallery-reel-action { min-width: 2.55rem; min-height: 2.7rem; }
  .gallery-reel-action > span { font-size: 1.4rem; }
  .gallery-reel-caption { right: 3.5rem; left: 0.8rem; bottom: calc(1.05rem + env(safe-area-inset-bottom)); }
  .gallery-reel-caption h2 { font-size: 0.94rem; }
}

@media (max-width: 420px) {
  .gallery-reels-back span { display: none; }
  .gallery-reels-back { font-size: 1.2rem; padding-inline: 0.7rem; }
  .gallery-reels-library { font-size: 0.7rem; }
  .gallery-reel-caption h2 { font-size: 0.9rem; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-reel-play,
  .gallery-reels-up-next-item { transition: none; }
}
