/* Component „faq”: questions and answers, one open at a time (<details name>). The layer order is the base's
   (kit.css), so this file's place among the links does not matter, and the Site's own site.css wins over it. */
@layer components {
  /* Accordion (the questions): <details name> rows, one open at a time; the opening is in motion */
  .faq-list { display: grid; gap: 0.6rem; }
  /* grouped: a topic's heading over its questions, the first one flush with the list's top */
  .faq-topic { margin-block-start: var(--space-m); font-size: var(--type-body-size); color: var(--c-text-muted); }
  .faq-topic:first-child { margin-block-start: 0; }
  .faq-item { --card-pad: 0; transition: background-color var(--dur-base), border-color var(--dur-base); }
  .faq-item[open] { --card-line: var(--c-line-strong); --card-bg: color-mix(in oklch, var(--c-text) 6%, transparent); }
  .faq-item summary {
    display: flex; justify-content: space-between; align-items: center; gap: var(--space-s);
    padding: var(--space-s) var(--space-s) var(--space-s) var(--space-m); cursor: pointer; list-style: none;
    font-family: var(--font-display); font-weight: var(--heading-weight); font-size: var(--type-body-size); line-height: var(--type-body-leading);
  }
  .faq-item summary::-webkit-details-marker { display: none; }
  .faq-item summary:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: var(--radius-card); }
  .faq-icon {
    position: relative; flex: none; inline-size: 2.25rem; block-size: 2.25rem; border-radius: 50%;
    border: var(--border-w) solid var(--c-line-strong); transition: background-color var(--dur-base), border-color var(--dur-base), color var(--dur-base);
  }
  .faq-icon::before, .faq-icon::after {
    content: ""; position: absolute; inset: 50% auto auto 50%; inline-size: 0.8rem; block-size: 2px; border-radius: var(--radius-badge);
    background: currentColor; translate: -50% -50%;
  }
  .faq-icon::after { rotate: 90deg; }
  .faq-item[open] .faq-icon { background: var(--c-mark); border-color: var(--c-mark); color: var(--c-on-mark); }
  .faq-item[open] .faq-icon::after { rotate: 0deg; }
  /* The answer's box has no padding of its own (its text has it), so faq.js can animate its height to 0 */
  .faq-answer { color: var(--c-text-muted); overflow: clip; }
  .faq-answer p { max-inline-size: calc(62ch + 2 * var(--space-m)); padding: 0 var(--space-m) var(--space-m); }
}

@layer sections {
  /* The head beside the questions on a wide screen, staying in view while they scroll */
  .faq-grid { display: grid; gap: var(--space-xl); }
  @media (min-width: 62rem) {
    .faq-grid { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); align-items: start; }
    .faq-head { position: sticky; inset-block-start: calc(var(--nav-h) + var(--space-m)); }
  }
}

@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    /* The accordion opens to its content's height (interpolate-size; elsewhere it just opens), the
       answer fading down into it, the plus turning into a minus. The one place a size animates: a
       short block, one at a time. */
    @supports (interpolate-size: allow-keywords) {
      .faq-item { interpolate-size: allow-keywords; }
      .faq-item::details-content {
        block-size: 0; overflow-y: clip;
        transition: block-size var(--dur-medium) var(--ease-out), content-visibility var(--dur-medium) allow-discrete;
      }
      .faq-item[open]::details-content { block-size: auto; transition-duration: var(--dur-move); }
      .faq-answer { transition: opacity var(--dur-move) var(--ease-out), translate var(--dur-move) var(--ease-out); }
      .faq-item:not([open]) .faq-answer { opacity: 0; translate: 0 calc(-1 * var(--rise-s)); }
      /* the closed answer was never rendered (content-visibility): its first style needs a start */
      @starting-style { .faq-item[open] .faq-answer { opacity: 0; translate: 0 calc(-1 * var(--rise-s)); } }
    }
    /* Elsewhere (Safari has no interpolate-size) faq.js animates the answer's height and fade */
    .faq-icon::after { transition: rotate var(--dur-medium) var(--ease-out); }
  }
}
