/**
 * @file
 * FAQ Section — Wealthsimple-style two-column sticky-sidebar accordion.
 *
 * Brand tokens: navy #1C3557, green #3CB944, accent green 2 #1D9E75,
 * heading #0A0A0A, body #45464F, light wash #E8F5E9. Font: Manrope.
 *
 * SPACING — strict 4px rule via the shared rem scale; vertical rhythm halved
 * from the prior build for a tighter, denser column.
 * TYPOGRAPHY — line-height & tracking are inversely proportional to font size
 * (large headings: tight line-height + negative tracking; body: loose + 0).
 *
 * Animation: the open/close height transition is pure CSS (0.3s) using the
 * grid-template-rows 0fr -> 1fr trick on .faq-content-wrapper.is-open
 * (no JS height math). JS only toggles ARIA state + the .is-open class.
 */

@font-face {
  font-family: 'Manrope';
  src: url('../../fonts/Manrope-VariableFont_wght.woff2?v=2') format('woff2-variations');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

.faq-section {
  /* Brand tokens */
  --navy-primary: #1c3557;
  --green-accent: #3cb944;
  --green-accent-2: #1d9e75;
  --heading-black: #0a0a0a;
  --body-text: #45464f;
  --light-wash: #e8f5e9;
  --hairline-light: #ededed;

  /* 4px spacing scale (rem) */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-16: 4rem;     /* 64px */

  /* Radii */
  --faq-radius: 16px;

  background: #fff;
  color: var(--body-text);
  font-family: 'Manrope', -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Layout ---------- */
.faq-grid-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-16);
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
  /* Unified section rhythm token — every homepage section shares the same
     padding-block (replaces the old halved one-off values). */
  padding: var(--et-section-pad-y, 5rem) var(--space-8);
}

/* min-width:0 lets grid children shrink so long content never forces
   horizontal page scroll. */
.faq-sidebar,
.faq-accordion-group {
  min-width: 0;
}

/* ---------- Sticky sidebar ---------- */
.faq-sidebar {
  position: sticky;
  top: 120px;
}

/* Unified H2 token — identical to every other section title. */
.faq-sidebar__heading {
  margin: 0 0 var(--space-3);
  font-family: 'Manrope', sans-serif; /* beats the base theme's h1-h6 Roboto rule */
  font-size: var(--et-h2-size);
  font-weight: var(--et-h2-weight, 800);
  line-height: var(--et-h2-lh, 1.15); /* large heading => tight */
  letter-spacing: var(--et-h2-track, -0.02em);
  color: var(--et-heading-color, #0a0a0a);
}

/* Sub-description under the heading. Reads as secondary copy: body colour
   (Tailwind #6b7280 from the reference remapped to the locked --body-text so it
   still clears WCAG AA on white), loose body line-height, narrow measure so it
   wraps cleanly beneath the heading like the reference. */
.faq-sub-description {
  max-width: 34ch;
  margin: var(--space-4) 0 var(--space-10);   /* 16px top / 40px bottom */
  font-size: var(--et-lead-size, 1.125rem);   /* unified lead size */
  line-height: var(--et-body-lh, 1.6);        /* body copy => loose, breathable */
  letter-spacing: 0;        /* body size => neutral tracking */
  color: var(--body-text);
}

.faq-sidebar__media {
  margin-top: var(--space-2);
}

.faq-sidebar__media img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--faq-radius);
}

/* ---------- Accordion ---------- */
.faq-item {
  border-bottom: 1px solid var(--hairline-light);
}

.faq-item:first-child {
  border-top: 1px solid var(--hairline-light);
}

.faq-item__title {
  margin: 0;
  /* Explicit family: the base theme's h1-h6 Roboto element rule would win over
     inheritance here, and the trigger button inherits FROM this h3. */
  font-family: 'Manrope', sans-serif;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.faq-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  width: 100%;
  padding: var(--space-4) 0;   /* 16px — rows breathe; 12px read squished (2026-07-09 audit) */
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;            /* mid size => moderate */
  letter-spacing: -0.01em;
  text-align: left;
  color: var(--navy-primary);
  background: none;
  border: none;
  cursor: pointer;
}

.faq-trigger__text {
  overflow-wrap: anywhere;
}

.faq-trigger:hover {
  color: var(--green-accent);
}

.faq-trigger:focus-visible {
  outline: 2px solid var(--green-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- +/- icon ---------- */
.faq-icon {
  flex: 0 0 auto;
  color: var(--navy-primary);
  transition: transform 0.3s ease;
}

.faq-icon__bar {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.faq-trigger:hover .faq-icon {
  color: var(--green-accent);
}

/* Plus rotates 45deg -> becomes a "x" (close) when the row is open. */
.faq-trigger[aria-expanded='true'] .faq-icon {
  transform: rotate(45deg);
  color: var(--green-accent);
}

/* ---------- Answer (CSS grid height animation) ---------- */
.faq-content-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease-out;
}

/* The display:grid above out-specifies the UA [hidden] rule, so restore it
   explicitly — otherwise the collapsed-by-default [hidden] panel would show. */
.faq-content-wrapper[hidden] {
  display: none;
}

.faq-content-wrapper.is-open {
  grid-template-rows: 1fr;
}

.faq-answer-inner {
  overflow: hidden;
  min-height: 0;
  padding-bottom: var(--space-4);   /* 16px — clear air before the divider */
  color: var(--body-text);
  line-height: 1.6;                 /* body => loose, breathable */
}

/* Mobile (2026-07-09 polish loop): the 16px rhythm is now the base rule —
   phones only add looser leading for two-line titles and cap the artwork. */
@media (max-width: 768px) {
  .faq-trigger {
    gap: var(--space-4);
    line-height: 1.5;            /* wrapped titles breathe */
  }

  /* The decorative illustration was full-column on phones — nearly a whole
     viewport between the intro and the first question. Cap it to an accent. */
  .faq-sidebar__media {
    max-width: 176px;            /* 8pt grid */
    margin-inline: auto;
  }
}

.faq-answer-inner > :first-child {
  margin-top: 0;
}

.faq-answer-inner > :last-child {
  margin-bottom: 0;
}

.faq-answer-inner a {
  color: var(--green-accent);
  text-decoration: underline;
}

.faq-answer-inner a:focus-visible {
  outline: 2px solid var(--green-accent);
  outline-offset: 2px;
}

/* ---------- Responsive: unpin sidebar, single column ---------- */
@media (max-width: 991px) {
  .faq-grid-layout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding: var(--et-section-pad-y, 3rem) var(--space-5);
  }

  .faq-sidebar {
    position: relative;
    top: auto;
  }
}

/* ---------- Reduced motion: instant open/close, no rotation ---------- */
@media (prefers-reduced-motion: reduce) {
  .faq-content-wrapper {
    transition: none;
  }

  .faq-icon {
    transition: none;
  }
}
