/* Browser machines card on the Virtual Machines page.
 *
 * Built from the site's own tokens (--panel, --line, --accent, --r/--r2) and
 * controls (.card, .chips/.chip, .btn) so it belongs to the same UI as the
 * launcher and the settings page: chips pick the machine, outline buttons drive
 * it, and the guest gets a black slab with the site's radius.
 */

/* In the desktop layout the dock rail floats over the page edges, so the view
   keeps clear of it instead of letting headings run underneath. */
@media (min-width: 900px) {
  body[data-layout="os"] #v-vms {
    padding: 0 12px 0 72px;
    box-sizing: border-box;
  }
}

.vmhub {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(1280px, calc(100% - 40px));
  margin: 32px auto 24px;
  box-sizing: border-box;
}

.vmhub-head p {
  margin-top: 6px;
  max-width: 68ch;
  font-size: 14px;
}

.vmhub-chips {
  padding-bottom: 0;
  gap: 6px;
}

.vmhub-chips .chip {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.vmhub-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.vmhub-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Site buttons are 46px tall for page actions; toolbars need the compact size
   while keeping the same radius, weight and colours. */
.btn.vmhub-btn {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.btn.vmhub-btn:disabled {
  opacity: 0.42;
  pointer-events: none;
}

.vmhub-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.vmhub-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--muted);
  font: 500 12px/1 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  white-space: nowrap;
}

.vmhub-badge[data-tone="ok"] {
  color: #7ee2a8;
}

.vmhub-badge[data-tone="busy"] {
  color: #ffc466;
}

.vmhub-badge[data-tone="err"] {
  color: #ff8a8a;
}

.vmhub-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r2);
  background: #05070f;
  overflow: hidden;
}

.vmhub-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 440px;
}

.vmhub-panel[hidden] {
  display: none !important;
}

.vmhub-screen {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 440px;
  overflow: auto;
  background: #000;
}

/* v86 writes text-mode output into this node, so the pre spacing is what turns
   its newlines into lines instead of literal \n. */
.vmhub-screen > div {
  margin: auto;
  color: #d8d8d8;
  background: #000;
  text-align: left;
  /* The guest is an 80-column console: keep its lines intact and let the slab
     scroll sideways on narrow screens instead of wrapping commands. */
  white-space: pre;
}

.vmhub-screen canvas {
  display: block;
  margin: auto;
  max-width: 100%;
  background: #000;
  image-rendering: pixelated;
  outline: 0;
}

.vmhub-frame-host {
  flex: 1;
  display: flex;
  justify-content: center;
  min-height: 440px;
  background: #000;
}

/* Bellard's console is about 640px wide; cap it instead of letting its page
   background stretch across the whole stage. */
.vmhub-frame-host[data-frame-host="jslinux"] .vmhub-frame {
  flex: 0 1 655px;
}

.vmhub-frame {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 440px;
  border: 0;
  background: #000;
}

.vmhub-foot-note {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.vmhub-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 10px;
  justify-items: center;
  padding: 26px;
  text-align: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(3px);
}

.vmhub-overlay[hidden] {
  display: none !important;
}

.vmhub-title {
  font: 600 16px/1.3 var(--display);
  color: var(--text);
}

.vmhub-detail {
  margin: 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 13px;
}

.vmhub-hint {
  margin: 0;
  min-height: 1em;
  color: var(--muted);
  font: 12px/1 ui-monospace, Menlo, Consolas, monospace;
}

.vmhub-progress {
  width: min(360px, 72%);
  height: 6px;
  border-radius: 999px;
  background: var(--panel2);
  overflow: hidden;
}

.vmhub-progress i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.18s ease-out;
}

.vmhub-progress[data-indeterminate="true"] i {
  width: 35%;
  animation: vmhub-sweep 1.1s ease-in-out infinite;
}

@keyframes vmhub-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(340%); }
}

.vmhub-spin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--panel2);
  border-top-color: var(--accent);
  animation: vmhub-spin 0.8s linear infinite;
}

@keyframes vmhub-spin {
  to { transform: rotate(360deg); }
}

/* ---------------- fullscreen ----------------
   The panel is the native fullscreen element, so the browser hides the page
   and its own chrome. The .vmhub-fs class paints the same state for browsers
   that refuse the request (embedded frames, restrictive kiosks): the stage is
   lifted over the page and everything but the guest is dropped. */

.vmhub-exit {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: none;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 13px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(10, 12, 20, 0.74);
  color: #fff;
  font: 600 12px/1 var(--font);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.vmhub-exit .msr {
  font-size: 16px;
}

.vmhub-exit:hover,
.vmhub-exit:focus-visible {
  background: rgba(10, 12, 20, 0.92);
  border-color: rgba(255, 255, 255, 0.5);
}

.vmhub-fs .vmhub-exit,
.vmhub-panel:fullscreen .vmhub-exit {
  display: inline-flex;
}

/* Fullscreen hides the page around it: rail, top bar, clock, tabs, updates. */
body.vmhub-fs-lock .topbar,
body.vmhub-fs-lock .tabbar,
body.vmhub-fs-lock .os-taskbar,
body.vmhub-fs-lock .os-dock-extras,
body.vmhub-fs-lock .os-desktop-brand,
body.vmhub-fs-lock .os-hint,
body.vmhub-fs-lock .os-popout,
body.vmhub-fs-lock .os-start-menu,
body.vmhub-fs-lock .os-launcher-scrim,
body.vmhub-fs-lock .os-osd,
body.vmhub-fs-lock .whats-new {
  visibility: hidden !important;
}

/* Whatever the page chrome is doing, the machine alone fills the viewport. */
.vmhub-fs {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: block;
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
}

.vmhub-fs > .vmhub-head,
.vmhub-fs > .vmhub-chips,
.vmhub-fs > .vmhub-bar,
.vmhub-fs > .vmhub-note {
  display: none;
}

.vmhub-fs > .vmhub-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
}

.vmhub-fs > .vmhub-stage .vmhub-panel:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
}

.vmhub-fs .vmhub-screen,
.vmhub-fs .vmhub-frame-host,
.vmhub-fs .vmhub-frame {
  min-height: 0;
}

.vmhub-fs .vmhub-foot-note {
  display: none;
}

body.vmhub-fs-lock {
  overflow: hidden;
}

.vmhub-panel:fullscreen {
  width: 100%;
  height: 100%;
  background: #000;
}

.vmhub-panel:fullscreen .vmhub-screen,
.vmhub-panel:fullscreen .vmhub-frame,
.vmhub-panel:fullscreen .vmhub-frame-host {
  min-height: 0;
}

.vmhub-panel:fullscreen .vmhub-foot-note {
  display: none;
}

.vmhub-note {
  margin: 0;
  font-size: 12px;
}

@media (max-width: 720px) {
  .vmhub-panel,
  .vmhub-screen,
  .vmhub-frame-host,
  .vmhub-frame {
    min-height: 340px;
  }
  .vmhub-stats {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vmhub-progress[data-indeterminate="true"] i,
  .vmhub-spin {
    animation-duration: 0.001ms;
    animation-iteration-count: 1;
  }
}
