/* Automations page of the game menu (Menu > Automations): the options use the switches of settings.css (see theme.css for the colors) */
.automations-intro {
  flex: 0 0 auto;
  padding: 0 2px;
  font-size: 11px;
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-text-soft);
}

/* Options: two columns, one column on narrow screens */
.automation-options {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
}

/* A turned on automation gets the accent border */
.automation-options .settings-option:has(input:checked) {
  border-color: var(--color-accent-dark);
}

/* The coin exchange waits for auto loot: dimmed while it is off, but it can still be changed */
.automation-options.idle .settings-option {
  opacity: 0.55;
}

/* The Items button of Auto Loot: opens the auto loot list (shared ui-button look) */
.modal button.automation-configure {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 3px 8px;
  font-size: 10px;
}

.automation-configure svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.4;
}

.automations-note {
  flex: 0 0 auto;
  margin-top: 6px;
  padding: 0 2px;
  font-size: 10px;
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-warning);
}

/* Auto Loot page (Menu > Automations > Settings): the premium offer for free accounts, the lists for premium accounts */
.auto-loot-page {
  gap: 10px;
}

.auto-loot-free {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

/* Fixed layout that fills the window, from top to bottom: the rules, the rarity, the lists with the search,
   the loot container and the note. Every list scrolls inside its own box, so many items or containers never resize anything */
.auto-loot-premium {
  display: grid;
  flex: 1 1 0;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  gap: 8px;
  min-height: 0;
  --auto-loot-backpack-height: 112px;
}

/* Small titles of the rows on the page (Rarity, Loot goes to) */
.auto-loot-label {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-accent);
}

/* The boxes that hold items or containers: one dark inset look for all of them */
.auto-loot-box {
  box-sizing: border-box;
  min-height: 0;
  padding: 4px;
  border: 1px solid black;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
}

/* Minimum rarity of the rarity rule: one chip per rarity in its loot color, dimmed with the other rules */
.auto-loot-rarity {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 2px;
  overflow: hidden;
  white-space: nowrap;
}

/* With another rule the rarities are dimmed: clicking one switches to the rarity rule */
.auto-loot-rarity.disabled {
  opacity: 0.5;
  transition: opacity 0.12s;
}

.auto-loot-rarity.disabled:hover {
  opacity: 1;
}

.modal button.auto-loot-rarity-option {
  flex: 0 0 auto;
  margin: 0;
  padding: 2px 10px;
  font-size: 10px;
  color: var(--color-text-dim);
  border: 1px solid black;
  border-radius: 10px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
}

/* The chosen rarity is outlined in its color, the better rarities are included and shown in theirs */
.modal button.auto-loot-rarity-option.selected,
.modal button.auto-loot-rarity-option.included {
  color: var(--rarity-color);
}

.modal button.auto-loot-rarity-option.selected {
  border-color: var(--rarity-color);
  background-image: none;
  background-color: rgba(0, 0, 0, 0.55);
  box-shadow: 0 0 5px var(--rarity-color);
}

.modal button.auto-loot-rarity-option:not(.selected):hover {
  border-color: var(--rarity-color);
}

.auto-loot-rarity-option[rarity="1"] { --rarity-color: var(--color-rarity-uncommon); }
.auto-loot-rarity-option[rarity="2"] { --rarity-color: var(--color-rarity-rare); }
.auto-loot-rarity-option[rarity="3"] { --rarity-color: var(--color-rarity-epic); }
.auto-loot-rarity-option[rarity="4"] { --rarity-color: var(--color-rarity-legendary); }

.auto-loot-rarity-hint {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}

/* The lists: the tabs and the search on the page (like the Party page), the list and the results in two boxes below.
   One column on narrow screens: the tabs with the list, then the search with the results */
.auto-loot-lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "toolbar search"
    "list results";
  gap: 6px 8px;
  min-height: 0;
}

.auto-loot-toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.auto-loot-lists > .auto-loot-search-wrapper {
  grid-area: search;
  align-self: center;
}

.auto-loot-list {
  grid-area: list;
}

.auto-loot-results {
  grid-area: results;
}

@media (max-width: 520px) {
  .auto-loot-lists {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas:
      "toolbar"
      "list"
      "search"
      "results";
  }
}

/* Always / Never loot tabs (shared ui-tabs look) with the number of items */
.auto-loot-tabs {
  flex: 0 1 auto;
  min-width: 0;
}

.modal button.auto-loot-tab {
  padding: 3px 10px;
  font-size: 10px;
}

.auto-loot-tab-count {
  margin-left: 3px;
  padding: 0 5px;
  border-radius: 7px;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  background-color: rgba(0, 0, 0, 0.45);
}

/* The list a search result is on, when it is not the shown one (clicking moves it) */
.auto-loot-item-tag {
  flex: 0 0 auto;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 8px;
  font-weight: bold;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.auto-loot-item-tag:empty {
  display: none;
}

.auto-loot-item-tag.always {
  color: var(--color-accent-text);
  border-color: var(--color-accent-dark);
}

.auto-loot-item-tag.never {
  color: var(--color-danger);
  border-color: var(--color-danger-dark);
}

/* Items of a loot message open their auto loot options when clicked (see LootItemMenu) */
#chat-text-area [data-loot-item] {
  cursor: pointer;
}

#chat-text-area [data-loot-item]:hover {
  text-decoration: underline;
}

/* Ctrl held: the link cursor shows that a click writes the item link in the chat (see ItemLink) */
body[data-cursor="alias"] #chat-text-area [data-loot-item] {
  cursor: alias;
}

/* What auto loot did with the item (see LootMessage.setResults): looted items get a green check, items left in the corpse fade */
#chat-text-area [data-loot-result="looted"]::after {
  content: " \2713";
  color: var(--color-success);
}

#chat-text-area [data-loot-result="left"] {
  opacity: 0.45;
}

/* The container that receives the auto loot: a gold icon in the title of its window and on the backpack slot (main backpack) */
.window .header[data-loot-target] .title::before {
  content: "move_to_inbox";
  margin-right: 3px;
  vertical-align: -2px;
  font-family: "Material Icons";
  font-size: 12px;
  font-weight: normal;
  color: var(--color-accent);
  font-feature-settings: "liga";
}

.slot[data-loot-target]::after {
  content: "move_to_inbox";
  position: absolute;
  top: -2px;
  right: -2px;
  z-index: 101;
  font-family: "Material Icons";
  font-size: 11px;
  line-height: 1;
  color: var(--color-accent);
  text-shadow: 0 0 2px black, 0 0 3px black;
  font-feature-settings: "liga";
  pointer-events: none;
}

/* Lists that scroll keep the room of their scrollbar, so the rows do not change width when it shows */
.auto-loot-backpacks,
.auto-loot-items {
  scrollbar-gutter: stable;
}

/* Premium offer: the items free accounts leave behind, locked */
.auto-loot-free-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  text-align: center;
  border: 1px solid var(--color-accent-dark);
  border-radius: 10px;
  background-image:
    radial-gradient(circle at 50% 0%, var(--color-accent-haze), transparent 70%),
    var(--gradient-card);
}

.auto-loot-showcase {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.auto-loot-showcase-slot {
  position: relative;
  display: flex;
  border: 1px solid var(--color-accent-dark);
  border-radius: 6px;
  background-color: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8);
}

.auto-loot-showcase-slot canvas {
  filter: grayscale(0.6) brightness(0.75);
}

/* A small gold lock in the corner of every locked item (the lock is drawn in --color-accent-darker: variables do not work inside the image) */
.auto-loot-showcase-slot::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 5.5V4.25a2 2 0 0 1 4 0V5.5' fill='none' stroke='%232e2a1f' stroke-width='1.3'/%3E%3Crect x='3' y='5.5' width='6' height='4' rx='0.8' fill='%232e2a1f'/%3E%3C/svg%3E") center / 10px no-repeat;
  box-shadow: 0 0 4px var(--color-accent-glow);
}

.auto-loot-free-title {
  font-size: 16px;
  font-weight: bold;
  color: var(--color-accent-text);
}

.auto-loot-free-text {
  max-width: 420px;
  font-size: 11px;
  font-weight: normal;
  line-height: 1.5;
  color: var(--color-text-soft);
}

.auto-loot-free-text b {
  color: white;
}

.auto-loot-free .game-menu-benefits {
  margin-top: 0;
}

/* Rule: three cards, the selected one gets the accent */
.auto-loot-modes {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}

.modal button.auto-loot-mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  margin: 0;
  padding: 7px 10px;
  text-align: left;
  border: 1px solid black;
  border-radius: 8px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
}

.modal button.auto-loot-mode * {
  pointer-events: none;
}

.modal button.auto-loot-mode:not(.selected):hover {
  border-color: var(--color-accent-text);
  background-image: var(--gradient-surface-hover);
}

.modal button.auto-loot-mode.selected {
  border-color: var(--color-accent);
  background-image: var(--gradient-accent);
  box-shadow: var(--shadow-accent);
}

.auto-loot-mode-title {
  font-size: 12px;
  font-weight: bold;
}

.modal button.auto-loot-mode.selected .auto-loot-mode-title {
  color: var(--color-accent-text);
}

.auto-loot-mode-text {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}

/* Loot container (at the bottom): a header that folds the tree and always shows where the loot goes, then the tree.
   Folded (the default) the lists get its room; unfolded the tree has a fixed height */
.modal button.auto-loot-backpack-header {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  width: 100%;
  height: 24px;
  margin: 0;
  padding: 0 8px;
  white-space: nowrap;
  text-align: left;
  border: 1px solid black;
  border-radius: 6px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
}

.modal button.auto-loot-backpack-header * {
  pointer-events: none;
}

.modal button.auto-loot-backpack-header:hover {
  border-color: var(--color-accent);
  background-image: var(--gradient-surface-hover);
}

/* Arrow drawn with two borders: right when folded, down when unfolded */
.auto-loot-chevron {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  margin: 0 2px 0 0;
  border: solid var(--color-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(-45deg);
  transition: transform 0.12s;
}

.auto-loot-premium.backpacks-open .auto-loot-chevron {
  transform: rotate(45deg);
}

.auto-loot-backpack-target {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  font-weight: bold;
  color: var(--color-accent-text);
}

#auto-loot-backpacks {
  display: none;
  height: var(--auto-loot-backpack-height);
}

.auto-loot-premium.backpacks-open #auto-loot-backpacks {
  display: flex;
}

/* One line: a long note is cut (the full text is its title) instead of growing the header */
.auto-loot-backpack-note {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}

.auto-loot-backpack-note.warning {
  color: var(--color-warning);
}

.auto-loot-backpacks {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

/* One row per container, indented by its depth inside the main backpack (--depth, set by AutoLootPage) */
.modal button.auto-loot-container {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 38px;
  margin: 0 0 0 calc(var(--depth, 0) * 18px);
  padding: 2px 8px 2px 2px;
  text-align: left;
  border: 1px solid black;
  border-radius: 5px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
}

.modal button.auto-loot-container * {
  pointer-events: none;
}

/* The branch line towards the parent container */
.modal button.auto-loot-container.nested::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 9px;
  height: 1px;
  background-color: var(--color-accent-dark);
}

.modal button.auto-loot-container:not(.selected):hover {
  border-color: var(--color-accent-text);
  background-image: var(--gradient-surface-hover);
}

.modal button.auto-loot-container.selected {
  border-color: var(--color-accent);
  background-image: var(--gradient-accent);
  box-shadow: var(--shadow-accent);
}

.modal button.auto-loot-container.selected .auto-loot-item-name {
  color: var(--color-accent-text);
}

.auto-loot-container-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.auto-loot-container-slots {
  font-size: 9px;
  font-weight: normal;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* A few of the items inside, at a smaller size */
.auto-loot-container-preview {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.auto-loot-container-preview canvas {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  background-color: rgba(0, 0, 0, 0.35);
}

.modal button.auto-loot-clear {
  flex: 0 0 auto;
  margin: 0 0 0 auto;
  padding: 3px 10px;
  font-size: 10px;
}

/* Waiting for the second click that empties the list: the shared look of two-click actions (--color-confirming) */
.modal button.auto-loot-clear.confirming {
  color: var(--color-confirming);
  border-color: var(--color-confirming);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 6px var(--color-confirming);
}

/* Items: sprite, name and the add (+) or remove (x) mark */
.auto-loot-items {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.modal button.auto-loot-item {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 38px;
  margin: 0;
  padding: 2px 8px 2px 2px;
  text-align: left;
  border: 1px solid black;
  border-radius: 5px;
  background-image: var(--gradient-surface);
  box-shadow: var(--shadow-raised);
}

.modal button.auto-loot-item * {
  pointer-events: none;
}

.modal button.auto-loot-item:hover {
  border-color: var(--color-accent);
  background-image: var(--gradient-surface-hover);
}

.auto-loot-item-sprite {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.35);
}

.auto-loot-item-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.auto-loot-item-action {
  flex: 0 0 auto;
  width: 16px;
  font-size: 14px;
  line-height: 1;
  text-align: center;
  color: var(--color-accent);
}

.auto-loot-item-action::before {
  content: "+";
}

/* Search results that are already on the list */
.modal button.auto-loot-item.listed {
  border-color: var(--color-accent-dark);
  background-image: var(--gradient-accent);
}

.modal button.auto-loot-item.listed .auto-loot-item-action::before {
  content: "\2713";
  font-size: 12px;
}

/* Items of the list are removed with a click */
.auto-loot-item.remove .auto-loot-item-action::before {
  content: "\2715";
  font-size: 11px;
}

.auto-loot-item.remove .auto-loot-item-action {
  color: var(--color-text-dim);
}

.modal button.auto-loot-item.remove:hover {
  border-color: var(--color-danger-dark);
}

.modal button.auto-loot-item.remove:hover .auto-loot-item-action {
  color: var(--color-danger);
}

.auto-loot-empty {
  padding: 12px 8px;
  font-size: 10px;
  font-weight: normal;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
  color: var(--color-text-muted);
}

.auto-loot-note {
  flex: 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 2px;
  font-size: 10px;
  font-weight: normal;
  color: var(--color-text-muted);
}
