/* Color swatches, the native color input, drawer, chat parts, dots, copy field,
   avatar, empty state and uptime strip. */

fd-swatches {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

fd-swatches input {
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border-radius: var(--fd-radius-pill);
  background-color: var(--_color);
  box-shadow: inset 0 0 0 1px var(--fd-line);
  cursor: pointer;
}

fd-swatches input:checked {
  outline: 2px solid var(--fd-ink);
  outline-offset: 2px;
}

fd-swatches input:focus-visible {
  outline: 2px solid var(--fd-focus);
  outline-offset: 2px;
}

.fd-color {
  appearance: none;
  width: var(--fd-control);
  height: var(--fd-control);
  padding: 3px;
  border: 0;
  border-radius: var(--fd-radius-control);
  background: none;
  box-shadow: inset 0 0 0 1px var(--fd-edge);
  cursor: pointer;
}

.fd-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.fd-color::-webkit-color-swatch {
  border: 0;
  border-radius: var(--fd-radius-pill);
}

.fd-color::-moz-color-swatch {
  border: 0;
  border-radius: var(--fd-radius-pill);
}

/* .fd-drawer goes on a real <dialog>, opened with showModal(). data-side="bottom"
   makes it a sheet. It uses the same screen as .fd-dialog, so load dialog.css too. */
.fd-dialog.fd-drawer {
  width: min(360px, calc(100vw - 32px));
  max-height: none;
  height: 100dvh;
  margin: 0 0 0 auto;
  border-radius: 0;
  translate: 100% 0;
}

.fd-dialog.fd-drawer[open] {
  translate: 0;
}

@starting-style {
  .fd-dialog.fd-drawer[open] {
    translate: 100% 0;
  }
}

.fd-dialog.fd-drawer[data-side='bottom'] {
  width: 100%;
  max-width: none;
  height: auto;
  max-height: 80dvh;
  margin: auto 0 0;
  border-radius: calc(var(--fd-radius-control) + 4px) calc(var(--fd-radius-control) + 4px) 0 0;
  translate: 0 100%;
}

.fd-dialog.fd-drawer[data-side='bottom'][open] {
  translate: 0;
}

@starting-style {
  .fd-dialog.fd-drawer[data-side='bottom'][open] {
    translate: 0 100%;
  }
}

.fd-message {
  width: fit-content;
  max-width: 75%;
  padding: 8px 12px;
  border-radius: calc(var(--fd-radius-control) + 2px);
  background-color: var(--fd-soft);
  color: var(--fd-ink);
  font: var(--fd-weight-regular) var(--fd-font-size) / var(--fd-line-height) var(--fd-font-sans);
}

.fd-message[data-from='me'] {
  margin-inline-start: auto;
  background-color: var(--fd-ink);
  color: var(--fd-on-solid);
}

/* .fd-thinking holds a label beside a .fd-loader. */
.fd-thinking {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--fd-ink-soft);
  font: var(--fd-weight-regular) var(--fd-font-size) / var(--fd-line-height) var(--fd-font-sans);
}

.fd-composer {
  display: flex;
  align-items: flex-end;
  gap: var(--fd-gap);
}

.fd-composer .fd-input {
  flex: 1;
  resize: none;
}

/* Dots for a carousel. Put the current one's aria-current="true". */
.fd-dots {
  display: inline-flex;
  gap: 6px;
}

.fd-dots button {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  background-color: var(--fd-edge);
  cursor: pointer;
  transition: background-color var(--fd-spring-quick);
}

.fd-dots button[aria-current='true'] {
  background-color: var(--fd-ink);
}

.fd-dots button:focus-visible {
  outline: 1px solid var(--fd-focus);
  outline-offset: 2px;
}

fd-copy {
  display: flex;
  gap: var(--fd-gap);
}

.fd-avatar {
  --_tone: var(--fd-ink-soft);
  --_dots: color-mix(in srgb, var(--_tone) 40%, transparent);
  display: inline-grid;
  place-items: center;
  width: var(--fd-control);
  height: var(--fd-control);
  border-radius: var(--fd-radius-control);
  background-image: repeating-conic-gradient(var(--_dots) 0 25%, transparent 0 50%);
  background-size: 4px 4px;
  color: var(--fd-ink);
  font: var(--fd-weight-strong) var(--fd-font-size) / 1 var(--fd-font-sans);
  text-shadow: 0 0 2px var(--fd-paper), 0 0 2px var(--fd-paper), 0 0 3px var(--fd-paper);
}

.fd-empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 32px 16px;
  color: var(--fd-ink-soft);
  font: var(--fd-weight-regular) var(--fd-font-size) / var(--fd-line-height) var(--fd-font-sans);
  text-align: center;
}

.fd-empty-title {
  margin: 0;
  color: var(--fd-ink);
  font-size: 14px;
  font-weight: var(--fd-weight-strong);
}

/* .fd-uptime holds one <i data-state="up|down|partial"> per period. */
.fd-uptime {
  display: flex;
  gap: 2px;
  height: 24px;
}

.fd-uptime i {
  --_dots: color-mix(in srgb, var(--_state, var(--fd-green)) 70%, transparent);
  flex: 1;
  background-color: var(--_state, var(--fd-green));
}

.fd-uptime i[data-state='down'] {
  --_state: var(--fd-red);
}

.fd-uptime i[data-state='partial'] {
  --_state: var(--fd-orange);
  background-color: transparent;
  background-image: repeating-conic-gradient(var(--_dots) 0 25%, transparent 0 50%);
  background-size: 4px 4px;
}

/* <fd-composer> wraps a .fd-composer form. Its suggestion shows as the placeholder. */
fd-composer {
  display: block;
  position: relative;
}

fd-composer .fd-input {
  field-sizing: content;
  max-height: 120px;
}

.fd-composer-tab {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-end: 72px;
  padding-inline: 5px;
  border-radius: var(--fd-radius-pill);
  background-color: var(--fd-soft);
  color: var(--fd-ink-soft);
  font: var(--fd-weight-regular) 11px / 18px var(--fd-font-sans);
  pointer-events: none;
}

.fd-composer-tab[hidden] {
  display: none;
}

/* <fd-color-picker>: a field of color cells over a hue slider, with the hex to type. */
fd-color-picker {
  display: grid;
  gap: 8px;
  width: min(100%, 256px);
  color: var(--fd-ink);
}

.fd-color-field {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--fd-radius-control);
  cursor: crosshair;
  touch-action: none;
}

.fd-color-field > canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.fd-color-field:focus-visible {
  outline: 1px solid var(--fd-focus);
  outline-offset: 2px;
}

.fd-color-mark {
  position: absolute;
  left: var(--_x);
  top: var(--_y);
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  box-shadow: 0 0 0 2px var(--fd-paper), 0 0 0 3px var(--fd-ink);
  pointer-events: none;
}

.fd-color-hue {
  appearance: none;
  width: 100%;
  height: 10px;
  margin: 0;
  border-radius: var(--fd-radius-pill);
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

.fd-color-hue::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 16px;
  border-radius: 3px;
  background-color: var(--fd-ink);
  box-shadow: 0 0 0 2px var(--fd-paper);
}

.fd-color-hue::-moz-range-thumb {
  width: 10px;
  height: 16px;
  border: 0;
  border-radius: 3px;
  background-color: var(--fd-ink);
  box-shadow: 0 0 0 2px var(--fd-paper);
}

.fd-color-hue:focus-visible {
  outline: 1px solid var(--fd-focus);
  outline-offset: 3px;
}

/* <kbd class="fd-kbd"> is one key or shortcut. */
.fd-kbd {
  display: inline-flex;
  align-items: center;
  min-width: 18px;
  height: 18px;
  justify-content: center;
  padding-inline: 5px;
  border-radius: var(--fd-radius-pill);
  background-color: var(--fd-soft);
  box-shadow: inset 0 -1px 0 var(--fd-line);
  color: var(--fd-ink-soft);
  font: var(--fd-weight-regular) 11px / 16px var(--fd-font-sans);
}
