.faq-section {
  width: 100%;
  max-width: 800px;
  margin-block: var(--section-space);
  margin-inline: auto;
}

.faq-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.faq-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition:
    border-color var(--transition),
    background-color var(--transition);
}

.faq-item__header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 12px 16px;
}

/* Override the general content h3 spacing without changing other headings. */
.faq-section .faq-item__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.faq-item__question {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
}

.faq-item__question:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: -3px;
}

.faq-item__icon {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0;
  transition:
    color 0.22s ease,
    border-color 0.22s ease,
    background-color 0.22s ease;
}

.faq-item__icon::before,
.faq-item__icon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%);
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

.faq-item__icon::after {
  width: 2px;
  height: 12px;
  transform: translate(-50%, -50%) scaleY(1);
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.faq-item__answer {
  height: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  padding: 0 16px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  transition:
    opacity var(--transition),
    visibility var(--transition);
}

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

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

.faq-item__answer p {
  margin-block: 0 12px;
}

.faq-item__answer ul,
.faq-item__answer ol {
  padding-inline-start: 22px;
}

.faq-item__answer a {
  text-underline-offset: 3px;
}

.faq-item__answer pre {
  max-width: 100%;
  overflow-x: auto;
}

.faq-item__answer iframe {
  max-width: 100%;
}

.faq-item.is-open {
  border-color: var(--line-accent);
  background: var(--surface-2);
}

.faq-item.is-open .faq-item__icon {
  color: var(--accent);
  border-color: rgba(255, 40, 84, 0.25);
  background: rgba(255, 40, 84, 0.05);
}

.faq-item.is-open .faq-item__icon::after {
  transform: translate(-50%, -50%) scaleY(0.4);
  opacity: 0;
}

.faq-item.is-open .faq-item__answer {
  height: auto;
  visibility: visible;
  opacity: 1;
  padding-top: 4px;
  padding-bottom: 18px;
}

/* Animate intrinsic height where supported; elsewhere reveal without a height cap. */
@supports (interpolate-size: allow-keywords) {
  .faq-item__answer {
    interpolate-size: allow-keywords;
    transition:
      height var(--transition),
      padding var(--transition),
      opacity var(--transition),
      visibility var(--transition);
  }
}

@media (min-width: 768px) {
  .faq-list {
    gap: 12px;
  }

  .faq-item__header {
    padding-inline: 20px;
  }

  .faq-section .faq-item__title {
    font-size: 17px;
  }

  .faq-item__answer {
    padding-inline: 20px;
    font-size: 16px;
  }
}

@media (hover: hover) {
  .faq-item:has(.faq-item__question:hover) {
    border-color: var(--line-strong);
  }
}

@media (prefers-reduced-motion: reduce) {

  .faq-item,
  .faq-item__icon,
  .faq-item__icon::before,
  .faq-item__icon::after,
  .faq-item__answer {
    transition: none;
  }
}
@media (max-width: 640px) {
  .faq-section { max-width: none; }
}

@media (max-width: 640px) {
  .faq-item__header { min-height: 56px; padding: 14px 16px; gap: 10px; }
  .faq-section .faq-item__title { font-size: 14px; line-height: 1.35; }
  .faq-item__icon { flex-basis: 34px; width: 34px; height: 34px; }
  .faq-item__answer { font-size: 14px; line-height: 1.5; }
}
