/**
 * Custom Bricks element: FAQ
 */
.brxe-custom-faq {
  --faq-transition: 300ms;
  /* Bricks containers default to align-items: flex-start, which would shrink the
     element to its longest line. Fill the parent instead; the Style > Width
     control still wins via #brxe-<id>. */
  width: 100%;
}

/* Base look mirrors the control defaults, so the element looks right however it
   was created (builder, import, programmatic). Control values win via #brxe-<id>. */
.brxe-custom-faq .faq-title {
  margin: 0 0 2rem;
}

.brxe-custom-faq .faq-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Hairline divider that adapts to whatever text colour the item inherits, so it
   stays subtle on light, dark, warm and cool backgrounds alike. The element's
   Border control outputs #brxe-<id> rules, which override this. */
.brxe-custom-faq .faq-item {
  position: relative;
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.brxe-custom-faq .faq-question-heading {
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
}

/* Question: a real <button> so keyboard & screen readers work out of the box */
.brxe-custom-faq .faq-question {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 1rem 0;
  font: inherit;
  font-weight: 700;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: inherit;
  cursor: pointer;
  appearance: none;
}

.brxe-custom-faq .faq-question.icon-left {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.brxe-custom-faq .faq-question-text {
  flex: 1 1 auto;
}

.brxe-custom-faq .faq-question:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.brxe-custom-faq .faq-icon {
  flex: 0 0 auto;
  /* The +/- glyphs carry a lot of internal padding, so they read thin at the
     question's own size. Icon > Typography overrides this. */
  font-size: 1.35em;
  line-height: 1;
  transition: transform var(--faq-transition) ease;
}

.brxe-custom-faq .faq-icon svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: currentColor;
}

/* Swap the closed/open icons (+ / -). The adjacent-sibling rule only fires when
   an expanded icon was actually rendered, so clearing that control leaves the
   single icon visible in both states. */
.brxe-custom-faq .faq-icon.expanded {
  display: none;
}

.brxe-custom-faq .faq-item.brx-open .faq-icon.expanded {
  display: block;
}

.brxe-custom-faq .faq-item.brx-open .faq-icon.expanded + .faq-icon {
  display: none;
}

/* Answer: grid-rows trick animates to the content's natural height */
.brxe-custom-faq .faq-answer {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition:
    grid-template-rows var(--faq-transition) ease,
    visibility var(--faq-transition) ease;
}

.brxe-custom-faq .faq-item.brx-open > .faq-answer {
  grid-template-rows: 1fr;
  visibility: visible;
}

/* Keep this wrapper free of padding/margin/border: any of them would stop the
   collapsed 0fr row from shrinking all the way to 0. */
.brxe-custom-faq .faq-answer-inner {
  min-height: 0;
  overflow: hidden;
}

.brxe-custom-faq .faq-answer-content {
  padding-bottom: 1.5rem;
}

.brxe-custom-faq .faq-answer-content > *:first-child {
  margin-top: 0;
}

.brxe-custom-faq .faq-answer-content > *:last-child {
  margin-bottom: 0;
}

@media (prefers-reduced-motion: reduce) {
  .brxe-custom-faq .faq-answer,
  .brxe-custom-faq .faq-icon {
    transition-duration: 1ms;
  }
}
