/* Staff highlight pins on indicator pages (chat_hl_pins.js). Spec: designer
   site-chat-2026-11-23/HIGHLIGHTS-SPEC.md §4, §8, §9. The layer is absolutely positioned at the
   document origin; JS writes every pin's left/top as the anchor point, and the pin's bottom-left
   corner (the tail) sits on it. Placement mode (staff) draws its cover and draft in the
   same layer, so leaving it leaves nothing on the page. Area notes: docs/notes/chat.md › 站方標示 */

#hl_layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  /* no z-index: the layer makes no stacking context, so its parts layer against the page on their
     own — pins at 10 (over the charts' crosshair canvases, 3), the dock column at 12 above them
     (its handle wins where they meet, spec §4), popovers at 13, all under the top bar (999) */
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

/* a button: no shadow (canon; main.css strips it from every button anyway), a 1px frame inside the 24 */
#hl_layer .hl_pin {
  position: absolute;
  width: 24px;
  height: 24px;
  padding: 1px;
  box-sizing: border-box;
  border: 1px solid var(--border-frame);
  border-radius: 12px 12px 12px 3px;
  background: var(--surface-card);
  transform: translateY(-100%);
  cursor: pointer;
  z-index: 10;
}

/* 44 hit area; on its right it stops at the content's edge (--hl-hit-r, chat_hl_pins.js) */
#hl_layer .hl_pin::before {
  content: "";
  position: absolute;
  inset: -10px;
  right: calc(-1 * var(--hl-hit-r, 10px));
}

#hl_layer .hl_pin:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* the avatar is the chat's .chat_av (chat_avatar.js; base look in chat/main.css), sized here:
   20 in the pin, 22 in the popover head, initial 10 */
#hl_layer .chat_av.hl_pa {
  display: flex;
  width: 20px;
  height: 20px;
  font-size: 10px;
}

#hl_layer .chat_av.hl_av {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

#hl_layer .hl_cnt {
  position: absolute;
  top: -8px;
  right: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 var(--space-4);
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  box-shadow: 0 0 0 1px var(--border-frame);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

/* opened from chat: one ring, fading out (opacity only); reduced motion keeps it 2 s (JS) */
#hl_layer .hl_pin.flash::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 17px 17px 17px 8px;
  box-shadow: 0 0 0 2px var(--ink);
  pointer-events: none;
  animation: hl-flash var(--motion-flash) var(--ease-standard) forwards;
}

@keyframes hl-flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  #hl_layer .hl_pin.flash::after {
    animation: none;
  }
}

/* ---- hover ✕ on a single pin (spec §8 › 用戶隱藏): the pin's next sibling. 12 circle centred on
   the pin's rim (chat_hl_geom.js HL_HIDE writes the position); the 24 hit area grows up and right
   from the ✕'s bottom-left, so it never covers the pin's centre. Mouse only, never in the Tab order. */
#hl_layer .hl_hx {
  display: none;
  position: absolute;
  z-index: 11; /* over the pin's hit area */
  width: 12px;
  height: 12px;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid var(--border-frame);
  border-radius: var(--radius-pill);
  background: var(--surface-card);
  color: var(--ink-2);
  align-items: center;
  justify-content: center;
}

/* the hit area's corner is the ✕'s outer bottom-left (the border box), so it starts 1px out: left/bottom -1 */
#hl_layer .hl_hx::before {
  content: "";
  position: absolute;
  left: -1px;
  bottom: -1px;
  width: 24px;
  max-width: var(--hl-hx-w, 24px);
  height: 24px;
}

#hl_layer .hl_hx .ico {
  width: 8px;
  height: 8px;
}

@media (hover: hover) {
  #hl_layer .hl_hx {
    display: inline-flex;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-fast) var(--ease-standard);
  }

  #hl_layer .hl_pin:hover + .hl_hx,
  #hl_layer .hl_hx:hover {
    opacity: 1;
    pointer-events: auto;
  }

  #hl_layer .hl_hx:hover {
    background: var(--surface-muted);
    color: var(--ink);
  }
}

/* ---- popover (canon › Dropdown menu › Panel look; content, not a menu) ---- */
#hl_layer .hl_pop {
  position: absolute;
  width: 280px;
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-12) 40px var(--space-12) 14px;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-md);
  z-index: 13;
}

#hl_layer .hl_pop.multi {
  width: 300px;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

/* the hairline runs edge to edge: each entry takes back the popover's side padding */
#hl_layer .hl_pop.multi .hl_pe {
  margin: 0 -40px 0 -14px;
  padding: 10px 40px 10px 14px;
}

#hl_layer .hl_pop.multi .hl_pe + .hl_pe {
  border-top: 1px solid var(--border-hairline);
}

#hl_layer .hl_hd {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  min-width: 0;
}

#hl_layer .hl_nm {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#hl_layer .chat_plan.staff {
  flex: none;
  background-color: var(--control-fill);
  color: var(--control-fill-text);
  font-size: 11px;
}

#hl_layer .hl_tm {
  flex: none;
  color: var(--ink-3);
  font-size: 11px;
}

#hl_layer .hl_tx {
  margin: var(--space-6) 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

#hl_layer .hl_acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0 14px;
  margin-top: var(--space-8);
}

#hl_layer .hl_lq {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link-quiet);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* 44 tall hit area (a 12px link's line is 19.2) */
#hl_layer .hl_lq::before {
  content: "";
  position: absolute;
  inset: -13px calc(-1 * var(--space-6));
}

@media (hover: hover) {
  #hl_layer .hl_lq:hover {
    color: var(--link-quiet-hover);
  }
}

#hl_layer .hl_x {
  position: absolute;
  top: var(--space-8);
  right: var(--space-8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--ink-3);
}

#hl_layer .hl_x::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--space-8));
}

#hl_layer .hl_x .ico {
  width: 16px;
  height: 16px;
}

@media (hover: hover) {
  #hl_layer .hl_x:hover {
    background: var(--surface-muted);
    color: var(--ink);
  }
}

/* ---- placement mode (staff, spec §9) ---- */
/* outside the content area nothing answers: not-allowed (chat_hl_pins.js swallows the click) */
html.hl-placing body,
html.hl-placing body * {
  cursor: not-allowed !important;
}

html.hl-placing #box_main,
html.hl-placing #box_main *,
html.hl-placing #hl_layer .hl_cover {
  cursor: crosshair !important;
}

html.hl-placing #hl_layer .hl_compose,
html.hl-placing #hl_layer .hl_compose * {
  cursor: auto !important;
}

html.hl-placing #hl_layer .hl_compose button,
html.hl-placing #dk_place,
html.hl-placing #dk_place *,
html.hl-placing #dk_open_m,
html.hl-placing #dk_open_m * {
  cursor: pointer !important;
}

/* the cover over #box_main catches the pointer, under the pins */
#hl_layer .hl_cover {
  z-index: 9;
}

/* placing: the pins already on the page and the draft are drawn but take no pointer (their 44
   hit areas sit over the cover), so a click next to one still drops the draft; no hover ✕ */
html.hl-placing #hl_layer .hl_pin,
html.hl-placing #hl_layer .hl_hx {
  pointer-events: none;
}

/* outranks the hover rule (#hl_layer .hl_pin:hover + .hl_hx) by the html class */
html.hl-placing #hl_layer .hl_pin + .hl_hx,
html.hl-placing #hl_layer .hl_hx:hover {
  display: none;
}

/* compose popover beside the draft pin */
#hl_layer .hl_compose {
  position: absolute;
  width: 320px;
  padding: var(--space-12) 14px;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  box-shadow: var(--shadow-md);
  z-index: 13;
}

#hl_layer .hl_compose textarea {
  display: block;
  width: 100%;
  min-height: 72px;
  padding: var(--space-8) var(--space-12);
  box-sizing: border-box;
  border: 1px solid var(--border-field);
  border-radius: var(--radius-md);
  background: var(--surface-field);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

#hl_layer .hl_hint {
  display: flex;
  justify-content: space-between;
  gap: var(--space-8);
  margin-top: var(--space-6);
  color: var(--ink-3);
  font-size: 12px;
}

#hl_layer .hl_err {
  margin: var(--space-8) 0 0;
  color: var(--ink-2);
  font-size: 12px;
}

#hl_layer .hl_foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-8);
  margin-top: var(--space-12);
}

@media (pointer: coarse) {
  #hl_layer .hl_compose textarea {
    font-size: 16px;
  }
}

/* the toast's 復原: the canon Toast text button (13, quiet link, 44 tall hit area) */
#hl_layer .hl_toast_act {
  margin-left: var(--space-12);
  font-size: 13px;
}

/* the layer is a 0×0 box at the document origin: keep the sentence and 復原 on one line */
#hl_layer #hl_toast {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
