/* ---------------------------------------------------------------------------
   Window furniture: menu bar, pull-down menus, windows, dialogs, status bar.
   ------------------------------------------------------------------------ */

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

.menubar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: 22px;
  padding: 0 4px;
  background: var(--paper);
  border-bottom: var(--line);
  box-shadow: 0 1px 0 var(--ink);
  user-select: none;
}

.menubar__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
  background: none;
  border: 0;
  cursor: default;
  white-space: nowrap;
}

.menubar__item[aria-expanded='true'] {
  background: var(--ink);
  color: var(--paper);
}

.menubar__mark {
  width: 12px;
  height: 12px;
  background-color: currentColor;
  /* The Sikons mark: a two-bit checker lozenge. */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill-rule='evenodd' d='M2 0h4v1h1v1h1v4h-1v1h-1v1h-4v-1h-1v-1h-1v-4h1v-1h1zM2 2h2v2h-2zM4 4h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill-rule='evenodd' d='M2 0h4v1h1v1h1v4h-1v1h-1v1h-4v-1h-1v-1h-1v-4h1v-1h1zM2 2h2v2h-2zM4 4h2v2h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  min-width: 200px;
  padding: 2px 0;
  background: var(--paper);
  /* The panel hangs inside the menu bar's title, which is inverted while the
     menu is open. A new surface has to restate its own ink, or every item
     inherits white text onto white paper. */
  color: var(--ink);
  border: var(--line);
  box-shadow: var(--drop);
}

.menu__item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 1px 12px 1px 20px;
  background: none;
  border: 0;
  text-align: left;
  cursor: default;
}

.menu__item:not([aria-disabled='true']):hover,
.menu__item:not([aria-disabled='true']):focus {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.menu__item[aria-disabled='true'] {
  color: var(--dim);
}

.menu__label {
  flex: 1 1 auto;
}

.menu__key {
  font-size: var(--size-small);
  opacity: 0.85;
}

.menu__check {
  position: absolute;
  left: 6px;
}

.menu__separator {
  height: 1px;
  margin: 3px 0;
  background-color: var(--paper);
  background-image: var(--dither-50);
  background-size: 2px 2px;
}

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

.window {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--paper);
  border: var(--line);
  box-shadow: var(--drop);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 17px;
  padding: 0 4px;
  border-bottom: var(--line);
  background: var(--stripes);
  user-select: none;
}

.titlebar__box {
  width: 11px;
  height: 11px;
  flex: none;
  background: var(--paper);
  border: var(--line);
}

.titlebar__box--grow {
  background-image: linear-gradient(to bottom right, var(--paper) 55%, var(--ink) 55%);
}

.titlebar__title {
  flex: 1 1 auto;
  padding: 0 6px;
  font-size: var(--size-small);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--paper);
}

.window__body {
  flex: 1 1 auto;
  min-height: 0;
  padding: var(--gap);
}

.window__body--tight {
  padding: 4px;
}

.window__footer {
  border-top: var(--line);
  padding: 4px 6px;
  font-size: var(--size-small);
}

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

.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.35);
}

.dialog {
  max-width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  /* The classic double frame: heavy outer rule, thin inner rule. */
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--ink), 4px 4px 0 var(--ink);
}

.dialog__title {
  padding: 3px 8px;
  font-size: var(--size-small);
  font-weight: 700;
  text-align: center;
  border-bottom: var(--line);
  background: var(--stripes);
}

.dialog__title span {
  background: var(--paper);
  padding: 0 8px;
}

.dialog__body {
  padding: 14px 16px;
  overflow: auto;
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 16px 14px;
}

.dialog__message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.dialog__glyph {
  flex: none;
}

/* --------------------------------------------------------------- statusbar */

.statusbar {
  position: sticky;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 20px;
  padding: 0 8px;
  font-size: var(--size-small);
  background: var(--paper);
  border-top: var(--line);
  box-shadow: 0 -1px 0 var(--ink);
  white-space: nowrap;
  overflow: hidden;
}

.statusbar__cell {
  display: inline-flex;
  gap: 5px;
}

.statusbar__cell b {
  font-weight: 700;
}
