/* The jump palette: the places as tiles and the field on one band, grouped
   links below (owner, 2026-11-17, on the "Chalet AI Connect" canvas). */
@layer components {
  /* A .popup (see popups.css), and the one that needs no anchor: the button it
     belongs to never moves, so it stands under the header in the header's own
     terms, a fixed offset. Anchored, on an iPhone at the foot of a long page,
     it opened with its top above the screen (owner, 2026-11-09). Desktop
     WebKit placed it correctly, so the cause is unknown. The doubled selector
     outranks .popup's whatever the file order. */
  .popup.palette {
    --popup-area: none;
    --popup-try: none;

    inset-block: var(--header-height) auto;
    inset-inline: 0 var(--panel-inset, 0px);
    margin-block-start: 0;
    margin-inline: auto;
  }

  /* Wide enough to read a project name and its description in one line. */
  .palette {
    inline-size: min(34rem, 92vw);

    /* The fixed doors stand on the wash, closed by a hairline; what they find
       stands on the paper below. The band runs to the float's edges, past the
       popup's own padding. */
    .palette__doors {
      margin: calc(var(--block-space-half) * -1) calc(var(--block-space-half) * -1) 0;
      padding: calc(var(--block-space) * 1.5) calc(var(--block-space) * 1.5) 0;
      background-color: var(--color-surface);
      border-block-end: var(--border);
    }

    /* Equal columns filling the width, so the tiles read as one row of
       destinations rather than buttons of different weight. They wrap rather
       than compress: one row wherever there is room, two on a phone. */
    .palette__sections {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
      gap: var(--block-space);
    }

    /* The field says what it finds, in the float's own words (owner,
       2026-11-17: the body size the canvas drew stood out from every other
       float). Its glyph is a mark, not a word, so it may be faint. */
    .palette__field {
      --icon-size: 1rem;

      padding: calc(var(--block-space) * 1.5) var(--inline-space-half);
      color: var(--color-ink-faint);
    }

    input {
      flex: 1;
      min-inline-size: 0;
      padding: 0;
      font-size: inherit;
      color: var(--color-ink);
      background-color: transparent;
      border: none;

      &::placeholder {
        color: var(--color-ink-faint);
      }

      /* The palette opens with this field already focused, and the shu caret
         is the whole focus mark of a field. */
      &:focus-visible {
        outline: none;
      }
    }

    /* The groups scroll together, so a heading cannot sit still while its own
       rows slide away underneath it. */
    .palette__results {
      margin-block-start: var(--block-space-half);
      max-block-size: 50vh;
      overflow: auto;
    }

    /* A heading with nothing left under it is a label for nothing. The filter
       hides rows; this asks the group whether it still has any — no controller
       has to know that headings exist. */
    .palette__group:not(:has(li:not([hidden]))) {
      display: none;
    }

    /* At rest the palette is short — five recent pages and five projects,
       the starred first, the jump menu's own measure (user, 2026-10-12). The
       rest waits for a query: the older visits and projects, the lists, the
       directories, the pings, what the server finds. The empty field is the
       state, so no controller keeps it; navigable_list skips what this hides. */
    &:has(input:placeholder-shown) :is(.palette__recent li:nth-child(n + 6), .palette__projects li:nth-child(n + 6), .palette__more) {
      display: none;
    }

    .palette__group > h2 {
      padding: var(--block-space) var(--inline-space) var(--block-space-half);
    }

    /* A group after another starts further down, so Projects breathes below
       Recently visited instead of reading as its last row (user,
       2026-10-12). Double, because the palette's rows run on a tight
       --block-space of their own. */
    :is(.palette__group, turbo-frame) ~ .palette__group > h2 {
      padding-block-start: var(--block-space-double);
    }

    /* A row has room around its words, which are the float's size, and the
       place after the name a step down. A row that opens something rather
       than going somewhere is a button (the keys), and reads the same. */
    li :is(a, button) {
      display: flex;
      align-items: center;
      gap: var(--inline-space);
      inline-size: 100%;
      min-block-size: 2.125rem;
      padding: 0 var(--inline-space-half);
      color: var(--color-ink);
      text-decoration: none;
      background-color: transparent;
      border: none;
      border-radius: var(--border-radius);
      cursor: pointer;

      &:hover,
      &:focus-visible {
        background-color: var(--color-surface);
      }

      /* One line a row, on a phone as at a desk (user, 2026-10-14). The place
         follows the name after a dot, and is cut first; only a name wider
         than the row is cut. */
      > [data-filter-context] {
        flex: 0 1000 auto;

        &::before {
          content: "· ";
        }
      }
    }

    /* A row's glyph in its circle (rows.css), a size down, so the names
       start on one line whatever the glyph. */
    .row__glyph {
      --row-glyph-size: 1.5rem;
      --icon-size: 0.875rem;

      margin-inline-end: var(--inline-space-half);
    }

    /* Where the arrows are, and what return will follow. Selected is mizu, and
       a tint brings its paired ink — including for the place beside the name,
       which would otherwise stay grey on a wash. */
    li[data-selected] :is(a, button) {
      color: var(--color-selected-ink);
      background-color: var(--color-selected);

      .txt-subtle {
        color: inherit;
        opacity: 0.7;
      }
    }

    /* The search door under the jump list: one hairline says where jumping
       ends and finding begins. Its glyph needs no circle: it is a way out, not
       a thing. */
    .palette__search {
      margin-block-start: var(--block-space-half);
      padding-block-start: var(--block-space-half);
      border-block-start: var(--border);

      a {
        color: var(--color-ink-subtle);
      }

      .row__glyph {
        background-color: transparent;
      }
    }
  }

  /* The tile's layout, edge and radius are utilities on the element; what is
     left here is what makes it a destination rather than a box: paper on the
     band, its height, the glyph's size, and where you already are. */
  .palette-section {
    --icon-size: 0.875rem;

    block-size: 2.5rem;
    padding-inline: var(--inline-space-half);
    color: var(--color-ink);
    text-decoration: none;
    background-color: var(--color-canvas);

    &:hover {
      background-color: var(--color-surface);
    }

    /* Where you already are, or where the arrows put you, is mizu, and a tint
       brings its paired ink. */
    &:is([aria-current="page"], :focus-visible) {
      color: var(--color-selected-ink);
      --border-color: transparent;

      background-color: var(--color-selected);
      outline: none;
    }
  }
}
