/* HamRig meters - the display component of one meter head (assets/js/meter-viz.js).
   The seven instrument faces are HamRigAmpViz's (assets/css/amp-viz.css, meters-view.css);
   this file draws the meter's own two (Bars, Compact) and the meter chips/lines used on
   the radio cards, the amps page and the Station Console. Colours are tokens a host
   (a console skin, the control client, the pop-out) redefines; dark everywhere. */

.mv-host, .mtl, .st-mtr {
    --mv-text: #e5e7eb; --mv-dim: #8e8e93; --mv-value: #f2f2f7; --mv-line: rgba(255, 255, 255, .11); --mv-bg: rgba(255, 255, 255, .04);
    --mv-ok: #34c759; --mv-warn: #f59e0b; --mv-alarm: #ff3b30; --mv-acc: #2dd4bf; --mv-fwd: #E05252; --mv-ref: #f0a35a;
    --mv-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
.mv-host { min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; color: var(--mv-text); }
.mv-host[data-stale="1"] .mv-compact, .mv-host[data-stale="1"] .mv-bars { opacity: .55; filter: grayscale(.8); }

/* ---- Compact: SWR large, forward / reflected under it ---- */
.mv-compact { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35em; width: 100%; min-width: 0; }
.mv-big { display: flex; align-items: baseline; justify-content: center; gap: .45em; min-width: 0; }
.mv-cap { font: 700 .7em/1 Inter, system-ui, sans-serif; letter-spacing: .1em; color: var(--mv-dim); text-transform: uppercase; }
.mv-big b { font: 750 2.3em/1 var(--mv-mono); color: var(--mv-value); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mv-big b[data-zone="ok"] { color: var(--mv-ok); }
.mv-big b[data-zone="warn"] { color: var(--mv-warn); }
.mv-big b[data-zone="alarm"] { color: var(--mv-alarm); }
.mv-sub { display: flex; flex-wrap: wrap; justify-content: center; gap: .2em 1em; font: 600 .82em/1.25 var(--mv-mono); color: var(--mv-dim); }
.mv-sub b { color: var(--mv-value); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Bars: forward and reflected with their limits ---- */
.mv-bars { display: flex; flex-direction: column; justify-content: center; gap: .55em; width: 100%; min-width: 0; padding: 0 .2em; }
.mv-bars .mv-big { justify-content: flex-start; }
.mv-bars .mv-big b { font-size: 1.8em; }
.mv-bars .mx-bar-h { display: flex; justify-content: space-between; gap: 8px; font: 600 .66em/1.2 Inter, system-ui, sans-serif; color: var(--mv-dim); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .06em; }
.mv-bars .mx-bar-scale { font-family: var(--mv-mono); text-transform: none; letter-spacing: 0; }
.mv-bars .mx-bar-track { position: relative; height: .8em; min-height: 7px; border-radius: 6px; background: var(--mv-bg); box-shadow: inset 0 0 0 1px var(--mv-line); overflow: hidden; }
.mv-bars .mx-bar-track i { position: absolute; top: 0; bottom: 0; left: 0; display: block; transition: width .12s linear, left .12s linear; }
.mv-bars .mx-bar-pk { background: color-mix(in srgb, var(--mv-fwd) 35%, transparent); }
.mv-bars .mx-bar-avg { background: var(--mv-fwd); }
.mv-bars .mx-bar-ref .mx-bar-pk { background: color-mix(in srgb, var(--mv-ref) 35%, transparent); }
.mv-bars .mx-bar-ref .mx-bar-avg { background: var(--mv-ref); }
.mv-bars .mx-bar[data-zone="warn"] .mx-bar-avg { background: var(--mv-warn); }
.mv-bars .mx-bar[data-zone="alarm"] .mx-bar-avg { background: var(--mv-alarm); }
.mv-bars .mx-bar-hold { width: 2px; background: var(--mv-value); margin-left: -1px; }
.mv-bars .mx-bar-lim { width: 2px; background: var(--mv-alarm); margin-left: -1px; opacity: 0; }

/* ---- the meter line on radio cards and the amps page (assets/js/meter-links.js) ---- */
.mtl { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.mtl:empty, .mtl[hidden] { display: none; }
.mtl-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; padding: 3px 9px; border-radius: 999px;
    font: 600 12px/1.35 Inter, system-ui, sans-serif; color: var(--mv-text); background: rgba(45, 212, 191, .08); border: 1px solid rgba(45, 212, 191, .35);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.mtl-chip:hover { border-color: var(--mv-acc); }
.mtl-chip > i { color: var(--mv-acc); font-size: 11px; flex: 0 0 auto; }
.mtl-chip b { font-family: var(--mv-mono); font-weight: 700; color: var(--mv-value); font-variant-numeric: tabular-nums; }
.mtl-chip .mtl-k { color: var(--mv-dim); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.mtl-chip[data-zone="ok"] b.mtl-swr { color: var(--mv-ok); }
.mtl-chip[data-zone="warn"] { border-color: rgba(245, 158, 11, .6); background: rgba(245, 158, 11, .1); }
.mtl-chip[data-zone="warn"] b.mtl-swr { color: var(--mv-warn); }
.mtl-chip[data-zone="alarm"] { border-color: rgba(255, 59, 48, .7); background: rgba(255, 59, 48, .13); }
.mtl-chip[data-zone="alarm"] b.mtl-swr { color: #ff8a82; }
.mtl-chip[data-tx="1"] > i { color: #ff3b30; filter: drop-shadow(0 0 4px rgba(255, 59, 48, .7)); }
.mtl-chip[data-off="1"] { opacity: .65; }

/* ---- a face in a box of fixed size (console cell, meter window, pop-out): the face takes the room ---- */
.mv-fit { container-type: size; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
.mv-fit.ampv[data-viz="hamrig"] .amp-disc { width: min(100cqw, 100cqh); max-width: none; height: auto; }
.mv-fit.ampv[data-viz="analog"] .ampv-an { width: 100%; max-width: min(100cqw, (100cqh - 30px) * 1.46); }
.mv-fit.ampv[data-viz="digital"] { align-items: center; }
.mv-fit.ampv[data-viz="digital"] .ampv-lcd { width: 100%; flex: 0 0 auto; align-self: center; height: auto; max-height: none; }
.mv-fit { overflow: hidden; }
.mv-fit > .ampx { align-self: stretch; max-width: none; }
.mv-fit > .ampx { width: 100%; min-width: 0; }
.mv-fit > .ampx > .ampx-svg { width: 100%; height: 100%; max-height: 100%; }
.mv-fit > .mv-compact, .mv-fit > .mv-bars { font-size: min(1em, 9cqh); }
.mv-fit > .mv-compact .mv-big b { font-size: clamp(1.4em, 30cqh, 4.2em); }
.rc-meter { margin: 6px 0 2px; }
.amp-item-mtl { margin-top: 6px; }
.amp-detail-mtl { margin-top: 6px; }

/* ---- the mode switch of a head: PEP · AVG · HOLD (+ hold time and release in HOLD) ---- */
.mv-mode { display: inline-flex; align-items: stretch; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(0, 0, 0, .35); border: 1px solid var(--mv-line, rgba(255, 255, 255, .11)); flex: 0 0 auto; max-width: 100%; }
.mv-mode button { all: unset; box-sizing: border-box; cursor: pointer; min-width: 2.6em; min-height: 26px; padding: 0 .55em; border-radius: 7px; text-align: center;
    font: 700 11px/26px 'JetBrains Mono', ui-monospace, monospace; letter-spacing: .05em; color: var(--mv-dim, #8e8e93); white-space: nowrap; }
.mv-mode button:hover { color: var(--mv-text, #e5e7eb); background: rgba(255, 255, 255, .06); }
.mv-mode button:focus-visible { outline: 2px solid var(--mv-acc, #2dd4bf); outline-offset: 1px; }
.mv-mode button[aria-pressed="true"] { color: var(--mv-value, #f2f2f7); background: rgba(45, 212, 191, .18); box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .6); }
.mv-mode .mv-mode-t, .mv-mode .mv-mode-r { display: none; min-width: 0; }
.mv-mode[data-mode="hold"] .mv-mode-t, .mv-mode[data-mode="hold"] .mv-mode-r { display: inline-block; }
.mv-mode .mv-mode-t { color: var(--mv-warn, #f59e0b); }
@media (pointer: coarse) { .mv-mode button { min-height: 36px; line-height: 36px; } }
.mv-mode-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
