/* FAQ accordion (see /js/faq-block.js). Used by the quiz 'faq' block, the
   landing page 'lp_faq' block and the builder canvas. Colors come from the
   theme vars (--text, --primary, and the --surface* set theme-surface.js
   adds on dark themes), so it stays readable on every theme preset. */

.yf-faq {
  --faq-accent: var(--primary, #2563eb);
  --faq-border: var(--surface-border, #e5e7eb);
  --faq-surface: var(--surface, #ffffff);
  /* Accent nudged toward the text color: lifts the icons on dark themes
     and keeps them crisp on light ones. */
  --faq-ink: var(--faq-accent);
  --faq-ink: color-mix(in srgb, var(--faq-accent) 78%, var(--text, #111827));
  text-align: left;
  font-family: inherit;
}

.yf-faq-header {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-align: center;
  color: var(--text, #111827);
}

.yf-faq-sub {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  color: var(--theme-muted, #6b7280);
}

.yf-faq-header + .yf-faq-list {
  margin-top: 16px;
}

.yf-faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Item ---------- */

.yf-faq-item {
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.yf-faq-q {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 16px 18px;
  border: 0;
  background: none;
  color: var(--text, #111827);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.yf-faq-q:focus-visible {
  outline: 2px solid var(--faq-accent);
  outline-offset: -2px;
  border-radius: inherit;
}

.yf-faq-qtext {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Icon badge: a tinted circle with the icon masked in the accent color. */
.yf-faq-badge {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
  background: color-mix(in srgb, var(--faq-accent) 14%, transparent);
}

.yf-faq-icon {
  width: 18px;
  height: 18px;
  background: var(--faq-ink);
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}

/* Plus that turns into a minus. */
.yf-faq-toggle {
  position: relative;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
  background: color-mix(in srgb, var(--faq-accent) 12%, transparent);
  transition: background-color 0.2s ease, transform 0.25s ease;
}

.yf-faq-toggle::before,
.yf-faq-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  border-radius: 2px;
  background: var(--faq-ink);
  transition: transform 0.25s ease, background-color 0.2s ease;
}

.yf-faq-toggle::after {
  transform: rotate(90deg);
}

.yf-faq-item.is-open .yf-faq-toggle {
  background: var(--faq-accent);
}

.yf-faq-item.is-open .yf-faq-toggle::before,
.yf-faq-item.is-open .yf-faq-toggle::after {
  background: #ffffff;
}

.yf-faq-item.is-open .yf-faq-toggle::after {
  transform: rotate(0deg);
}

/* Chevron variant. */
.yf-faq--chevron .yf-faq-toggle {
  background: none;
}

.yf-faq--chevron .yf-faq-toggle::before {
  width: 8px;
  height: 8px;
  margin: -6px 0 0 -4px;
  border-radius: 0;
  background: none;
  border-right: 2px solid var(--faq-ink);
  border-bottom: 2px solid var(--faq-ink);
  transform: rotate(45deg);
}

.yf-faq--chevron .yf-faq-toggle::after {
  display: none;
}

.yf-faq--chevron .yf-faq-item.is-open .yf-faq-toggle {
  background: none;
  transform: rotate(180deg);
}

.yf-faq--chevron .yf-faq-item.is-open .yf-faq-toggle::before {
  background: none;
}

/* Answer: animates open with the grid-rows trick, no height measuring. */
.yf-faq-a {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
}

.yf-faq-item.is-open .yf-faq-a {
  grid-template-rows: 1fr;
}

.yf-faq-a-inner {
  min-height: 0;
  overflow: hidden;
}

.yf-faq-answer {
  margin: 0;
  padding: 0 18px 18px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: break-word;
  color: var(--theme-soft, #4b5563);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.yf-faq-item.has-icon .yf-faq-answer {
  padding-left: 66px;
}

.yf-faq-item.is-open .yf-faq-answer {
  opacity: 1;
  transform: none;
}

/* ---------- Styles ---------- */

/* Cards: separate rounded cards that lift when open. */
.yf-faq--cards .yf-faq-item {
  border: 1px solid var(--faq-border);
  border-radius: 14px;
  background: var(--faq-surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.yf-faq--cards .yf-faq-item.is-open {
  border-color: var(--faq-accent);
  border-color: color-mix(in srgb, var(--faq-accent) 45%, var(--faq-border));
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.22);
}

/* Minimal: just dividers, sits on the page background. */
.yf-faq--minimal .yf-faq-list {
  gap: 0;
}

.yf-faq--minimal .yf-faq-item {
  border-bottom: 1px solid var(--faq-border);
}

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

.yf-faq--minimal .yf-faq-q {
  padding-left: 2px;
  padding-right: 2px;
}

.yf-faq--minimal .yf-faq-answer {
  padding-left: 2px;
  padding-right: 2px;
}

.yf-faq--minimal .yf-faq-item.has-icon .yf-faq-answer {
  padding-left: 50px;
}

/* Boxed: one panel with rows inside. */
.yf-faq--boxed .yf-faq-list {
  gap: 0;
  border: 1px solid var(--faq-border);
  border-radius: 16px;
  background: var(--faq-surface);
  overflow: hidden;
}

.yf-faq--boxed .yf-faq-item + .yf-faq-item {
  border-top: 1px solid var(--faq-border);
}

/* Highlight (e.g. a guarantee): accent tint plus an accent edge. */
.yf-faq-item.is-highlight {
  background: rgba(37, 99, 235, 0.06);
  background: color-mix(in srgb, var(--faq-accent) 7%, var(--faq-surface));
}

.yf-faq--cards .yf-faq-item.is-highlight,
.yf-faq--boxed .yf-faq-item.is-highlight {
  box-shadow: inset 3px 0 0 var(--faq-accent);
}

.yf-faq--cards .yf-faq-item.is-highlight.is-open {
  box-shadow: inset 3px 0 0 var(--faq-accent), 0 10px 24px -12px rgba(0, 0, 0, 0.22);
}

.yf-faq--minimal .yf-faq-item.is-highlight {
  border-radius: 10px;
  box-shadow: inset 3px 0 0 var(--faq-accent);
}

.yf-faq--minimal .yf-faq-item.is-highlight .yf-faq-q,
.yf-faq--minimal .yf-faq-item.is-highlight .yf-faq-answer {
  padding-left: 14px;
  padding-right: 12px;
}

.yf-faq--minimal .yf-faq-item.is-highlight.has-icon .yf-faq-answer {
  padding-left: 62px;
}

@media (hover: hover) {
  .yf-faq--cards .yf-faq-item:not(.is-open):hover {
    border-color: color-mix(in srgb, var(--faq-accent) 30%, var(--faq-border));
  }

  .yf-faq-q:hover .yf-faq-qtext {
    color: var(--faq-accent);
    color: color-mix(in srgb, var(--faq-accent) 70%, var(--text, #111827));
  }
}

@media (prefers-reduced-motion: reduce) {
  .yf-faq-a,
  .yf-faq-answer,
  .yf-faq-toggle,
  .yf-faq-toggle::before,
  .yf-faq-toggle::after {
    transition: none;
  }
}
