/* Poolly Guides: native vertical-scroll-driven gallery. This file is scoped to
   the Guides landing page, and doesn't affect the Studio or other card grids. */
.guides-gallery {
  width: 100%;
  max-width: 100%;
  padding: 20px 0 80px;
}
.guides-gallery__sticky { position: relative; width: 100%; }
.guides-gallery__viewport { width: 100%; max-width: 100%; }
.guides-gallery__progress { display: none; }

/* Accessible, non-animated desktop layout is the default and also the
   reduced-motion / short-screen fallback. */
@media (min-width: 769px) {
  .guides-gallery:not(.is-pinned) .guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    width: min(calc(100% - 48px), var(--max));
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    border: 0;
  }
  .guides-gallery:not(.is-pinned) .guide-card {
    min-width: 0;
    min-height: 440px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--line);
  }
}

/* Scroll wrapper is as tall as one visible gallery stage plus the actual
   horizontal travel distance. JS measures this from the real rendered track. */
.guides-gallery.is-pinned {
  padding: 0;
  height: calc(var(--guides-stage-height) + var(--guides-travel));
}
.guides-gallery.is-pinned .guides-gallery__sticky {
  position: sticky;
  top: var(--guides-sticky-top);
  width: 100%;
  height: var(--guides-stage-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: visible;
}
.guides-gallery.is-pinned .guides-gallery__viewport {
  flex: 0 0 auto;
  width: 100%;
  overflow: hidden;
  overflow: clip;
}
.guides-gallery.is-pinned .guide-grid {
  display: flex;
  align-items: stretch;
  flex-wrap: nowrap;
  gap: 0;
  box-sizing: border-box;
  width: max-content;
  min-width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 max(24px, calc((100vw - var(--max)) / 2));
  border: 0;
  overflow: visible;
  scroll-snap-type: none;
  transform: translate3d(0,0,0);
  will-change: transform;
}
.guides-gallery.is-pinned .guide-card {
  position: relative;
  flex: 0 0 clamp(300px, 27vw, 390px);
  width: clamp(300px, 27vw, 390px);
  min-width: 0;
  height: clamp(330px, calc(100svh - 180px), 560px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 38px 34px;
  border: 1px solid var(--line);
  border-right: 0;
  background: #fff;
  box-sizing: border-box;
  scroll-snap-align: none;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.guides-gallery.is-pinned .guide-card:last-child { border-right: 1px solid var(--line); }
.guides-gallery .guide-card h2 { margin-top: auto; }
.guides-gallery .guide-card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -4px;
  position: relative;
  z-index: 1;
}
@media (hover: hover) {
  .guides-gallery.is-pinned .guide-card:hover {
    background-color: var(--blue);
    border-color: var(--blue);
    color: #fff;
  }
  .guides-gallery.is-pinned .guide-card:hover .num,
  .guides-gallery.is-pinned .guide-card:hover > span:last-child { color: #d9ebf3; }
}
.guides-gallery.is-pinned .guides-gallery__progress {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(calc(100% - 48px), var(--max));
  max-width: 100%;
  margin: 18px auto 0;
  color: var(--blue);
  font-size: 11px;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.guides-gallery__progress-rail {
  display: block;
  width: min(28vw, 280px);
  height: 2px;
  background: rgba(18,77,105,.15);
}
.guides-gallery__progress-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left center;
}

/* Touch users retain ordinary horizontal swiping, without taking control of
   their vertical scroll. No overflow is permitted outside the viewport. */
@media (max-width: 768px) {
  .guides-gallery { padding: 20px 0 70px; }
  .guides-gallery__viewport {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
  }
  .guides-gallery .guide-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    box-sizing: border-box;
    width: max-content;
    max-width: none;
    margin: 0;
    padding: 12px 15px;
    border: 0;
  }
  .guides-gallery .guide-card {
    flex: 0 0 min(84vw, 360px);
    width: min(84vw, 360px);
    min-width: 0;
    min-height: min(60vh, 470px);
    display: flex;
    flex-direction: column;
    padding: 30px 26px;
    border: 1px solid var(--line);
    border-right: 0;
    background: #fff;
    scroll-snap-align: start;
  }
  .guides-gallery .guide-card:last-child { border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  .guides-gallery .guide-card,
  .guides-gallery .guide-grid { animation: none !important; transition: none !important; }
}
/* studio-panel-tabs has generic portrait-strip overflow rules. Keep those
   rules on other pages, but prevent a second scrollbar inside Guides cards. */
.guides-gallery:not(.is-pinned) .guide-grid {
  overflow: visible;
  scroll-snap-type: none;
}
@media (max-width: 768px) {
  .guides-gallery .guide-grid {
    overflow: visible;
    scroll-snap-type: none;
  }
}
