/* GM info (GmInfoObject.js, GmInfos.js, GmInfoCard.js): pins with their headings, clusters and the
   card. Only the GM ever has GM info. Colours come from the table's tokens (table.css), which take
   the Bootstrap variables, so a brand changes them there. */

/* ---- Layer ------------------------------------------------------------------------------- */

/* Above the tokens layer (3) and its trails. */
.table-layer--gminfo {
  z-index: 4;
}

.table-layer--gminfo[hidden] {
  display: none;
}

/* ---- Pins -------------------------------------------------------------------------------- */

/* The object is a small box around the anchor (its centre); its row keeps its size on screen
   (Camera writes --cam-scale when it settles, like the measure labels). Pins are light: a small
   sigil and a plain heading, so dozens of them stay calm. */
.table-object[data-kind="gminfo"] {
  cursor: pointer;
}

.table-object[data-kind="gminfo"].is-clustered {
  display: none;
}

/* The box itself shows nothing: no shadow of an object's content (table.css) around it. */
.table-object__content.table-gminfo {
  position: absolute;
  inset: 0;
  box-shadow: none;
}

/* GM info is always hidden and only the GM sees it: no dimming, no dashed outline, no closed eye
   like the GM's other hidden objects (table.css). */
.table-object[data-kind="gminfo"].is-hidden > .table-object__content {
  outline: none;
  opacity: 1;
}

.table-gminfo__row {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transform: scale(calc(1 / var(--cam-scale, 1)));
  transform-origin: 0 0;
}

.table-gminfo__pin {
  display: flex;
  align-items: center;
  gap: 5px;
  outline: none;
}

.table-gminfo__sigil {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  color: var(--table-accent-text);
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1.5px solid rgba(var(--table-accent-rgb), 0.8);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(var(--table-black-rgb), 0.45);
}

.table-gminfo__sigil > .table-icon {
  width: 10px;
  height: 10px;
}

.table-gminfo__label {
  max-width: min(220px, var(--gminfo-label-room, 220px));
  margin-top: -9px;
  padding: 1px 6px;
  overflow: hidden;
  color: color-mix(in srgb, var(--table-text) 88%, transparent);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  text-overflow: ellipsis;
  background: rgba(var(--table-panel-rgb), 0.62);
  border-radius: 3px;
}

.table-gminfo__pin:hover .table-gminfo__sigil,
.table-object.is-open .table-gminfo__sigil {
  color: rgba(var(--table-white-rgb), 0.95);
  background: rgba(var(--table-accent-rgb), 0.9);
}

.table-gminfo__pin:hover .table-gminfo__label,
.table-object.is-open .table-gminfo__label,
.table-object.is-selected .table-gminfo__label {
  color: var(--table-text);
  background: rgba(var(--table-panel-rgb), 0.92);
}

/* Selected, open or focused: a ring around the sigil (it has no selection frame). */
.table-object.is-selected .table-gminfo__sigil,
.table-object.is-open .table-gminfo__sigil,
.table-gminfo__pin:focus-visible .table-gminfo__sigil {
  box-shadow:
    0 0 0 2px rgba(var(--table-panel-rgb), 0.8),
    0 0 0 4px rgba(var(--table-accent-rgb), 0.6);
}

/* Danger keeps its meaning's colour; every other icon takes the accent. */
.table-object[data-kind="gminfo"][data-icon="danger"]:not(.is-section) .table-gminfo__sigil {
  color: var(--table-danger);
  border-color: var(--table-danger);
}

/* A section: a chapter heading for a part of the table. It stays readable zoomed out, and the
   entries next to it fold into it there, with their count after the heading. */
.table-object.is-section .table-gminfo__sigil {
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  color: rgba(var(--table-white-rgb), 0.95);
  background: rgba(var(--table-accent-rgb), 0.88);
  border-color: rgba(var(--table-white-rgb), 0.4);
  border-radius: 5px;
  transform: rotate(45deg) scale(0.86);
}

.table-object.is-section .table-gminfo__sigil > .table-icon {
  width: 12px;
  height: 12px;
  transform: rotate(-45deg);
}

.table-object.is-section .table-gminfo__label {
  max-width: min(320px, var(--gminfo-label-room, 320px));
  margin-top: -11px;
  padding: 2px 8px;
  color: var(--table-text);
  font-size: 14px;
  font-weight: 650;
  line-height: 18px;
  background: rgba(var(--table-panel-rgb), 0.8);
  border-bottom: 1.5px solid rgba(var(--table-accent-rgb), 0.7);
  border-radius: 3px 3px 0 0;
}

/* Zoomed out an entry is a dot, and a pin whose label has no room shows its sigil only. */
.table-object.is-compact .table-gminfo__label,
.table-object.is-crowded .table-gminfo__label {
  display: none;
}

.table-object.is-compact .table-gminfo__sigil {
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  background: rgba(var(--table-accent-rgb), 0.85);
  border: 1.5px solid rgba(var(--table-panel-rgb), 0.85);
}

.table-object.is-compact .table-gminfo__sigil > .table-icon {
  display: none;
}

/* ---- Counts: a section's folded entries, and chips of entries without one ------------------ */

.table-gminfo__count,
.table-gminfo-cluster__count {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  color: var(--table-accent-text);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  background: rgba(var(--table-panel-rgb), 0.9);
  border: 1px solid rgba(var(--table-accent-rgb), 0.6);
  border-radius: 9px;
  cursor: zoom-in;
  outline: none;
}

.table-gminfo__count {
  margin-top: -9px;
}

.table-gminfo__count[hidden] {
  display: none;
}

.table-gminfo__count:hover,
.table-gminfo-cluster__count:hover {
  color: rgba(var(--table-white-rgb), 0.95);
  background: rgba(var(--table-accent-rgb), 0.85);
}

.table-gminfo__count:focus-visible,
.table-gminfo-cluster__count:focus-visible {
  box-shadow: 0 0 0 2px rgba(var(--table-accent-rgb), 0.7);
}

.table-gminfo-cluster {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
}

/* On its first entry's anchor, so it reads as "this list starts here". */
.table-gminfo-cluster__count {
  position: absolute;
  transform: scale(calc(1 / var(--cam-scale, 1))) translate(-10px, -50%);
  transform-origin: 0 0;
}

/* ---- The card ------------------------------------------------------------------------------ */

.table-gminfo-card {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-height: min(64vh, 540px);
  color: var(--table-text);
  font-size: 14px;
  line-height: 1.5;
  background: rgba(var(--table-panel-rgb), 0.97);
  border: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-top: 3px solid var(--table-accent);
  border-radius: 10px;
  box-shadow:
    0 18px 50px rgba(var(--table-black-rgb), 0.6),
    0 0 0 1px rgba(var(--table-black-rgb), 0.4);
  pointer-events: auto;
  user-select: text;
}

.table-gminfo-card[hidden] {
  display: none;
}

.table-gminfo-card.is-editing {
  width: 420px;
  max-height: min(80vh, 640px);
}

/* The beak towards the pin. */
.table-gminfo-card::before {
  content: "";
  position: absolute;
  top: var(--beak-y, 24px);
  left: -8px;
  width: 14px;
  height: 14px;
  background: rgb(var(--table-panel-rgb));
  border-bottom: 1px solid rgba(var(--table-accent-rgb), 0.45);
  border-left: 1px solid rgba(var(--table-accent-rgb), 0.45);
  transform: rotate(45deg);
}

.table-gminfo-card.is-left::before {
  right: -8px;
  left: auto;
  transform: rotate(225deg);
}

.table-gminfo-card__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 10px 10px 14px;
  border-bottom: 1px solid rgba(var(--table-accent-rgb), 0.18);
}

.table-gminfo-card__sigil {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--table-accent-text);
  background: rgba(var(--table-accent-rgb), 0.14);
  border: 1px solid rgba(var(--table-accent-rgb), 0.4);
  border-radius: 50%;
}

.table-gminfo-card__sigil[data-icon="danger"] {
  color: var(--table-danger);
}

.table-gminfo-card__sigil .table-icon {
  width: 15px;
  height: 15px;
}

.table-gminfo-card__titles {
  flex: 1;
  min-width: 0;
}

.table-gminfo-card__title {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.table-gminfo-card__where {
  margin-top: 2px;
  color: var(--table-muted);
  font-size: 12px;
}

.table-gminfo-card__actions {
  display: flex;
  gap: 2px;
}

.table-gminfo-card__icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--table-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.table-gminfo-card__icon-button:hover,
.table-gminfo-card__icon-button:focus-visible {
  color: var(--table-text);
  background: rgba(var(--table-accent-rgb), 0.16);
  outline: none;
}

.table-gminfo-card__icon-button .table-icon {
  width: 16px;
  height: 16px;
}

.table-gminfo-card__body {
  padding: 12px 16px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  overflow-wrap: anywhere;
}

.table-gminfo-card__body.is-plain {
  white-space: pre-wrap;
}

.table-gminfo-card__body.is-empty {
  color: var(--table-muted);
  font-style: italic;
}

.table-gminfo-card__body > :first-child {
  margin-top: 0;
}

.table-gminfo-card__body > :last-child {
  margin-bottom: 0;
}

.table-gminfo-card__body :is(p, ul, ol, blockquote, table, pre) {
  margin: 0 0 0.7em;
}

.table-gminfo-card__body :is(h1, h2, h3, h4, h5) {
  margin: 1em 0 0.35em;
  color: var(--table-accent-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-gminfo-card__body :is(ul, ol) {
  padding-left: 1.3em;
}

.table-gminfo-card__body li {
  margin-bottom: 0.25em;
}

.table-gminfo-card__body li::marker {
  color: var(--table-accent-text);
}

.table-gminfo-card__body strong {
  color: rgba(var(--table-white-rgb), 0.96);
}

.table-gminfo-card__body blockquote {
  padding: 4px 0 4px 12px;
  color: var(--table-muted);
  border-left: 2px solid rgba(var(--table-accent-rgb), 0.5);
}

.table-gminfo-card__body :is(code, pre) {
  font-size: 12.5px;
  background: rgba(var(--table-black-rgb), 0.3);
  border-radius: 4px;
}

.table-gminfo-card__body table {
  border-collapse: collapse;
}

.table-gminfo-card__body :is(th, td) {
  padding: 2px 8px;
  border: 1px solid rgba(var(--table-accent-rgb), 0.25);
}

.table-gminfo-card__body a {
  color: var(--table-accent-text);
}

.table-gminfo-card__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--table-muted);
  font-size: 12px;
  border-top: 1px solid rgba(var(--table-accent-rgb), 0.18);
}

.table-gminfo-card__only {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table-gminfo-card__only .table-icon {
  width: 14px;
  height: 14px;
}

.table-gminfo-card__spacer {
  flex: 1;
}

.table-gminfo-card__button {
  padding: 4px 10px;
  color: var(--table-text);
  font: inherit;
  font-weight: 600;
  background: rgba(var(--table-accent-rgb), 0.14);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 6px;
  cursor: pointer;
}

.table-gminfo-card__button:hover,
.table-gminfo-card__button:focus-visible {
  background: rgba(var(--table-accent-rgb), 0.26);
  outline: none;
}

.table-gminfo-card__button.is-primary {
  color: rgba(var(--table-white-rgb), 0.96);
  background: var(--table-accent);
  border-color: var(--table-accent);
}

/* The form. */
.table-gminfo-card__form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.table-gminfo-card__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--table-muted);
  font-size: 12px;
  font-weight: 600;
}

.table-gminfo-card__form :is(input[type="text"], textarea) {
  padding: 6px 9px;
  color: var(--table-text);
  font: 14px/1.45 var(--bs-body-font-family, system-ui, sans-serif);
  background: rgba(var(--table-black-rgb), 0.3);
  border: 1px solid rgba(var(--table-accent-rgb), 0.35);
  border-radius: 6px;
}

.table-gminfo-card__heading {
  font-weight: 600 !important;
}

.table-gminfo-card__text {
  min-height: 180px;
  font: 13px/1.45 var(--bs-font-monospace, ui-monospace, monospace) !important;
  resize: vertical;
}

.table-gminfo-card__form :is(input, textarea):focus {
  border-color: var(--table-accent);
  outline: 2px solid rgba(var(--table-accent-rgb), 0.35);
}

.table-gminfo-card__icons {
  display: flex;
  gap: 4px;
}

.table-gminfo-card__icons button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--table-muted);
  background: transparent;
  border: 1px solid rgba(var(--table-accent-rgb), 0.25);
  border-radius: 50%;
  cursor: pointer;
}

.table-gminfo-card__icons button[aria-checked="true"] {
  color: rgba(var(--table-white-rgb), 0.96);
  background: var(--table-accent);
  border-color: var(--table-accent);
}

.table-gminfo-card__icons button[data-icon="danger"][aria-checked="true"] {
  background: var(--table-danger);
  border-color: var(--table-danger);
}

.table-gminfo-card__icons button:focus-visible {
  outline: 2px solid rgba(var(--table-accent-rgb), 0.6);
  outline-offset: 2px;
}

.table-gminfo-card__icons .table-icon {
  width: 15px;
  height: 15px;
}

.table-gminfo-card__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.table-gminfo-card__check input {
  accent-color: var(--table-accent);
}

.table-gminfo-card__hint {
  margin: 0;
  color: var(--table-muted);
  font-size: 11.5px;
}

/* ---- Phones -------------------------------------------------------------------------------- */

@media (max-width: 576px) {
  /* The card is a sheet above the HUD bar; GmInfos pans the pin above it. */
  .table-gminfo-card,
  .table-gminfo-card.is-editing {
    top: auto;
    right: 8px;
    bottom: 64px;
    left: 8px;
    width: auto;
    max-height: 52vh;
    transform: none !important;
  }

  .table-gminfo-card::before {
    display: none;
  }

  .table-gminfo__label {
    max-width: min(150px, var(--gminfo-label-room, 150px));
  }

  .table-gminfo-card__icon-button {
    width: 40px;
    height: 40px;
  }

  .table-gminfo-card__button {
    min-height: 40px;
  }
}

/* ---- The list of folded entries (a count's or chip's menu, ContextMenu) -------------------- */

.table-gminfo-list .table-menu__item {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
