/* ==========================================================================
   Devgun Family Law -- Block: FAQ accordion (FaqBlock)
   Figma: FAQ sections 7115:502 (Home), 7138:665 (Family Law LP), 7138:855
   (Collab detail). Full-width band (bg via the shared section-bg--* utility
   on the block wrapper -- foundation/base.css), centered heading, 988px
   question/answer column, 1px hairline between items.

   Type per frontend-build-spec.md: questions are Heading 5 (28/600,
   Forest Green on light bands -- contrast pairing #9); answers are Body-2
   on --color-text-default (pairing #6). Section heading pixel-samples to
   Dark Green #1D2B24 at H3 scale/regular weight on every design frame.

   Interaction (spec 5.3, prescribed): collapsed by default, chevron
   rotates on open, grid-template-rows transition. All motion is scoped
   under prefers-reduced-motion: no-preference (belt) on top of the global
   reduced-motion kill switch in foundation/base.css (braces).

   Progressive enhancement: without chrome.js the server markup renders
   every answer open and no chevron. chrome.js adds .faq-block--enhanced,
   which switches on the collapsed/animated styles.
   ========================================================================== */

.faq-block {
  --faq-heading-color: var(--color-green-dark);
  --faq-question-color: var(--color-text-heading);
  --faq-answer-color: var(--color-text-default);
  /* Visible hairline between items (2026-07-04): the old --color-border-subtle
     (12%) was too faint to read on the cream band. */
  --faq-divider-color: rgba(32, 49, 52, 0.22);
}

/* Dark bands (shared section-bg contract): text flips to white/muted
   white, hairline flips to the Light Blue brand divider color. */
.faq-block.section-bg--dark-blue,
.faq-block.section-bg--forest-green,
.faq-block.section-bg--dark-green,
.faq-block.section-bg--rich-black {
  --faq-heading-color: var(--color-text-on-dark);
  --faq-question-color: var(--color-text-on-dark);
  --faq-answer-color: var(--color-text-muted-on-dark);
  --faq-divider-color: var(--color-divider);
}

/* Canopy Blue band keeps dark text (base contract) but Forest Green on
   Canopy is only 2.49:1 -- fall back to the default text color, which
   clears the 3:1 large-text threshold for the H5 questions/heading. */
.faq-block.section-bg--canopy-blue {
  --faq-heading-color: var(--color-text-default);
  --faq-question-color: var(--color-text-default);
}

.faq-block__inner {
  max-width: calc(988px + 2 * var(--space-page-gutter));
  margin: 0 auto;
  /* Tighter top than bottom (Dave 2026-07-04): trim the gap above the FAQ. */
  padding: calc(var(--space-section-y) * 0.5) var(--space-page-gutter) var(--space-section-y);
}

/* Section heading (X10): was rendering at the H3 clamp (42px desktop);
   design measures ~28px -- moved to the section-headline token
   (foundation/tokens.css), which mirrors the H5 clamp shape/range. */
.faq-block__heading {
  font-weight: var(--fw-regular);
  font-size: var(--fs-section-headline);
  line-height: var(--lh-h5);
  letter-spacing: var(--ls-h5);
  color: var(--faq-heading-color);
  text-align: center;
  margin: 0 0 1.25rem;
}

.faq-block__intro {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.faq-block__intro p:last-child {
  margin-bottom: 0;
}

/* Heading -> first question gap is ~60px in the design (7115:505). */
.faq-block__list:not(:first-child) {
  margin-top: clamp(2rem, 3.5vw, 3.75rem);
}

/* Hairline between items only (none above the first or below the last). */
.faq-block__item + .faq-block__item {
  border-top: 1px solid var(--faq-divider-color);
}

.faq-block__question {
  margin: 0;
}

/* Question row: H5 type on a full-width transparent button. */
.faq-block__question-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  margin: 0;
  padding: 1.25rem 0;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-family-base);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-h5);
  line-height: var(--lh-h5);
  letter-spacing: var(--ls-h5);
  color: var(--faq-question-color);
}

.faq-block__item:first-child .faq-block__question-button {
  padding-top: 0;
}

/* Hover/focus affordance per spec 5.3 (question underline). */
.faq-block__question-button:hover .faq-block__question-text,
.faq-block__question-button:focus-visible .faq-block__question-text {
  text-decoration: underline;
}

/* Chevron: matches the question text color; hidden until JS enhances the
   block (static open markup should not advertise a toggle). */
.faq-block__chevron {
  display: none;
  flex: 0 0 auto;
  width: 1em;
  height: auto;
}

.faq-block--enhanced .faq-block__chevron {
  display: block;
}

.faq-block__question-button[aria-expanded='true'] .faq-block__chevron {
  transform: rotate(180deg);
}

/* Answers: Body-2. Bottom spacing comes from the CMS content's own
   trailing paragraph margin (contained by the overflow context below). */
.faq-block__answer-body {
  min-height: 0;
  overflow: hidden;
  font-weight: var(--fw-regular);
  font-size: var(--fs-body2);
  line-height: var(--lh-body2);
  letter-spacing: var(--ls-body2);
  color: var(--faq-answer-color);
}

/* Collapsed/expanded states -- only once JS has enhanced the block. */
.faq-block--enhanced .faq-block__answer {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
}

.faq-block--enhanced .faq-block__item.is-open .faq-block__answer {
  grid-template-rows: 1fr;
  visibility: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .faq-block__chevron {
    transition: transform 0.3s ease;
  }

  .faq-block--enhanced .faq-block__answer {
    transition: grid-template-rows 0.3s ease, visibility 0s linear 0.3s;
  }

  .faq-block--enhanced .faq-block__item.is-open .faq-block__answer {
    transition: grid-template-rows 0.3s ease, visibility 0s;
  }
}
