/* Copyright 2018-2026 Preston A. Elder <prez@neuromancy.net>. All rights reserved. */
/* The card toolbar: icon buttons drawn with the addon's own art, the game's state pills, and the action cluster that
   sits flush right on every card, condition row and list row (site/editor-icons.mjs). Loaded by the editor and the account page. */

/* ---- icon buttons: trash, copy, up, down (site/img/addon/controls/*.svg, a mask so the icon takes the text color) ---- */
.button.small.icon-button {
  --icon-size: 32px;
  width: var(--icon-size);
  height: var(--icon-size);
  min-width: var(--icon-size);
  min-height: var(--icon-size);
  padding: 0;
  justify-content: center;
  flex: none;
}

.icon-button .ed-icon {
  display: block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
  pointer-events: none;
}

.ed-icon-trash .ed-icon {
  -webkit-mask-image: url("img/addon/controls/trash.svg");
  mask-image: url("img/addon/controls/trash.svg");
}

.ed-icon-copy .ed-icon {
  -webkit-mask-image: url("img/addon/controls/copy.svg");
  mask-image: url("img/addon/controls/copy.svg");
}

.ed-icon-up .ed-icon {
  -webkit-mask-image: url("img/addon/controls/up.svg");
  mask-image: url("img/addon/controls/up.svg");
}

.ed-icon-down .ed-icon {
  -webkit-mask-image: url("img/addon/controls/down.svg");
  mask-image: url("img/addon/controls/down.svg");
}

.icon-button:disabled {
  opacity: 0.4;
}

/* The tooltip of ours, for keyboard focus (the title attribute does the mouse). */
.ed-tip {
  position: fixed;
  z-index: 1000;
  max-width: min(260px, calc(100vw - 16px));
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--azure);
  box-shadow: var(--shadow-raised);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

/* ---- state pills (UI/controls.lua CreateWorkbenchPill): green enabled / If, red Unless, amber All / Any, gray off ---- */
.ed-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-sizing: border-box;
  min-height: 32px;
  max-width: 100%;
  padding: 2px 12px;
  margin: 0;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.ed-state.static {
  cursor: default;
}

button.ed-state:hover {
  background: var(--surface-2);
}

.ed-state.tone-ok {
  border-color: var(--ok);
  color: var(--ok);
  background: var(--ok-surface);
}

.ed-state.tone-warn {
  border-color: var(--warn);
  color: var(--warn);
  background: var(--warn-surface);
}

.ed-state.tone-danger {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-surface);
}

/* Off is not only gray: the border is dashed and the check mark is gone. */
.ed-state.is-off.has-check {
  border-style: dashed;
}

.ed-state-check {
  flex: none;
  width: 12px;
  height: 12px;
  background-color: currentColor;
  -webkit-mask: url("img/addon/controls/check.svg") center / contain no-repeat;
  mask: url("img/addon/controls/check.svg") center / contain no-repeat;
}

.ed-pill-field {
  align-items: flex-start;
}

/* The same pill on a card of the in-game view: a button where the editor allows the change. */
button.rv-pill.clickable {
  font: inherit;
  font-size: 11px;
  line-height: 16px;
  background: transparent;
  cursor: pointer;
  padding: 3px 9px;
  margin: -3px 0;
}

button.rv-pill.clickable:hover {
  background: var(--surface-2);
}

button.rv-pill.clickable:focus-visible {
  outline: 2px solid var(--azure);
  outline-offset: 1px;
}

button.rv-pill.clickable:not(.on):not(.branch-mode) {
  border-style: dashed;
}

button.rv-pill.clickable.on:not(.branch-mode)::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  background-color: currentColor;
  -webkit-mask: url("img/addon/controls/check.svg") center / contain no-repeat;
  mask: url("img/addon/controls/check.svg") center / contain no-repeat;
}

/* ---- the bar and the cluster ----
   Left, with the card's content: Move up and down. Right, always in this order: Enabled, Duplicate, Delete. Each has a slot
   of its own that stays when the action is missing, so Delete is always rightmost and nothing shifts from card to card. */
.ed-cond-bar,
.ed-step-tools,
.ed-output-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
}

.ed-step-tools {
  margin-bottom: 8px;
}

.ed-output-tools {
  margin-top: 8px;
}

.ed-cond-bar {
  margin-bottom: 4px;
}

.ed-moves {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.ed-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  margin-inline-start: auto;
}

.ed-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.ed-slot-enable {
  width: 7.25rem;
}

.ed-slot-duplicate,
.ed-slot-delete {
  width: 32px;
}

.ed-slot-enable > .ed-state {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ed-cluster-plain .ed-slot {
  width: auto;
}

/* List rows (items, categories, effect steps, drafts): the name and moves on the left, Delete flush right. */
.ed-item,
.ed-draft {
  align-items: center;
}

.ed-draft {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin: 4px 0;
}

@media (max-width: 720px) {
  /* Touch size: 40px icons and pills (the cluster and the arrows share one line on a phone), not 28 or 32. */
  .button.small.icon-button {
    --icon-size: 40px;
  }
  .ed-state {
    min-height: 40px;
    padding: 2px 8px;
  }
  .ed-slot-enable {
    width: 6.5rem;
  }
  .ed-slot-duplicate,
  .ed-slot-delete {
    width: 40px;
  }
  .ed-cluster {
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-button,
  .ed-state {
    transition: none;
  }
}
