/* aimlink.ai FAQ page (support/faq/index.html). Load after site.css and nav.css. Script: assets/faq-page.js.
   The questions are written into the HTML by support/faq/build_faq.py from content/faq.js.

   The FAQ is the quick answer. On the frame of the Contact page (dark hero, light content, dark footer):
   1. Hero (data-rhythm="hero"): the statement on night with the rings of the target as hairlines.
   2. The search hangs over the hero's hard edge, as the form does on Contact. Under it two rows of filters (product, and who
      you are) that combine with the search, and a count that is read out when it changes.
   3. The questions: native <details>, so they open without JS and with the keyboard. Each has a tag for its product, an
      optional "See it in the video" link and a link to copy. Where the browser has JS, a link with a #question opens it.
   4. "Didn't find your answer?" sits beside the list on wide screens (it follows you) and under it on narrow ones.
   Static by default: without JS the search and filters do not show and every question is a closed <details>.
   Reduced motion keeps colour and opacity only. Type and space come from the tokens. */

@layer sections {
  /* ───────────────────────── Hero ───────────────────────── */
  .fq-top { --fq-over: 2.25rem; position: relative; isolation: isolate; }
  .fq-hero { position: relative; isolation: isolate; overflow: clip; background: var(--color-night); color: var(--text); padding-bottom: calc(var(--fq-over) + var(--space-6)); }
  .fq-hero-copy { display: grid; justify-items: start; }
  .fq-hero .hl { display: block; }
  .fq-hero .lede { margin-top: var(--gap-head); color: var(--text); opacity: 0.92; max-width: 34ch; }
  .fq-hero .w { display: inline-block; animation: rise var(--duration-reveal) var(--ease-out) both; animation-delay: calc(120ms + var(--i) * var(--motion-stagger)); }
  .fq-hero .lede { animation: rise var(--duration-reveal) var(--ease-out) 360ms both; }
  .fq-rings {
    position: absolute; z-index: -1; right: -26vw; top: -14vw; width: 72vw; aspect-ratio: 1; pointer-events: none;
    background: repeating-radial-gradient(circle at 50% 50%, transparent 0 calc(5.5% - 1px), rgb(160 224 32 / 0.16) calc(5.5% - 1px) 5.5%);
    -webkit-mask-image: radial-gradient(circle at 50% 50%, black 0 56%, transparent 71%);
    mask-image: radial-gradient(circle at 50% 50%, black 0 56%, transparent 71%);
  }
  @media (min-width: 900px) { .fq-rings { right: -2vw; top: -12vw; width: 50vw; } }

  /* ───────────────────────── Body ───────────────────────── */
  .fq-body { background: var(--bg); color: var(--text); padding-top: 0; }
  .fq-grid { display: grid; gap: var(--gap-action); }
  .fq-find { position: relative; margin-top: calc(-1 * var(--fq-over)); display: grid; gap: var(--space-5); min-width: 0; }
  .fq-main { min-width: 0; display: grid; gap: var(--space-4); align-content: start; }
  @media (min-width: 1100px) {
    .fq-grid { grid-template-columns: minmax(0, 1fr) 20rem; grid-template-areas: "find ." "main ask"; column-gap: clamp(2rem, 5vw, 5rem); row-gap: var(--space-6); align-items: start; }
    .fq-find { grid-area: find; }
    .fq-main { grid-area: main; }
    .fq-ask { grid-area: ask; position: sticky; top: calc(var(--nav-space) + var(--space-4)); }
  }

  /* the search: a white pill that straddles the edge of the hero */
  .fq-search {
    position: relative; display: flex; align-items: center; gap: var(--space-3); min-height: 4.5rem; padding: 0 var(--space-3) 0 var(--space-5);
    border-radius: var(--radius-pill); background: var(--color-white); color: var(--color-ink); box-shadow: 0 0 0 1px var(--color-line-light), 0 18px 40px -18px rgb(12 20 28 / 0.55);
    animation: fq-ride 700ms var(--ease-out) 200ms both;
  }
  .fq-search[hidden] { display: none; }
  @keyframes fq-ride { from { opacity: 0; transform: translateY(14px); } }
  .fq-search:focus-within { box-shadow: 0 0 0 2px var(--color-moss), 0 18px 40px -18px rgb(12 20 28 / 0.55); }
  .fq-search-ic { flex: none; width: 28px; height: 28px; color: var(--color-ink-3); }
  .fq-search input {
    flex: 1; min-width: 0; height: 4.5rem; padding: 0; border: 0; background: transparent; color: var(--color-ink); font: 400 1.1875rem/1.3 var(--font-text);
  }
  .fq-search input::placeholder { color: var(--color-ink-3); opacity: 1; }
  .fq-search input:focus-visible { outline: none; }
  .fq-search input::-webkit-search-cancel-button, .fq-search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
  .fq-clear { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--color-paper); color: var(--color-ink); cursor: pointer; transition: background-color var(--duration-hover) var(--ease-hover); }
  .fq-clear[hidden] { display: none; }
  .fq-clear .icon { width: 28px; height: 28px; }
  @media (hover: hover) and (pointer: fine) { .fq-clear:hover { background: var(--color-stone); } }
  .fq-clear:focus-visible { outline: var(--line-focus) solid var(--focus); outline-offset: 2px; }

  /* the filters: two rows of chips (the site's chip component, real buttons with aria-pressed) */
  .fq-filters { display: grid; gap: var(--space-4); }
  .fq-filters[hidden] { display: none; }
  /* both stand in their place from the first paint (class .js is set in the head); faq-page.js only unhides them, so the list below does not drop by their height */
  .js .fq-search[hidden] { display: flex; }
  .js .fq-filters[hidden] { display: grid; }
  .fq-fgroup { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); align-items: center; gap: var(--space-3); }
  .fq-flabel { font: 700 var(--type-label-size)/1.3 var(--font-text); letter-spacing: var(--type-label-tracking); text-transform: uppercase; color: var(--text-subtle); }
  .fq-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
  @media (max-width: 599.98px) { .fq-fgroup { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); } }

  .fq-count { font-size: var(--type-small-size); color: var(--text-muted); min-height: 1.5em; }

  .fq-refine[hidden], .fq-selection[hidden], .fq-reset-all[hidden] { display: none; }
  .fq-refine > summary { display: none; }
  .fq-selection { display: flex; flex-wrap: wrap; gap: 4px var(--space-4); align-items: center; padding-block: var(--space-3); border-bottom: 1px solid var(--line); background: var(--bg); }
  .fq-selection p { flex: 1 1 16ch; font-size: var(--type-small-size); color: var(--text); }
  .fq-reset-all, .fq-selection > a, .fq-back-to-filters { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: var(--accent-text); font: 700 .875rem/1.4 var(--font-text); text-decoration: underline; text-underline-offset: .2em; cursor: pointer; }
  .fq-reset-all:focus-visible, .fq-selection > a:focus-visible, .fq-back-to-filters:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  .fq-selection > a { display: none; }
  .fq-back-to-filters { color: var(--text-muted); }
  .fq-back-to-filters--mobile { display: none; }
  @media (max-width: 1023.98px) {
    .fq-back-to-filters--mobile { display: inline-flex; }
  }
  .fq[open] { background: var(--bg-alt); }
  .fq[open] .fq-q { color: var(--accent-text); }
  .fq summary, .fq-a-in { padding-inline: var(--space-3); }
  @media (max-width: 599.98px) {
    .fq-find { gap: var(--space-3); scroll-margin-top: var(--space-4); }
    .fq-refine { border: 1px solid var(--line); border-radius: var(--radius-media); padding: 0 var(--space-4); }
    .fq-refine > summary { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px var(--space-3); min-height: 76px; padding-block: 12px; list-style: none; font: 500 1.5rem/1.1 var(--font-display); cursor: pointer; }
    .fq-refine > summary::-webkit-details-marker { display: none; }
    .fq-refine > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-xs); }
    .fq-refine > summary > small { grid-column: 1; font: 400 .875rem/1.4 var(--font-text); color: var(--text-muted); }
    .fq-refine > summary > .icon { grid-column: 2; grid-row: 1 / 3; width: 24px; height: 24px; }
    .fq-refine[open] > summary > .icon { transform: rotate(180deg); }
    .fq-refine .fq-filters { padding-block: var(--space-3) var(--space-5); border-top: 1px solid var(--line); }
    .fq-chips .chip { min-height: 44px; }
    .fq-selection { position: sticky; top: 0; z-index: 4; padding: 8px 12px; margin-inline: -12px; }
    .fq-selection > p { flex-basis: 100%; }
    .fq-selection > a { display: inline-flex; }
  }

  /* ───────────────────────── The questions ───────────────────────── */
  .fq-list { list-style: none; margin: 0; padding: 0; border-top: var(--line-hairline) solid var(--line); }
  .fq-li { border-bottom: var(--line-hairline) solid var(--line); scroll-margin-top: calc(var(--nav-space) + var(--space-4)); }
  .fq-li[hidden] { display: none; }
  .fq { scroll-margin-top: calc(var(--nav-space) + var(--space-4)); }
  /* the question is a heading inside the summary (so a screen reader can jump from question to question), the tag sits under it,
     the plus on the right spans both rows */
  .fq summary {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "q ic" "tag ic"; align-items: center; justify-items: start;
    column-gap: var(--space-4); row-gap: var(--space-2); min-height: 4.5rem; padding: var(--space-4) 0; cursor: pointer; list-style: none;
    -webkit-tap-highlight-color: transparent;
  }
  .fq summary::-webkit-details-marker { display: none; }
  .fq summary:focus-visible { outline: var(--line-focus) solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }
  .fq-q { grid-area: q; min-width: 0; margin: 0; font: 600 clamp(1.125rem, 1.05rem + 0.35vw, 1.3125rem)/1.35 var(--font-text); color: var(--text); text-wrap: balance; transition: color var(--duration-hover) var(--ease-hover); }
  @media (hover: hover) and (pointer: fine) { .fq summary:hover .fq-q { color: var(--accent-strong); } }
  .fq-ic { grid-area: ic; justify-self: end; flex: none; width: 36px; height: 36px; color: var(--text); transition: transform var(--duration-nav) var(--ease-out); }
  .fq[open] .fq-ic { transform: rotate(45deg); }

  /* the product tag: the app's colours as fills with dark text (lime never stands alone on white) */
  .fq-tag { grid-area: tag; display: inline-block; padding: 3px 10px 2px; border-radius: var(--radius-pill); font: 700 0.6875rem/1.4 var(--font-text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-ink); background: var(--color-stone); }
  .fq-tag[data-cat="go"] { background: var(--color-lime); }
  .fq-tag[data-cat="club"] { background: var(--color-orange); }
  .fq-tag[data-cat="target"] { background: var(--color-yellow); }

  /* the answer opens and closes by grid rows (0fr to 1fr, 240 ms, the site's ease-out) with the text fading 180 ms; the icon turns
     in the same 240 ms. ::details-content is the grid, .fq-a the clipped row, .fq-a-in the padded content. Browsers without
     ::details-content (and without interpolating the keyword) simply show and hide the answer. */
  .fq-a { min-height: 0; overflow: hidden; }
  .fq-a-in { display: grid; gap: var(--space-4); justify-items: start; padding: 0 0 var(--space-6); }
  @supports selector(::details-content) {
    .fq::details-content { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--duration-nav) var(--ease-out), content-visibility var(--duration-nav) allow-discrete; }
    .fq[open]::details-content { grid-template-rows: 1fr; }
    .fq-a-in { opacity: 0; transition: opacity var(--duration-exit) var(--ease-out); }
    .fq[open] .fq-a-in { opacity: 1; transition-duration: 180ms; transition-delay: 40ms; }
    @starting-style { .fq[open] .fq-a-in { opacity: 0; } }
    .fq-list.is-quiet .fq::details-content, .fq-list.is-quiet .fq-a-in { transition: none; }
  }
  .fq-text { max-width: 65ch; font-size: var(--type-body-size); line-height: 1.65; color: var(--text-muted); text-wrap: pretty; }
  .fq-text a, .fq-empty a, .fq-ask p a {
    color: var(--text); text-decoration: underline; text-decoration-thickness: var(--line-underline); text-underline-offset: 0.2em; text-decoration-color: var(--text-subtle);
    transition: text-decoration-color var(--duration-hover) var(--ease-hover);
  }
  @media (hover: hover) and (pointer: fine) { .fq-text a:hover, .fq-empty a:hover, .fq-ask p a:hover { text-decoration-color: var(--accent-strong); } }
  .fq-text a:focus-visible, .fq-empty a:focus-visible, .fq-ask p a:focus-visible { outline: var(--line-focus) solid var(--focus); outline-offset: 2px; border-radius: 2px; }
  .fq-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-5); }
  .fq-video, .fq-copy {
    display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
    font: 700 var(--type-small-size)/1.2 var(--font-text); color: var(--accent-text); text-decoration: none;
    transition: color var(--duration-hover) var(--ease-hover);
  }
  .fq-copy { color: var(--text-muted); font-weight: 600; text-decoration: underline; text-decoration-thickness: var(--line-underline); text-underline-offset: 0.2em; text-decoration-color: var(--text-subtle); }
  .fq-copy[hidden] { display: none; }
  .fq-video .icon { width: 28px; height: 28px; margin: -4px 0; }
  @media (hover: hover) and (pointer: fine) { .fq-video:hover { color: var(--accent-strong); } .fq-copy:hover { color: var(--text); } }
  .fq-video:focus-visible, .fq-copy:focus-visible { outline: var(--line-focus) solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }

  /* the match in a question or an answer */
  .fq mark { padding: 0 0.12em; margin: 0 -0.04em; border-radius: 3px; background: var(--color-lime); color: var(--color-ink); }
  .fq-li.is-target > .fq { animation: fq-flash 1600ms var(--ease-out) both; }
  @keyframes fq-flash { from { background: color-mix(in srgb, var(--color-lime) 35%, transparent); } to { background: transparent; } }

  /* nothing matches */
  .fq-empty { display: grid; gap: var(--space-3); justify-items: start; padding: var(--space-6) 0; }
  .fq-empty[hidden] { display: none; }
  .fq-empty-title { font: var(--type-title-weight) var(--type-title-size)/var(--type-title-leading) var(--font-display); letter-spacing: var(--type-title-tracking); }
  .fq-empty p { color: var(--text-muted); font-size: var(--type-body-size); }

  /* didn't find your answer */
  .fq-ask { display: grid; gap: var(--space-3); align-content: start; padding: clamp(1.5rem, 3vw, 2rem); margin-top: var(--space-4); border-radius: var(--radius-panel); background: var(--bg-alt); box-shadow: inset 0 0 0 1px var(--line); }
  @media (min-width: 1100px) { .fq-ask { margin-top: 0; } }
  .fq-ask p { color: var(--text-muted); font-size: var(--type-body-size); line-height: 1.55; }
  .fq-ask-actions { margin-top: var(--space-2); }
  .fq-ask-mail, .fq-ask-more { font-size: var(--type-small-size); }
}

/* ───────────────────────── Reduced motion: colour and opacity only ───────────────────────── */
@layer utilities {
  @media (prefers-reduced-motion: reduce) {
    .fq-hero .w, .fq-hero .lede, .fq-search, .fq-li.is-target > .fq { animation: none; }
    .fq-ic { transition: none; }
    /* the answer still fades (feedback), the height does not move */
    .fq::details-content { transition: none; }
    .fq-a-in, .fq[open] .fq-a-in { transition-duration: var(--duration-reduced); transition-delay: 0s; }
  }
}

/* a short settle when the filter or search changes which questions show (faq-page.js) */
@media (prefers-reduced-motion: no-preference) {
  [data-fq-list].is-fresh { animation: fq-fresh 140ms var(--ease-out); }
  @keyframes fq-fresh { from { opacity: 0.55; } to { opacity: 1; } }
}
