/**
 * @file
 * Topic filter pills. "More topics" follows the last primary pill and
 * reveals the rest in that same row.
 */

.rn-topic-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid #ececec;
}

/* One wrapping row: the primary pills, then the toggle, then (once open)
   the rest. display: contents lets those pieces share the nav's flex line
   instead of the toggle sitting in its own box at the right edge. */
.rn-topic-pills__list,
.rn-topic-pills__more,
.rn-topic-pills__menu {
  display: contents;
}

.rn-topic-pills__list,
.rn-topic-pills__menu {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The disclosure's content box would otherwise wrap the extra pills in
   their own block, so they could not continue the row. */
.rn-topic-pills__more[open]::details-content {
  display: contents;
}

.rn-topic-pills__more:not([open]) .rn-topic-pills__menu,
.rn-topic-pills__more:not([open])::details-content {
  display: none;
}

.rn-topic-pills .rn-topic-pills__list li,
.rn-topic-pills .rn-topic-pills__menu li {
  margin: 0;
  padding: 0;
  list-style: none;
}

.rn-topic-pills .rn-topic-pills__pill {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border: 1px solid #dedede;
  background: #fff;
  font-family: Poppins, sans-serif;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--rn-pill-color, #121212);
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease;
}

.rn-topic-pills .rn-topic-pills__pill:hover,
.rn-topic-pills .rn-topic-pills__pill:focus-visible {
  border-color: var(--rn-pill-color, #121212);
}

.rn-topic-pills .rn-topic-pills__pill.is-active {
  border-color: #121212;
  background: #121212;
  color: #fff;
}

/* More topics ------------------------------------------------------------- */

/* custom.css gives every summary a grey box, a text shadow and a bottom
   margin. */
.rn-topic-pills .rn-topic-pills__more-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  margin: 0;
  padding: 0;
  background: none;
  text-shadow: none;
  font-family: Poppins, sans-serif;
  font-size: 12px;
  line-height: 14px;
  font-weight: 600;
  text-transform: uppercase;
  color: #686868;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.rn-topic-pills__more-toggle::-webkit-details-marker,
.rn-topic-pills__more-toggle::marker {
  content: none;
  display: none;
}

.rn-topic-pills__more-toggle::after {
  content: "";
  width: 20px;
  height: 20px;
  background: url(../../assets/images/chevron-down-small.svg) center / 20px 20px no-repeat;
  transition: transform 150ms ease;
}

.rn-topic-pills__more[open] .rn-topic-pills__more-toggle::after {
  transform: rotate(180deg);
}

.rn-topic-pills__more.is-active .rn-topic-pills__more-toggle {
  color: #121212;
}

/* Extra topics stay black. The primary pills above keep their topic color. */
.rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill {
  color: #121212;
}

.rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill:hover,
.rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill:focus-visible {
  border-color: #121212;
}

.rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill.is-active {
  color: #fff;
}

/* Narrow screens: the primary pills scroll sideways on one line, and
   "More topics" is a dropdown centered under that row. */
@media (max-width: 767px) {
  .rn-topic-pills {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 12px;
  }

  .rn-topic-pills .rn-topic-pills__list {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .rn-topic-pills .rn-topic-pills__list::-webkit-scrollbar {
    display: none;
  }

  .rn-topic-pills .rn-topic-pills__more {
    display: block;
    position: relative;
    align-self: center;
  }

  .rn-topic-pills .rn-topic-pills__more[open]::details-content {
    display: block;
  }

  .rn-topic-pills .rn-topic-pills__menu {
    display: block;
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 50%;
    box-sizing: border-box;
    min-width: 220px;
    max-height: 320px;
    padding: 4px 0;
    overflow-y: auto;
    border: 1px solid #dedede;
    background: #fff;
    box-shadow: 0 8px 24px rgba(18, 18, 18, 0.12);
    transform: translateX(-50%);
  }

  .rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill {
    display: block;
    height: auto;
    padding: 8px 16px;
    border: 0;
    background: transparent;
    color: #121212;
  }

  .rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill:hover,
  .rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill:focus-visible {
    border-color: transparent;
    background: #f6f6f6;
  }

  .rn-topic-pills .rn-topic-pills__menu .rn-topic-pills__pill.is-active {
    border-color: transparent;
    background: #121212;
    color: #fff;
  }
}
