/* Format buttons above a code textarea (lib/text-format.js). */

.fmt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.fmt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

.fmt-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: var(--border);
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}
.fmt-btn:hover { background: var(--cat-json); }
.fmt-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.fmt-btn:disabled { color: var(--line-soft); background: var(--surface-2); box-shadow: none; cursor: not-allowed; }
.fmt-btn svg { width: 22px; height: 22px; }

/* The hint: shown on hover and on keyboard focus, so it is not only for mouse users. */
.fmt-btn[data-hint]::after {
  content: attr(data-hint);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  width: max-content;
  max-width: 240px;
  padding: 6px 10px;
  font: 500 12px/1.4 var(--font-body);
  text-align: left;
  white-space: normal;
  color: var(--on-ink);
  background: var(--ink);
  border-radius: 8px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.fmt-btn[data-hint]:hover::after,
.fmt-btn[data-hint]:focus-visible::after { opacity: 1; visibility: visible; }

.fmt-status { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.fmt-status.is-error { color: #B42318; }
.fmt-status:empty { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .fmt-btn[data-hint]::after { transition: opacity 120ms ease 300ms; }
}
