/* Editor value list + demand drawer. */

.values-body {
  background:
    radial-gradient(900px 520px at 14% -8%, rgba(255, 117, 90, 0.1), transparent 60%),
    radial-gradient(760px 480px at 100% 0%, rgba(80, 108, 255, 0.1), transparent 55%),
    url("/static/res/icons/pet_background.webp") repeat,
    #141821;
  background-blend-mode: normal, normal, overlay, normal;
}

.values-body .pet-card {
  cursor: pointer;
}

.values-body .pet-card:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 2px;
}

.values-exists-status {
  color: #737d90;
  font-size: 9px;
}

.values-backfill {
  margin-left: 4px;
}

.values-editor-hint {
  margin-left: auto;
  color: #6f7888;
  font-size: 9px;
  letter-spacing: 0.4px;
}

.demand-pill.very-high { background: color-mix(in srgb, var(--demand-very-high) 12%, transparent); color: var(--demand-very-high); }
.demand-pill.above-average { background: color-mix(in srgb, var(--demand-above-average) 12%, transparent); color: var(--demand-above-average); }
.demand-pill.na { background: color-mix(in srgb, var(--demand-na) 10%, transparent); color: var(--demand-na); }

/* Drawer */

.demand-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}

.demand-drawer[hidden] {
  display: none;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.62);
  backdrop-filter: blur(3px);
  animation: drawer-fade 160ms ease both;
}

.drawer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(390px, 100%);
  flex-direction: column;
  gap: 13px;
  overflow-y: auto;
  padding: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.13);
  background: linear-gradient(180deg, rgba(28, 33, 44, 0.98), rgba(18, 22, 30, 0.99));
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.45);
  animation: drawer-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes drawer-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: none; }
}

.drawer-pet {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-right: 26px;
}

.drawer-pet img {
  width: 82px;
  height: 82px;
  flex: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  object-fit: contain;
}

.drawer-pet h2 {
  margin: 2px 0 0;
  color: #fff;
  font-size: 22px;
  line-height: 1.1;
}

.drawer-pet .web-muted {
  margin: 4px 0 0;
  font-size: 11px;
}

.drawer-score-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.drawer-score-row label {
  color: #8b94a6;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.drawer-score-row output {
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

#drawer-score {
  width: 100%;
  accent-color: var(--ui-accent);
}

.drawer-score-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: #5f6878;
  font-size: 8px;
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 5px;
}

.drawer-field span {
  color: #8b94a6;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.drawer-field select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  outline: 0;
  background: rgba(0, 0, 0, 0.2);
  color: #e8ebf2;
  font: inherit;
  font-size: 12px;
}

.drawer-refresh {
  width: 100%;
  margin-top: 4px;
}

/* Editor-only settle control, in the same slot the reason picker occupies in
   edit mode. The accent edge marks it apart from the vote buttons. */
.drawer-settle {
  width: 100%;
  margin-top: 6px;
  border-color: var(--ui-accent-line);
}

.drawer-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* `.web-btn` sets `display: inline-flex`, which beats the UA rule for the
   `hidden` attribute. Without this the drawer's hidden actions (Clear vote in
   edit mode, Clear demand in poll mode) and the tier preview stayed visible. */
#demand-drawer [hidden] {
  display: none !important;
}

.drawer-actions .web-btn-primary {
  width: auto;
  flex: 1;
}

.drawer-status {
  min-height: 14px;
  margin: 0;
  color: #ff9a9a;
  font-size: 10px;
}

.drawer-status.ok {
  color: #84e9b4;
}

@media (max-width: 720px) {
  .values-editor-hint {
    display: none;
  }

  .drawer-panel {
    width: 100%;
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drawer-backdrop,
  .drawer-panel {
    animation: none;
  }
}


.values-body:not(.editor-mode) .editor-only {
  display: none !important;
}

/* Discussers see the demand list (`editor-mode`) but cannot change it
   (`demand-editable`); hide every write control from them. */
.values-body:not(.demand-editable) .backfill-only {
  display: none !important;
}

/* Poll mode keeps the slider and the submit button (discussers use both) but
   hides the manual-demand tools. */
#demand-drawer[data-mode="poll"] .drawer-field,
#demand-drawer[data-mode="poll"] .drawer-refresh {
  display: none !important;
}

/* The Demand.gg label is the last item in the card's meta row, matching the
   collection page. `margin-left: auto` there keeps it right-aligned. */

.pet-card {
  cursor: pointer;
}

.card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.card-action {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  background: rgba(12, 15, 21, 0.86);
  color: #dce1ea;
  font: inherit;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.3px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.pet-card:hover .card-action,
.card-action:focus-visible {
  opacity: 1;
  transform: none;
}

/* Polling is the discusser action, so it carries the accent at rest. */
.card-poll {
  border-color: color-mix(in srgb, var(--ui-accent) 45%, transparent);
}

/* Purple is the theme accent. The old hover used a translucent blue that
   washed the label out; a solid dark tint keeps "Edit" / "Poll" readable. */
.card-action:hover {
  background: color-mix(in srgb, var(--ui-accent) 30%, #14111f);
  border-color: var(--ui-accent);
  color: #fff;
}

.card-action:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}

/* Shares the compact control height the old Edit button used. */
body .card-action {
  height: var(--ctl-h-sm);
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}


/* One-row editor/public toolbar */

.values-toolbar {
  padding: 10px 12px;
}

.values-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

.values-filter-row::-webkit-scrollbar {
  display: none;
}

.values-filter-row .control-label {
  width: auto;
  flex: none;
}

.values-filter-row .collection-search {
  min-width: 180px;
  flex: 1 1 220px;
  max-width: 320px;
}

.values-divider {
  width: 1px;
  height: 18px;
  flex: none;
  background: rgba(255, 255, 255, 0.1);
}

.values-filter-row .collection-sort,
.values-filter-row .switch-label,
.values-filter-row .segmented,
.values-filter-row .rarity-switch,
.values-filter-row .icon-button {
  flex: none;
}

/* Rarity themes: menus + indicators. Card names stay white.
   Legendary, celestial, infinity and void are handled as gradients in
   `collection.v1.css`. A flat `color` here would paint over that gradient (the
   gradient only shows through a transparent `color`), and a flat `background`
   resets `background-image` to none — which is why the gradients never
   appeared. Secret and exclusive stay flat. */

.rarity-switch button[data-rarity="secret"]:hover,
.rarity-switch button[data-rarity="secret"][aria-pressed="true"] {
  color: #f700ff;
}

.rarity-switch button[data-rarity="exclusive"]:hover,
.rarity-switch button[data-rarity="exclusive"][aria-pressed="true"] {
  color: #ff7a45;
}

.rarity-switch button[data-rarity="secret"][aria-pressed="true"] {
  background: rgba(247, 0, 255, 0.11);
}

.rarity-switch button[data-rarity="exclusive"][aria-pressed="true"] {
  background: rgba(255, 122, 69, 0.13);
}

/* Gradient indicators; names remain white. */

.rarity-legendary {
  --dot: #ff8000;
}

.rarity-legendary .rarity-dot {
  animation: legendary-dot 2.5s linear infinite;
}

@keyframes legendary-dot {
  0% { background: #ff0000; }
  20% { background: #ff8000; }
  40% { background: #ffff00; }
  60% { background: #00ff80; }
  80% { background: #0099ff; }
  100% { background: #ff0000; }
}

.rarity-celestial .rarity-dot,
.rarity-infinity .rarity-dot,
.rarity-void .rarity-dot {
  background-size: 200% auto;
  animation: rarity-wave 3.5s linear infinite;
}

.rarity-celestial .rarity-dot {
  --dot: #9ddffd;
  background-image: linear-gradient(90deg, #9ddffd, #ff9bf7, #9ddffd);
}

.rarity-infinity .rarity-dot {
  --dot: #6401ff;
  background-image: linear-gradient(90deg, #ff0000, #6401ff, #ff0000);
}

.rarity-void .rarity-dot {
  --dot: #2b00ff;
  background-image: linear-gradient(90deg, #2b0001, #2b00ff, #ea00ff, #2b00ff, #2b0001);
}

@keyframes rarity-wave {
  from { background-position: 0% 0; }
  to { background-position: 200% 0; }
}

/* The value list can hold ~100 cards, and every Legendary+ card normally runs
   two infinite gradient animations (the border ring in collection.v1.css and
   the rarity dot above). That is ~200 concurrent animations, which saturated
   the main thread and made a single card's hover stutter. Keep the rarity
   colours, but only animate the card the pointer is actually on. */
.values-body .pet-card::after,
.values-body .pet-card .rarity-dot {
  animation: none;
}

.values-body .pet-card:hover::after,
.values-body .pet-card:focus-visible::after {
  animation: collection-rarity-wave 3.5s linear infinite;
}

.values-admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 1px 0;
  min-height: 26px;
}

.values-admin-label {
  color: #6f7888;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.values-admin-row .values-backfill {
  /* A small utility action, not a page-level button: the shared 32px control
     height made it as tall as the toolbar fields. */
  height: var(--ctl-h-sm, 24px);
  padding: 0 10px;
  font-size: 10px;
  font-weight: 600;
  font-size: 9px;
}

.values-exists-status {
  color: #8b94a6;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.values-hatch-summary {
  margin-top: 8px;
  color: #a8b1c2;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.values-filter-row {
  gap: 6px;
}

.values-filter-row .collection-search {
  min-width: 150px;
  flex: 1 1 170px;
  max-width: 245px;
}

.values-filter-row .switch-label {
  gap: 3px;
}

.values-filter-row .control-label {
  font-size: 8px;
}

/* Keep the Advanced popup outside the horizontal filter scroller. */
.values-filter-row {
  flex-wrap: wrap;
  overflow: visible;
}

/* Match the tighter selector bar used elsewhere. */
.values-toolbar {
  padding: 8px 12px;
}

.values-filter-row {
  min-height: 28px;
  gap: 3px 7px;
}

.values-filter-row {
  gap: 6px 7px;
}

/* Admin-only controls (exists backfill). Gated on the body class so a stale
   session cannot show them before the permission check lands. */
.values-body:not(.admin-mode) .admin-only {
  display: none !important;
}

/* The backfill row sits above the toolbar, right-aligned with it. */
.values-admin-row {
  justify-content: flex-end;
  margin: 0 0 8px;
}

/* Predicted tier for the score currently being edited. */
.drawer-tier-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px solid var(--surface-soft-border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: #8b94a6;
  font-size: 10px;
}

.drawer-tier-preview b {
  font-size: 13px;
}

/* The previous vote, when there is one. Deliberately a pill rather than another
   line of muted body text: it is the one thing a returning voter came to check. */
.drawer-vote {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  margin: 8px 0 0;
  padding: 3px 9px;
  border: 1px solid var(--ui-accent-line);
  border-radius: 999px;
  background: var(--ui-accent-soft);
  color: #e6e2ff;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

/* Editor-only tally, mirroring the pet page's breakdown. */
.drawer-breakdown {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.drawer-breakdown-head {
  margin: 0 0 8px;
  color: #e6eaf2;
  font-size: 12px;
  font-weight: 600;
}

.drawer-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.drawer-bar-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ui-accent), #c4b5fd);
  transition: width 220ms ease;
}

.drawer-breakdown-meta {
  margin: 7px 0 0;
  color: #8b94a6;
  font-size: 10px;
  line-height: 1.5;
}

.drawer-breakdown-warn {
  margin: 6px 0 0;
  color: #ffcf9b;
  font-size: 10px;
}

/* Edit drawer follows the updated popup material and control buttons. */
.drawer-panel {
  border-left: 1px solid var(--popup-border);
  background: var(--popup-bg);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.4);
}

.drawer-close {
  border: 1px solid var(--surface-soft-border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.drawer-close:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.055);
}

.drawer-field select {
  height: 34px;
  border: 1px solid var(--surface-soft-border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: #e8ebf2;
  font-family: inherit;
  font-size: 12px;
  font-weight: 550;
}

.drawer-actions button,
.drawer-refresh {
  height: 34px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  letter-spacing: 0;
}

.drawer-refresh,
.drawer-actions .web-btn:not(.web-btn-primary) {
  border: 1px solid var(--surface-soft-border);
  background: var(--surface-soft);
  color: #c8d0dc;
}

.drawer-refresh:hover,
.drawer-actions .web-btn:not(.web-btn-primary):hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
}

.drawer-actions .web-btn-primary {
  border-color: transparent;
  background: var(--ui-accent);
  color: #0d1016;
  font-weight: 600;
}

.drawer-actions .web-btn-primary:hover {
  background: color-mix(in srgb, var(--ui-accent) 86%, white);
}

.drawer-tier-preview {
  background: var(--surface-soft);
  border-color: var(--surface-soft-border);
}

/* Values loads this sheet after collection.v1.css, so the mobile two-row
   layout needs body-level specificity to beat the base flex rule above. */
@media (max-width: 760px) {
  body .values-filter-row,
  body .collection-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px 7px;
    overflow: visible;
  }

  body .values-filter-row > .collection-search,
  body .collection-filter-row > .collection-search {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    order: 0;
  }

  body .values-filter-row > .collection-sort,
  body .collection-filter-row > .collection-sort {
    grid-column: 2;
    grid-row: 1;
    order: 0;
  }

  body .values-filter-row > .advanced-filter,
  body .collection-filter-row > .advanced-filter {
    grid-column: 3;
    grid-row: 1;
    margin-top: 0;
    order: 0;
  }

  body .collection-sort > span:not(.custom-select) {
    display: none;
  }

  body .values-filter-row > .filter-scroll,
  body .collection-filter-row > .filter-scroll {
    display: flex;
    grid-column: 1 / -1;
    grid-row: 2;
    align-items: center;
    gap: 7px;
    padding-bottom: 2px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  body .values-filter-row > .filter-scroll::-webkit-scrollbar,
  body .collection-filter-row > .filter-scroll::-webkit-scrollbar {
    display: none;
  }

  body .values-filter-row > .filter-scroll > *,
  body .collection-filter-row > .filter-scroll > * {
    flex: none;
    order: 0;
  }
}
