/* ═══════════ The VPN dropdown (2026-10-05) — renderer/vpn-menu.js ═══════════
   Hung under the browser bar's VPN pill in the Hearth Shell. Hearthside
   palette (--wbc-*, styles.css "Browser chrome"); the one colour that changes
   is --vpnm-ink, set by the measured grade, and every graded thing also
   carries a word so the reading never rides on colour alone. */
.vpnm {
  --vpnm-ink: var(--wbc-dim, rgba(241, 230, 218, .7));
  --vpnm-lantern: url('browser-home/vpn-off.webp');
  --vpnm-lantern-filter: grayscale(.5) drop-shadow(0 2px 4px rgba(0, 0, 0, .6));
  --vpnm-smooth: #bff08f;
  --vpnm-fair: #f3d98a;
  --vpnm-laggy: #ffb27a;
  --vpnm-crawl: #ff8f73;
  position: fixed; z-index: 2147483400;
  width: 372px; max-width: calc(100vw - 16px);
  display: flex; flex-direction: column;
  padding: 14px 14px 10px;
  background:
    radial-gradient(120% 70% at 12% 0%, color-mix(in srgb, var(--vpnm-ink) 9%, transparent), transparent 62%),
    var(--wbc-panel, #1b1412);
  border: 1px solid var(--wbc-line-hi, rgba(255, 190, 130, .26));
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .62), inset 0 1px 0 rgba(255, 240, 220, .05);
  color: var(--wbc-text, #f1e6da);
  font: 400 12.5px/1.45 var(--font-ui, system-ui, -apple-system, 'Segoe UI', sans-serif);
  -webkit-app-region: no-drag;
  transform-origin: calc(100% - 42px) 0;
  animation: vpnm-in .16s cubic-bezier(.2, .8, .2, 1) both;
  transition: background .3s ease;
}
@keyframes vpnm-in { from { opacity: 0; transform: translateY(-6px) scale(.97); } to { opacity: 1; transform: none; } }

.vpnm[data-grade="smooth"]   { --vpnm-ink: var(--vpnm-smooth); --vpnm-lantern: url('browser-home/vpn-on.webp'); --vpnm-lantern-filter: drop-shadow(0 0 9px rgba(150, 230, 90, .5)); }
.vpnm[data-grade="fair"]     { --vpnm-ink: var(--vpnm-fair);   --vpnm-lantern: url('browser-home/vpn-on.webp'); --vpnm-lantern-filter: sepia(.85) saturate(1.9) hue-rotate(8deg) drop-shadow(0 0 9px rgba(240, 210, 110, .45)); }
.vpnm[data-grade="laggy"]    { --vpnm-ink: var(--vpnm-laggy);  --vpnm-lantern: url('browser-home/vpn-on.webp'); --vpnm-lantern-filter: sepia(.95) saturate(2.4) hue-rotate(-14deg) drop-shadow(0 0 9px rgba(255, 150, 70, .5)); }
.vpnm[data-grade="crawling"] { --vpnm-ink: var(--vpnm-crawl);  --vpnm-lantern: url('browser-home/vpn-on.webp'); --vpnm-lantern-filter: sepia(1) saturate(3) hue-rotate(-28deg) brightness(.95) drop-shadow(0 0 9px rgba(255, 110, 70, .5)); }
.vpnm[data-grade="down"]     { --vpnm-ink: var(--vpnm-crawl);  --vpnm-lantern: url('browser-home/vpn-warn.webp'); --vpnm-lantern-filter: drop-shadow(0 0 9px rgba(255, 110, 40, .55)); }

/* ── verdict ── */
.vpnm-head { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px; }
.vpnm-lantern {
  width: 46px; height: 46px;
  background: var(--vpnm-lantern) center / contain no-repeat;
  filter: var(--vpnm-lantern-filter);
  transition: filter .35s ease;
}
.vpnm[data-grade="checking"] .vpnm-lantern { animation: vpnm-breathe 1.6s ease-in-out infinite; }
@keyframes vpnm-breathe { 0%, 100% { opacity: .5; } 50% { opacity: .95; } }
.vpnm-title { min-width: 0; display: flex; flex-direction: column; }
.vpnm-verdict { font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; color: var(--vpnm-ink); transition: color .3s ease; }
.vpnm-sub { color: var(--wbc-dim, rgba(241, 230, 218, .7)); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.vpnm-say { margin: 9px 0 0; color: rgba(241, 230, 218, .86); text-wrap: pretty; }

/* The switch: the lantern itself slides across — lit when the VPN is on. */
.vpnm-switch {
  position: relative; width: 64px; height: 30px; padding: 0; flex: none;
  border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(150, 222, 98, .42); background: rgba(126, 206, 84, .13);
  color: #bff08f; font: 650 11px/1 var(--font-ui, system-ui, sans-serif); letter-spacing: .03em;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
.vpnm-switch-word { position: absolute; left: 11px; top: 50%; translate: 0 -50%; transition: left .22s cubic-bezier(.2, .8, .2, 1); }
.vpnm-switch-thumb {
  position: absolute; top: 2px; left: 36px; width: 24px; height: 24px;
  background: url('browser-home/vpn-on.webp') center / contain no-repeat;
  filter: drop-shadow(0 0 4px rgba(150, 230, 90, .6));
  transition: left .22s cubic-bezier(.2, .8, .2, 1), filter .2s ease;
}
.vpnm-switch[aria-checked="false"] { border-color: var(--wbc-line-hi, rgba(255, 190, 130, .26)); border-style: dashed; background: rgba(8, 5, 6, .4); color: var(--wbc-dim, rgba(241, 230, 218, .7)); }
.vpnm-switch[aria-checked="false"] .vpnm-switch-word { left: 33px; }
.vpnm-switch[aria-checked="false"] .vpnm-switch-thumb { left: 3px; background-image: url('browser-home/vpn-off.webp'); filter: grayscale(.4) drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.vpnm-switch:hover { filter: brightness(1.15); }
.vpnm-switch[disabled] { cursor: progress; opacity: .6; }

/* ── the path: You → Hearth → exit ── */
.vpnm-path {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: flex; align-items: center;
}
.vpnm-path[hidden], .vpnm-stats[hidden], .vpnm-loc[hidden], .vpnm-retest[hidden], .vpnm-loc-note[hidden] { display: none; }
.vpnm-node {
  flex: none; padding: 4px 9px; border-radius: 8px;
  border: 1px solid var(--wbc-line-hi, rgba(255, 190, 130, .26)); background: rgba(8, 5, 6, .35);
  font-size: 11px; font-weight: 650; letter-spacing: .02em; white-space: nowrap;
}
/* A long city gives way before a leg does. */
.vpnm-node:last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vpnm-leg {
  --leg: var(--wbc-dim, rgba(241, 230, 218, .7));
  /* Both legs take the same share and never shrink under their label. The
     one column is pinned to the leg's own width: left to size itself it grew
     to the label and pushed the wire through the next node. No gap either
     side, so the wire runs node to node. */
  flex: 1 0 60px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: 3px;
}
.vpnm-leg[data-grade="smooth"]   { --leg: var(--vpnm-smooth); }
.vpnm-leg[data-grade="fair"]     { --leg: var(--vpnm-fair); }
.vpnm-leg[data-grade="laggy"]    { --leg: var(--vpnm-laggy); }
.vpnm-leg[data-grade="crawling"],
.vpnm-leg[data-grade="down"]     { --leg: var(--vpnm-crawl); }
.vpnm-leg b { font-size: 12.5px; font-weight: 700; color: var(--leg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vpnm-leg span { font-size: 10px; color: rgba(241, 230, 218, .55); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.vpnm-leg i {
  position: relative; display: block; width: 100%; height: 3px; overflow: hidden;
  background: color-mix(in srgb, var(--leg) 26%, transparent);
  transform-origin: 0 50%; animation: vpnm-draw .34s cubic-bezier(.2, .8, .2, 1) both;
}
.vpnm-leg:nth-of-type(4) i { animation-delay: .12s; }
/* An ember crossing the leg, as slowly as the hop is slow. */
.vpnm-leg i::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 34%;
  background: linear-gradient(90deg, transparent, var(--leg), transparent);
  animation: vpnm-cross var(--dur, 1.6s) linear infinite;
}
.vpnm-leg[data-grade="down"] i::after, .vpnm-leg[data-grade="checking"] i::after { animation: none; opacity: 0; }
@keyframes vpnm-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes vpnm-cross { from { transform: translateX(-100%); } to { transform: translateX(295%); } }

/* ── three readings, one row ── */
.vpnm-stats {
  margin: 14px 0 0; padding: 10px 0; display: grid; grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--wbc-line, rgba(255, 206, 160, .09));
  border-bottom: 1px solid var(--wbc-line, rgba(255, 206, 160, .09));
}
.vpnm-stats > div { min-width: 0; padding: 0 10px; }
.vpnm-stats > div:first-child { padding-left: 2px; }
.vpnm-stats > div + div { border-left: 1px solid var(--wbc-line, rgba(255, 206, 160, .09)); }
.vpnm-stats dt { font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: rgba(241, 230, 218, .55); }
.vpnm-stats dd { margin: 2px 0 0; display: flex; align-items: baseline; gap: 5px; min-height: 22px; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vpnm-stats small { font-size: 11px; font-weight: 500; color: var(--wbc-dim, rgba(241, 230, 218, .7)); }
.vpnm-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 18px; align-self: center; }
.vpnm-bars i { width: 4px; border-radius: 1px; background: var(--vpnm-smooth); }
.vpnm-bars i[data-grade="fair"] { background: var(--vpnm-fair); }
.vpnm-bars i[data-grade="laggy"] { background: var(--vpnm-crawl); }

/* ── exit location ── */
.vpnm-loc { margin-top: 12px; display: flex; flex-direction: column; min-height: 0; }
.vpnm-loc-head { display: flex; align-items: center; gap: 10px; }
.vpnm-loc-head h3 { margin: 0; flex: none; font-size: 10px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: rgba(241, 230, 218, .55); }
.vpnm-find {
  flex: 1; min-width: 0; height: 28px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--wbc-line-hi, rgba(255, 190, 130, .26));
  background: rgba(8, 5, 6, .45); color: var(--wbc-text, #f1e6da);
  font: inherit; font-size: 12.5px;
}
.vpnm-find::placeholder { color: rgba(241, 230, 218, .45); }
/* The rows bleed 8px past the column each side, so a row's text sits on the
   same edges as everything above it; the 4px scrollbar lives in the right
   bleed (gutter reserved, so a short list keeps the same edge). The last 16px
   fade out: a row cut by the fold reads as "more below", not as a collision
   with the note under it. */
.vpnm-cities {
  list-style: none; margin: 8px -12px 0 -8px; padding: 0 0 8px;
  max-height: 214px; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 16px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 16px), transparent);
}
.vpnm-cities::-webkit-scrollbar { width: 4px; }
.vpnm-cities::-webkit-scrollbar-track { background: transparent; }
.vpnm-cities::-webkit-scrollbar-thumb { border-radius: 2px; background: rgba(255, 190, 130, .28); }
@supports not selector(::-webkit-scrollbar) {
  .vpnm-cities { scrollbar-width: thin; scrollbar-color: rgba(255, 190, 130, .28) transparent; }
}
.vpnm-city {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; column-gap: 8px;
  padding: 7px 8px; border: 0; border-radius: 8px; background: none; cursor: pointer;
  color: var(--wbc-text, #f1e6da); font: inherit; text-align: left;
  transition: background .12s ease;
}
.vpnm-city-name { font-weight: 600; white-space: nowrap; }
.vpnm-city-country { min-width: 0; font-size: 11.5px; color: rgba(241, 230, 218, .55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpnm-city-meta { font-size: 11.5px; color: var(--wbc-dim, rgba(241, 230, 218, .7)); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vpnm-city:hover:not([disabled]), .vpnm-city:focus-visible { background: var(--wbc-hover, rgba(255, 154, 60, .12)); }
.vpnm-city[disabled] { cursor: default; }
.vpnm-city[disabled]:not([aria-selected="true"]):not(.is-moving) > * { opacity: .45; }
.vpnm-city[aria-selected="true"] { background: color-mix(in srgb, var(--vpnm-ink) 11%, transparent); box-shadow: inset 2px 0 0 var(--vpnm-ink); }
.vpnm-city[aria-selected="true"] .vpnm-city-meta { color: var(--vpnm-ink); font-weight: 600; }
.vpnm-city.is-moving {
  background: linear-gradient(90deg, transparent, rgba(255, 154, 60, .2), transparent) 0 0 / 220% 100%, rgba(255, 154, 60, .08);
  animation: vpnm-move 1.3s linear infinite;
}
.vpnm-city.is-moving .vpnm-city-meta { color: var(--wbc-ember-hi, #ffc77a); font-weight: 600; }
@keyframes vpnm-move { from { background-position: 120% 0, 0 0; } to { background-position: -100% 0, 0 0; } }
.vpnm-calm { padding: 10px 8px; color: var(--wbc-dim, rgba(241, 230, 218, .7)); }
.vpnm-loc-note { margin: 2px 0 0; font-size: 11.5px; color: var(--vpnm-smooth); text-wrap: pretty; }
.vpnm-loc-note[data-bad="true"] { color: var(--vpnm-laggy); }

/* ── foot ── */
.vpnm-foot { margin-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; }
.vpnm-age { font-size: 11px; color: rgba(241, 230, 218, .55); font-variant-numeric: tabular-nums; }
.vpnm-retest {
  height: 28px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--wbc-line-hi, rgba(255, 190, 130, .26)); background: rgba(255, 154, 60, .08);
  color: var(--wbc-ember-hi, #ffc77a); font: 600 11.5px/1 var(--font-ui, system-ui, sans-serif);
  transition: background .14s ease, border-color .14s ease;
}
.vpnm-retest:hover:not([disabled]) { background: var(--wbc-press, rgba(255, 154, 60, .2)); border-color: rgba(255, 190, 130, .45); }
.vpnm-retest[disabled] { opacity: .5; cursor: progress; }

.vpnm :is(button, input):focus-visible { outline: 2px solid var(--wbc-ember, #ff9a3c); outline-offset: 2px; }
body.locked .vpnm { display: none; }

/* The pill's fourth lighting: the tunnel works, but it is measurably slow. */
#view-browser #browser-bar #browser-vpn[data-state="slow"] {
  --pic: url('browser-home/vpn-on.webp');
  --vpn-ink: #ffb27a;
  background: rgba(255, 150, 60, .12); border-color: rgba(255, 160, 80, .5);
}
#view-browser #browser-bar #browser-vpn[data-state="slow"]::before { filter: sepia(.95) saturate(2.4) hue-rotate(-14deg) drop-shadow(0 0 5px rgba(255, 150, 70, .55)); }
#view-browser #browser-bar #browser-vpn[data-state="slow"]:hover { background: rgba(255, 150, 60, .19); border-color: rgba(255, 170, 90, .65); }
#view-browser #browser-bar #browser-vpn[aria-expanded="true"] { box-shadow: 0 0 0 2px color-mix(in srgb, var(--vpn-ink) 30%, transparent); }

@media (prefers-reduced-motion: reduce) {
  .vpnm, .vpnm-leg i, .vpnm-leg i::after, .vpnm-city.is-moving, .vpnm[data-grade="checking"] .vpnm-lantern { animation: none; }
  .vpnm-leg i::after { width: 100%; opacity: .55; background: var(--leg); }
  .vpnm-switch-word, .vpnm-switch-thumb { transition: none; }
}
