/* =========================================================
   Nowspeed Post FAQs — base styles (2.4.2)

   HOW STYLING WORKS
   The settings page emits CSS custom properties per level on
   .post-faqs__item--parent / --child. This file owns every
   selector and consumes those variables.

   To tweak a site without !important or specificity fights,
   redefine variables in your theme's ns-post-faqs-override.css:

     .post-faqs__item--parent { --faq-icon-bg-open: #24464b; }

   WHY !important: page builders (Beaver Builder Global Styles,
   theme button presets) style every <button> and <p> with
   selectors we can't reliably outrank, e.g.
   `.fl-page .fl-builder-content .fl-module-content:not(:has(..)) button:not(..)`.
   Visual declarations here are !important, but every one of them
   only reads a --faq-* variable, so settings and variable overrides
   still work. Layout properties (width, display, gap) are NOT
   !important, so plain CSS can still adjust them.
   ========================================================= */

.post-faqs {
  margin: 1rem 0 3.5rem;
  padding-top: 1.5rem;
}

.post-faqs__heading {
  margin-bottom: 1.5rem;
}

.post-faqs .post-faqs__items {
  padding-left: var(--faq-indent, 0);
}

.post-faqs .post-faqs__items--child {
  margin-top: 0.9rem;
}

.post-faqs .post-faqs__item {
  margin-bottom: var(--faq-item-gap, 16px);
}

/* ---------- Question button ----------
   Buttons don't inherit fonts by default, and themes style
   them heavily, so reset what themes commonly set. */
.post-faqs .post-faqs__item > .post-faqs__question {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 0 !important;
  height: auto !important;
  margin: 0 !important;
  padding:
    var(--faq-q-pt, 10px)
    var(--faq-q-pr, 14px)
    var(--faq-q-pb, 10px)
    var(--faq-q-pl, 14px) !important;
  text-align: left !important;
  cursor: pointer;

  font-family: inherit !important;
  font-size: var(--faq-q-size, 16px) !important;
  font-weight: var(--faq-q-weight, 600) !important;
  line-height: var(--faq-q-lh, 1.2) !important;
  font-style: normal !important;
  letter-spacing: inherit !important;
  text-transform: none !important;
  text-decoration: none !important;
  text-shadow: none !important;
  white-space: normal;

  color: var(--faq-q-color, #222) !important;
  background: var(--faq-q-bg, #f4f4f4) !important;
  border-style: solid !important;
  border-color: var(--faq-q-border, #ccc) !important;
  border-width:
    var(--faq-q-bt, 1px)
    var(--faq-q-br, 1px)
    var(--faq-q-bb, 1px)
    var(--faq-q-bl, 1px) !important;
  border-radius: var(--faq-q-radius, 4px) !important;
  box-shadow: none !important;

  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Open first, hover after: same specificity, so hover wins and
   open items still give hover feedback. Open values fall back to
   the closed-state values when "Same as closed" is ticked. */
.post-faqs .post-faqs__item > .post-faqs__question[aria-expanded="true"] {
  color: var(--faq-q-color-open, var(--faq-q-color, #222)) !important;
  background: var(--faq-q-bg-open, var(--faq-q-bg, #f4f4f4)) !important;
  border-color: var(--faq-q-border-open, var(--faq-q-border, #ccc)) !important;
}

.post-faqs .post-faqs__item > .post-faqs__question:hover,
.post-faqs .post-faqs__item > .post-faqs__question:focus-visible {
  color: var(--faq-q-color-hover, #222) !important;
  background: var(--faq-q-bg-hover, #e9e9e9) !important;
  border-color: var(--faq-q-border-hover, #ccc) !important;
}

.post-faqs .post-faqs__item > .post-faqs__question:focus {
  outline: none !important;
}

.post-faqs .post-faqs__item > .post-faqs__question:focus-visible {
  outline: var(--faq-focus-w, 2px) var(--faq-focus-style, solid) var(--faq-focus-color, #2271b1) !important;
  outline-offset: var(--faq-focus-offset, 2px) !important;
}

.post-faqs__question-text {
  flex: 1 1 auto;
}

/* Builders often set `button * { color: … }`, which overrides inheritance on
   the text span. Hand it back to the button. */
.post-faqs .post-faqs__item > .post-faqs__question .post-faqs__question-text {
  color: inherit !important;
  font: inherit !important;
  text-transform: inherit !important;
  letter-spacing: inherit !important;
}

/* ---------- Toggle icon ----------
   Two absolutely-centered bars instead of a "+" character.
   A text glyph is positioned by font metrics, so it can never
   be truly centered inside a background shape. */
.post-faqs .post-faqs__item > .post-faqs__question .post-faqs__icon {
  position: relative;
  flex: 0 0 auto;
  display: block;
  width: var(--faq-icon-box, 28px);
  height: var(--faq-icon-box, 28px) !important;
  border-radius: var(--faq-icon-radius, 50%) !important;
  color: var(--faq-icon-color, currentColor) !important;
  background: var(--faq-icon-bg, transparent) !important;
  font-size: 0 !important;
  line-height: 0 !important;
  transition:
    transform var(--ns-anim, 300ms) ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.post-faqs .post-faqs__icon::before,
.post-faqs .post-faqs__icon::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  background: currentColor;
  transition: transform var(--ns-anim, 300ms) ease;
}

/* horizontal bar */
.post-faqs .post-faqs__icon::before {
  width: var(--faq-icon-len, 14px);
  height: var(--faq-icon-stroke, 2px);
}

/* vertical bar */
.post-faqs .post-faqs__icon::after {
  width: var(--faq-icon-stroke, 2px);
  height: var(--faq-icon-len, 14px);
}

.post-faqs .post-faqs__item > .post-faqs__question[aria-expanded="true"] .post-faqs__icon {
  color: var(--faq-icon-color-open, var(--faq-icon-color, currentColor)) !important;
  background: var(--faq-icon-bg-open, var(--faq-icon-bg, transparent)) !important;
}

/* + rotates to ×  (whole icon rotates; the shape is symmetric) */
.post-faqs[data-icon-style="plus-x"] .post-faqs__item > .post-faqs__question[aria-expanded="true"] .post-faqs__icon {
  transform: rotate(45deg);
}

/* + becomes −  (vertical bar collapses) */
.post-faqs[data-icon-style="plus-minus"] .post-faqs__item > .post-faqs__question[aria-expanded="true"] .post-faqs__icon::after {
  transform: scaleY(0);
}

/* ---------- Collapse mechanism ----------
   grid-template-rows 0fr -> 1fr animates height WITHOUT a
   measured pixel cap, so a nested accordion can grow inside
   an open parent without being clipped. */
.post-faqs__answer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--ns-anim, 300ms) ease;
}

.post-faqs__answer--open {
  grid-template-rows: 1fr;
}

/* The single grid child must be able to collapse to zero. It carries NO
   padding/background itself — padding on the collapsing element would leak
   through as a sliver when closed. */
.post-faqs__answer > .post-faqs__answer-inner {
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
}

/* ---------- Answer content ---------- */
.post-faqs .post-faqs__item .post-faqs__answer-content {
  box-sizing: border-box;
  padding:
    var(--faq-a-pt, 16px)
    var(--faq-a-pr, 16px)
    var(--faq-a-pb, 16px)
    var(--faq-a-pl, 16px) !important;
  color: var(--faq-a-color, #333) !important;
  background: var(--faq-a-bg, #fff) !important;
  font-size: var(--faq-a-size, 16px) !important;
  line-height: var(--faq-a-lh, 1.5) !important;
}

/* ---------- Always-visible description ----------
   Each value falls back to the answer's when "Match answer styles" is
   selected (the --faq-d-* variables are set to `initial`). */
.post-faqs .post-faqs__item .post-faqs__description {
  box-sizing: border-box;
  margin: var(--faq-d-mt, 0.5rem) 0 var(--faq-d-mb, 0) !important;
  padding:
    var(--faq-d-pt, var(--faq-a-pt, 16px))
    var(--faq-d-pr, var(--faq-a-pr, 16px))
    var(--faq-d-pb, var(--faq-a-pb, 16px))
    var(--faq-d-pl, var(--faq-a-pl, 16px)) !important;
  color: var(--faq-d-color, var(--faq-a-color, #333)) !important;
  background: var(--faq-d-bg, var(--faq-a-bg, #fff)) !important;
  font-size: var(--faq-d-size, var(--faq-a-size, 16px)) !important;
  font-weight: var(--faq-d-weight, normal) !important;
  line-height: var(--faq-d-lh, var(--faq-a-lh, 1.5)) !important;
  border-style: solid !important;
  border-color: var(--faq-d-border, transparent) !important;
  border-width:
    var(--faq-d-bt, 0)
    var(--faq-d-br, 0)
    var(--faq-d-bb, 0)
    var(--faq-d-bl, 0) !important;
  border-radius: var(--faq-d-radius, 0) !important;
}

/* Themes usually set color/size directly on p, li, etc., which beats the
   inherited value from the container. Force body-copy elements back to
   the settings. Headings and links are left to the theme on purpose. */
.post-faqs .post-faqs__answer-content :is(p, li, dt, dd, td, th, blockquote, figcaption),
.post-faqs .post-faqs__description :is(p, li, dt, dd, td, th, blockquote, figcaption) {
  color: inherit !important;
  font-size: inherit !important;
  line-height: inherit !important;
}

/* Paragraph margins otherwise add uneven space inside the padding. */
.post-faqs .post-faqs__answer-content > :first-child,
.post-faqs .post-faqs__description > :first-child {
  margin-top: 0 !important;
}

.post-faqs .post-faqs__answer-content > :last-child,
.post-faqs .post-faqs__description > :last-child {
  margin-bottom: 0 !important;
}

/* Reduced motion: skip the animation entirely. */
@media (prefers-reduced-motion: reduce) {
  .post-faqs__answer,
  .post-faqs .post-faqs__icon,
  .post-faqs .post-faqs__icon::before,
  .post-faqs .post-faqs__icon::after {
    transition: none;
  }
}
