@import url('../tokens.css');

.pager {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.pager__title {
  margin: 0;
  text-align: center;
  color: #232030;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
}

/* Market-style pages show only the page numbers, no preamble heading. */
.category-page.is-category-discovery-page .pager__title {
  display: none;
}

.pager__row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 42px;
}

.pager__pages {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.pager__btn {
  position: relative;
  isolation: isolate;
  min-width: 72px;
  width: 72px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #232030;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  transition: color 0.18s ease;
}

.pager__btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: #eee5da;
  box-shadow: none;
  transform: scale(1);
  transform-origin: center;
  transition: transform 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.pager__label,
.pager__arrow-icon {
  position: relative;
  z-index: 1;
  transform: none;
  transition: none;
}

.pager__btn:not(:disabled):not(.pager__btn--active):not(.pager__btn--arrow):hover,
.pager__btn:not(:disabled):not(.pager__btn--active):not(.pager__btn--arrow):focus-visible {
  background: transparent;
  box-shadow: none;
}

.pager__btn:not(:disabled):not(.pager__btn--active):not(.pager__btn--arrow):hover::before,
.pager__btn:not(:disabled):not(.pager__btn--active):not(.pager__btn--arrow):focus-visible::before,
.pager__btn--arrow:not(:disabled):hover::before,
.pager__btn--arrow:not(:disabled):focus-visible::before {
  transform: scale(1.04);
}

.pager__btn:focus-visible {
  outline: 2px solid rgba(35, 32, 48, 0.35);
  outline-offset: 6px;
}

.pager__btn--active {
  color: #232030;
  outline: 0;
  box-shadow: none;
}

.pager__btn--active::before {
  background: #b3bfb2;
  box-shadow: inset 0 0 0 2px #829181;
}

.pager__btn--arrow .icon {
  display: none;
}

.pager__btn--arrow {
  padding: 0;
}

.pager__btn--arrow::before {
  background: #b3bfb2;
}

.pager__arrow-icon {
  width: 22px;
  height: 14px;
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.pager__arrow-icon--inactive {
  display: none;
}

.pager__btn--arrow:disabled .pager__arrow-icon--active {
  display: none;
}

.pager__btn--arrow:disabled .pager__arrow-icon--inactive {
  display: block;
}

.pager__btn--arrow:disabled {
  cursor: not-allowed;
  box-shadow: none;
  opacity: 1;
}

.pager__btn--arrow:disabled::before {
  background: #dcddd3;
}

.pager__dots {
  position: relative;
  isolation: isolate;
  min-width: 72px;
  width: 72px;
  height: 54px;
  padding: 0;
  border-radius: 999px;
  background: #eee5da;
  color: #232030;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 1.6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: default;
}

.pager__dots:hover {
  background: #eee5da;
  color: #232030;
  box-shadow: none;
}

@media (max-width: 980px) {
  .pager__row {
    width: 100%;
    overflow-x: auto;
    padding: 4px 2px 10px;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .pager__row {
    gap: 10px;
    justify-content: center;
    overflow-x: visible;
  }

  .pager__pages {
    gap: 6px;
  }

  .pager__btn,
  .pager__dots {
    min-width: 54px;
    width: 54px;
  }
}

/* Extra-narrow phones (≤360px, e.g. iPhone SE / 320px): the 54px buttons +
   gaps still push the page-number row a touch past the edge, clipping the
   arrow. Tighten to 48px (still ≥44px WCAG tap target) with minimal gaps so
   the full pager fits without clipping. */
@media (max-width: 360px) {
  .pager__row {
    gap: 8px;
    flex-wrap: wrap;
  }
  .pager__pages {
    gap: 3px;
  }
  .pager__btn,
  .pager__dots {
    min-width: 48px;
    width: 48px;
    height: 48px;
  }
}
