/*
  Save-status callouts and the whole answer-reaction family: row, chips, the
  names popover and the picker.
  Cut from pwa_round_and_result_deck.css and must load directly after it, and
  before pwa_responsive_overrides.css, which overrides the reaction overlay by
  cascade order alone.
  Colors and theme tokens live in pwa_theme.css -- change them there, not here.
*/

.save-status {
  border-left: 4px solid var(--color-border-strong);
  margin-block: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

.save-status--missing {
  background: var(--color-warning-soft);
  border-left-color: var(--color-warning);
}

.save-status--saved {
  background: var(--color-success-soft);
  border-left-color: var(--color-success);
}

.save-status--dirty {
  background: var(--color-warning-soft);
  border-left-color: var(--color-warning);
}

.save-status--blocked {
  background: var(--color-danger-soft);
  border-left-color: var(--color-danger);
}

.reaction-row {
  --reaction-control-height: 1.8rem;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.reaction-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.reaction-chip {
  display: inline-flex;
  min-width: 0;
}

.reaction-chip__summary {
  align-items: center;
  background: var(--color-surface-muted);
  border: 0;
  border-radius: var(--radius-pill);
  box-sizing: border-box;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  gap: 0.25em;
  height: var(--reaction-control-height);
  padding-block: 0;
  padding-inline: 0.5em;
  width: fit-content;
}

.reaction-chip__summary::after {
  content: "▾";
  font-size: 0.62em;
  opacity: 0.7;
}

.reaction-chip:has([data-reaction-names]:popover-open) .reaction-chip__summary::after {
  content: "▴";
}

.reaction-chip--active .reaction-chip__summary {
  background: var(--color-accent-strong);
  color: var(--color-surface);
  font-weight: 600;
}

/* Top layer, so neither the paged deck's `overflow: hidden` nor the track's transform clips
   this. `position: absolute` against the initial containing block means the inline `top` and
   `left` the script writes are document coordinates, so the panel scrolls with the page by
   itself. */
.reaction-names {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-elevated);
  box-sizing: border-box;
  color: var(--color-text);
  inset: auto;
  margin: 0;
  max-width: min(16rem, calc(100vw - 2rem));
  min-width: 10rem;
  overflow: visible;
  padding: 0;
  position: absolute;
}

.reaction-names:not([data-placed]) {
  opacity: 0;
}

.reaction-names__pointer {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
  height: 10px;
  left: var(--reaction-names-pointer-x, 16px);
  position: absolute;
  top: -6px;
  transform: rotate(45deg);
  width: 10px;
}

.reaction-names[data-placement="above"] .reaction-names__pointer {
  border-bottom: 1px solid var(--color-border);
  border-left: 0;
  border-right: 1px solid var(--color-border);
  border-top: 0;
  bottom: -6px;
  top: auto;
}

.reaction-names__head {
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  font-size: 0.78rem;
  gap: 0.35em;
  margin: 0;
  padding: var(--space-1) var(--space-2);
}

.reaction-names__list {
  max-height: 9rem;
  overflow-y: auto;
  padding: var(--space-1) var(--space-2) var(--space-2);
}

.reaction-names__name {
  align-items: center;
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding-block: 0.15em;
}

/* Without popover support the panel would otherwise sit permanently open under every chip. */
@supports not selector(:popover-open) {
  [data-reaction-names] {
    display: none;
  }
}

.reaction-picker {
  margin-left: auto;
  min-width: 0;
}

/* Grid, not flex: the option bar sits in the browser's `<details>` content box, and only a
   zero-min track lets that box shrink so the bar scrolls instead of overflowing the card. */
.reaction-picker[open] {
  align-items: center;
  display: grid;
  flex-basis: 100%;
  gap: var(--space-2);
  grid-template-columns: auto minmax(0, max-content);
  margin-left: 0;
}

.reaction-picker__opener {
  align-items: center;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-sizing: border-box;
  color: var(--color-accent);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  height: var(--reaction-control-height);
  justify-content: center;
  list-style: none;
  padding: 0;
  width: var(--reaction-control-height);
}

.reaction-picker__opener::-webkit-details-marker {
  display: none;
}

.reaction-picker[open] .reaction-picker__opener {
  background: var(--color-primary-soft);
  border-color: var(--color-accent);
}

.reaction-picker__icon {
  height: 1.05rem;
  width: 1.05rem;
}

.reaction-picker__options {
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-1);
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 0.2em 0.35em;
  scrollbar-width: thin;
}

.reaction-picker__option {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 1.4rem;
  padding: 0.25em 0.5em;
}

.reaction-picker__option--active {
  border-color: var(--color-accent);
}

