/* What lies on top of the window for a moment: menus, dialogs, the color
   picker and the preview of a symbol. And, before anything else, the
   loading screen. */

/* Loading screen: covers the window while the modules load, so that the
   empty frame is not seen. The letters of the name swell and shrink one
   after the other; when the wave is through at the back, it starts again
   at the front. Once the program has started the screen fades out
   (.isDone) and is taken away. */

.loadingScreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background);
  transition: opacity 0.5s ease-in-out;
}

.loadingScreen.isDone {
  opacity: 0;
  /* What lies under it can be used while it fades. */
  pointer-events: none;
}

.loadingTitle {
  display: flex;
  color: var(--color-text);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
}

/* --place is the place of the letter in the name, counted from 0: each
   letter starts a little after the one before it. One letter is busy for
   the first 40 percent of a round, and the last one is done just before
   the round ends. */
.loadingTitle span {
  display: inline-block;
  padding: 0 1px;
  transform-origin: 50% 65%;
  animation: loadingLetter 1.5s ease-in-out infinite;
  animation-delay: calc(var(--place) * 0.13s);
}

@keyframes loadingLetter {
  0%,
  40%,
  100% {
    transform: scale(1);
  }
  20% {
    transform: scale(1.55);
  }
}

@media (prefers-reduced-motion: reduce) {
  .loadingTitle span {
    animation: none;
  }
}

/* Context menu, also the menus of the top bar */

.contextMenu {
  position: fixed;
  z-index: 100;
  min-width: 220px;
  padding: 4px 0;
  background: var(--color-panel-raised);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.contextMenuItem {
  display: flex;
  align-items: center;
  width: 100%;
  height: 24px;
  padding: 0 12px 0 6px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: default;
}

.contextMenuItem:disabled {
  color: var(--color-text-dim);
  opacity: 0.6;
}

.contextMenuItem:hover:not(:disabled),
.contextMenuItem:focus-visible {
  background: var(--color-accent);
  color: #ffffff;
  outline: none;
}

.contextMenuCheck {
  flex: none;
  width: 18px;
  text-align: center;
}

.contextMenuLabel {
  flex: 1;
}

.contextMenuShortcut {
  margin-left: 24px;
  opacity: 0.6;
}

.contextMenuSeparator {
  height: 1px;
  margin: 4px 0;
  background: var(--color-border);
}

/* Dialog */

dialog {
  width: 260px;
  padding: 14px 16px 16px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialogTitle {
  margin-bottom: 8px;
}

.checkRow {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

dialog .fieldGrid {
  margin-top: 10px;
}

/* The small dialogs that ask or tell something, see source/ui/dialogs.js */
.appDialog {
  width: 320px;
}

.dialogMessage {
  margin: 0;
  line-height: 1.45;
  /* A message can have lines of its own, a list for example. */
  white-space: pre-line;
}

.dialogField label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--color-text-dim);
}

.dialogButtons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.dialogButtons button {
  min-width: 80px;
  height: 24px;
  background: var(--color-panel-raised);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
}

.dialogButtons .primaryButton {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #ffffff;
}

/* Color picker */

.colorPicker {
  position: fixed;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--color-panel-raised);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* While a picker is open the stage offers its colors: the mouse is an
   eyedropper there (source/ui/colorPicker.js). This has to be stronger
   than the cursor the tool in use has set on the stage. */
.isOfferingColors {
  cursor: var(--eyedropper-cursor) !important;
}

/* The controls a color is made with (source/ui/colorEditor.js). They are
   in the picker, and built into the side panel for fills and gradients;
   there they are as wide as the panel. */

.colorEditor {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.colorPicker .colorEditor,
.colorPicker .palette {
  width: 208px;
}

.colorPickerField {
  --picker-hue: #ff0000;
  position: relative;
  height: 132px;
  border-radius: 3px;
  background:
    linear-gradient(to top, #000000, transparent),
    linear-gradient(to right, #ffffff, var(--picker-hue));
  cursor: crosshair;
  touch-action: none;
}

.colorPickerThumb {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.colorPickerRow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.colorPickerHue,
.colorPickerAlpha {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  margin: 0;
  border-radius: 6px;
  cursor: pointer;
}

.colorPickerHue {
  background: linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
}

.colorPickerAlpha {
  --picker-color: #000000;
  flex: 1;
  min-width: 0;
  background:
    linear-gradient(to right, transparent, var(--picker-color)),
    repeating-conic-gradient(#b8b8b8 0% 25%, #ffffff 0% 50%) 0 0 / 8px 8px;
}

.colorPickerHue::-webkit-slider-thumb,
.colorPickerAlpha::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 50%;
}

.colorPickerHue::-moz-range-thumb,
.colorPickerAlpha::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.6);
  border-radius: 50%;
}

/* "No color", left of the opacity. As high as the row, so it does not
   make the row taller. */
.colorPickerNone {
  flex: none;
  width: 22px;
  height: 18px;
}

.colorPickerSave {
  flex: none;
  width: 24px;
  height: 22px;
}

.colorPickerPercent {
  flex: none;
  width: 40px;
  text-align: right;
  color: var(--color-text-dim);
}

.colorPickerPreview {
  --picker-color: #000000;
  --picker-opacity: 1;
  position: relative;
  flex: none;
  width: 22px;
  height: 22px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: repeating-conic-gradient(#b8b8b8 0% 25%, #ffffff 0% 50%) 0 0 / 10px 10px;
  overflow: hidden;
}

.colorPickerPreview::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--picker-color);
  opacity: var(--picker-opacity);
}

.colorPickerHex {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
}

/* The picture of a symbol, shown beside the side panel while the mouse is
   over its row in the library. */

.symbolPreview {
  position: fixed;
  z-index: 90;
  padding: 6px;
  background: var(--color-panel-raised);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.symbolPreview canvas {
  display: block;
  border-radius: 3px;
}

.symbolPreviewEmpty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: #808080;
}

/* The list of fonts below the font field of the Text section, see
   source/ui/fontPicker.js. Every entry is written in its own font. */

.fontMenu {
  position: fixed;
  z-index: 100;
  padding: 4px 0;
  overflow-y: auto;
  background: var(--color-panel-raised);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.fontMenuItem {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  cursor: default;
}

.fontMenuName {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A font the drawing asks for and the computer does not have. */
.fontMenuNote {
  flex: none;
  color: var(--color-text-dim);
  font-size: 11px;
}

.fontMenuItem:hover,
.fontMenuItem.isActive {
  background: var(--color-accent);
  color: #ffffff;
}

.fontMenuItem:hover .fontMenuNote,
.fontMenuItem.isActive .fontMenuNote {
  color: #ffffff;
}

.fontMenuEmpty,
.fontMenuLoad {
  padding: 6px 10px;
  color: var(--color-text-dim);
}

.fontMenuLoad {
  margin-top: 4px;
  border-top: 1px solid var(--color-border);
  cursor: default;
}

.fontMenuLoad:hover {
  color: var(--color-text);
}
