/* The info mark (info_mark.rs, `InfoMark`; docs/decisions.md, the note titled "Calmer pages, one: …",
   (1)): a small round button that opens a short note. Round, because a control rests on the shell
   (the corners rule); the need mark's size, because it is that mark's quiet sibling: ! says
   something is needed, i says there is more to read. */
.info {
  /* One anchor name for every mark, scoped to its own wrapper, so no instance needs a name. */
  anchor-scope: --info-mark;
  /* At rest fainter than anything read; near, what it becomes while the pointer is on the thing it
     explains (its label, its heading, its value), which is when a person is already interested. The
     dark theme's pair is tokens.css's. */
  --info-ring: var(--color-info-ring);
  --info-glyph: var(--color-info-glyph);
  --info-ring-near: var(--color-info-ring-near);
  --info-glyph-near: var(--color-info-glyph-near);
  display: inline-block;
  vertical-align: middle;
  line-height: 0;
  margin-inline-start: var(--space-1);
}

/* On the ground, which is dark in both themes, the dark theme's strength in the ground's inks. */
.on-ground .info {
  --info-ring: var(--color-field-line);
  --info-glyph: var(--color-on-ground-muted);
  --info-ring-near: var(--color-on-ground-muted);
  --info-glyph-near: var(--color-on-ground);
}

.info-mark {
  anchor-name: --info-mark;
  position: relative;
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: var(--need-mark);
  height: var(--need-mark);
  padding: 0;
  border: var(--hairline) solid var(--info-ring);
  border-radius: 50%;
  background: transparent;
  color: var(--info-glyph);
  cursor: pointer;
}

/* The i is drawn, a dot over a stem, so it sits on the circle's centre: a face's letter i carries a
   foot and a flag to one side and reads off-centre in a ring this small. */
.info-glyph {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Near: the pointer is on what the mark explains (whatever element the mark stands in). */
:hover > .info > .info-mark {
  border-color: var(--info-ring-near);
  color: var(--info-glyph-near);
}

/* What the pointer and a thumb press, past the ring on every side, drawn by nothing. */
.info-mark::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--info-mark-reach));
  border-radius: 50%;
}

.info > .info-mark:hover {
  border-color: var(--color-ink);
  color: var(--color-ink);
}

.info-mark:focus-visible {
  outline: var(--focus-width) solid var(--color-ink);
  outline-offset: var(--focus-offset);
}

/* Open: filled, so the note and its mark read as one thing without an arrow between them. */
.info > .info-mark:has(+ .info-note:popover-open) {
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-accent-ink);
}

/* The note: in the browser's top layer, so no table, row or scrolling list clips it. On the shell's
   surface with a hairline and the raised card's shadow, as the More… menu is. It resets every
   property of type it would inherit from where the mark stands (a mono label, a column's head, the
   ground), and on the ground the shell's inks, so a note reads the same wherever it is opened. */
.info-note {
  position: fixed;
  inset: auto;
  margin: var(--space-2) 0;
  position-anchor: --info-mark;
  position-area: bottom span-right;
  position-try-fallbacks: flip-inline, --info-under, flip-block, flip-block flip-inline, --info-over;
  box-sizing: border-box;
  width: max-content;
  max-width: min(var(--info-note-width), calc(100vw - 2 * var(--space-4)));
  padding: var(--space-3);
  border: var(--hairline) solid var(--color-shell-line);
  border-radius: var(--radius);
  background: var(--color-shell);
  box-shadow: var(--shadow-raised);
  color: var(--color-shell-ink);
  font-family: var(--font-sans);
  font-size: var(--text-quiet);
  font-style: normal;
  font-weight: var(--weight-regular);
  letter-spacing: normal;
  line-height: var(--leading-body);
  text-align: start;
  text-transform: none;
  white-space: normal;
}

/* Where neither side has the room (a phone): under the mark, centred on it as far as the window
   allows; and the same above. */
@position-try --info-under {
  position-area: bottom span-all;
  justify-self: anchor-center;
  margin: var(--space-2) var(--space-3);
}

@position-try --info-over {
  position-area: top span-all;
  justify-self: anchor-center;
  margin: var(--space-2) var(--space-3);
}

.info-note a {
  color: inherit;
}

/* Two ideas are two paragraphs. Spans, so a mark can stand inside a label, a heading or a cell. */
.info-para {
  display: block;
}

.info-para + .info-para {
  margin-top: var(--space-2);
}
