/*
 * Royal Vision Traders - Shop archive layout.
 *
 * Two column shop: filter sidebar plus the product grid. Product card
 * styling already lives in rvt-design.css and is deliberately not repeated
 * here; this file handles the layout, the sidebar, and the grid density the
 * narrower main column needs.
 *
 * Tokens come from rvt-design.css (:root), which loads site wide.
 */

/* ===============================================================
   1. Layout

   .site-main carries no horizontal padding and no max width, so this
   wrapper supplies the measure, matching the 1240px used elsewhere.
   =============================================================== */

.rvt-shop-layout {
  display: grid;
  box-sizing: border-box;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  gap: 32px;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 24px;
}

.rvt-shop-layout *,
.rvt-shop-layout *::before,
.rvt-shop-layout *::after {
  box-sizing: border-box;
}

.woocommerce-shop .woocommerce-products-header,
.tax-product_cat .woocommerce-products-header,
.tax-product_tag .woocommerce-products-header {
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 24px;
}

/*
 * The main column holds the result count, the sort form, the grid and the
 * pagination as siblings. Everything spans the full width except the first
 * two, which share one row.
 */
.rvt-shop-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 16px;
  min-width: 0;
}

.rvt-shop-main > * {
  grid-column: 1 / -1;
  min-width: 0;
}

.rvt-shop-main > .woocommerce-result-count {
  grid-column: 1;
  margin: 0;
}

.rvt-shop-main > .woocommerce-ordering {
  grid-column: 2;
  justify-self: end;
  margin: 0;
}

/* ===============================================================
   2. Sidebar shell
   =============================================================== */

.rvt-shop-sidebar {
  position: sticky;
  top: calc(var(--rvt-nav-h) + 16px);
  min-width: 0;
}

.rvt-filters {
  overflow: hidden;
  border: 1px solid var(--rvt-border);
  border-radius: var(--rvt-rm);
  background: var(--rvt-surface);
  box-shadow: var(--rvt-sh);
}

/* The panel is always open on desktop, so its toggle is not needed. */
.rvt-filters__toggle {
  display: none;
}

.rvt-filters__body {
  padding: 20px;
}

.rvt-filter-group + .rvt-filter-group {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--rvt-border);
}

.rvt-filter-group__title {
  margin: 0 0 12px;
  color: var(--rvt-muted);
  font-family: var(--rvt-h);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ===============================================================
   3. Category list
   =============================================================== */

.rvt-filter-list,
.rvt-filter-children {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rvt-filter-list > li + li {
  margin-top: 2px;
}

.rvt-filter-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rvt-rp);
  color: var(--rvt-ink);
  font-family: var(--rvt-b);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.rvt-filter-list a span {
  flex-shrink: 0;
  color: var(--rvt-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.rvt-filter-list a:hover {
  background: var(--rvt-bg);
  color: var(--rvt-accent);
}

.rvt-filter-list a.is-active {
  background: var(--rvt-accent);
  color: #fff;
}

.rvt-filter-list a.is-active span {
  color: rgba(255, 255, 255, 0.75);
}

.rvt-filter-list a.is-ancestor {
  color: var(--rvt-accent);
}

/* Sub categories, if any are added later. */
.rvt-filter-children {
  margin: 2px 0 2px 14px;
  padding-left: 10px;
  border-left: 1px solid var(--rvt-border);
}

.rvt-filter-children a {
  padding: 8px 12px;
  font-size: 13.5px;
}

/* ===============================================================
   4. Price filter
   =============================================================== */

.rvt-price-fields {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rvt-price-fields label {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
}

.rvt-price-fields input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--rvt-border);
  border-radius: var(--rvt-rs);
  background: var(--rvt-surface);
  color: var(--rvt-ink);
  font-family: var(--rvt-b);
  font-size: 14px;
}

.rvt-price-fields input:focus {
  border-color: var(--rvt-accent);
  box-shadow: 0 0 0 3px rgba(47, 169, 160, 0.16);
  outline: none;
}

.rvt-price-sep {
  flex-shrink: 0;
  color: var(--rvt-muted);
  font-size: 13px;
}

.rvt-price-note {
  margin: 10px 0 12px;
  color: var(--rvt-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.rvt-price-note .woocommerce-Price-currencySymbol {
  font-size: 85%;
}

.rvt-filter-apply {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border: 0;
  border-radius: var(--rvt-rp);
  background: var(--rvt-accent);
  color: #fff;
  cursor: pointer;
  font-family: var(--rvt-b);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 0.2s ease;
}

.rvt-filter-apply:hover {
  background: var(--rvt-accent-h);
}

.rvt-filter-clear {
  display: block;
  margin-top: 18px;
  color: var(--rvt-muted);
  font-size: 13.5px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rvt-filter-clear:hover {
  color: var(--rvt-coral);
}

.rvt-shop-layout a:focus-visible,
.rvt-shop-layout button:focus-visible,
.rvt-shop-layout input:focus-visible,
.rvt-shop-layout summary:focus-visible {
  outline: 2px solid var(--rvt-accent);
  outline-offset: 3px;
}

/* ===============================================================
   5. Product grid density

   rvt-design.css forces a four column grid with !important. With the
   filter column taking 260px, three across gives the cards room to
   breathe, so this override has to match that weight.
   =============================================================== */

.rvt-shop-main ul.products {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 22px !important;
}

/* Square media, matching the best sellers section on the home page. */
.rvt-shop-main ul.products li.product img {
  aspect-ratio: 1 / 1;
  padding: 8%;
  object-fit: contain;
}

.rvt-shop-main .woocommerce-pagination ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  border: 0;
  list-style: none;
}

.rvt-shop-main .woocommerce-pagination ul li {
  margin: 0;
  border: 0;
}

.rvt-shop-main .woocommerce-pagination a,
.rvt-shop-main .woocommerce-pagination span {
  display: inline-flex;
  min-width: 42px;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--rvt-border);
  border-radius: var(--rvt-rp);
  background: var(--rvt-surface);
  color: var(--rvt-ink);
  font-family: var(--rvt-b);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.rvt-shop-main .woocommerce-pagination a:hover {
  border-color: var(--rvt-accent);
  color: var(--rvt-accent);
}

.rvt-shop-main .woocommerce-pagination span.current {
  border-color: var(--rvt-accent);
  background: var(--rvt-accent);
  color: #fff;
}

/* ===============================================================
   6. Responsive
   =============================================================== */

@media (max-width: 1200px) {
  .rvt-shop-layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 26px;
  }

  .rvt-shop-main ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 900px) {
  /* The sidebar moves above the grid and collapses into a toggle. */
  .rvt-shop-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    padding-inline: 16px;
  }

  .woocommerce-shop .woocommerce-products-header,
  .tax-product_cat .woocommerce-products-header,
  .tax-product_tag .woocommerce-products-header {
    padding-inline: 16px;
  }

  .rvt-shop-sidebar {
    position: static;
    top: auto;
  }

  .rvt-filters__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    color: var(--rvt-ink);
    cursor: pointer;
    font-family: var(--rvt-h);
    font-size: 15px;
    font-weight: 600;
    list-style: none;
  }

  .rvt-filters__toggle::-webkit-details-marker {
    display: none;
  }

  .rvt-filters__toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    transition: transform 0.2s ease;
  }

  .rvt-filters[open] .rvt-filters__toggle svg {
    transform: rotate(180deg);
  }

  .rvt-filters[open] .rvt-filters__toggle {
    border-bottom: 1px solid var(--rvt-border);
  }

  .rvt-filters__body {
    padding: 18px;
  }

  .rvt-shop-main ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }
}

@media (max-width: 560px) {
  .rvt-shop-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .rvt-shop-main > .woocommerce-result-count,
  .rvt-shop-main > .woocommerce-ordering {
    grid-column: 1;
    justify-self: stretch;
  }

  .rvt-shop-main > .woocommerce-ordering select {
    width: 100%;
  }

  /* Two across on a phone, matching the home page product grid. */
  .rvt-shop-main ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  .rvt-shop-main ul.products li.product {
    padding: 10px;
  }
}

@media (max-width: 400px) {
  .rvt-shop-layout {
    padding-inline: 12px;
  }

  .rvt-price-fields {
    flex-wrap: wrap;
  }

  .rvt-price-sep {
    display: none;
  }

  .rvt-price-fields label {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rvt-filter-list a,
  .rvt-filter-apply,
  .rvt-filters__toggle svg {
    transition: none;
  }
}
