/* ui/PilotTag — contract: ./PilotTag.spec.md. Tokens from ui/Theme. */

/* One line, one height: the name gives way first, nothing wraps. */
.sp-pilot-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 20px;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: middle;
}

/* docs/profiles.md: a tag that opens a profile is a bare button, the same line.
   Its hit area reaches past the 20 px line so a thumb can find it. */
button.sp-pilot-tag {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
  overflow: visible;
}
button.sp-pilot-tag::before {
  content: "";
  position: absolute;
  inset: -12px -6px;
}
button.sp-pilot-tag .sp-pilot-tag__name {
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
  text-underline-offset: 3px;
}
button.sp-pilot-tag:hover .sp-pilot-tag__name { text-decoration-color: currentColor; }

/* The name gives way first: twice the plate's shrink, down to four letters.
   A short name does not give way at all. */
.sp-pilot-tag__name {
  flex: 0 2 auto;
  min-width: 4ch;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-pilot-tag__name[data-short] { flex-shrink: 0; }

/* A narrow card (wrap): lines like text, the name whole, breaking inside itself if it must. */
.sp-pilot-tag[data-wrap] {
  flex-wrap: wrap;
  row-gap: 2px;
  height: auto;
  overflow: visible;
  white-space: normal;
}
.sp-pilot-tag[data-wrap] .sp-pilot-tag__name {
  flex: 0 1 auto;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

/* Tier pips: one diamond per form, part of the name. */
.sp-pilot-tag__tier {
  position: relative; /* contains the visually hidden text */
  flex: none;
  margin-left: -2px;
  font: 700 12px/1 var(--sp-font-mono);
  letter-spacing: 0.02em;
  color: var(--sp-text-dim);
}

.sp-pilot-tag__tier[data-forms="3"] {
  color: var(--sp-rarity-legendary);
  text-shadow: 0 0 6px color-mix(in oklab, var(--sp-rarity-legendary) 55%, transparent);
}

/* The Armory title: a plate right after the name, in its rarity's colour. No
   border: the border belongs to the chips, and the plate is part of the name. */
.sp-pilot-tag__title {
  --rarity: var(--sp-rarity-common);
  position: relative;
  flex: 0 1 auto;
  min-width: 2.4em;
  max-width: 9.5em;
  height: 18px;
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 0;
  border-radius: var(--sp-radius-sm);
  background: color-mix(in oklab, var(--rarity) 18%, transparent);
  color: color-mix(in oklab, var(--rarity) 80%, var(--sp-text));
  font: 700 12px/18px var(--sp-font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sp-pilot-tag__title[data-rarity="rare"] { --rarity: var(--sp-rarity-rare); }
.sp-pilot-tag__title[data-rarity="epic"] { --rarity: var(--sp-rarity-epic); }
.sp-pilot-tag__title[data-rarity="legendary"] { --rarity: var(--sp-rarity-legendary); }

/* Mastery, You and Bot: one set of chips. */
.sp-pilot-tag__chip {
  --chip: var(--sp-text-faint);
  position: relative; /* contains the visually hidden text */
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-sizing: border-box;
  height: 18px;
  padding: 0 6px;
  border: 1px solid color-mix(in oklab, var(--chip) 55%, transparent);
  border-radius: var(--sp-radius-sm);
  color: var(--chip);
  font: 700 12px/1 var(--sp-font-ui);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sp-pilot-tag__you { --chip: var(--sp-accent-2); }
.sp-pilot-tag__bot { --chip: var(--sp-text-faint); }

/* The mastery chip: the kill feed's hexagon as a mark before the digits. */
.sp-pilot-tag__mastery {
  --chip: var(--sp-rarity-common);
  font-family: var(--sp-font-mono);
  letter-spacing: 0;
  color: color-mix(in oklab, var(--chip) 70%, var(--sp-text));
  background: color-mix(in oklab, var(--chip) 12%, transparent);
}
.sp-pilot-tag__mastery::before {
  content: "";
  flex: none;
  width: 7px;
  height: 8px;
  background: var(--chip);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}
.sp-pilot-tag__mastery[data-tier="rare"] { --chip: var(--sp-rarity-rare); }
.sp-pilot-tag__mastery[data-tier="epic"] { --chip: var(--sp-rarity-epic); }
.sp-pilot-tag__mastery[data-tier="legendary"] { --chip: var(--sp-rarity-legendary); }

/* ——— The device mark (docs/mobile-assist.md D7): a phone or a mouse, quiet ——— */
.sp-pilot-device {
  flex: none;
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
  background-color: var(--sp-text-faint);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 14px 14px;
  mask-size: 14px 14px;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}
/* A phone: a tall rounded slab with a home bar. */
.sp-pilot-device[data-device="touch"] {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='3.7' y='1' width='6.6' height='12' rx='1.6'/%3E%3Cpath d='M6 10.9h2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='3.7' y='1' width='6.6' height='12' rx='1.6'/%3E%3Cpath d='M6 10.9h2'/%3E%3C/svg%3E");
}
/* A mouse: a capsule with its wheel. */
.sp-pilot-device[data-device="pointer"] {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='3.5' y='1' width='7' height='12' rx='3.5'/%3E%3Cpath d='M7 3.4v2.2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='3.5' y='1' width='7' height='12' rx='3.5'/%3E%3Cpath d='M7 3.4v2.2'/%3E%3C/svg%3E");
}
