/* Floating formatting toolbar — appears above the focused editable field. */

.fmt-toolbar {
  position: fixed;
  z-index: 200;
  display: none;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(20, 17, 14, 0.92);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  backdrop-filter: blur(20px) saturate(140%);
  color: #f1ece0;
  font-family: var(--f-body, system-ui), system-ui, sans-serif;
  font-size: 13px;
  user-select: none;
  animation: fmt-fade-in 120ms ease-out;
}
.fmt-toolbar.is-visible { display: inline-flex; }
@keyframes fmt-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.fmt-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 30px;
  height: 28px;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: background 120ms ease, color 120ms ease;
}
.fmt-btn:hover { background: rgba(255, 255, 255, 0.10); }
.fmt-btn.is-on { background: var(--accent, #B5462C); color: #14110E; }
.fmt-btn[data-act="bold"] { font-weight: 700; }
.fmt-btn[data-act="italic"] { font-style: italic; font-family: Georgia, serif; }
.fmt-btn[data-act="underline"] { text-decoration: underline; text-underline-offset: 3px; }
.fmt-btn[data-act="color"] { font-size: 16px; color: var(--accent, #B5462C); }
.fmt-btn[data-act="font"] { font-family: var(--f-display, Georgia), Georgia, serif; }
.fmt-btn[data-act="move"] { font-size: 15px; }
.fmt-btn--ghost { color: rgba(241, 236, 224, 0.5); }
.fmt-btn--ghost:hover { color: #f1ece0; }

.fmt-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* Popovers (color + font) */
.fmt-popover {
  position: fixed;
  z-index: 201;
  background: rgba(20, 17, 14, 0.95);
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  color: #f1ece0;
  font-family: var(--f-body, system-ui), system-ui, sans-serif;
  font-size: 12.5px;
  padding: 10px 12px;
  min-width: 220px;
  animation: fmt-fade-in 120ms ease-out;
}
.fmt-pop-title {
  font-family: var(--f-mono, ui-monospace), ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(241, 236, 224, 0.5);
  margin-bottom: 8px;
}

.fmt-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.fmt-color-swatch {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  width: 100%;
  aspect-ratio: 1;
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease, border-color 120ms ease;
}
.fmt-color-swatch:hover {
  border-color: #f1ece0;
  transform: scale(1.08);
}

.fmt-color-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.fmt-hex {
  flex: 1 1 auto;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: inherit;
  font-family: var(--f-mono, ui-monospace), ui-monospace, monospace;
  font-size: 12px;
  border-radius: 6px;
  padding: 6px 8px;
  outline: none;
}
.fmt-hex:focus { border-color: var(--accent, #B5462C); }
.fmt-native-color {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.fmt-font-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fmt-font-item {
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: inherit;
  text-align: left;
  padding: 8px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease;
}
.fmt-font-item:hover { background: rgba(255, 255, 255, 0.10); }

/* Move-mode visual on the field being dragged */
[data-field][data-moving] {
  outline: 1.5px dashed var(--accent, #B5462C);
  outline-offset: 4px;
  cursor: grab;
}
[data-field][data-moving]:active { cursor: grabbing; }

/* While Alt/Option is held, every editable text field offers a grab cursor
   so the user discovers the alt-drag affordance. */
body.is-alt-down [data-field] { cursor: grab !important; }
body.is-alt-down [data-field]:active { cursor: grabbing !important; }

/* Hide toolbar in print */
@media print {
  .fmt-toolbar, .fmt-popover { display: none !important; }
}
