/* The number popup ("Where this number comes from", QA pack F14): js/chat/evidence.js. The designer's popup of 26 Nov 2026
   (hk-evidence.css): quiet and easy to scan. A white card with the dropdowns' 1px ring and no
   drop shadow; the number, one sentence, then "How it was counted" as one paper block of rows
   ending in the result. Wider than 600px it sits beside the number (placed by evidence.js
   placePanel); 600px and under it rises from the bottom as a sheet. Also used on /r/
   (report-page.php links this file). */

:root {
  --ev-w: 352px;              /* popup width on desktop           */
  --ev-pad: 22px;             /* popup inset                      */
  --ev-gap: 18px;             /* between its parts                */
  --ev-big: 40px;             /* the number                       */
}

/* ---- the number in the text: a real button that reads as text. No underline; a faint tint
   (the grey tags' tone), a little more on hover, the orange wash while its popup is open. ---- */
.ev-num { display: inline; margin: 0; padding: 0 .1em; border: 0; border-radius: var(--r-xs);
  background: var(--sunk); color: inherit; font: inherit; line-height: inherit; letter-spacing: inherit; text-align: inherit;
  text-decoration: none; -webkit-box-decoration-break: clone; box-decoration-break: clone; cursor: pointer;
  transition: background-color var(--dur-1); }
.ev-num:hover { background: var(--sunk-hover); }
.ev-num[aria-expanded="true"] { background: var(--orange-wash); }
.ev-num:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }

/* ---- the popup ---- */
.ev-panel { position: fixed; z-index: 70; left: 0; top: 0; display: grid; gap: var(--ev-gap);
  width: min(var(--ev-w), calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; overscroll-behavior: contain;
  padding: var(--ev-pad); border-radius: var(--r-l); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line);
  font-family: var(--font); color: var(--ink); outline: none;
  opacity: 0; transform: translateY(6px); pointer-events: none; visibility: hidden;
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2); }
.ev-panel.open { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

.ev-x { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0;
  border-radius: var(--r-s); background: none; color: var(--ink-3); cursor: pointer; transition: background-color var(--dur-1), color var(--dur-1); }
.ev-x:hover { background: var(--sunk); color: var(--ink); }
.ev-x:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.ev-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

/* the number and what it says */
.ev-head { display: grid; gap: 8px; padding-right: 36px; }
.ev-big { font: var(--w-medium) var(--ev-big)/1 var(--font); letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.ev-big .u { color: var(--orange); }                        /* orange for symbols and unit words only */
.ev-big .u--word { margin-left: .18em; font-size: .5em; letter-spacing: -.01em; }
.ev-says { margin: 0; font: var(--w-regular) var(--fs-meta)/1.5 var(--font); color: var(--read-ink, #2A2926); text-wrap: pretty; }

/* a section: a label led by the plan card's orange square, then its content */
.ev-sec { display: grid; gap: 8px; min-width: 0; }
.ev-h { display: flex; align-items: center; gap: 10px; margin: 0; font: var(--w-regular) var(--fs-label)/1.3 var(--font); color: var(--ink-3); }
.ev-h::before { content: ""; width: 8px; height: 8px; flex: none; background: var(--orange); }
.ev-p { margin: 0; font: var(--w-regular) var(--fs-label)/1.5 var(--font); color: var(--ink-3); }

/* how it was counted: one paper block of rows, the result last */
.ev-rows { display: grid; gap: 4px; margin: 0; padding: 12px 14px; list-style: none; border-radius: var(--r-m); background: var(--paper); }
.ev-rows li { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; font: var(--w-regular) var(--fs-label)/1.45 var(--font); color: var(--ink-2); }
.ev-rows li b { flex: none; font-weight: var(--w-regular); color: var(--ink); font-variant-numeric: tabular-nums; }
.ev-rows li.ev-result { margin-top: 6px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ev-rows li.ev-result b { font-weight: var(--w-medium); }

/* the reminder under a number the analysis counted with its own query */
.ev-note { margin: 0; font: var(--w-regular) var(--fs-label)/1.45 var(--font); color: var(--ink-3); }

/* a section's own lines read a step darker than the lone note */
.ev-sec .ev-p { color: var(--ink-2); }

/* ---- the scrim: phones only (on wider screens a click outside closes the popup) ---- */
.ev-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(20, 20, 20, .28); opacity: 0; pointer-events: none; transition: opacity var(--dur-2); }

/* ---- phones: a sheet from the bottom, on the scrim, like the dialogs: no shadow ---- */
@media (max-width: 600px) {
  .ev-panel { left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-height: 82vh;
    border-radius: var(--r-l) var(--r-l) 0 0; padding-bottom: calc(var(--ev-pad) + env(safe-area-inset-bottom)); box-shadow: none;
    transform: translateY(24px); }
  .ev-panel.open { transform: none; }
  .ev-backdrop.show { opacity: 1; pointer-events: auto; }
}

@media (prefers-reduced-motion: reduce) { .ev-panel, .ev-backdrop { transition: none; } }
@media print { .ev-panel, .ev-backdrop { display: none; } .ev-num { background: none; padding: 0; } }
