/*
 * Recipe Hub (archive-recipe.php): filter sidebar (a drawer below 768px),
 * selected-filter chips, the results grid, Load More and the sticky Reset bar.
 * Tokens only; 1px borders are the kit's hairline.
 */

.section-recipe-hub {
  background: var(--cream);
}

.recipe-hub {
  display: grid;
  gap: var(--spacer--lg);
  align-items: start;
}

/*
 * Sidebar. Without JavaScript it is a plain block above the results on every
 * width; recipe-hub.js adds `recipe-hub-js` to <html>, and only then does the
 * mobile sidebar become the off-canvas drawer (see the end of this file).
 */

.recipe-hub__filters {
  display: flex;
  flex-direction: column;
  gap: var(--spacer--md);
}

html:not(.recipe-hub-js) .recipe-hub__close,
html:not(.recipe-hub-js) .recipe-hub__filter-toggle {
  display: none;
}

.recipe-hub__drawer-head {
  display: flex;
  align-items: center;
  gap: var(--spacer--md);
}

.recipe-hub__title {
  flex: 1;
  margin: 0;
  font-size: var(--h3-font-size);
  font-weight: var(--font-weight--bold);
  line-height: 1.3;
}

.recipe-hub__close {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  color: var(--secondary);
  cursor: pointer;
}

.recipe-hub__close svg {
  width: 1.25rem;
  height: 1.25rem;
}

.recipe-hub .recipe-hub__reset,
.recipe-hub .recipe-hub__submit {
  border-radius: var(--border-radius--md);
}

.recipe-hub__sort {
  display: flex;
  flex-direction: column;
  gap: var(--spacer--xs);
}

.recipe-hub__sort label {
  font-size: var(--button--font-size--sm);
  text-transform: uppercase;
}

.recipe-hub__sort select {
  max-width: 18rem;
  min-height: var(--input--min-height);
  padding-inline: var(--spacer--md);
  border: 0;
  border-radius: var(--border-radius--md);
  background: var(--paper, var(--white));
  font-size: var(--input--font-size);
  font-weight: var(--font-weight--bold);
  text-transform: uppercase;
}

/* Two classes: the parent's input[type="search"] rule outranks one. */
.recipe-hub__filters .recipe-hub__search {
  width: 100%;
  min-height: 2.5625rem;
  border: 0;
  background: var(--white, var(--paper));
  border-radius: var(--border-radius--md);
  padding-inline: 2rem var(--spacer--xl);
  font-size: 1rem;
}

.recipe-hub__search::placeholder {
  color: var(--masala);
}

.recipe-hub__panel {
  background: var(--paper, var(--white));
  border-radius: var(--border-radius--md);
  padding: var(--spacer--xs) var(--spacer--xl);
}

.recipe-hub__panel[open] {
  padding-block: var(--spacer--xl);
}

.recipe-hub__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 1.25rem;
  font-size: var(--body-font-size);
  font-weight: var(--font-weight--bold);
  list-style: none;
  cursor: pointer;
}

.recipe-hub__panel-head::-webkit-details-marker {
  display: none;
}

.recipe-hub__icon {
  display: inline-flex;
  line-height: 0;
}

/*
 * The SVG is a triangle pointing left; turned a quarter clockwise it points
 * up, which is how the design shows it on open and closed panels alike.
 */
.recipe-hub__icon--chevron-down svg {
  width: 0.5rem;
  height: 0.9375rem;
  transform: rotate(90deg);
}

.recipe-hub__options {
  display: flex;
  flex-direction: column;
  margin-top: var(--spacer--lg);
}

/* One 2.0625rem row per option; the kit's label margin would add 1rem more. */
.recipe-hub__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacer--sm);
  margin: 0;
  font-size: var(--button--font-size--sm);
  font-weight: var(--font-weight--bold);
  line-height: 2.0625rem;
  cursor: pointer;
}

.recipe-hub__option-label {
  display: inline-flex;
  align-items: center;
  gap: var(--spacer--2xs);
}

/*
 * The marker: still a real checkbox (the form and recipe-hub.js read it),
 * drawn as the design's 0.6875rem ring with a hairline, filled black when checked.
 */
.recipe-hub__option input[type="checkbox"] {
  flex: 0 0 auto;
  width: 0.6875rem;
  height: 0.6875rem;
  margin: 0;
  border: var(--button--border-width--md) solid var(--black);
  border-radius: 50%;
  background: transparent;
  appearance: none;
  cursor: pointer;
}

.recipe-hub__option input[type="checkbox"]:checked {
  background: var(--black);
}

.recipe-hub__option input[type="checkbox"]:focus-visible {
  outline: 0.125rem solid var(--black);
  outline-offset: 0.125rem;
}

.recipe-hub__option-icon,
.recipe-hub__chip-icon {
  display: inline-flex;
  width: 1rem;
  height: 1rem;
}

.recipe-hub__option-icon svg,
.recipe-hub__chip-icon svg {
  width: 100%;
  height: 100%;
}

.recipe-hub__actions {
  display: flex;
  gap: var(--spacer--sm);
}

.recipe-hub__actions .recipe-hub__reset {
  display: none;
}

.recipe-hub__actions .recipe-hub__submit {
  flex: 1;
}

/* Results */

.recipe-hub__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--spacer--sm);
}

.recipe-hub__selected {
  flex: 1;
  margin: 0;
  font-size: var(--h3-font-size);
  font-weight: var(--font-weight--bold);
  line-height: 1.2;
}

.recipe-hub__filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 1px solid var(--black);
  border-radius: 50%;
  background: none;
  color: var(--black);
  cursor: pointer;
}

.recipe-hub__filter-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.recipe-hub__chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacer--xs);
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recipe-hub__chip {
  display: inline-flex;
  align-items: center;
  min-height: 2.5625rem;
  gap: var(--spacer--2xs);
  border: 1px solid var(--black);
  border-radius: var(--border-radius--md);
  padding: var(--spacer--xs) var(--spacer--md);
  color: var(--black);
  font-size: var(--small-font-size--mobile);
  font-weight: var(--font-weight--bold);
  text-transform: uppercase;
  text-decoration: none;
}

.recipe-hub__chip:hover,
.recipe-hub__chip:focus-visible {
  background: var(--black);
  color: var(--white);
}

.recipe-hub__count {
  margin: var(--spacer--xs) 0 var(--spacer--md);
  font-size: var(--small-font-size--mobile);
  text-transform: uppercase;
}

.recipe-hub__empty {
  margin: var(--spacer--xl) 0;
}

.recipe-hub__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--spacer--sm);
}

.recipe-hub__more-wrap {
  display: flex;
  justify-content: center;
  margin-top: var(--spacer--xl);
}

.recipe-hub__sticky {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: var(--spacer--lg);
  padding: var(--spacer--sm) var(--spacer--md);
  background: var(--paper, var(--white));
  border-top: 1px solid var(--black);
}

.recipe-hub__sticky .recipe-hub__reset {
  display: flex;
  justify-content: center;
  width: 100%;
}

body.recipe-hub-drawer-open {
  overflow: hidden;
}

@media (min-width: 768px) {
  .recipe-hub {
    grid-template-columns: 22.0625rem minmax(0, 1fr);
  }

  .recipe-hub__panel {
    padding: var(--spacer--xl);
  }

  .recipe-hub__panel-head {
    font-size: var(--large-font-size);
  }

  .recipe-hub__actions .recipe-hub__reset {
    display: inline-flex;
  }

  .recipe-hub__actions .recipe-hub__reset,
  .recipe-hub__actions .recipe-hub__submit {
    flex: 1;
    justify-content: center;
  }

  .recipe-hub__selected {
    flex: 0 1 auto;
    font-size: var(--h2-font-size);
  }

  .recipe-hub__chips {
    flex: 1;
    width: auto;
    gap: var(--spacer--sm);
  }

  .recipe-hub__chip {
    font-size: var(--button--font-size--sm);
    text-transform: none;
  }

  .recipe-hub__count {
    font-size: var(--button--font-size--sm);
  }

  .recipe-hub__grid {
    gap: var(--spacer--lg);
  }
}

@media not all and (min-width: 768px) {
  .recipe-hub__option {
    font-size: 0.75rem;
    line-height: 1.75rem;
    text-transform: uppercase;
  }

  /* Label and a paper pill with a solid caret on one row. */
  .recipe-hub__sort {
    flex-direction: row;
    align-items: center;
    gap: var(--spacer--sm);
  }

  .recipe-hub__sort label {
    flex: 0 0 auto;
    margin: 0;
  }

  .recipe-hub__sort select {
    flex: 1 1 auto;
    max-width: none;
    min-height: 2.5625rem;
    padding-inline: var(--spacer--md) var(--spacer--xl);
    border-radius: var(--input--border-radius);
    appearance: none;
    color: var(--black);
  }

  .recipe-hub__sort::after {
    content: "";
    flex: 0 0 auto;
    margin-inline-start: calc((var(--spacer--md) + 0.75rem + var(--spacer--sm)) * -1);
    margin-inline-end: var(--spacer--md);
    border-inline: 0.375rem solid transparent;
    border-top: 0.4375rem solid var(--black);
    pointer-events: none;
  }
}

/*
 * The off-canvas drawer: mobile, and only when recipe-hub.js runs.
 * The sidebar sits in the hub's container, which the kit's container rule
 * makes a stacking context (z-index 1) below the site header's (100). While the
 * drawer is open the hub is lifted above the header so the drawer's title,
 * Reset and close X paint on top; it drops back once the slide-out ends.
 */
@media not all and (min-width: 768px) {
  .recipe-hub-js .recipe-hub {
    transition: z-index 0s linear .2s;
  }

  .recipe-hub-drawer-open .recipe-hub {
    z-index: 1000;
    transition: none;
  }

  .recipe-hub-js .recipe-hub__sidebar {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: auto;
    background: var(--cream);
    transform: translateX(100%);
    visibility: hidden;
    /* Hide only after the slide-out finishes. */
    transition: transform .2s, visibility 0s linear .2s;
  }

  .recipe-hub-js .recipe-hub__sidebar.is-open {
    transform: none;
    visibility: visible;
    transition: transform .2s, visibility 0s;
  }

  .recipe-hub-js .recipe-hub__filters {
    min-height: 100%;
    padding: var(--spacer--xl) var(--spacer--md) 0;
  }

  .recipe-hub-js .recipe-hub__actions {
    position: sticky;
    bottom: 0;
    margin-inline: calc(var(--spacer--md) * -1);
    margin-top: auto;
    padding: var(--spacer--md);
    background: var(--paper, var(--white));
    border-top: 1px solid var(--black);
  }
}

/*
 * Forced colours replace author backgrounds, which would hide the checked
 * fill; draw the marker in system colours so the state stays visible.
 */
@media (forced-colors: active) {
  .recipe-hub__option input[type="checkbox"] {
    border-color: CanvasText;
  }

  .recipe-hub__option input[type="checkbox"]:checked {
    forced-color-adjust: none;
    background: CanvasText;
  }
}
