/* Data-coloured tag badges and their native selection controls. */
/* Shared tags retain their original readable type, outlined pills and counts. */
.tag-chip {
  --bs-badge-color: var(--app-accent);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  max-width: 100%;
  padding: .25rem .25rem .25rem .75rem;
  border: 1px solid var(--app-accent);
  border-radius: 999px;
  background: transparent;
  color: var(--app-accent);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}
.tag-chip__name { overflow-wrap: anywhere; }
.tag-chip__count {
  flex-shrink: 0;
  padding: 0 .5rem;
  border-radius: 999px;
  background: var(--app-page-bg);
  color: var(--bs-secondary-color);
  font-size: .8125rem;
  font-weight: 400;
  line-height: 1.5;
}
.tag-chip--compact { padding: .125rem .75rem; font-size: .875rem; }
.tag-chip--compact:has(.tag-chip__count) { padding-right: .125rem; }
.tag-chip--compact .tag-chip__count { font-size: .75rem; }
a.tag-chip:hover { background: var(--app-accent); color: var(--app-accent-ink); }
a.tag-chip:hover .tag-chip__count { background: var(--app-accent-ink); color: var(--app-accent); }
.tag-chip--empty { border-style: dashed; border-color: var(--bs-border-color); color: var(--bs-secondary-color); }
.tag-chip--colored {
  --tag-edge: color-mix(in srgb, var(--tag-color) 70%, var(--bs-body-color));
  border-color: var(--tag-edge);
  background: color-mix(in srgb, var(--tag-color, transparent) 18%, var(--bs-body-bg));
  color: var(--bs-body-color);
}
a.tag-chip--colored:hover {
  background: color-mix(in srgb, var(--tag-color, var(--app-accent)) 35%, var(--bs-body-bg));
  color: var(--bs-body-color);
}
a.tag-chip--colored:hover .tag-chip__count { background: var(--app-page-bg); color: var(--bs-secondary-color); }
.tag-toggle { position: relative; min-width: 0; max-width: 100%; }
.tag-toggle__chip { cursor: pointer; user-select: none; }
.tag-toggle__input:not(:checked) + .tag-toggle__chip { opacity: .55; }
.tag-toggle__input:not(:checked) + .tag-toggle__chip:hover,
.tag-toggle__input:not(:checked):focus-visible + .tag-toggle__chip { opacity: .85; }
.tag-toggle__input:checked + .tag-toggle__chip::before { content: "✓" / ""; margin-right: -.25rem; color: var(--tag-edge, currentColor); font-weight: 700; }
.tag-toggle__input:focus-visible + .tag-toggle__chip,
.link-fields__remove:has(input:focus-visible),
.color-menu__preset:has(input:focus-visible),
.color-menu__clear:has(input:focus-visible) {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}
/* Saved links use a checkbox so removal still works without JavaScript. */
.link-fields__remove { position: relative; }
.link-fields__remove:has(input:checked) {
  background: var(--bs-btn-hover-bg);
  color: var(--bs-btn-hover-color);
}

/* Native disclosures use Bootstrap surfaces; only positioning and swatch
   geometry are custom. New-tag menus anchor to the containing form. */
.color-menu { position: relative; }
/* Flex centering avoids the SVG baseline gap and keeps the control square. */
.color-menu__summary {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  list-style: none;
}
.color-menu__summary::-webkit-details-marker { display: none; }
.color-menu__none { stroke: var(--bs-secondary-color); stroke-width: 1.5; stroke-dasharray: 3 2; }
.color-menu__panel {
  position: absolute;
  right: 0;
  z-index: 1030;
  width: 17rem;
  max-width: calc(100vw - 2rem);
  margin-top: .25rem;
}
.color-menu__presets {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: .25rem;
  margin-bottom: .75rem;
}
.color-menu__preset {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: none;
}
.color-menu__preset circle,
.color-menu__summary circle:not(.color-menu__none) {
  stroke: var(--bs-secondary-color);
  stroke-opacity: .45;
  stroke-width: 1;
}
.color-menu__preset:hover { border-color: var(--bs-border-color); }
.color-menu__preset[aria-pressed="true"],
.color-menu__clear[aria-pressed="true"],
.color-menu__preset:has(input:checked),
.color-menu__clear:has(input:checked) { border-color: var(--bs-body-color); }
.color-menu__clear { grid-column: 1 / -1; }
.color-choice .color-menu__preset,
.color-choice .color-menu__clear { cursor: pointer; }
.color-choice .color-menu__presets { margin-bottom: 0; }
.tags-page__new { position: relative; }
.tags-page__new .color-choice { position: static; }
.color-choice .color-menu__panel { top: 100%; right: 0; left: auto; }
@media (max-width: 767.98px) {
  .color-menu:not(.color-choice) .color-menu__panel { right: auto; left: 0; }
}

/* Leaflet needs sized canvases and adaptation of its own control surfaces. */
.map__canvas {
  height: 60vh;
  min-height: 20rem;
  border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background: var(--bs-body-bg);
}
body:has(.collection--map) { display: flex; flex-direction: column; min-height: 100dvh; }
.collection--map { display: flex; flex: 1; flex-direction: column; }
.collection--map .map { display: flex; flex: 1; flex-direction: column; }
.collection--map .map__canvas { flex: 1; height: auto; }
.map--picker .map__canvas { height: 18rem; min-height: 0; }
.map-pin {
  border-radius: 50%;
  background: var(--bs-primary);
  border: 2px solid var(--bs-body-bg);
  box-shadow: 0 1px 3px rgb(0 0 0 / .4);
}
.map-pin--chosen { background: var(--bs-danger); }
.map__canvas.leaflet-container .leaflet-bar a,
.map__canvas.leaflet-container .leaflet-popup-content-wrapper,
.map__canvas.leaflet-container .leaflet-popup-tip {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
}
.map__canvas.leaflet-container .leaflet-bar a { border-bottom-color: var(--bs-border-color); }
.map__canvas.leaflet-container .leaflet-bar a:hover { background: var(--bs-tertiary-bg); }
.map__canvas.leaflet-container .leaflet-control-attribution {
  background: color-mix(in srgb, var(--bs-body-bg) 85%, transparent);
  color: var(--bs-secondary-color);
}
.map__canvas.leaflet-container a.leaflet-popup-close-button { color: var(--bs-secondary-color); }
.map__canvas .leaflet-popup-content { max-width: calc(100vw - 5rem); }
.leaflet-popup-content .map-popup { overflow-wrap: anywhere; display: grid; gap: .25rem; color: var(--bs-body-color); }
.leaflet-popup-content .map-popup p { margin: 0; }

/* Dynamic content must not force Bootstrap grid/flex columns wider. */
.place-form__primary, .place-form__optional, .location__lookup input { min-width: 0; }
.place__title, .tag-badges, .tag-badges > li { min-width: 0; max-width: 100%; }
.place__title h1 { max-width: 100%; }
.collection__frame[busy] .collection__results { opacity: .6; }
.places-table__hours { max-width: 16rem; }
.location__status:empty, .website-import__status:empty { display: none; }
.website-import__row input { flex: 1 1 16rem; min-width: 0; }

.tags-page__new .form-control, .tags-page__rename .form-control { min-width: 0; max-width: 100%; }

/* Let the name field shrink so tag actions stay together on one row. */
.tags-page__controls { flex: 0 1 34rem; min-width: 0; }
.tags-page__controls > .color-menu,
.tags-page__controls > .button_to,
.tags-page__rename > .btn { flex-shrink: 0; }
.tags-page__rename { flex: 1 1 16rem; min-width: 0; max-width: 100%; }
.tags-page__rename .form-control { flex: 1 1 0; width: 0; }
.tags-page__list .tag-chip { min-width: 0; }

/* Original flexible filter proportions and full-height inputs, without grid gutters. */
.filters { flex: 0 0 auto; padding: 1rem; }
.filters__row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filters__row .field { flex: 1 1 10rem; min-width: 0; }
.filters__row .filters__search, .filters__row .filters__sort { flex: 2 1 16rem; }
.filters__row .form-control, .filters__row .form-select { padding: .5rem; min-height: calc(1.5em + 1rem + 2px); }
.filters__row .form-select { padding-right: 2rem; }
.filters__clear { flex: 0 0 auto; padding: .5rem 1rem; }
.filters__tags { min-width: 0; padding: 0; border: 0; }
.filters__tags > legend { float: none; width: auto; margin-bottom: .5rem; padding: 0; font-size: 1rem; font-weight: 600; }
.filters__hint { margin-left: .5rem; font-size: .875rem; font-weight: 400; }
.field-group .tag-toggles { margin-bottom: .75rem; }
