/* ─────────────────────────────────────────────────────────────────────────
   CHECKLIST — a description's tick boxes (METIS-pub#745).

   Quill writes a checklist as <ul data-checked="true|false">. Wherever a
   description is shown — the CRM, the invitation pages, the public site — the
   list loses its bullets and each item gets a box: drawn with ::before when the
   reader may not tick (read-only and public pages), or by the .checklist-box
   button the description row adds for an editor. A ticked item is not struck
   through: the box says it.

   The button is a 44px tap target, written in px because the app's rem is
   14px. An item holding one is at least 44px tall, so neighbouring targets
   never overlap and a tap cannot tick the line below.

   Scoped away from Quill's own editor (`.ql-editor > ul`), which draws its
   own boxes: this layer beats Quill's stylesheet, so unscoped rules would
   restyle the editor's boxes too. Adjacent checklists close up, because a
   tick splits one list into up to three (core/checklists.py).

   Tokens only; no literal colour, radius or duration.
   ───────────────────────────────────────────────────────────────────────── */
@layer components {
  :not(.ql-editor) > ul[data-checked] {
    list-style: none;
    padding-left: 0;
  }

  :not(.ql-editor) > ul[data-checked]:has(+ ul[data-checked]) {
    margin-bottom: 0;
  }

  :not(.ql-editor) > ul[data-checked] + ul[data-checked] {
    margin-top: 0;
  }

  :not(.ql-editor) > ul[data-checked] > li {
    position: relative;
    padding-left: var(--space-8);
    min-height: var(--space-6);
  }

  /* The box: drawn by the li when there is no button in it. */
  :not(.ql-editor) > ul[data-checked] > li::before {
    content: "";
    position: absolute;
    left: var(--space-1);
    top: 0.2em;
    width: var(--space-4);
    height: var(--space-4);
    border: 1.5px solid var(--color-text-muted);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
  }

  :not(.ql-editor) > ul[data-checked="true"] > li::before {
    content: "✓";
    display: grid;
    place-items: center;
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-text);
    font-size: var(--text-xs);
    line-height: 1;
  }

  :not(.ql-editor) > ul[data-checked] > li:has(> .checklist-box) {
    box-sizing: border-box;
    min-height: 44px;
    line-height: 1.4;  /* the padding below centres one line of this height */
    padding-block: calc((44px - 1.4em) / 2);
  }

  :not(.ql-editor) > ul[data-checked] > li:has(> .checklist-box)::before {
    content: none;
  }

  /* The editor's tickable box: a 44px target around the drawn box. */
  .checklist-box {
    position: absolute;
    left: calc((var(--space-6) - 44px) / 2);
    top: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .checklist-box::after {
    content: "";
    position: absolute;
    left: calc((44px - var(--space-4)) / 2);
    top: calc((44px - var(--space-4)) / 2);
    width: var(--space-4);
    height: var(--space-4);
    border: 1.5px solid var(--color-text-muted);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    transition: background var(--dur-fast) var(--ease-out);
  }

  .checklist-box[aria-pressed="true"]::after {
    content: "✓";
    display: grid;
    place-items: center;
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-text);
    font-size: var(--text-xs);
    line-height: 1;
  }

  .checklist-box:focus-visible::after {
    outline: 2px solid var(--color-accent-ring);
    outline-offset: 2px;
  }
}
