/* Compact category chips with single-line ellipsis, +N disclosure, and top-layer full-name tooltip. */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group {
  --eha-cat-max: 6.75rem;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 4px !important;
  max-inline-size: 100%;
  min-inline-size: 0;
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) :is(
  .post-content-overlay > .eha-cat-group,
  .post-content-overlay.eha-cat-group
) {
  max-inline-size: calc(100% - 24px);
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-regional-section .eha-regional-list-category.eha-cat-group {
  --eha-cat-max: 6.25rem;
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-article-labels.eha-cat-group {
  --eha-cat-max: 7.75rem;
}

/* Expanded state when the user clicks +N */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group[data-eha-cat-expanded="true"] {
  flex-wrap: wrap !important;
  --eha-cat-max: 8.5rem;
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) :is(
  .post-content-overlay > .eha-cat-group,
  .post-content-overlay.eha-cat-group
)[data-eha-cat-expanded="true"] {
  background: rgba(9, 43, 77, 0.88);
  padding: 6px;
  border-radius: 5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  z-index: 6 !important;
}

/* Hidden extra categories while collapsed */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group > .eha-cat-chip[hidden] {
  display: none !important;
}

/* Flex item sizing: protect <=10-char section names while capping and shrinking longer labels */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group > .eha-cat-chip {
  position: relative;
  z-index: 3;
  flex: 0 1 auto !important;
  min-inline-size: 0 !important;
  max-inline-size: min(var(--eha-cat-max, 6.75rem), 100%) !important;
  margin: 0 !important;
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group > .eha-cat-chip.eha-cat-chip-short {
  flex-shrink: 0 !important;
}

/* Single-line visual truncation only; full text remains in the DOM */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group .eha-cat-chip-text,
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group span.post-cat.eha-cat-chip-text {
  display: block !important;
  min-inline-size: 0;
  max-inline-size: 100%;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  overflow-wrap: normal !important;
}

/* Subtle cursor cue on truncated chips */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group > .eha-cat-chip.is-truncated {
  cursor: pointer;
}

/* +N / − disclosure button */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-inline-size: 22px;
  padding: 2px 6px;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: rgba(9, 43, 77, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  color: #fff;
  font: 700 0.625rem/1.4 Roboto, Arial, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Expand pointer hit area without inflating visual pill height */
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn::after {
  content: "";
  position: absolute;
  inset: -4px -2px;
}

@media (pointer: coarse) {
  :is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn {
    padding: 3px 7px;
  }
  :is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn::after {
    inset: -8px -4px;
  }
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn:hover {
  background: #144372;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-more-btn:focus-visible,
:is(body[data-direction-preview="propuesta"], body[data-eha-site-mode="public"]) .eha-cat-group > .eha-cat-chip:focus-visible {
  outline: 2px solid #9387b7;
  outline-offset: 2px;
}

/* Top-layer tooltip for full category names and +N preview */
.eha-cat-tooltip {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 5px 9px;
  max-inline-size: min(22rem, calc(100vw - 16px));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  background: rgba(9, 43, 77, 0.96);
  color: #fff;
  box-shadow: 0 6px 18px rgba(9, 43, 77, 0.3);
  font: 500 0.75rem/1.4 Roboto, Arial, sans-serif;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: normal;
  z-index: 2147483646;
  pointer-events: auto;
  display: none;
}

.eha-cat-tooltip:is(:popover-open, .\:popover-open, .is-open) {
  display: block;
}
