/**
 * The product archive: the hero, the two columns, and the three controls.
 *
 * The pager's rules are WP Grid Builder's own, lifted from the live shop so the
 * two look the same — the markup carries the same `.wpgb-facet .wpgb-pagination`
 * classes for exactly that reason. WP Grid Builder is not installed here, so
 * the rules travel with the markup.
 */

:root {
  /* innowine's own accent for the current page. */
  --wpgb-accent-scheme-1: #e65953;
}

/* --------------------------------------------------------------- the frame
   Etch's container caps the width but has no gutter of its own, so without
   this the hero photo and the sidebar sit flush against the viewport edge. */

.archive-section {
  /* Etch's container caps itself at var(--content-width); redefining it here
     sets this page's width without touching the site-wide Automatic.css
     setting. 1450px: no page is wider than the header and the mega menus
     (was 1700px). */
  --content-width: 1450px;
  /* The pager's "Tetejére" link lands here. */
  scroll-margin-block-start: var(--space-s, 2rem);
  padding-block: var(--space-s, 2rem) var(--space-m, 3rem);
  padding-inline: var(--space-s, 2rem);
}

@media (width <= 767px) {
  .archive-section {
    padding-inline: var(--space-xs, 1.33rem);
  }
}

/* ---------------------------------------------------------------- the hero */

/*
 * Half image, half words, the way innowine.hu draws a category: the two
 * columns take the same share, the photo fills its half and is cropped to it,
 * and the corner radius is the shop's own 10px rather than the card radius.
 */
.archive-hero {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: var(--space-l, 4.5rem);
  inline-size: 100%;
  padding-block: var(--space-s, 2rem) var(--space-m, 3rem);
}

/* Both halves grow from nothing, so the gap comes out of neither of them and
   the two columns end up genuinely equal rather than 50% and "the rest". */
.archive-hero__media {
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  min-inline-size: 0;
  overflow: hidden;
  border-radius: 10px;
  background-color: #f2f2f2;
}

/* Nothing at all to show, neither a cover nor a brand's mark, so no empty
   frame. */
.archive-hero__media:not(:has(.archive-hero__img[src]:not([src=""]), .archive-hero__logo-img[src]:not([src=""]))) {
  display: none;
}

/* A brand's mark with no banner under it: the empty cover would otherwise
   draw its alt text as a broken image. */
.archive-hero__img:not([src]),
.archive-hero__img[src=""] {
  display: none;
}

.archive-hero__img {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  border-radius: 10px;
  object-fit: cover;
}

/*
 * The stand-in is capped the way innowine caps its own: a category with no
 * cover gets a band rather than a full-height photo, so the hero does not
 * pretend the picture belongs to this category.
 */
.archive-hero__media[data-placeholder="1"] .archive-hero__img {
  max-block-size: 200px;
}

/*
 * The brand's mark, as a white tab hanging off the top of the banner — the
 * shape innowine gives it: square where it meets the edge, rounded below.
 *
 * Only a brand archive fills {term.logo}; on a category the src comes out
 * empty and the tab folds away, which is what keeps the shop's logo off the
 * category pages.
 */
.archive-hero__logo {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 25px;
  border-end-start-radius: 10px;
  border-end-end-radius: 10px;
  background-color: var(--white, #fff);
  translate: -50% 0;
}

.archive-hero__logo:not(:has(.archive-hero__logo-img[src]:not([src=""]))) {
  display: none;
}

/* Two classes deep on purpose: WooCommerce's `.woocommerce img { height: auto }`
   is one class and would otherwise decide how tall the mark is. */
.archive-hero__logo .archive-hero__logo-img {
  display: block;
  inline-size: auto;
  block-size: 44px;
  max-inline-size: 220px;
  object-fit: contain;
}

.archive-hero__body {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-xs, 1.33rem);
  min-inline-size: 0;
  text-align: start;
}

.archive-hero__title {
  margin: 0;
  color: var(--black, #000);
  font-size: calc(var(--text-m) + 12px);
  font-weight: 700;
  line-height: 1.15;
}

/*
 * The selection is the shop speaking in its own name, so its heading carries
 * the mark where another category carries only a word: the logo says
 * "Innowine", the term says the rest, and the rest is the badge's gold instead
 * of the page's black — the same gold the cards use for the same wines.
 */
.archive-hero__title--selection {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

/* Two classes deep on purpose, the same reason the brand's mark is: one class
   and one element is all `.woocommerce img { height: auto }` needs to win. */
.archive-hero__title .archive-hero__wordmark {
  display: block;
  flex: none;
  inline-size: auto;
  block-size: 54px;
  max-inline-size: 100%;
  object-fit: contain;
}

.archive-hero__title-name {
  color: #9a7418;
}

.archive-hero__desc {
  margin: 0;
  max-inline-size: 70ch;
  color: #4a4a4a;
  font-size: var(--text-m);
  line-height: 1.6;
}

.archive-hero__desc:empty {
  display: none;
}

/*
 * Every archive cover (category, brand, region) is a landscape, capped at
 * 360px tall. The frame sizes to the picture rather than stretching to the
 * text beside it, so a cap never leaves a grey band above and below; past
 * 360px the photo is cropped, not squashed. Without the cap a portrait cover
 * filled its whole column and pushed the products off the first screen.
 */
.archive-hero__media {
  align-self: center;
}

.archive-hero__img {
  block-size: auto;
  max-block-size: 360px;
  aspect-ratio: 3 / 2;
}

/* A region's description comes out of wpautop as paragraphs. */
.archive-hero__desc > p {
  margin: 0;
}

.archive-hero__desc > p + p {
  margin-block-start: 0.8em;
}

.archive-hero__desc a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* "Tovább olvasom", down to the longer text under the grid. */
.archive-hero__more a {
  color: var(--black, #000);
  font-weight: 600;
  text-decoration-color: #e65953;
  text-underline-offset: 3px;
}

.archive-hero__more a:hover {
  color: #B3161E; /* 6.9:1; the lighter #e65953 was 3.6:1 (WCAG AA) */
}

/* A chevron pointing down the page, drawn from two borders. */
.archive-hero__more a::after {
  content: "";
  display: inline-block;
  inline-size: 6px;
  block-size: 6px;
  margin-inline-start: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  vertical-align: 0.25em;
  rotate: 45deg;
}

/* ------------------------------------------------------- similar pages
   [innowine_similar_terms], under the hero's text: a quiet label and a row of
   outlined buttons. Centred with the words when the hero is. */

.archive-similar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-block-start: 4px;
}

.archive-similar__label {
  color: #6b6a66; /* 5.4:1; #8a8a8a was 3.5:1 */
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.archive-similar__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-similar__list > li {
  margin: 0;
}

.archive-similar__link {
  display: block;
  padding: 6px 14px;
  border: 1px solid #dcdcdc;
  border-radius: 999px;
  color: var(--black, #000);
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.archive-similar__link:hover,
.archive-similar__link:focus-visible {
  border-color: var(--black, #000);
  background-color: #f6f6f6;
}

.archive-similar__link:focus-visible {
  outline: 2px solid var(--black, #000);
  outline-offset: 2px;
}

.archive-hero[data-hero="kozep"] .archive-similar,
.archive-hero[data-hero="kozep"] .archive-similar__list {
  justify-content: center;
}

/*
 * A phone: one row that scrolls sideways instead of five that push the
 * products down, running out to the screen's edges and fading there. Centred
 * with auto margins rather than justify-content, which would cut off the
 * start of a row too long to fit; the margins give way to zero instead.
 */
@media (width <= 767px) {
  .archive-similar {
    flex-direction: column;
    align-items: flex-start;
    align-self: stretch;
    gap: 8px;
    min-inline-size: 0;
  }

  .archive-hero[data-hero="kozep"] .archive-similar {
    align-items: center;
  }

  .archive-hero .archive-similar .archive-similar__list {
    align-self: stretch;
    flex-wrap: nowrap;
    justify-content: flex-start;
    max-inline-size: calc(100% + 2 * var(--space-xs, 1.33rem));
    margin-inline: calc(-1 * var(--space-xs, 1.33rem));
    padding: 2px var(--space-xs, 1.33rem);
    overflow-x: auto;
    scrollbar-width: none;
    mask-image: linear-gradient(to right, transparent, #000 var(--space-xs, 1.33rem), #000 calc(100% - var(--space-xs, 1.33rem)), transparent);
  }

  .archive-similar__list::-webkit-scrollbar {
    display: none;
  }

  .archive-hero[data-hero="kozep"] .archive-similar__list > li:first-child {
    margin-inline-start: auto;
  }

  .archive-hero[data-hero="kozep"] .archive-similar__list > li:last-child {
    margin-inline-end: auto;
  }

  .archive-similar__link {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .archive-similar__link {
    transition: none;
  }
}

/* -------------------------------------------------- the hero without a cover
   `data-hero` comes from {term.hero} on the category and brand templates; see
   innowine_archive_hero_layout(). */

/* No picture: the name and the short text, centred over the listing. */
.archive-hero[data-hero="kozep"] {
  justify-content: center;
}

.archive-hero[data-hero="kozep"] .archive-hero__body {
  flex: 0 1 auto;
  align-items: center;
  max-inline-size: 80ch;
  text-align: center;
}

/* A brand's own mark and no banner: the mark left of the words, the words
   ranged left against it, the pair centred over the listing. */
.archive-hero[data-hero="logo"] {
  align-items: center;
  justify-content: center;
}

.archive-hero[data-hero="logo"] .archive-hero__media {
  flex: none;
  overflow: visible;
  border-radius: 0;
  background: none;
}

.archive-hero[data-hero="logo"] .archive-hero__logo {
  position: static;
  padding: 0;
  border-radius: 0;
  background: none;
  translate: none;
}

.archive-hero[data-hero="logo"] .archive-hero__logo .archive-hero__logo-img {
  block-size: auto;
  max-block-size: 160px;
  max-inline-size: 220px;
}

.archive-hero[data-hero="logo"] .archive-hero__body {
  flex: 0 1 auto;
  max-inline-size: 80ch;
}

/* ------------------------------------------------------ the longer text
   The part of a category description after `<!--more-->`, under the grid in
   the main column. A category without one prints an empty box, which folds. */

.archive-more {
  max-inline-size: 80ch;
  margin-block-start: var(--space-l, 4.5rem);
  padding-block-start: var(--space-m, 3rem);
  border-block-start: 1px solid #e5e5e5;
  color: #4a4a4a;
  font-size: var(--text-m);
  line-height: 1.7;
}

.archive-more:empty {
  display: none;
}

/* Where the hero's "Tovább olvasom" lands: a little air above the line. */
.archive-more {
  scroll-margin-block-start: var(--space-m, 3rem);
}

.archive-more h2 {
  margin: 1.6em 0 0.5em;
  color: var(--black, #000);
  font-size: calc(var(--text-m) + 6px);
  font-weight: 700;
  line-height: 1.25;
}

.archive-more > h2:first-child {
  margin-block-start: 0;
}

.archive-more p {
  margin: 0;
}

.archive-more p + p {
  margin-block-start: 0.9em;
}

.archive-more a {
  color: var(--black, #000);
  text-decoration: underline;
  text-decoration-color: #e65953;
  text-underline-offset: 3px;
}

.archive-more a:hover {
  color: #B3161E; /* 6.9:1; the lighter #e65953 was 3.6:1 (WCAG AA) */
}

/*
 * The photographer's credit a Wikimedia Commons cover owes, laid over the
 * picture's bottom corner. An Unsplash cover has none, and the line folds away.
 */
.archive-hero__credit {
  position: absolute;
  inset-block-end: 8px;
  inset-inline-end: 8px;
  max-inline-size: calc(100% - 16px);
  margin: 0;
  padding: 3px 8px;
  border-radius: 4px;
  background-color: rgb(0 0 0 / 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1.4;
}

.archive-hero__credit a {
  color: inherit;
  text-decoration: underline;
}

.archive-hero__credit:not(:has(a)) {
  display: none;
}

/* ------------------------------------------------------------- the columns */

.archive-body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
  gap: var(--space-m, 3rem);
  inline-size: 100%;
}

.archive-sidebar {
  position: sticky;
  inset-block-start: var(--space-s, 2rem);
  display: flex;
  flex-direction: column;
  gap: var(--space-s, 2rem);
  padding: var(--space-s, 2rem);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-s, 0.6666rem);
  background-color: var(--white, #fff);
}

/*
 * The sidebar is taller than a laptop screen (1025px against 900), and stuck,
 * so its foot - the price filter - could not be reached until the end of the
 * grid, and its head sat under the stuck site header. A keyboard user tabbing
 * into the price filter got a focus nobody could see (WCAG 2.4.7 / 2.4.11).
 * It sticks below the header now (`--iw-header-cover` comes from the header
 * script) and scrolls within itself when it does not fit.
 */
@media (width > 991px) {
  .archive-sidebar {
    inset-block-start: calc(var(--iw-header-cover, 0px) + var(--space-s, 2rem));
    max-block-size: calc(100dvh - var(--iw-header-cover, 0px) - 2 * var(--space-s, 2rem));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    transition: inset-block-start 0.2s ease;
  }
}

.archive-sidebar__title {
  margin: 0;
  color: var(--black, #000);
  font-size: calc(var(--text-m) + 2px);
  font-weight: 700;
  text-align: center;
}

.archive-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-s, 2rem);
  min-inline-size: 0;
}

/* ------------------------------------------------------------- the toolbar */

.archive-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs, 1.33rem);
  inline-size: 100%;
}

/* The column's gap is for the grid and the pager. Under the toolbar the card's
   own 20px padding already makes the room, so the gap would double it. On a
   phone the card has no padding, and a smaller gap stays. */
.archive-main > .archive-toolbar {
  margin-block-end: calc(-1 * var(--space-s, 2rem));

  @media (width <= 767px) {
    margin-block-end: calc(12px - var(--space-s, 2rem));
  }
}

.innowine-count {
  color: #333;
  font-size: 16px;
}

.innowine-sorting {
  display: flex;
  align-items: center;
  margin-inline-start: auto;
}

.innowine-sorting__go {
  margin-inline-start: 6px;
  padding: 7px 12px;
  border: 1px solid var(--black, #000);
  border-radius: var(--radius-xs, 0.444rem);
  background-color: var(--black, #000);
  color: var(--white, #fff);
  font-family: inherit;
  font-size: var(--text-s);
  cursor: pointer;
}

.wpgb-sr-only {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --------------------------------------------------------------- the pager
   The grey bar is innowine's own: the way back up on the left, the pages in
   the middle, the page size on the right. The rules inside the page list are
   WP Grid Builder's, as they are on the live shop. */

.innowine-pagerbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs, 1.33rem);
  inline-size: 100%;
  margin-block-start: var(--space-s, 2rem);
  padding: 6px var(--space-s, 2rem);
  border-radius: 5px;
  background-color: #f6f6f6;
}

/* The two ends grow equally, so the page list is centred on the bar rather
   than on whatever room the ends happen to leave. */
.innowine-pagerbar__top,
.innowine-perpage {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  min-inline-size: 0;
}

.innowine-pagerbar__top {
  gap: 6px;
  color: var(--black, #000);
  font-size: 16px;
  text-decoration: none;
}

/* The words are underlined, the chevron is not. */
.innowine-pagerbar__top span {
  text-decoration: underline;
}

.innowine-pagerbar__icon {
  flex: none;
  inline-size: 16px;
  block-size: 16px;
}

.innowine-perpage {
  justify-content: flex-end;
}

.innowine-pagination {
  display: flex;
  flex: none;
  justify-content: center;
}

/*
 * The two listing selects. The native arrow is replaced by the shop's own in
 * its own compartment, so the control reads the same in every browser — which
 * is the whole reason the select gives up its appearance.
 */
.innowine-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  inline-size: 180px;
  max-inline-size: 100%;
}

.innowine-select .wpgb-select {
  inline-size: 100%;
  padding: 11px 48px 11px 14px;
  border: 1px solid #e3e5e8;
  border-radius: 4px;
  background-color: var(--white, #fff);
  color: #4a4a4a;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  text-overflow: ellipsis;
  appearance: none;
  cursor: pointer;
}

.innowine-select .wpgb-select:focus-visible {
  border-color: var(--black, #000);
  outline: none;
}

.innowine-select__controls {
  position: absolute;
  inset-block: 1px;
  inset-inline-end: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 38px;
  border-inline-start: 1px solid #e3e5e8;
  color: #9aa0a6;
  pointer-events: none;
}

.innowine-select__controls svg {
  inline-size: 16px;
  block-size: 16px;
}

/* In the pager's bar it holds two digits, so it needs none of that width. */
.innowine-perpage .innowine-select {
  inline-size: 96px;
}

.innowine-perpage .innowine-select .wpgb-select {
  padding: 9px 40px 9px 12px;
}

.innowine-perpage .innowine-select__controls {
  inline-size: 32px;
}

.wpgb-facet .wpgb-pagination {
  display: inline-block;
  margin: 0;
  padding: 0;
  position: relative;
}

.wpgb-facet .wpgb-pagination li {
  cursor: default;
  display: inline-block;
  font-size: 16px;
  font-weight: 700;
  height: 32px;
  line-height: 32px;
  list-style: none;
  margin: 4px;
  min-width: 32px;
  padding: 0;
  position: relative;
  text-align: center;
  vertical-align: middle;
}

.wpgb-facet .wpgb-pagination li a,
.wpgb-facet .wpgb-pagination li a:hover {
  border: none;
  box-shadow: none;
  display: block;
  font-size: 16px;
  font-style: unset;
  font-weight: 400;
  line-height: 32px;
  padding: 0 11px;
  position: relative;
  text-decoration: none;
}

.wpgb-facet .wpgb-pagination li a {
  color: var(--black, #000);
}

.wpgb-facet .wpgb-pagination li a[aria-current] {
  color: #B3161E; /* text needs 4.5:1: the accent #e65953 is 3.3:1 on the grey bar */
  font-weight: 600;
}

.wpgb-facet .wpgb-pagination li span {
  display: block;
}

.wpgb-facet .wpgb-pagination li a:focus-visible {
  outline-color: -webkit-focus-ring-color;
  outline-offset: 2px;
  outline-style: solid;
  outline-width: 1.5px;
}

.wpgb-facet .wpgb-pagination .wpgb-page-dots span {
  color: #6b6a66;
  font-weight: 400;
}

/* ------------------------------------------------------------------ narrow */

@media (width <= 991px) {
  .archive-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .archive-sidebar {
    position: static;
  }

  .archive-hero {
    gap: var(--space-s, 2rem);
  }
}

@media (width <= 767px) {
  .archive-hero {
    flex-direction: column;
    padding-block-end: var(--space-s, 2rem);
  }

  .archive-hero__media {
    flex: none;
    inline-size: 100%;
  }

  /* The mark above the words, both ranged left. */
  .archive-hero[data-hero="logo"] {
    align-items: flex-start;
    gap: var(--space-xs, 1.33rem);
  }

  .archive-hero[data-hero="logo"] .archive-hero__media {
    align-self: flex-start;
    inline-size: auto;
  }

  .archive-hero[data-hero="logo"] .archive-hero__logo .archive-hero__logo-img {
    max-block-size: 80px;
    max-inline-size: 160px;
  }

  .archive-hero__title--selection {
    gap: 12px;
  }

  .archive-hero__title .archive-hero__wordmark {
    block-size: 42px;
  }

  .innowine-pagerbar {
    padding-inline: var(--space-xs, 1.33rem);
  }

  /* Three things do not fit across a phone: the page list takes a row of its
     own and the two controls share the one below it. */
  .innowine-pagination {
    order: -1;
    flex: 1 0 100%;
  }

  .innowine-pagerbar__top,
  .innowine-perpage {
    flex: 0 0 auto;
  }
}
