/* Guida v2: titolo con ricerca e link rapidi, percorsi guidati, indice appiccicato a sinistra e domande (.qa) a
   destra, invito finale (.chapter.close). Sul telefono l'indice diventa una riga di pillole che scorre. */

@layer pages {
  .help { padding-top: clamp(24px, 3vw, 40px); padding-bottom: var(--section); }

  /* ---------- Titolo ---------- */
  .help-hero {
    margin-top: clamp(28px, 4vw, 56px);
    max-width: 60rem;

    & h1 { margin-top: 10px; font-size: var(--step-hero); max-width: 14ch; }
    & .lead { margin-top: 20px; max-width: 58ch; color: var(--ink-soft); }
  }

  .help-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
    font-size: var(--step-small);

    & li { padding: 6px 14px; border-radius: var(--r-pill); background: var(--tint); }
  }

  .help-search {
    margin-top: 36px;
    max-width: 640px;

    & .field input { height: var(--control-h); font-size: var(--step-body); }
  }
  .help-count {
    margin-top: 12px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font-size: var(--step-small);
    font-weight: 600;
    cursor: pointer;

    &:hover { text-decoration: underline; text-underline-offset: 4px; }
  }
  .help-empty { margin-top: 12px; font-size: var(--step-small); }

  .help-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0 0;
    padding: 0;
    list-style: none;

    & a {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      height: var(--control-h-sm);
      padding: 0 16px;
      border-radius: var(--r-pill);
      box-shadow: inset 0 0 0 1px var(--line);
      font-size: var(--step-small);
      font-weight: 500;
      text-decoration: none;
      transition: box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
    }
    & a:hover { background: var(--tint); box-shadow: inset 0 0 0 1px var(--ink); }
    & .icon { width: 14px; height: 14px; color: var(--accent); }
  }

  /* ---------- Percorsi guidati ---------- */
  .help-paths { padding-top: var(--block); }
  .help-paths-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: var(--gap);
  }
  .help-path {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: clamp(22px, 2.4vw, 32px);
    border-radius: var(--r-md);
    background: var(--tint);

    & h3 { font-size: var(--step-lead); }
    & p { font-size: var(--step-small); }
    & ol {
      display: grid;
      gap: 8px;
      margin: 4px 0 0;
      padding-left: 1.3em;
      font-size: var(--step-small);
    }
    & li::marker { color: var(--accent); font-weight: 600; }
    & .link { margin-top: auto; padding-top: 8px; font-size: var(--step-small); }
  }

  /* ---------- Indice e domande ---------- */
  .help-body {
    display: grid;
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
    column-gap: clamp(40px, 6vw, 112px);
    align-items: start;
    padding-top: var(--section);
  }

  .help-side {
    position: sticky;
    top: 96px;
    max-height: calc(100dvh - 120px);
    overflow-y: auto;
    padding: 2px 2px 4px; /* l'anello di focus e il bordo dei bottoni non vengono tagliati */
  }
  .help-toc {
    font-size: var(--step-small);

    & ul { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
    & a {
      display: block;
      padding: 7px 0;
      color: var(--ink-soft);
      text-decoration: none;
      transition: color var(--dur-fast) var(--ease);
    }
    & a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
  }
  .help-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

  .help-sections { display: grid; gap: var(--block); }
  .help-section { scroll-margin-top: 96px; }
  .help-section-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px 24px;

    & h2 { font-size: var(--step-head); max-width: 22ch; }
  }
  .help-intro { margin-top: 14px; max-width: 62ch; color: var(--ink-soft); }
  .help-tip {
    margin-top: 18px;
    max-width: 62ch;
    padding: 14px 18px;
    border-radius: var(--r-md);
    background: var(--accent-soft);
    font-size: var(--step-small);
  }
  .help-section .qa { margin-top: 24px; }
  .help-section .qa details { scroll-margin-top: 96px; }
  .help-section .qa summary { font-size: clamp(1.125rem, 1.05rem + 0.35vw, 1.375rem); }
  .help-section .qa .q { flex: 1; }
  .help-section .qa .answer {
    display: grid;
    gap: 10px;

    & ol { margin: 0; padding-left: 1.3em; }
    & li + li { margin-top: 4px; }
    & li::marker { color: var(--accent); font-weight: 600; }
    & .hint { font-size: var(--step-small); color: var(--ink-soft); }
  }

  /* copia link: si vede al passaggio sulla domanda (sempre su schermi touch) */
  .help-copy {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);

    & .icon { width: 16px; height: 16px; }
    &:hover { background: var(--tint); color: var(--ink); }
    &:focus-visible { opacity: 1; }
    &.is-done { opacity: 1; color: var(--accent); }
  }
  .qa summary:hover .help-copy, .qa details[open] .help-copy { opacity: 1; }
  @media (hover: none) { .help-copy { opacity: 1; } }

  /* durante la ricerca i risultati salgono: l'indice non serve */
  .help.is-searching .help-toc { display: none; }

  .help-cta { margin-top: var(--section); }

  @media (max-width: 960px) {
    .help-body { grid-template-columns: minmax(0, 1fr); row-gap: 32px; }
    .help-side { position: static; max-height: none; overflow: visible; padding: 0; }
    .help-toc ul {
      display: flex;
      gap: 8px;
      overflow-x: auto;
      scrollbar-width: none;
      margin-inline: calc(var(--m) * -1);
      padding-inline: var(--m);
    }
    .help-toc ul::-webkit-scrollbar { display: none; }
    .help-toc a, .help-toc a:hover {
      text-decoration: none;
      white-space: nowrap;
      padding: 8px 14px;
      border-radius: var(--r-pill);
      background: var(--tint);
      color: var(--ink);
    }
  }
}
