/* ═══════════════════════════════════════════════════════════════
   J-Bot Vitals Ribbon — companion stylesheet
   Consumes --jbot-* canonical tokens exclusively, so the ribbon
   skins with whatever theme file is linked as #theme.
   ═══════════════════════════════════════════════════════════════ */

#jbot-vitals {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
}

/* On sidebar layouts (body: flex row), sticky can't stack above —
   pin to the viewport instead. Opt-in class set by vitals-ribbon.js. */
#jbot-vitals.vitals--fixed {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

#jbot-vitals {

  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;

  /* Top padding absorbs the Android/iOS status-bar overlay when the page
     is served edge-to-edge (viewport-fit=cover). env() honored on modern
     browsers; mobile fallback below for WebViews that return 0 despite
     viewport-fit (Tauri Android shipped with this quirk). */
  padding: calc(5px + env(safe-area-inset-top, 0px)) 18px 5px 18px;
  min-height: 28px;

  background:
    linear-gradient(90deg,
      var(--jbot-bg) 0%,
      var(--jbot-bg-panel) 50%,
      var(--jbot-bg) 100%);
  border-bottom: 1px solid var(--jbot-border);

  font-family: var(--jbot-font-mono);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 1px;
  color: var(--jbot-fg-dim);
  text-transform: uppercase;

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}


#jbot-vitals .vitals__cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

#jbot-vitals .vitals__emoji {
  font-size: 14px;
  line-height: 1;
  filter: drop-shadow(0 0 4px var(--jbot-accent-glow, transparent));
}

#jbot-vitals .vitals__label {
  color: var(--jbot-fg-bright);
  letter-spacing: 1.5px;
  font-weight: 500;
}

#jbot-vitals .vitals__muted {
  color: var(--jbot-fg-muted);
  font-style: italic;
  font-weight: 300;
}

/* ── Node dots ── */
#jbot-vitals .vitals__cell--nodes {
  gap: 5px;
}

#jbot-vitals .vitals__dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jbot-fg-muted);
  transition: background var(--jbot-transition, 0.25s ease);
}
#jbot-vitals .vitals__dot--ok {
  background: var(--jbot-success, var(--jbot-accent));
  box-shadow: 0 0 5px var(--jbot-success, var(--jbot-accent));
  animation: jbot-vitals-dot-breathe 2.4s ease-in-out infinite;
}
#jbot-vitals .vitals__dot--warn {
  background: var(--jbot-warn);
  box-shadow: 0 0 5px var(--jbot-warn);
}
#jbot-vitals .vitals__dot--err {
  background: var(--jbot-alert);
  box-shadow: 0 0 5px var(--jbot-alert);
  animation: jbot-vitals-dot-blink 1s steps(2, jump-none) infinite;
}

@keyframes jbot-vitals-dot-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@keyframes jbot-vitals-dot-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

#jbot-vitals .vitals__nodes-count {
  margin-left: 2px;
  font-size: 10px;
}

/* ── Cost bar ── */
#jbot-vitals .vitals__cell--cost {
  gap: 8px;
}

#jbot-vitals .vitals__bar {
  display: inline-block;
  width: 64px;
  height: 4px;
  background: var(--jbot-bg-panel-hi);
  border: 1px solid var(--jbot-border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

#jbot-vitals .vitals__bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--jbot-accent);
  transition: width var(--jbot-transition, 0.25s ease),
              background var(--jbot-transition, 0.25s ease);
}

/* ── Clock pinned right ── */
#jbot-vitals .vitals__cell--clock {
  margin-left: auto;
  color: var(--jbot-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  font-weight: 500;
}

/* ── Narrow viewport collapse ── */
@media (max-width: 560px) {
  #jbot-vitals {
    gap: 12px;
    padding: 5px 10px;
    font-size: 10px;
  }
  #jbot-vitals .vitals__bar { width: 40px; }
}

/* Phone collapse — single-row, essentials only */
@media (max-width: 480px) {
  #jbot-vitals {
    gap: 8px;
    padding: 4px 8px;
    font-size: 9px;
    letter-spacing: 0.5px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  #jbot-vitals .vitals__nodes-count,
  #jbot-vitals .vitals__cell--cost .vitals__bar,
  #jbot-vitals .vitals__cell--goals .vitals__muted,
  #jbot-vitals .vitals__cell--nodes .vitals__muted,
  #jbot-vitals .vitals__cell--mood .vitals__label {
    display: none;
  }
  #jbot-vitals .vitals__cell--clock { letter-spacing: 1px; }
}

@media (max-width: 360px) {
  #jbot-vitals { gap: 6px; padding: 3px 6px; }
  #jbot-vitals .vitals__cell--goals { display: none; }
}

/* ── Status-bar safe-area floor (MUST be last to beat the 480/360 rules) ──
   Tauri Android renders edge-to-edge and env(safe-area-inset-top) returns
   0 despite viewport-fit=cover, so the system clock/icons overlay the
   ribbon. A hard floor of 36px clears a standard Android status bar on
   the A14 and similar devices. Desktop is unaffected (this only applies
   at mobile widths). */
@media (max-width: 768px) {
  #jbot-vitals {
    padding-top: max(env(safe-area-inset-top, 36px), 36px) !important;
  }
}
