/* ══════════════════════════════════════════════
   HEADER "+ Report" MENU  (js/report-menu.js)
   ──────────────────────────────────────────────
   Ported from the Bencho "Create menu" component, MIT licensed,
   https://bencho.dev/licence (React + framer-motion → plain JS).
   One shape and no filter on it: the liquid is entirely in the timing.
   The press sinks, and the spread starts while the sink is still running,
   so there is never a still frame.

   Bencho's tokens, mapped onto the app theme (on .crt only, nothing
   leaks out):
     --board → --bg2          the open panel's ground
     --fill-slab              unset in this app, so --slab falls back to
                              --board, as Bencho's own fallback says;
                              shut, the pill takes --bg3 like the header's
                              other secondary buttons
     --ink → --text           --fill-on / --fill-on-rgb: unset, fall back to ink
     --ink-rgb                three bare numbers of --text, per theme
     --pane-edge → --border   the ring, switched on (see .crt-body)
     --font-ui → inherit      Inter, from body

   Changed for the header: the stage is the pill's own size in the row,
   and the panel grows DOWNWARD from the pill's top edge, centred on it,
   on its own layer, so opening pushes nothing and nothing goes off the
   top of the screen. Desktop only: phones keep field mode's Report.
══════════════════════════════════════════════ */
.crt {
  --ink: var(--text);
  --ink-rgb: 15, 23, 42;
  --board: var(--bg2);
  --pane-edge: var(--border);
  --slab: var(--fill-slab, var(--board));
  --on-slab: var(--fill-on, var(--ink));
  --on-slab-rgb: var(--fill-on-rgb, var(--ink-rgb));
  /* The pill, and only the pill. Its WIDTH is set inline from the
     measured label, so the label can change (a language switch) without
     the shape jumping; this is the fallback for the frame before that
     measurement lands. 36 tall, the height of the search beside it. */
  --pill-w: 104px;
  --pill-h: 36px;
  --panel-w: 212px;
  /* four rows and the padding; the JS sets it from how many rows the
     person may see */
  --panel-h: 166px;
  position: relative;
  flex-shrink: 0;
  width: var(--pill-w);
  height: var(--pill-h);
  /* Below dialogs (1000+), like the search circle (960). */
  z-index: 950;
  font-family: inherit;
}
body.dark-mode .crt { --ink-rgb: 236, 236, 236; }
/* above the search circle (960), which the open panel overlaps */
.crt[data-open="true"] { z-index: 970; }

/* ── the one shape ────────────────────────────────────────
   Width, height and the corner are written inline by one spring
   (js/report-menu.js); `scale` stays here because the press beat is a
   discrete state, not a value being interpolated from JS. Centred on
   the pill with left 50% and the individual `translate` property, which
   is half of whatever the box is right now, so there is nothing to keep
   in step. (Bencho used auto margins, which only centre inside a stage
   bigger than the panel; this stage is the pill.) */
.crt-body {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;
  width: var(--pill-w);
  height: var(--pill-h);
  /* the app's button corner; the JS animates it to the panel's 10 */
  border-radius: 9px;
  background: var(--bg3);
  /* The ring. Bencho draws it only when Stroke is on; every control in
     this header carries the same hairline, so it is on. A spread shadow
     because the shape has no ::before to hang a border on. */
  box-shadow: 0 0 0 1px var(--pane-edge);
  pointer-events: none;
  transition: scale 420ms cubic-bezier(0.22, 1, 0.36, 1), background 160ms ease, box-shadow 220ms ease;
}
/* Open, it is a panel over the page's own cards rather than the page
   opening up, so it takes the board and a soft lift. (Bencho has no
   shadow; it sits on an empty page, this does not.) */
.crt[data-open="true"] .crt-body {
  background: var(--slab);
  box-shadow: 0 0 0 1px var(--pane-edge), 0 10px 28px rgba(0, 0, 0, 0.10);
}
body.dark-mode .crt[data-open="true"] .crt-body {
  box-shadow: 0 0 0 1px var(--pane-edge), 0 10px 28px rgba(0, 0, 0, 0.40);
}
.crt:not([data-open="true"]):hover .crt-body { background: var(--bg2); }

/* The first beat: pressed down. A plain uniform shrink, in fast, because
   a press should be felt at once and not eased into. 160 against a 60ms
   handoff: the spread starts while this is still running, so there is
   never a frame where nothing is moving. */
.crt[data-sink="true"] .crt-body,
.crt[data-sink="true"] .crt-pill {
  scale: 0.94;
  transition: scale 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
/* and closing is the same single move, run down */
.crt:not([data-open="true"]) .crt-body {
  transition: scale 220ms cubic-bezier(0.22, 1, 0.36, 1), background 160ms ease, box-shadow 220ms ease;
}

/* The pill. It does not move aside, it is simply not there once the
   shape has spread. */
.crt-pill {
  position: relative;
  width: var(--pill-w);
  height: var(--pill-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--on-slab);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 160ms ease, scale 420ms cubic-bezier(0.22, 1, 0.36, 1);
}
.crt-pill:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; border-radius: 9px; }
.crt[data-open="true"] .crt-pill { opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
/* held at full strength through the press: fading it during the squash
   would hide the beat that the squash is for */
.crt[data-sink="true"] .crt-pill { opacity: 1; }
.crt-glyph { display: grid; place-items: center; }
.crt-glyph svg { width: 16px; height: 16px; }
/* the pill takes the width of whatever it is saying */
.crt-say { display: block; overflow: hidden; white-space: nowrap; text-align: left; }
/* inline-block so it has an offsetWidth to be measured by */
.crt-say > span { display: inline-block; }

/* the window, in the same place */
.crt-panel {
  position: absolute;
  top: 0;
  left: 50%;
  translate: -50% 0;
  width: var(--panel-w);
  height: var(--panel-h);
  padding: 12px;
  box-sizing: border-box;
  color: var(--on-slab);
  pointer-events: none;
}
.crt[data-open="true"] .crt-panel { pointer-events: auto; }
.crt-menu { margin: 0; padding: 0; list-style: none; display: grid; align-content: start; gap: 2px; }
.crt-item {
  opacity: 0;
  transform: translateY(6px);
  /* the same curve as the shell, and no overshoot either: a row that
     slides past its resting line and comes back is the same wobble at a
     smaller size */
  transition: opacity 160ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.crt-item[hidden] { display: none; }
.crt[data-open="true"] .crt-item { opacity: 1; transform: none; }

.crt-item button {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 34px;
  padding: 0 16px;
  /* concentric, as Bencho cuts it: the panel's corner less 10, so a
     row looks like it belongs in the panel rather than sitting in one.
     At the app's 10 that is square. */
  border: 0;
  border-radius: 0;
  background: none;
  /* 0.78: dark type at 0.72 on white lands only just over 4.5:1, and
     this is the menu's only body text */
  color: rgba(var(--on-slab-rgb), 0.78);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: color 220ms ease;
  /* the wash sits behind the label, inside its own row */
  isolation: isolate;
}
.crt-item button svg { width: 16px; height: 16px; flex-shrink: 0; }
.crt-item button:hover { color: var(--on-slab); }
/* the hover wash, one per row: each row fades its own in and out,
   nothing travels between them */
.crt-item button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: rgba(var(--on-slab-rgb), 0.08);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
}
@media (hover: hover) {
  .crt-item button:hover::before { opacity: 1; transition-duration: 160ms; }
}
.crt-item button:focus-visible { outline: none; color: var(--on-slab); }
.crt-item button:focus-visible::before { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .crt-body, .crt-pill, .crt-item { transition-duration: 160ms; }
  .crt[data-sink="true"] .crt-body,
  .crt[data-sink="true"] .crt-pill { scale: 1; }
}

/* Phones use field mode's own Report button; this stays desktop-only. */
@media (max-width: 768px), (orientation: landscape) and (pointer: coarse) and (max-height: 500px) { .crt { display: none !important; } }
