/* Colours are Tokyo Night's, Omarchy's default theme, so the page and the
   desktop that replaces it read as one thing. */
:root {
  --bg: #1a1b26;
  --panel: #16161e;
  --line: #292e42;
  --fg: #a9b1d6;
  --dim: #565f89;
  --bright: #c0caf5;
  --accent: #7aa2f7;
  --warn: #e0af68;
  --bad: #f7768e;
  --mono: "JetBrainsMono Nerd Font", "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* The desktop. Sized by main.js to the guest's mode; letterboxed if the
   window and the mode disagree. #standin lies exactly over it while the
   desktop changes size (main.js, the old wallpaper). */
#screen, #standin {
  position: fixed;
  inset: 0;
  margin: auto;
  /* As large as the window allows at the picture's own shape (main.js sets
     --ar, width over height): a resumed desktop has the size it was
     snapshotted at. */
  width: min(100vw, calc(100dvh * var(--ar, 1.6)));
  height: auto;
  max-width: 100vw;
  max-height: 100dvh;
  background: #000;
  outline: none;
  touch-action: none;
  cursor: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
body.live #screen { opacity: 1; }
#standin { opacity: 1; transition: none; pointer-events: none; cursor: none; }
body:not(.live) #standin, body.console #standin { display: none; }
body.console #screen { cursor: default; }

/* While the guest changes its display's size to the window's (main.js, fit). */
#fitting {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 12px;
  pointer-events: none;
  z-index: 3;
}
body:not(.live) #fitting, body.console #fitting { display: none; }

/* Boot screen: over the canvas until the desktop draws its first frame. */
#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s;
}
body.live:not(.console) #boot { opacity: 0; visibility: hidden; pointer-events: none; }

/* The load screen: a name, a line, a word or two. The boot log is the Log
   button's (body.console). */
.boot-inner { width: min(280px, 100%); text-align: center; }
body.console .boot-inner { width: min(760px, 100%); text-align: left; }

/* A resume has the desktop's last frame seconds before it has the machine
   (machine.js, preview): it shows, dimmed, behind the load screen. */
body.preview:not(.live) #screen { opacity: 0.45; }
body.preview:not(.live):not(.console) #boot { background: transparent; }
body.preview:not(.live):not(.console) .boot-inner {
  padding: 18px 22px 14px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--line);
}

h1 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--bright);
}

#status { margin: 10px 0 0; min-height: 1.5em; color: var(--dim); font-size: 12px; }
#status.error { color: var(--bad); white-space: pre-wrap; text-align: left; }

.bar { height: 2px; background: var(--line); overflow: hidden; }
#progress { height: 100%; width: 0; background: var(--accent); transition: width 0.3s ease; }
#progress.busy { width: 30%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

#log {
  display: none;
  height: min(46dvh, 420px);
  margin: 12px 0;
  padding: 12px 14px;
  overflow: hidden auto;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--dim);
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
body.console #log { display: block; }

#btn-show { margin: 10px 0 0; }
.credit { margin: 10px 0 0; color: var(--dim); font-size: 11px; }
.credit a { color: inherit; }
body.console .credit { display: none; }

/* Before a download that is worth asking about: what it costs, and the button. */
.ask { margin: 0 0 14px; color: var(--fg); font-size: 13px; }
button.primary {
  padding: 6px 22px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg);
  font-size: 13px;
  font-weight: 700;
}
button.primary:hover { background: var(--bright); border-color: var(--bright); color: var(--bg); }
#gate, #gate-resume { margin-bottom: 4px; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--bright); }
#keys a.fine { float: right; color: var(--dim); font-size: 12px; line-height: 26px; }

/* Page controls: out of the desktop's way until the pointer nears the corner. */
#chips {
  position: fixed;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
  opacity: 0.9;
  transition: opacity 0.3s ease;
}
/* There until the pointer has been over them once (main.js, chips-seen), so
   that a visitor finds them; after that, only near the corner. */
body.live:not(.console).chips-seen #chips { opacity: 0; }
body.live:not(.console).chips-seen #chips:hover,
body.live:not(.console).chips-seen #chips:focus-within { opacity: 0.95; }

button {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--fg);
  font: 12px/1.5 var(--mono);
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--bright); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#keys {
  position: fixed;
  right: 10px;
  bottom: 48px;
  width: min(380px, calc(100vw - 20px));
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
}
#keys h2 { margin: 0 0 8px; font-size: 14px; color: var(--bright); }
#keys p { margin: 0 0 12px; color: var(--fg); text-wrap: pretty; }
#keys .taps button { margin: 4px 4px 0 0; padding: 3px 9px; font: inherit; font-size: 12px; color: var(--bright); background: var(--bg); border: 1px solid var(--line); cursor: pointer; }
#keys .taps button:hover { border-color: var(--accent); }
#keys .super-key { color: var(--dim); font-size: 12px; }
#keys .super-key select { font: inherit; color: var(--bright); background: var(--bg); border: 1px solid var(--line); padding: 2px 4px; }
#keys .last-key { color: var(--dim); font-size: 12px; }
#keys .last-key b { color: var(--warn); font-weight: normal; }
#keys dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; }
#keys dt { white-space: nowrap; }
#keys dd { margin: 0; color: var(--dim); }
kbd {
  padding: 1px 5px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--bright);
  font: inherit;
}

@media (prefers-reduced-motion: reduce) {
  #screen, #boot, #chips, #progress { transition: none; }
  #progress.busy { animation: none; width: 100%; opacity: 0.5; }
}
