/* What the whole program shares: colors and sizes, the ground rules, and
   the controls that turn up in more than one place (buttons, fields,
   numbers to drag, color swatches).

   The other files, in the order index.html loads them:
     frame.css     the window: top bar, tool bar, stage, status bar
     panels.css    the side panel and its sections
     overlays.css  what lies on top: menus, dialogs, the color picker
   A rule goes where its part of the screen is. It comes here only if two
   of the others would need it. */

:root {
  --color-background: #262626;
  --color-panel: #323232;
  --color-panel-raised: #3d3d3d;
  --color-border: #1c1c1c;
  --color-text: #d8d8d8;
  --color-text-dim: #9a9a9a;
  --color-accent: #1473e6;
  --color-accent-soft: #2f4f7a;
  --color-field: #232323;
  --size-top-bar: 36px;
  --size-tool-bar: 44px;
  --size-side-panel: 240px;
  --size-status-bar: 24px;
}

* {
  box-sizing: border-box;
}

/* "hidden" must win over any display set anywhere else. */
[hidden] {
  display: none !important;
}

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

body {
  background: var(--color-background);
  color: var(--color-text);
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 1px solid var(--color-accent);
  outline-offset: 0;
}

.spacer {
  flex: 1;
}

/* The small headings of the side panel sections and of the dialogs. */
.panelTitle,
.dialogTitle {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

/* Buttons */

.iconButton,
.toolButton,
.layerFlag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}

.iconButton {
  width: 26px;
  height: 24px;
}

.iconButton:hover:not(:disabled),
.toolButton:hover {
  background: var(--color-panel-raised);
}

.iconButton:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Buttons that are either on or off, like bold or an alignment. */

.buttonRow {
  display: flex;
  align-items: center;
  gap: 2px;
}

.buttonGap {
  width: 8px;
}

.toggleButton.on {
  background: var(--color-accent);
  color: #ffffff;
}

.textStyleButton {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
}

/* Fields */

input[type="text"] {
  width: 100%;
  height: 22px;
  padding: 0 6px;
  background: var(--color-field);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  user-select: text;
  -webkit-user-select: text;
}

input[type="color"] {
  width: 44px;
  height: 22px;
  padding: 0;
  background: var(--color-field);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
}

/* Labels on the left, their fields on the right. */
.fieldGrid {
  display: grid;
  /* The second column may shrink below what its fields would like, or a
     long label would push them out of the panel. */
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 6px 10px;
}

.fieldGrid select {
  width: 100%;
  height: 22px;
  padding: 0 4px;
  background: var(--color-field);
  border: 1px solid var(--color-border);
  border-radius: 3px;
}

.checkLabel {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkLabel input,
.fieldGrid input[type="checkbox"] {
  margin: 0;
  justify-self: start;
}

/* A slider to drag with the exact number beside it. */
.sliderRow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.sliderRow input[type="range"] {
  flex: 1;
  min-width: 0;
  margin: 0;
  accent-color: var(--color-accent);
}

/* Several numbers in one row, each after a small icon that says what it
   is. */
.numberRow {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.numberIcon {
  display: inline-flex;
  margin-left: 8px;
  color: var(--color-text-dim);
}

/* A color with its name behind it, across both columns. */
.swatchRow {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* A number that can be dragged, see source/ui/scrubNumber.js. */

.scrubNumber {
  display: inline-block;
  min-width: 2ch;
  padding: 1px 2px;
  color: #6aa9ff;
  border-bottom: 1px dotted transparent;
  border-radius: 2px;
  cursor: ew-resize;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.scrubNumber:hover,
.scrubNumber.isDragging {
  border-bottom-color: currentColor;
}

.scrubNumber:focus-visible {
  outline: 1px solid var(--color-accent);
}

.scrubNumber.isOff {
  color: var(--color-text-dim);
  cursor: default;
  border-bottom-color: transparent;
}

/* The field the number turns into for typing. It weighs the same as the
   rule for text fields above and has to stay below it. */
input.scrubInput {
  /* Plain text color: the blue belongs to the number one can drag, not to
     the text one types. */
  color: var(--color-text);
  width: 64px;
  height: 20px;
  padding: 0 4px;
  border-color: var(--color-accent);
}

/* The number beside a slider keeps its place, whatever its digits. */
.sliderRow .scrubNumber {
  flex: none;
  min-width: 40px;
  text-align: right;
}

.sliderRow input.scrubInput {
  width: 52px;
}

/* Color swatches: buttons that show a color and open the picker. The
   checkerboard shows through where the color is not opaque. */

.colorSwatch {
  --swatch-color: #000000;
  width: 44px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  /* --swatch-image, where it is set, is what the field shows instead of
     the one color: a gradient. */
  background:
    var(--swatch-image, linear-gradient(var(--swatch-color), var(--swatch-color))),
    repeating-conic-gradient(#b8b8b8 0% 25%, #ffffff 0% 50%) 0 0 / 10px 10px;
  cursor: pointer;
}

/* The palette: the fills that were put aside, and the button that puts
   the current one there (source/ui/paletteView.js). It shows in the color
   picker and in the side panel. */

.palette {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paletteFields {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.paletteFields:empty {
  display: none;
}

.paletteField {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  background:
    var(--swatch-image),
    repeating-conic-gradient(#b8b8b8 0% 25%, #ffffff 0% 50%) 0 0 / 8px 8px;
  cursor: pointer;
}

.paletteField:hover {
  border-color: #ffffff;
}

/* Brings removed gradients back; as small as a field, behind the last. */
.paletteRestore {
  flex: none;
  width: 18px;
  height: 18px;
  padding: 0;
}

.paletteRestore svg {
  width: 14px;
  height: 14px;
}

/* No color: white with a red line from corner to corner. */
.colorSwatch.isNone {
  background: linear-gradient(to top right, #ffffff 46%, #e02020 46%, #e02020 54%, #ffffff 54%);
}
