/* A picture picked in the formatted editor and its menu (#314,
   `figures_frame.js`, `figures_menu.js`). The frame is drawn over the box,
   never inside its text, so the stored value never holds it. */
.aucra-editor.q-editor {
  position: relative;
}
/* Chrome paints a selected picture over in its selection colour, which hid
   it, and on a picture that can be edited it takes no notice of
   `user-select` (#327). It reads the colour from the `::selection` the
   picture inherits, so the text area's is clear while a pick's frame stands
   in the box: the frame shows the pick, and the selection still holds the
   picture. Not the picture's own `::selection`: Chrome does not paint a
   picture again for that one when the selection was there before the frame
   (the keys). With no frame, as in a selection across words, the wash stays. */
.aucra-editor .q-editor__content img {
  user-select: none;
}
.aucra-editor:has(> .aucra-figure-frame) .q-editor__content::selection {
  background: transparent;
}
/* The line is 5.76:1 on the box, as the corners are; `--gold` read 1.67:1. */
.aucra-figure-frame {
  position: absolute;
  z-index: 2;
  outline: 2px solid var(--gold-deep);
  outline-offset: 1px;
  pointer-events: none;
}
/* A 24px target (WCAG 2.5.8) round a 12px square on each corner. */
.aucra-figure-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  pointer-events: auto;
  touch-action: none;
}
.aucra-figure-handle::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 2px solid var(--gold-deep);
  border-radius: 2px;
  background: var(--aucra-corner, var(--panel));
}
/* A pressed corner fills. The rule is on the corner itself, not only on its
   square: Chrome sends a finger's press to the nearest thing that answers a
   press, and without it a press on the middle of a small picture's corner
   went to the menu's button 4px away and opened the menu (#328). */
.aucra-figure-handle:active {
  --aucra-corner: var(--gold-wash);
}
.aucra-figure-nw { left: -12px; top: -12px; cursor: nwse-resize; }
.aucra-figure-se { right: -12px; bottom: -12px; cursor: nwse-resize; }
.aucra-figure-ne { right: -12px; top: -12px; cursor: nesw-resize; }
.aucra-figure-sw { left: -12px; bottom: -12px; cursor: nesw-resize; }
/* The menu's button (#323), the way in where no right click is: 32px, by the
   picture's top right corner, clear of the corners' targets and of the words,
   or beside a picture too small to hold it. `spot` in `figures_place.js` sets
   its left and its top (#328). */
.aucra-figure-more {
  position: absolute;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line-control);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  pointer-events: auto;
}
.aucra-figure-more svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
/* A finger leaves no hover behind, so the button never looks pressed after a tap. */
@media (hover: hover) {
  .aucra-figure-more:hover {
    background: var(--gold-wash);
  }
}

/* The menu floats over the page like a dialog. `figures_menu.js` gives it the
   zoom of the box its picture is in, so it grows with the page size (#322),
   and `brand_size.css` the reader's text size (#332). */
.aucra-figure-menu {
  position: fixed;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  /* Never wider than the window, less the 4px it keeps from each edge
     (`figures_place.js`): at 150% text on a phone the description's field
     asked for 400px of a 390px window (#332). A percent is the window's
     width in the menu's own px at any zoom; `vw` is not. */
  max-width: calc(100% - 8px);
  padding: 6px;
  border: 1px solid var(--soft-line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--soft-float-shadow);
  /* `figures_menu.js` keeps it no taller than the window: past that it scrolls
     by itself, and the page behind it stays where it is. */
  overflow-y: auto;
  overscroll-behavior: contain;
}
.aucra-figure-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: calc(13px * var(--aucra-text-scale, 1));
  text-align: start;
  cursor: pointer;
}
.aucra-figure-item:hover {
  background: var(--gold-wash);
}
.aucra-figure-menu:focus-visible,
.aucra-figure-more:focus-visible,
.aucra-figure-item:focus-visible,
.aucra-figure-action:focus-visible,
.aucra-figure-field:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}
/* The size it has now carries a tick; the others keep its room. */
.aucra-figure-item[role="menuitemradio"]::before {
  content: "";
  width: 14px;
  color: var(--gold-deep);
  font-weight: var(--weight-bold);
}
.aucra-figure-item[aria-checked="true"]::before {
  content: "\2713";
}
.aucra-figure-rule {
  flex: none;
  height: 1px;
  margin: 4px 2px;
  background: var(--line);
}
.aucra-figure-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 4px 0;
  color: var(--muted);
  font-size: calc(12.5px * var(--aucra-text-scale, 1));
  font-weight: var(--weight-bold);
}
/* No least width of its own: it stretches to the dialog, and at 320px with
   the page at 120% a 260px least ran 13px past it (#335). */
.aucra-figure-field {
  padding: 6px 8px;
  border: 1px solid var(--line-control);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: calc(13.5px * var(--aucra-text-scale, 1));
  font-weight: normal;
}
/* Save or Apply, and Cancel, stay in sight when a dialog scrolls. They stand
   over the box's foot, its 6px of padding too, so no field shows under them. */
.aucra-figure-row {
  position: sticky;
  bottom: -6px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: -6px;
  padding: 8px 4px;
  background: var(--panel);
}
.aucra-figure-action {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line-control);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: calc(13px * var(--aucra-text-scale, 1));
  font-weight: var(--weight-bold);
  cursor: pointer;
}
.aucra-figure-action:first-child {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--on-ink);
}

/* A dialog in the menu's box, the description or the crop. Its least width
   grows with a text size over 100%, so the crop's four labelled fields still
   fit across under a picture that leaves the dialog at its least: at 150%
   "Bottom" was 66px in a 62px cell (#332). Never past the window, as above. */
.aucra-figure-menu[aria-modal] {
  min-width: min(calc(288px * max(1, var(--aucra-text-scale, 1))), calc(100% - 8px));
}
/* Crop picture (`figures_crop.js`): the picture under a frame, the part
   outside it dimmed. The handles reach past the picture, so the dimming has
   a layer of its own that keeps to it. */
.aucra-crop-stage {
  position: relative;
  align-self: center;
  margin: 14px 14px 10px;
  user-select: none;
}
.aucra-crop-stage img {
  display: block;
  width: 100%;
  height: 100%;
}
.aucra-crop-shade,
.aucra-crop-hole,
.aucra-crop-frame {
  position: absolute;
  inset: 0;
}
.aucra-crop-shade {
  overflow: hidden;
}
.aucra-crop-hole {
  box-shadow: 0 0 0 100vmax rgb(var(--shade) / 0.6);
}
.aucra-crop-frame {
  outline: 2px solid var(--gold);
  outline-offset: -1px;
}
/* An edge's target runs between its corners, its mark in the middle. */
.aucra-crop-n, .aucra-crop-s { left: 12px; right: 12px; width: auto; cursor: ns-resize; }
.aucra-crop-w, .aucra-crop-e { top: 12px; bottom: 12px; height: auto; cursor: ew-resize; }
.aucra-crop-n { top: -12px; }
.aucra-crop-s { bottom: -12px; }
.aucra-crop-w { left: -12px; }
.aucra-crop-e { right: -12px; }
.aucra-crop-n::after, .aucra-crop-s::after { inset: 6px calc(50% - 6px); }
.aucra-crop-w::after, .aucra-crop-e::after { inset: calc(50% - 6px) 6px; }
/* As wide as the picture makes the dialog, never wider for their own words. */
.aucra-crop-hint {
  width: 0;
  min-width: 100%;
  margin: 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: calc(12.5px * var(--aucra-text-scale, 1));
}
/* Four across where four fit, else two by two (#335): at 150% text on a
   320px phone "Bottom" was 66px in a 49px cell. Four fit while the row holds
   four of its longest label, "Bottom", 3.2em, with a label's 8px of padding
   and three 6px gaps. The query's em is the row's own, so it follows the
   text size. Three and one, as `auto-fit` gives, never shows. A label never
   shrinks under its word: past the sum the row wraps rather than cut it. */
.aucra-crop-fields {
  container: aucra-crop-fields / inline-size;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 0;
  min-width: 100%;
}
.aucra-crop-fields > .aucra-figure-label {
  flex: 1 1 0;
}
@container aucra-crop-fields (width < calc(4 * (3.2em + 8px) + 18px)) {
  .aucra-crop-fields > .aucra-figure-label {
    flex-basis: 40%;  /* Two to a row, never three. */
  }
}
/* A percent leaves the field's own 20 characters out of its label's least
   width; without it the four went two by two at 100%. */
.aucra-crop-fields .aucra-figure-field {
  width: 100%;
}
