/* Hand of God: plain early-web shell (are.na / craigslist / faculty-homepage register).
   One deliberate light look: white paper, black ink, 1px rules, blue underlined links,
   no radii, no shadows. Layout: menu bar (top), workspace, status bar (bottom), windows above. */

:root {
  --sans: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --serif: "Times New Roman", Times, serif;
  --mono: "Courier New", Courier, monospace;
  --fs: 13px;
  --fs-s: 12px;
  --fs-xs: 11px;

  --bar-h: 26px;
  --status-h: 22px;

  --paper: #ffffff;
  --ink: #000000;
  --gray: #767676;
  --gray-2: #a8a8a8;
  --rule: #000000;
  --rule-soft: #d4d4d4;
  --tint: #f2f2f2;
  --link: #0000ee;
  --visited: #551a8b;
  --live: #d10000;
  --workspace: #ffffff;

  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font: var(--fs) / 1.4 var(--sans);
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

kbd {
  font: inherit;
}

a {
  color: var(--link);
}

a:visited {
  color: var(--visited);
}

:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

/* A <button> that reads as a link. */
.linkbtn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.linkbtn:hover {
  color: var(--ink);
}

.linkbtn--quiet {
  color: var(--gray);
}

.sep {
  color: var(--gray-2);
  padding: 0 6px;
}

/* ---- menu bar ------------------------------------------------------------------------------ */

.menubar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(8px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  user-select: none;
  -webkit-user-select: none;
}

.menubar__app {
  font: bold 15px / 1 var(--serif);
  padding: 0 14px 0 4px;
  white-space: nowrap;
}

.menubar__menus {
  display: flex;
  align-items: stretch;
  height: 100%;
  min-width: 0;
}

.menubar__title {
  padding: 0 8px;
  border: 0;
  background: transparent;
  white-space: nowrap;
  cursor: default;
}

.menubar__title:hover {
  text-decoration: underline;
}

.menubar__title[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
}

.menubar__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.camtoggle__live {
  color: var(--live);
  margin-right: 6px;
  text-decoration: none;
  display: none;
}

.camtoggle[aria-pressed="true"] .camtoggle__live {
  display: inline-block; /* inline-block stops the parent link's underline from reaching it */
}

.camtoggle[data-state="starting"] {
  color: var(--gray);
  text-decoration: none;
}

/* ---- dropdown menu ------------------------------------------------------------------------- */

.menu {
  position: fixed;
  z-index: 40;
  min-width: 210px;
  max-width: calc(100vw - 16px);
  padding: 3px 0;
  background: var(--paper);
  border: 1px solid var(--rule);
  user-select: none;
  -webkit-user-select: none;
}

.menu:focus {
  outline: none;
}

.menu__item {
  width: 100%;
  height: 21px;
  padding: 0 10px 0 4px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: default;
}

.menu__item:visited {
  color: var(--ink);
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.menu__item[aria-disabled="true"] {
  color: var(--gray-2);
  background: transparent;
}

.menu__check {
  text-align: center;
  visibility: hidden;
}

.menu__item[aria-checked="true"] .menu__check {
  visibility: visible;
}

.menu__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu__key {
  padding-left: 20px;
  color: var(--gray);
  text-align: right;
}

.menu__item:hover .menu__key,
.menu__item:focus-visible .menu__key {
  color: inherit;
}

.menu__item[aria-disabled="true"] .menu__key {
  color: var(--gray-2);
}

.menu__header {
  padding: 5px 10px 1px 20px;
  font-size: var(--fs-xs);
  color: var(--gray);
  white-space: nowrap;
}

.menu__sep {
  height: 0;
  margin: 3px 0;
  border-top: 1px solid var(--rule-soft);
}

/* ---- workspace ----------------------------------------------------------------------------- */

.stage {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(var(--bar-h) + env(safe-area-inset-top, 0px) + 1px);
  bottom: calc(var(--status-h) + env(safe-area-inset-bottom, 0px) + 1px);
  overflow: hidden;
  background: var(--workspace);
  touch-action: none;
}

.layer {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

.layer--hud {
  pointer-events: none;
}

/* Kept in the layout (not display:none) so the browser keeps decoding frames. */
.cam {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.empty {
  position: absolute;
  inset: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px max(24px, env(safe-area-inset-right, 0px)) 24px max(24px, env(safe-area-inset-left, 0px));
  background: var(--paper);
  text-align: center;
}

.empty__box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.empty__title {
  margin: 0 0 6px;
  font: bold 30px / 1.15 var(--serif);
}

.empty__text {
  margin: 0 0 26px;
  font: 17px / 1.4 var(--serif);
}

.empty__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 0 0 26px;
}

.empty__note {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--gray);
}

.empty__error {
  margin: 12px 0 0;
  font-size: var(--fs-s);
  color: var(--live);
}

/* The one big button: plain, bordered, inverts on hover. */
.bigbtn {
  min-width: 240px;
  padding: 14px 32px;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: 18px / 1 var(--sans);
  cursor: pointer;
}

.bigbtn:hover,
.bigbtn:active {
  background: var(--ink);
  color: var(--paper);
}

.bigbtn:focus-visible {
  outline: 1px dotted var(--ink);
  outline-offset: 3px;
}

.debug {
  position: absolute;
  left: 8px;
  top: 8px;
  margin: 0;
  padding: 4px 6px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  font: 11px / 1.4 var(--mono);
  pointer-events: none;
  white-space: pre;
}

/* ---- status bar ---------------------------------------------------------------------------- */

.statusbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 30;
  height: calc(var(--status-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  font-size: var(--fs-xs);
  color: var(--gray);
  user-select: none;
  -webkit-user-select: none;
}

.statusbar__msg {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.statusbar__msg[data-kind="notice"] {
  color: var(--ink);
}

.statusbar__info {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.statusbar__item:not([hidden]) + .statusbar__item::before {
  content: "·";
  color: var(--gray-2);
  padding: 0 7px;
}

.statusbar__item--num {
  font-variant-numeric: tabular-nums;
}

/* ---- windows ------------------------------------------------------------------------------- */

.window {
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
}

.window__titlebar {
  height: 22px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 7px;
  background: var(--tint);
  border-bottom: 1px solid var(--rule);
  font-size: var(--fs-s);
  cursor: move;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.window__titlebar--static {
  cursor: default;
}

.window__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-s);
  font-weight: bold;
}

.window__count {
  font-weight: normal;
  color: var(--gray);
  font-variant-numeric: tabular-nums;
}

.window__close {
  font-size: var(--fs-xs);
}

.window--history {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  width: min(300px, calc(100vw - 16px));
  max-height: min(60vh, 520px);
}

.history {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.history__item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  padding: 6px 7px;
}

.history__item + .history__item {
  border-top: 1px solid var(--rule-soft);
}

.history__thumb {
  display: block;
  width: 48px;
  height: 36px;
  border: 1px solid var(--rule-soft);
  background: var(--tint);
}

.history__text {
  min-width: 0;
}

.history__title,
.history__meta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history__title {
  font-size: var(--fs-s);
}

span.history__title {
  color: var(--ink);
}

.history__meta {
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--gray);
}

.history__remove {
  font-size: var(--fs-xs);
  margin-top: 1px;
}

/* ---- dialogs ------------------------------------------------------------------------------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
  background: rgb(255 255 255 / 0.55);
}

.window--dialog {
  width: min(480px, 100%);
  max-height: calc(100% - 32px);
}

.dialog__body {
  padding: 12px 14px;
  overflow-y: auto;
  font: 15px / 1.45 var(--serif);
}

.dialog__body p {
  margin: 0;
}

.dialog__actions {
  padding: 0 14px 12px;
  font-size: var(--fs);
}

.dialog__note {
  margin-top: 12px !important;
  font: var(--fs-s) / 1.4 var(--sans);
  color: var(--gray);
}

.steps {
  margin: 0;
  padding-left: 1.4em;
}

.steps li + li {
  margin-top: 4px;
}

.keys {
  width: 100%;
  margin-top: 14px;
  border-collapse: collapse;
  font: var(--fs-s) / 1.4 var(--sans);
}

.keys caption {
  text-align: left;
  font-weight: bold;
  padding-bottom: 4px;
}

.keys th,
.keys td {
  padding: 3px 6px 3px 0;
  border-top: 1px solid var(--rule-soft);
  text-align: left;
  vertical-align: baseline;
}

.keys th {
  width: 64px;
  font-weight: normal;
  white-space: nowrap;
}

.keys td {
  color: var(--gray);
}

.keys kbd {
  font-family: var(--mono);
  color: var(--ink);
}

/* ---- toast (shown while the interface is hidden) ------------------------------------------- */

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-s);
  pointer-events: none;
  white-space: nowrap;
}

/* ---- hidden interface ---------------------------------------------------------------------- */

body.is-bare .menubar,
body.is-bare .statusbar,
body.is-bare .window--history,
body.is-bare .menu {
  display: none !important;
}

body.is-bare .stage {
  top: 0;
  bottom: 0;
}

/* ---- narrow screens ------------------------------------------------------------------------ */

@media (max-width: 560px) {
  .menubar__app {
    display: none;
  }

  .menubar__title {
    padding: 0 6px;
  }

  #status-mode {
    display: none;
  }
}

@media (max-width: 400px) {
  .camtoggle__live {
    margin-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
