/* ==========================================================================
   YT Digital Power — Product archive & category listing
   Hero, category tree, toolbar, AJAX grid state, pagination and empty state.
   Shared product-card styles live in components.css and are not repeated here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.yt-archive__hero {
  padding-block: 64px 48px;
  background: var(--yt-bg-soft);
}

.yt-archive__hero .yt-breadcrumbs {
  margin-bottom: 20px;
}

.yt-archive__hero .yt-page-title {
  max-width: 920px;
}

.yt-archive__hero .yt-page-sub {
  max-width: 760px;
  margin-top: 16px;
  color: var(--yt-gray-60);
  font-size: var(--yt-fs-16);
  line-height: var(--yt-lh-24);
}

.yt-archive__hero .yt-page-sub > :last-child {
  margin-bottom: 0;
}

.yt-archive__chips {
  margin-top: 24px;
}

.yt-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.yt-archive__hero .yt-chip {
  border-color: var(--yt-line);
  background: var(--yt-white);
}

.yt-archive__hero .yt-chip:hover {
  border-color: var(--yt-red);
}

.yt-archive__hero .yt-chip.is-active {
  border-color: var(--yt-red);
  background: var(--yt-red);
  color: var(--yt-white);
}

/* --------------------------------------------------------------------------
   Layout: sidebar + results
   -------------------------------------------------------------------------- */
.yt-archive__layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  align-items: start;
  gap: 48px;
  padding-block: 48px 100px;
}

.yt-archive__main {
  min-width: 0;
  scroll-margin-top: calc(var(--yt-header-h) + 24px);
}

/* --------------------------------------------------------------------------
   Category filter
   -------------------------------------------------------------------------- */
.yt-filter {
  position: sticky;
  top: calc(var(--yt-header-h) + 24px);
  max-height: calc(100vh - var(--yt-header-h) - 48px);
  min-width: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.admin-bar .yt-filter {
  top: calc(var(--yt-header-h) + 56px);
  max-height: calc(100vh - var(--yt-header-h) - 80px);
}

.yt-filter__title {
  margin: 0 0 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--yt-line);
  color: var(--yt-black);
  font-size: var(--yt-fs-20);
  font-weight: var(--yt-fw-bold);
  line-height: var(--yt-lh-28);
}

.yt-filter__toggle {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--yt-line);
  border-radius: var(--yt-radius);
  background: var(--yt-white);
  color: var(--yt-ink);
  font: inherit;
  font-size: var(--yt-fs-14);
  font-weight: var(--yt-fw-bold);
  line-height: var(--yt-lh-21);
  text-align: left;
  cursor: pointer;
  transition:
    border-color var(--yt-dur-fast) var(--yt-ease),
    color var(--yt-dur-fast) var(--yt-ease);
}

.yt-filter__toggle:hover {
  border-color: var(--yt-red);
  color: var(--yt-red);
}

.yt-filter__toggle svg {
  flex: 0 0 auto;
  transition: transform var(--yt-dur-fast) var(--yt-ease);
}

.yt-filter__toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.yt-filter__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.yt-filter__item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
}

.yt-filter__item + .yt-filter__item {
  margin-top: 2px;
}

.yt-filter__link {
  display: flex;
  flex: 1 1 auto;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 6px 0;
  color: var(--yt-ink);
  font-size: var(--yt-fs-14);
  line-height: var(--yt-lh-24);
  text-decoration: none;
  transition: color var(--yt-dur-fast) var(--yt-ease);
}

.yt-filter__link:hover {
  color: var(--yt-red);
}

.yt-filter__link[aria-current="page"],
.yt-filter__item.is-active > .yt-filter__link,
.yt-filter__children .is-active > .yt-filter__link {
  color: var(--yt-red);
  font-weight: var(--yt-fw-bold);
}

.yt-filter__item.is-current-parent > .yt-filter__link {
  font-weight: var(--yt-fw-bold);
}

.yt-filter__link[aria-current="page"] .yt-filter__count {
  color: var(--yt-red);
}

.yt-filter__count {
  flex: 0 0 auto;
  color: var(--yt-gray);
  font-size: var(--yt-fs-12);
  font-weight: var(--yt-fw-regular);
  line-height: 18px;
  font-variant-numeric: tabular-nums;
}

.yt-filter__expand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: 2px;
  padding: 0;
  border: 0;
  border-radius: var(--yt-radius);
  background: none;
  color: var(--yt-gray);
  cursor: pointer;
  transition: color var(--yt-dur-fast) var(--yt-ease);
}

.yt-filter__expand:hover {
  color: var(--yt-red);
}

.yt-filter__expand svg {
  transition: transform var(--yt-dur-fast) var(--yt-ease);
}

.yt-filter__expand[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.yt-filter__children {
  flex: 0 0 100%;
  margin: 0 0 8px 8px;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--yt-line);
  list-style: none;
}

.yt-filter__child {
  margin: 0;
  padding: 0;
}

.yt-filter__child .yt-filter__link {
  padding: 4px 0;
  font-size: var(--yt-fs-14);
  line-height: 22px;
}

/* Without JavaScript every category level stays visible on desktop; the
   expand control would be a dead button, so it is removed. Mobile keeps its
   horizontal top-level pills. */
@media (min-width: 768px) {
  html:not(.yt-archive-js) .yt-filter__expand {
    display: none;
  }

  html:not(.yt-archive-js) .yt-filter__children[hidden] {
    display: block !important;
  }
}

/* --------------------------------------------------------------------------
   Toolbar: count, search, sort
   -------------------------------------------------------------------------- */
.yt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 24px;
}

.yt-toolbar__controls {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
  margin-left: auto;
}

.yt-toolbar__search {
  position: relative;
  width: 240px;
  max-width: 100%;
}

.yt-toolbar__search-icon {
  position: absolute;
  top: 50%;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--yt-gray);
  transform: translateY(-50%);
  pointer-events: none;
}

.yt-toolbar__search-input {
  height: 40px;
  min-height: 40px;
  padding: 8px 12px 8px 38px;
  font-size: var(--yt-fs-14);
  line-height: 22px;
}

.yt-toolbar__sort {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--yt-gray-60);
  font-size: var(--yt-fs-14);
  line-height: var(--yt-lh-21);
  white-space: nowrap;
}

.yt-toolbar__select {
  width: auto;
  min-width: 150px;
  height: 40px;
  min-height: 40px;
  padding: 8px 36px 8px 12px;
  font-size: var(--yt-fs-14);
  line-height: 22px;
}

.yt-archive-js .yt-toolbar__apply {
  display: none;
}

.yt-toolbar__apply {
  height: 40px;
  min-height: 40px;
  padding-inline: 20px;
  font-size: var(--yt-fs-14);
}

/* --------------------------------------------------------------------------
   Result grid
   -------------------------------------------------------------------------- */
.yt-archive__main .yt-grid--products {
  gap: 24px;
  transition: opacity var(--yt-dur-fast) var(--yt-ease);
}

/* Long ACF model strings must wrap inside the 3-column card, never widen the
   page. Card visuals otherwise stay in components.css. */
.yt-archive__main .yt-product-card__model,
.yt-archive__main .yt-product-card__title,
.yt-archive__main .yt-product-card__title a,
.yt-archive__main .yt-product-card__cat {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.yt-archive__main .yt-grid--products.is-loading {
  opacity: 0.45;
  pointer-events: none;
}

.yt-archive__main .yt-grid--products:empty {
  display: none;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.yt-archive__main > .yt-empty {
  border: 1px solid var(--yt-line);
  background: var(--yt-white);
}

/* --------------------------------------------------------------------------
   Tablet
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
  .yt-archive__hero {
    padding-block: 48px 40px;
  }

  .yt-archive__layout {
    grid-template-columns: 200px minmax(0, 1fr);
    gap: 32px;
    padding-block: 40px 80px;
  }

  .yt-toolbar__search {
    width: 200px;
  }
}

/* --------------------------------------------------------------------------
   Mobile: horizontal category pills, stacked toolbar, one-column grid
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .yt-archive__hero {
    padding-block: 36px 32px;
  }

  .yt-archive__hero .yt-breadcrumbs {
    margin-bottom: 16px;
  }

  .yt-archive__chips {
    flex-wrap: nowrap;
    margin-top: 20px;
    padding-bottom: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .yt-archive__chips::-webkit-scrollbar {
    display: none;
  }

  .yt-archive__chips .yt-chip {
    flex: 0 0 auto;
  }

  .yt-archive__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-block: 24px 56px;
  }

  .yt-filter {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .yt-filter__title {
    display: none;
  }

  .yt-filter__toggle {
    display: flex;
  }

  html:not(.yt-archive-js) .yt-filter__toggle {
    display: none;
  }

  .yt-archive-js .yt-filter__panel {
    display: none;
  }

  .yt-archive-js .yt-filter__panel.is-open {
    display: block;
    margin-top: 12px;
  }

  .yt-filter__panel {
    padding-bottom: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .yt-filter__panel::-webkit-scrollbar {
    display: none;
  }

  .yt-filter__list {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    width: max-content;
  }

  .yt-filter__item {
    display: block;
    flex: 0 0 auto;
  }

  .yt-filter__item + .yt-filter__item {
    margin-top: 0;
  }

  .yt-filter__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--yt-line);
    background: var(--yt-white);
    color: var(--yt-ink);
    font-size: var(--yt-fs-14);
    line-height: 20px;
    white-space: nowrap;
  }

  .yt-filter__link:hover {
    border-color: var(--yt-red);
  }

  .yt-filter__item.is-active > .yt-filter__link,
  .yt-filter__link[aria-current="page"] {
    border-color: var(--yt-red);
    background: var(--yt-red);
    color: var(--yt-white);
  }

  .yt-filter__link[aria-current="page"] .yt-filter__count {
    color: var(--yt-white);
    opacity: 0.8;
  }

  .yt-filter__item.is-current-parent > .yt-filter__link {
    border-color: var(--yt-red);
    color: var(--yt-red);
  }

  .yt-filter__expand {
    display: none;
  }

  .yt-filter__children {
    display: none !important;
  }

  .yt-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 20px;
  }

  .yt-toolbar__controls {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-left: 0;
  }

  .yt-toolbar__search {
    width: 100%;
  }

  .yt-toolbar__sort {
    width: 100%;
    justify-content: space-between;
  }

  .yt-toolbar__select {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }

  .yt-toolbar__apply {
    width: 100%;
  }

  .yt-archive__main .yt-grid--products {
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .yt-filter__toggle svg,
  .yt-filter__expand svg,
  .yt-archive__main .yt-grid--products {
    transition: none;
  }
}

/* Target fidelity: the listing starts directly under the header; there is no
   large grey page hero. Cards use the square media frame from components.css. */
.yt-archive__layout {
  padding-block: 24px 100px;
}

@media (max-width: 1023px) {
  .yt-archive__layout {
    padding-block: 24px 80px;
  }
}

@media (max-width: 767px) {
  .yt-archive__layout {
    padding-block: 16px 56px;
  }
}
