/**
 * Nonprofit page, final pass (2026-11-21): Who are you here as (pathmap), the site map chart. Loaded for its class prefix
 * (site/plugins/peanut-site/extensions/stylesheets.php); loads after ind-p10.css.
 *
 * The block's head, buttons, boxes, captions and outro keep their styles in
 * ind-p10.css (pathmap__*). Here: when the shared "Tap who you are" hint
 * shows, and the tree itself (p10m-top, p10m-tree, p10m-branches,
 * p10m-branch, p10m-pages, p10m-page), whose connectors are segments each
 * drawn by the box they lead to, so every line meets its box:
 *   - phones (under 48rem): a vertical tree. The trunk runs down from the
 *     root; each branch draws the trunk from the one before it down to its
 *     own elbow (::before) and on past its pages (::after, all but the
 *     last), and its box draws the elbow (::before). Each branch's pages hang
 *     indented on their own spine, drawn the same way.
 *   - from 48rem: the root over a rail (p10m-rail, from the first branch's
 *     center to the last one's), a drop to each branch (::before), and each
 *     branch's pages centered under it on their own spine, each page joined
 *     to the box above it across the gap.
 * The chosen audience's path: its boxes mint, its connectors mint and
 * thicker (the stretch of the rail from the root's drop to its branches is
 * its own segment, p10m-rail--lit, placed by the snippet), the rest dims.
 *
 * Tokens only. Layer blocks for the static state, layer motion for what
 * moves: the button pressed during auto-play, a lit box's small settle and
 * the Donate pill's three pulses. Nothing changes size when the script
 * runs: the hint keeps its space while hidden.
 */

@layer blocks {
  /* ---------- the hint over the buttons ---------- */

  .p10m-choose {
    display: grid;
    gap: 0.75rem;
  }

  /* the hint is the shared one (snippets/demo/hint.php, industry.css) */

  /* the hint keeps its space, out of sight until the buttons work; with
     scripting off, not there */
  .p10m-map:not(.is-live) .p10m-hint {
    visibility: hidden;
  }

  @media (scripting: none) {
    .p10m-hint {
      display: none;
    }
  }

  @media (min-width: 64rem) {
    .pathmap__picker.p10m-picker {
      align-items: end;
    }

    .pathmap__picker.p10m-picker .pathmap__ask {
      padding-block-end: 0.375rem;
    }
  }

  /* ---------- the tree ---------- */

  .p10m-chart {
    --p10m-line: 1.5px;
    --p10m-lit: 4px;
  }

  .p10m-top,
  .p10m-tree,
  .p10m-branch,
  .p10m-page {
    position: relative;
  }

  .p10m-branches,
  .p10m-pages {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  /* every connector: ink, light; vertical ones centered on their x, the
     horizontal ones on their y, so a thicker lit line stays on the same axis */
  .p10m-top::after,
  .p10m-rail,
  .p10m-branch::before,
  .p10m-branch::after,
  .p10m-page::before,
  .p10m-page::after,
  .p10m-box::before {
    content: "";
    position: absolute;
    background: var(--color-ink);
    opacity: 0.45;
    transition: background-color 240ms var(--ease-out), opacity 240ms var(--ease-out), width 240ms var(--ease-out), height 240ms var(--ease-out);
  }

  .p10m-top::after,
  .p10m-branch::before,
  .p10m-branch::after,
  .p10m-page::before,
  .p10m-page::after {
    width: var(--p10m-line);
    translate: -50% 0;
  }

  .p10m-rail,
  .p10m-box::before {
    height: var(--p10m-line);
    translate: 0 -50%;
  }

  .p10m-branch:last-child::after,
  .p10m-page:last-child::after {
    display: none;
  }

  .p10m-branch > .pathmap__node,
  .p10m-page > .pathmap__node {
    transition: background-color 240ms var(--ease-out), opacity 240ms var(--ease-out);
  }

  /* chosen: its boxes mint, the rest dimmed; its lines mint, the rest fainter */
  .p10m-branch.is-lit > .pathmap__node,
  .p10m-page.is-lit > .pathmap__node {
    background: var(--color-brand);
  }

  .p10m-map.is-picked .p10m-branch:not(.is-lit) > .pathmap__node,
  .p10m-map.is-picked .p10m-page:not(.is-lit) > .pathmap__node {
    opacity: 0.35;
  }

  .p10m-map.is-picked .p10m-rail,
  .p10m-map.is-picked .p10m-branch::before,
  .p10m-map.is-picked .p10m-branch::after,
  .p10m-map.is-picked .p10m-page::before,
  .p10m-map.is-picked .p10m-page::after,
  .p10m-map.is-picked .p10m-box::before {
    opacity: 0.2;
  }

  .p10m-map.is-picked .p10m-top::after,
  .p10m-map.is-picked .p10m-page.is-lit::before,
  .p10m-map.is-picked .p10m-page:has(~ .p10m-page.is-lit)::before,
  .p10m-map.is-picked .p10m-page:has(~ .p10m-page.is-lit)::after {
    width: var(--p10m-lit);
    background: var(--color-brand);
    opacity: 1;
  }

  .p10m-map.is-picked .p10m-branch.is-lit > .p10m-box::before,
  .p10m-map.is-picked .p10m-page.is-lit > .p10m-box::before {
    height: var(--p10m-lit);
    background: var(--color-brand);
    opacity: 1;
  }

  /* the lit stretches of the rail are only seen while their audience is chosen */
  .p10m-rail--lit {
    opacity: 0;
  }

  .p10m-map.is-picked .p10m-rail--lit {
    opacity: 0;
  }

  .p10m-map.is-picked .p10m-rail--lit.is-lit {
    height: var(--p10m-lit);
    background: var(--color-brand);
    opacity: 1;
  }

  /* phones: a vertical tree. --p10m-trunk: the trunk's x, from the map's
     left; --p10m-indent: the branches' left; --p10m-spine and
     --p10m-pindent: the pages' spine and left, from their branch's left;
     --p10m-elbow: a branch's elbow, from its top; the gaps between branches
     and between pages, which the segments bridge */
  @media (max-width: 47.99rem) {
    .p10m-chart {
      --p10m-trunk: 1.5rem;
      --p10m-indent: 2.75rem;
      --p10m-spine: 1rem;
      --p10m-pindent: 2rem;
      --p10m-elbow: 1rem;
      --p10m-gap: 0.75rem;
      --p10m-pgap: 0.375rem;
    }

    /* Home and the Donate pill side by side; the trunk starts behind Home */
    .p10m-top {
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      gap: 0.75rem 1rem;
      align-items: center;
      justify-items: start;
    }

    .p10m-top::after {
      top: 50%;
      bottom: 0;
      left: var(--p10m-trunk);
    }

    .p10m-rail {
      display: none;
    }

    .p10m-branches {
      display: grid;
      gap: var(--p10m-gap);
      padding: var(--p10m-gap) 0 0 var(--p10m-indent);
    }

    .p10m-branch {
      display: grid;
      gap: var(--p10m-pgap);
      justify-items: start;
    }

    /* the trunk: from the branch above down to this one's elbow, then on */
    .p10m-branch::before {
      top: calc(-1 * var(--p10m-gap));
      left: calc(var(--p10m-trunk) - var(--p10m-indent));
      height: calc(var(--p10m-gap) + var(--p10m-elbow));
    }

    .p10m-branch::after {
      top: var(--p10m-elbow);
      bottom: 0;
      left: calc(var(--p10m-trunk) - var(--p10m-indent));
    }

    .p10m-branch > .p10m-box::before {
      top: calc(var(--p10m-elbow) - 1px);
      right: 100%;
      width: calc(var(--p10m-indent) - var(--p10m-trunk));
    }

    .p10m-pages {
      display: grid;
      gap: var(--p10m-pgap);
      padding-inline-start: var(--p10m-pindent);
    }

    /* the pages' spine: from the box above down to this page's middle, then on */
    .p10m-page::before {
      top: calc(-1 * var(--p10m-pgap));
      left: calc(var(--p10m-spine) - var(--p10m-pindent));
      height: calc(var(--p10m-pgap) + 50%);
    }

    .p10m-page::after {
      top: 50%;
      bottom: 0;
      left: calc(var(--p10m-spine) - var(--p10m-pindent));
    }

    .p10m-page > .p10m-box::before {
      top: 50%;
      right: 100%;
      width: calc(var(--p10m-pindent) - var(--p10m-spine));
    }

    /* chosen: the trunk lights from the root down to the chosen branches */
    .p10m-map.is-picked .p10m-branch.is-lit::before,
    .p10m-map.is-picked .p10m-branch:has(~ .p10m-branch.is-lit)::before,
    .p10m-map.is-picked .p10m-branch:has(~ .p10m-branch.is-lit)::after {
      width: var(--p10m-lit);
      background: var(--color-brand);
      opacity: 1;
    }
  }

  /* from 48rem: the root over the rail, the branches in equal columns (no
     gap, so a branch's center is (i + 0.5) / n of the row), a drop to each */
  @media (min-width: 48rem) {
    .p10m-chart {
      --p10m-drop: var(--space-4);
      --p10m-pgap: 0.5rem;
    }

    .p10m-top {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
      align-items: center;
      padding-block-end: var(--p10m-drop);
    }

    /* the root's drop starts behind Home (the Donate pill can make the row
       taller than Home), so it always leaves Home's bottom edge */
    .p10m-top::after {
      top: calc(50% - var(--p10m-drop) / 2);
      bottom: 0;
      left: 50%;
    }

    .p10m-rail {
      top: 0;
      right: calc(50% / var(--n, 6));
      left: calc(50% / var(--n, 6));
    }

    .p10m-rail--lit {
      right: var(--p10m-right);
      left: var(--p10m-left);
    }

    .p10m-branches {
      display: grid;
      grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr));
      padding-block-start: var(--p10m-drop);
    }

    .p10m-branch {
      display: grid;
      gap: var(--p10m-pgap);
      align-content: start;
      justify-items: center;
      padding-inline: 0.25rem;
      text-align: center;
    }

    .p10m-branch::before {
      top: calc(-1 * var(--p10m-drop));
      left: 50%;
      height: var(--p10m-drop);
    }

    .p10m-branch::after,
    .p10m-box::before {
      display: none;
    }

    .p10m-pages {
      display: grid;
      gap: var(--p10m-pgap);
      justify-items: center;
      width: 100%;
    }

    /* the pages' spine: each page joins the box above it across the gap
       (never behind a box, which shows through a dimmed one) */
    .p10m-page::before {
      top: calc(-1 * var(--p10m-pgap));
      left: 50%;
      height: var(--p10m-pgap);
    }

    .p10m-page::after {
      display: none;
    }

    .pathmap__node.p10m-box {
      text-wrap: balance;
    }

    .p10m-map.is-picked .p10m-branch.is-lit::before {
      width: var(--p10m-lit);
      background: var(--color-brand);
      opacity: 1;
    }
  }

  /* 48rem to 64rem: six columns are narrow, so the boxes are tighter */
  @media (min-width: 48rem) and (max-width: 63.99rem) {
    .p10m-chart.pathmap__map {
      padding-inline: var(--space-2);
    }

    .p10m-branch > .pathmap__node--branch {
      padding-inline: 0.5rem;
    }

    .p10m-page > .pathmap__node--page {
      padding-inline: 0.5rem;
      font-size: 0.6875rem;
    }
  }

}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* auto-play presses a button for a moment before it chooses */
    .p10m-pick {
      transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out), scale 200ms var(--ease-out);
    }

    .p10m-pick.is-tapped {
      scale: 0.94;
    }

    /* a lit box settles with a small pop */
    .p10m-map.is-live .p10m-branch.is-lit > .pathmap__node,
    .p10m-map.is-live .p10m-page.is-lit > .pathmap__node {
      animation: p10m-settle 360ms var(--ease-pop) both;
    }

    /* the Donate pill pulses three times when the donor's path lights */
    .p10m-map.is-live .p10m-header.is-lit {
      animation: p10m-pulse 700ms var(--ease-out) 3;
    }
  }

  @keyframes p10m-settle {
    50% {
      transform: scale(1.06);
    }
  }

  @keyframes p10m-pulse {
    50% {
      transform: scale(1.1);
    }
  }
}
