/* ==================================================================
   Category page -- "Special" layout
   Markup: WooCommerce's archive + hooks in inc/category-layout.php.
   Loaded only with that layout, after single-product-special.css, which
   supplies the --pdp-* variables (body.pdp-enh) and the Back bar styles.
   Breakpoints match the product page: 768px mobile, 576px small phone.
   ================================================================== */

/* Content starts close under the header. !important because the Shop page
   carries .post-type-archive-product .content-area { padding: 3rem 0 !important }
   in style.css, which also applied to product search. */
body.cat-enh .content-area {
  padding-top: 16px !important;
}

@media (max-width: 767.98px) {
  body.cat-enh .content-area {
    padding-top: 12px !important;
  }
}

/* The Shop page also adds 26px on top of the page wrapper
   (home-v1-premium.css: body.woocommerce-shop .site--container); the
   content-area padding above is the only gap this layout wants. */
body.cat-enh #page > .site--container,
body.cat-enh #page > .container-fluid {
  padding-top: 0;
}

/* ---------- Header: banner, title + count, description, chips ---------- */

body.cat-enh .woocommerce-products-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 0 0 18px;
}

/* DOM order is title, banner, count, description, chips; the banner goes
   first visually, everything else keeps its order. */
body.cat-enh .pahla-category-banner {
  order: -2;
  flex: 0 0 100%;
  margin: var(--cat-banner-mt-d, 0px) 0 var(--cat-banner-mb-d, 8px) !important;
  border-radius: var(--cat-banner-r-d, 18px) !important;
  box-shadow: none !important;
  overflow: hidden;
}

/* Banner frame: Natural / Set a height / Set an aspect ratio, plus fit and
   focus -- per device, from the Customizer (same strategy as the slider). */
body.cat-enh .pahla-category-banner {
  background: var(--pdp-soft); /* shows only around a Contain image */
}

body.cat-enh .pahla-category-banner img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: var(--cat-banner-h-d, auto) !important;
  aspect-ratio: var(--cat-banner-ratio-d, auto);
  object-fit: var(--cat-banner-fit-d, cover);
  object-position: var(--cat-banner-pos-d, center center);
}

body.cat-enh .woocommerce-products-header__title {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.1;
  color: var(--pdp-ink);
}

body.cat-enh .cat-count {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pdp-primary) 9%, #fff 91%);
  color: var(--pdp-primary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

body.cat-enh :is(.term-description, .page-description) {
  flex: 0 0 100%;
  max-width: 88ch;
  margin: 0;
  color: var(--pdp-muted);
  font-size: .95rem;
  line-height: 1.7;
}

/* Clamp to the chosen number of lines ("Show all" = none, which is not a
   valid clamp value, so the rule simply does nothing). */
body.cat-enh :is(.term-description, .page-description).is-clamped:not(.is-open) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--cat-lines-d, 3);
  overflow: hidden;
}

body.cat-enh :is(.term-description, .page-description) p {
  margin: 0 0 .6em;
}

body.cat-enh :is(.term-description, .page-description) p:last-child {
  margin-bottom: 0;
}

body.cat-enh .cat-more {
  flex: 0 0 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  margin-top: -4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pdp-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
  cursor: pointer;
}

body.cat-enh .cat-more i {
  font-size: 10px;
  transition: transform .2s ease;
}

body.cat-enh .cat-more[aria-expanded="true"] i {
  transform: rotate(180deg);
}

/* Subcategory chips */
body.cat-enh .cat-chips {
  flex: 0 0 100%;
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

body.cat-enh .cat-chips::-webkit-scrollbar {
  display: none;
}

body.cat-enh .cat-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 8px;
  border: 1px solid var(--pdp-line);
  border-radius: 999px;
  background: #fff;
  color: var(--pdp-ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .2s ease, background .2s ease;
}

body.cat-enh .cat-chip img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

body.cat-enh .cat-chip i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--pdp-icon);
  background: color-mix(in srgb, var(--pdp-icon) 10%, #fff 90%);
}

body.cat-enh .cat-chip small {
  font-size: 11px;
  font-weight: 700;
  color: var(--pdp-muted);
}

body.cat-enh .cat-chip:hover {
  border-color: var(--pdp-ink);
  color: var(--pdp-ink);
}

body.cat-enh .cat-chip.is-active {
  border-color: var(--pdp-primary);
  background: color-mix(in srgb, var(--pdp-primary) 8%, #fff 92%);
  color: var(--pdp-primary);
}

body.cat-enh .cat-chip.is-active small {
  color: var(--pdp-primary);
}

/* ---------- Toolbar: count · sort · per-row switch ---------- */

body.cat-enh .cat-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  padding: 10px 0;
  border-top: 1px solid var(--pdp-line);
  border-bottom: 1px solid var(--pdp-line);
}

body.cat-enh .cat-toolbar .woocommerce-result-count {
  float: none;
  margin: 0 auto 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--pdp-muted);
}

body.cat-enh .cat-toolbar .woocommerce-ordering {
  float: none;
  margin: 0;
}

body.cat-enh .cat-toolbar .woocommerce-ordering select {
  height: 40px;
  padding: 0 38px 0 16px;
  border: 1px solid var(--pdp-line);
  border-radius: 999px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%235b6777' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 14px center / 12px;
  color: var(--pdp-ink);
  font-size: 13px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

body.cat-enh .cat-toolbar .woocommerce-ordering select:focus-visible {
  outline: 2px solid var(--pdp-primary);
  outline-offset: 2px;
}

body.cat-enh .cat-view {
  display: none;
}

/* ---------- Pagination & empty state ---------- */

body.cat-enh nav.woocommerce-pagination {
  margin-top: 32px;
}

body.cat-enh nav.woocommerce-pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0 !important;
}

body.cat-enh nav.woocommerce-pagination ul li {
  float: none;
  border: 0 !important;
  overflow: visible;
}

body.cat-enh nav.woocommerce-pagination ul li a,
body.cat-enh nav.woocommerce-pagination ul li span {
  min-width: 42px;
  height: 42px;
  padding: 0 12px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--pdp-line);
  border-radius: 999px;
  background: #fff;
  color: var(--pdp-ink);
  font-weight: 700;
  line-height: 1;
}

body.cat-enh nav.woocommerce-pagination ul li a:hover {
  border-color: var(--pdp-ink);
  background: #fff;
  color: var(--pdp-ink);
}

body.cat-enh nav.woocommerce-pagination ul li span.current {
  border-color: var(--pdp-ink);
  background: var(--pdp-ink);
  color: #fff;
}

body.cat-enh .woocommerce-info {
  border: 1px solid var(--pdp-line);
  border-radius: 14px;
  background: var(--pdp-soft);
  color: var(--pdp-ink);
}

/* ---------- Mobile ---------- */

@media (max-width: 767.98px) {
  body.cat-enh .pdp-crumbbar {
    margin-bottom: 14px;
  }

  body.cat-enh .pahla-category-banner img {
    height: var(--cat-banner-h-m, auto) !important;
    aspect-ratio: var(--cat-banner-ratio-m, auto);
    object-fit: var(--cat-banner-fit-m, cover);
    object-position: var(--cat-banner-pos-m, center center);
  }

  body.cat-enh :is(.term-description, .page-description).is-clamped:not(.is-open) {
    -webkit-line-clamp: var(--cat-lines-m, 3);
  }

  body.cat-enh .pahla-category-banner {
    margin: var(--cat-banner-mt-m, 0px) 0 var(--cat-banner-mb-m, 8px) !important;
    border-radius: var(--cat-banner-r-m, 14px) !important;
  }

  body.cat-enh .woocommerce-products-header__title {
    font-size: 1.6rem;
  }

  body.cat-enh :is(.term-description, .page-description) {
    font-size: .9rem;
    line-height: 1.6;
  }

  /* Chips run edge to edge so the scroll reads as a scroll. */
  body.cat-enh .cat-chips {
    margin-left: calc(var(--pahla-m-gutter, 12px) * -1);
    margin-right: calc(var(--pahla-m-gutter, 12px) * -1);
    padding-left: var(--pahla-m-gutter, 12px);
    padding-right: var(--pahla-m-gutter, 12px);
  }

  body.cat-enh .cat-toolbar {
    gap: 8px;
    margin-bottom: 16px;
  }

  body.cat-enh .cat-toolbar .woocommerce-result-count {
    font-size: 12px;
  }

  body.cat-enh .cat-toolbar .woocommerce-ordering select {
    height: 36px;
    max-width: 150px;
    padding-left: 12px;
    font-size: 12px;
  }

  body.cat-enh .cat-view {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--pdp-line);
    border-radius: 999px;
  }

  body.cat-enh .cat-view__btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--pdp-muted);
    font-size: 12px;
    cursor: pointer;
  }

  body.cat-enh.cat-m-cols-1 .cat-view__btn[data-cols="1"],
  body.cat-enh.cat-m-cols-2 .cat-view__btn[data-cols="2"] {
    background: var(--pdp-ink);
    color: #fff;
  }
}

/* Small phones: the per-row choice decides the grid. */
@media (max-width: 575.98px) {
  body.cat-enh.cat-m-cols-2 ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.cat-enh.cat-m-cols-1 ul.products {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Two across: a compact card -- smaller type, icons in one row and the
     inquiry button on its own full-width line. */
  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card {
    border-radius: 12px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__thumb-link {
    padding: 6px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__body {
    gap: 6px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__title {
    font-size: .92rem;
    min-height: 0;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__price {
    font-size: .85rem;
    min-height: 0;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__meta {
    min-height: 0;
    gap: 4px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-chip {
    font-size: 9px;
    padding: 4px 6px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__actions {
    gap: 5px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__actions .pw-v2-icon-btn {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    font-size: 12px;
  }

  body.cat-enh.cat-m-cols-2 ul.products .pw-v2-card__actions .pw-v2-cta {
    flex: 1 1 100%;
    height: 32px;
    font-size: 10px;
    padding: 0 8px;
  }
}

/* ---------- Round thumbnail next to the title ---------- */

body.cat-enh .cat-avatar {
  order: -1; /* before the title; the banner (-2) stays above both */
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--pdp-line);
  overflow: hidden;
  background: var(--pdp-soft);
}

body.cat-enh .cat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 767.98px) {
  body.cat-enh .cat-avatar {
    flex-basis: 44px;
    width: 44px;
    height: 44px;
  }
}

/* ---------- Per-device show / hide (Customizer tabs) ----------
   A body class marks each thing switched OFF on a device; it is hidden
   only inside that device's range. */

@media (min-width: 768px) {
  body.cat-d-no-banner .pahla-category-banner,
  body.cat-d-no-thumb .cat-avatar,
  body.cat-d-no-desc :is(.term-description, .page-description),
  body.cat-d-no-desc .cat-more,
  body.cat-d-no-chips .cat-chips,
  body.cat-d-no-sticky .pahla-titlebar {
    display: none !important;
  }
}

@media (max-width: 767.98px) {
  body.cat-m-no-banner .pahla-category-banner,
  body.cat-m-no-thumb .cat-avatar,
  body.cat-m-no-desc :is(.term-description, .page-description),
  body.cat-m-no-desc .cat-more,
  body.cat-m-no-chips .cat-chips,
  body.cat-m-no-sticky .pahla-titlebar {
    display: none !important;
  }
}

/* Sticky title bar: shared component (.pahla-titlebar) in
   single-product-special.css; only the per-device switches above live here. */


/* The Read more button toggles with the hidden attribute; its own display
   rule above would otherwise override it. */
body.cat-enh .cat-more[hidden] {
  display: none;
}

/* ---------- Product search: refine-search box under the title ---------- */

body.cat-enh .cat-search {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  height: 48px;
  margin-top: 4px;
  padding: 0 5px 0 16px;
  border: 1px solid var(--pdp-line);
  border-radius: 999px;
  background: #fff;
}

body.cat-enh .cat-search:focus-within {
  border-color: var(--pdp-primary);
}

body.cat-enh .cat-search > i {
  color: var(--pdp-muted);
  font-size: 14px;
}

body.cat-enh .cat-search input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--pdp-ink);
  font-size: 15px;
}

body.cat-enh .cat-search button {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--pdp-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 767.98px) {
  body.cat-enh .cat-search {
    max-width: none;
    height: 44px;
  }

  /* 16px stops iOS zooming into the field. */
  body.cat-enh .cat-search input[type="search"] {
    font-size: 16px;
  }

  body.cat-enh .cat-search button {
    height: 34px;
    padding: 0 16px;
  }
}

/* Toolbar: the Shop page's own boxed result count / sort styles (from
   home-v1-premium.css) give way to the plain toolbar. */
body.cat-enh .cat-toolbar .woocommerce-result-count {
  margin: 0 auto 0 0 !important;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

body.cat-enh .cat-toolbar .woocommerce-ordering {
  margin: 0 !important;
}

/* Desktop / tablet: larger chips and category images. */
@media (min-width: 768px) {
  body.cat-enh .cat-chip {
    height: 46px;
    gap: 10px;
    padding: 0 18px 0 7px;
    font-size: 14px;
  }

  body.cat-enh .cat-chip img,
  body.cat-enh .cat-chip i {
    width: 32px;
    height: 32px;
  }

  body.cat-enh .cat-chip i {
    font-size: 13px;
  }

  body.cat-enh .cat-chip small {
    font-size: 12px;
  }

  body.cat-enh .cat-chips {
    gap: 10px;
  }
}

/* ------------------------------------------------------------------
   Chip row arrows (built by initChipArrows() in category-special.js).
   The wrapper takes the row's place in the header; each arrow and its
   edge fade appear only while there is more to scroll to on that side.
   Phones swipe, so they get the fade only.
   ------------------------------------------------------------------ */
body.cat-enh .cat-chips-wrap {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
}

body.cat-enh .cat-chips-wrap::before,
body.cat-enh .cat-chips-wrap::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 2px;
  z-index: 1;
  width: 56px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

body.cat-enh .cat-chips-wrap::before {
  left: 0;
  background: linear-gradient(90deg, var(--cat-fade-bg, #fff) 30%, transparent);
}

body.cat-enh .cat-chips-wrap::after {
  right: 0;
  background: linear-gradient(270deg, var(--cat-fade-bg, #fff) 30%, transparent);
}

body.cat-enh .cat-chips-wrap.can-prev::before,
body.cat-enh .cat-chips-wrap.can-next::after {
  opacity: 1;
}

body.cat-enh .cat-chips-arrow {
  position: absolute;
  top: calc(50% + 2px);
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(27, 39, 53, .12);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #1b2735;
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(15, 32, 58, .14);
  cursor: pointer;
  transform: translateY(-50%);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

body.cat-enh .cat-chips-arrow--prev {
  left: 0;
}

body.cat-enh .cat-chips-arrow--next {
  right: 0;
}

body.cat-enh .cat-chips-arrow:hover,
body.cat-enh .cat-chips-arrow:focus-visible {
  border-color: var(--primary, #0F766E);
  background: var(--primary, #0F766E);
  color: #fff;
}

@media (min-width: 768px) {
  body.cat-enh .cat-chips-wrap.can-prev .cat-chips-arrow--prev,
  body.cat-enh .cat-chips-wrap.can-next .cat-chips-arrow--next {
    display: inline-flex;
  }
}
