/* Owner collection: Showcase grid. */

.collection-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 70px;
}

.collection-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

/* Secondary content in the head row: the hatch total and — for admins — the
   exists backfill. Inline with the title so neither costs a row of vertical
   space, and the head stays the same height as the values page. */
.collection-head-aside {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  padding-bottom: 2px;
}

.collection-head-aside .values-admin-row {
  margin: 0;
  min-height: 0;
  gap: 8px;
}

.collection-head-aside .values-admin-row[hidden] {
  display: none;
}

/* `.web-btn` sets `display: inline-flex`, which beats the browser's built-in
   `[hidden]` rule. The profile link is hidden on your own collection. */
.collection-head-aside .collection-owner-link[hidden] {
  display: none;
}

.collection-head-aside .collection-owner-link {
  height: 24px;
  padding: 0 10px;
  font-size: 9px;
}

.collection-head-aside .values-backfill {
  height: 24px;
  padding: 0 10px;
  font-size: 9px;
}

.collection-head-aside .values-exists-status {
  color: #737d90;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Figures under the title: the filtered total, plus the collection's unique
   hatch count. Both pages print the same "N Pets" figure here. */
.collection-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 14px;
  margin: 7px 0 0;
  color: #8b94a6;
  font-size: 11px;
}

.collection-sub .values-hatch-summary {
  margin: 0;
  color: #a8b1c2;
  font-size: 11px;
}

.collection-sub .values-hatch-summary[hidden] {
  display: none;
}

.collection-head h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1;
  text-align: left;
  letter-spacing: -0.8px;
  text-shadow: none;
}

.collection-head .web-muted {
  max-width: 620px;
  margin: 9px 0 0;
}

.collection-summary {
  display: flex;
  gap: 8px;
  flex: none;
}

.collection-stat {
  min-width: 92px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.collection-stat b {
  display: block;
  color: #fff;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.collection-stat span {
  color: #8b94a6;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.collection-toolbar {
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.035));
}

.collection-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
}

.collection-row + .collection-row {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.collection-row-wrap {
  flex-wrap: wrap;
}

.control-label {
  width: 54px;
  flex: none;
  color: #7f889a;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.segmented,
.rarity-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.segmented button {
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9aa3b4;
  font: inherit;
  font-size: 10px;
  font-weight: 550;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.rarity-switch button {
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9aa3b4;
  font: inherit;
  font-size: 10px;
  font-weight: 550;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.segmented button:hover,
.rarity-switch button:hover {
  color: #e6e9f0;
}

.segmented button[aria-pressed="true"],
.rarity-switch button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.collection-slot-note {
  color: #737d90;
  font-size: 9px;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.collection-search {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 190px;
  flex: 1;
  max-width: 310px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
}

.collection-search svg {
  width: 13px;
  height: 13px;
  flex: none;
  fill: none;
  stroke: #7f889a;
  stroke-width: 2;
}

.collection-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e6e9f0;
  font: inherit;
  font-size: 11px;
}

.collection-search input::placeholder {
  color: #6f7888;
}

.collection-sort {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7f889a;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.collection-sort select {
  width: 140px;
  height: 30px;
  box-sizing: border-box;
  padding: 0 24px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
  color: #dce1ea;
  font: inherit;
  font-size: 11px;
}

.icon-button {
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  color: #dce1ea;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9aa3b4;
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.switch-label input {
  width: 13px;
  height: 13px;
  accent-color: var(--ui-accent);
}

.collection-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 1px 10px;
  color: #8b94a6;
  font-size: 10px;
}

.collection-hint {
  color: #5f6878;
  font-size: 9px;
  letter-spacing: 0.4px;
}

.pet-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--card-gap-roomy);
  /* Breathing room under the toolbar. The values page can have an empty
     admin/read-only row between them, which collapsed the gap to 0. */
  margin-top: var(--card-gap-roomy);
}

/* Card */

.pet-card {
  --dot: #8b94a6;
  position: relative;
  color: inherit;
  text-decoration: none;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  /* Keep each card's paint and layout local. The values page renders ~100
     cards and most rarity dots run an infinite shimmer; without containment
     every one of those animations invalidated the whole grid, so hovering a
     card stuttered. `paint` matches the clipping `overflow: hidden` already
     applies, so nothing visible changes. */
  contain: layout paint style;
  /* A 4% hairline instead of the 11% outline: enough to hold the card's shape
     against the page, quiet enough not to frame the artwork. Colour arrives on
     hover. */
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.038));
  box-shadow: 0 10px 26px -16px rgba(0, 0, 0, 0.75);
  animation: card-in 220ms ease both;
  transition: border-color 180ms ease, transform 180ms ease;
}

.pet-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.22);
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.card-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: var(--card-pad-roomy);
  overflow: hidden;
}

.card-media::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 38%;
  background: linear-gradient(180deg, transparent, rgba(18, 22, 31, 0.55));
  content: "";
  pointer-events: none;
}

.card-media img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05);
  /* No `filter: drop-shadow` here. Safari rasterises every filtered image
     separately; with ~100 cards in the value grid that turned each hover into
     a ~350ms frame. The card's background gradient carries the depth instead. */
  transition: transform 180ms ease;
}

.pet-card:hover .card-media img {
  transform: scale(1.035);
}

.you-badge {
  position: absolute;
  right: 16px;
  bottom: 14px;
  z-index: 2;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  background: rgba(10, 12, 17, 0.8);
  color: #dce1ea;
  font-size: 9px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}

.card-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
}

.name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.name-row h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #fff;
  font-size: 14px;
  font-weight: 550;
  letter-spacing: 0;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rarity-dot {
  position: relative;
  width: 9px;
  height: 9px;
  flex: none;
  margin-left: auto;
  border-radius: 50%;
  background: var(--dot);
  box-shadow: 0 0 7px var(--dot);
}

.rarity-common { --dot: #c8d0dc; }
.rarity-unique { --dot: #b07cff; }
.rarity-rare { --dot: #5aa6ff; }
.rarity-epic { --dot: #f3a13f; }
.rarity-legendary { --dot: #ffe14d; }
.rarity-secret { --dot: #f700ff; }
.rarity-celestial { --dot: #35e6c2; }
.rarity-infinity { --dot: #a6e9ff; }
.rarity-void { --dot: #fff; }

.demand-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(112, 190, 255, 0.12);
  color: #9ed2ff;
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.demand-pill.low { background: color-mix(in srgb, var(--demand-low) 10%, transparent); color: var(--demand-low); }
.demand-pill.average { background: color-mix(in srgb, var(--demand-medium) 10%, transparent); color: var(--demand-medium); }
.demand-pill.high { background: color-mix(in srgb, var(--demand-high) 10%, transparent); color: var(--demand-high); }
.demand-pill.insane { background: color-mix(in srgb, var(--demand-insane) 10%, transparent); color: var(--demand-insane); }

.demand-gg {
  margin-left: auto;
  overflow: hidden;
  color: #737d90;
  font-size: var(--card-demand-size);
  font-weight: 450;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.value-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 7px;
  min-width: 0;
}

.value-main {
  flex: none;
  white-space: nowrap;
  color: #fff;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.value-estimate {
  color: #a8b1c2;
  font-size: 10px;
  white-space: nowrap;
}

.trend {
  margin-left: auto;
  overflow: hidden;
  color: #7f889a;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 1px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.exists {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #7f889a;
  font-size: var(--card-exists-size);
  font-variant-numeric: tabular-nums;
}

.exists svg {
  width: var(--card-icon-size);
  height: var(--card-icon-size);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}

.exists[data-exists-tip] {
  cursor: help;
}

.exists-tip {
  position: fixed;
  z-index: 120;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: #151a24;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
  color: #c8d0dc;
  font-size: 10px;
  white-space: nowrap;
  pointer-events: none;
}

.exists b {
  color: #a8b1c2;
  font-weight: 550;
}

/* Compact: eight columns and condensed chrome. */

/* Compact is the default layout: eight across. Roomy is the opt-out at six. */
.collection-body.compact .pet-grid {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--card-gap-compact);
}

.collection-body.compact .pet-card {
  border-radius: 12px;
}

.collection-body.compact .card-media {
  padding: var(--card-pad-compact);
}

.collection-body.compact .card-media img {
  border-radius: 8px;
}

.collection-body.compact .card-body {
  gap: 4px;
  padding: 8px 9px 9px;
}

.collection-body.compact .name-row h3 {
  font-size: var(--card-title-compact);
}

.collection-body:not(.compact) .name-row h3 {
  font-size: var(--card-title-roomy);
}

.collection-body.compact .rarity-dot {
  width: 8px;
  height: 8px;
}

.collection-body.compact .variant-icons svg {
  width: 12px;
  height: 12px;
}

.collection-body.compact .demand-pill {
  padding: 2px 5px;
  font-size: 8px;
}

.collection-body.compact .demand-gg {
  font-size: var(--card-demand-size-compact);
}

.collection-body.compact .trend svg {
  width: 12px;
  height: 12px;
}

.collection-body.compact .card-our-demand {
  font-size: var(--card-demand-size-compact);
}

.collection-body.compact .card-our-demand svg {
  width: var(--card-icon-size-compact);
  height: var(--card-icon-size-compact);
}

.collection-body.compact .value-main {
  font-size: 20px;
}

.collection-body.compact .meta-line {
  gap: 8px;
  padding-top: 5px;
}

.collection-body.compact .exists,
.collection-body.compact .exists b {
  font-size: var(--card-exists-size-compact);
}

.collection-body.compact .exists svg {
  width: var(--card-icon-size-compact);
  height: var(--card-icon-size-compact);
}

.collection-body.compact .you-badge {
  right: 12px;
  bottom: 11px;
  padding: 2px 6px;
  font-size: 10px;
}

.collection-skeleton {
  aspect-ratio: 0.72;
  border-radius: 18px;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.04) 20%, rgba(255, 255, 255, 0.08) 40%, rgba(255, 255, 255, 0.04) 60%);
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.4s linear infinite;
}

@keyframes skeleton-shimmer {
  from { background-position: 180% 0; }
  to { background-position: -40% 0; }
}

.collection-empty {
  padding: 46px 18px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  color: #8b94a6;
  font-size: 12px;
  text-align: center;
}

.collection-more {
  display: flex;
  justify-content: center;
  padding-top: 18px;
}

#load-more[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .pet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .collection-body.compact .pet-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .collection-toolbar .grid-toggle { margin-left: auto; }
}

@media (max-width: 820px) {
  .collection-page { padding: 20px 12px 56px; }
  .collection-head { align-items: flex-start; flex-direction: column; gap: 12px; }
  .collection-summary { width: 100%; }
  .collection-stat { flex: 1; }
  .control-label { width: auto; }
  .collection-row { flex-wrap: wrap; }
  .collection-search { max-width: none; }
  .pet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .collection-body.compact .pet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .collection-hint { display: none; }
}

@media (max-width: 600px) {
  .pet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--card-gap-roomy); }
  .collection-body.compact .pet-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--card-gap-compact); }
  .card-media { padding: 12px; }
  .card-body { padding: 8px 9px 10px; }
  .value-main { font-size: 20px; }
  .collection-slot-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pet-card,
  .collection-skeleton {
    animation: none;
  }

  .pet-card,
  .card-media img,
  .rarity-dot {
    transition: none;
  }
}

.collection-body.reduce-motion *,
.collection-body.reduce-motion *::before,
.collection-body.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Rarity theme: menus and indicators. Card names stay white.
   Each rarity owns one custom property, and that property is the *same* value
   the card dots use — previously the switch hovered to a different hex per
   rarity than the palette (celestial #9ddffd here vs #35e6c2 on the card),
   so the hover never matched anything else in the UI. */
.rarity-switch button[data-rarity="legendary"] { --rc: #ff8000; }
.rarity-switch button[data-rarity="secret"] { --rc: #f700ff; }
.rarity-switch button[data-rarity="celestial"] { --rc: #9ddffd; }
.rarity-switch button[data-rarity="infinity"] { --rc: #6401ff; }
.rarity-switch button[data-rarity="void"] { --rc: #2b00ff; }
.rarity-switch button[data-rarity="exclusive"] { --rc: #ff7a45; }

/* Flat rarity colour for the rarities that have one. Legendary, celestial,
   infinity and void are excluded: they are gradients, and this rule's
   specificity (0,4,1) beats the gradient rule (0,3,1) — an opaque `color` here
   paints straight over `background-clip: text`, which is exactly why the
   selector stayed flat. */
.rarity-switch button[data-rarity]:not([data-rarity="all"]):not([data-rarity="legendary"]):not([data-rarity="celestial"]):not([data-rarity="infinity"]):not([data-rarity="void"]):hover,
.rarity-switch button[data-rarity]:not([data-rarity="all"]):not([data-rarity="legendary"]):not([data-rarity="celestial"]):not([data-rarity="infinity"]):not([data-rarity="void"])[aria-pressed="true"] {
  color: var(--rc);
}

/* Legendary, celestial, infinity and void are gradients on the cards — each one
   animates a wave across its own palette — so the selector uses the same four
   gradients instead of a flat hex. Idle stays neutral; the gradient appears on
   hover and on the active filter, where it reads as "this is that rarity". */
.rarity-switch button[data-rarity="legendary"] {
  --rc-gradient: linear-gradient(
    90deg,
    #ff0000,
    #ff8000,
    #ffff00,
    #00ff80,
    #0099ff,
    #ff0000
  );
}
.rarity-switch button[data-rarity="celestial"] {
  --rc-gradient: linear-gradient(90deg, #9ddffd, #ff9bf7, #9ddffd);
}
.rarity-switch button[data-rarity="infinity"] {
  --rc-gradient: linear-gradient(90deg, #ff0000, #6401ff, #ff0000);
}
.rarity-switch button[data-rarity="void"] {
  /* Exactly the card's gradient. Its near-black first stop is hard to read as
     text, which is accepted: it only shows on hover and on the active filter. */
  --rc-gradient: linear-gradient(90deg, #2b0001, #2b00ff, #ea00ff, #2b00ff, #2b0001);
}

.rarity-switch button[data-rarity="legendary"]:hover,
.rarity-switch button[data-rarity="celestial"]:hover,
.rarity-switch button[data-rarity="infinity"]:hover,
.rarity-switch button[data-rarity="void"]:hover,
.rarity-switch button[data-rarity="legendary"][aria-pressed="true"],
.rarity-switch button[data-rarity="celestial"][aria-pressed="true"],
.rarity-switch button[data-rarity="infinity"][aria-pressed="true"],
.rarity-switch button[data-rarity="void"][aria-pressed="true"] {
  background-image: var(--rc-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  /* The gradient only shows through a transparent `color`: an opaque one paints
     over the clipped background and the button looks flat. */
  color: transparent;
  animation: collection-rarity-wave 3.5s linear infinite;
  /* `background-clip: text` clips every background — including the active pill
     — to the glyphs, so the pill is painted with an inset shadow instead. */
  box-shadow: inset 0 0 0 100px rgba(255, 255, 255, 0.08);
}

/* The switch previously snapped between states; ease it like the rest. */
.rarity-switch button {
  transition: background 140ms ease, color 140ms ease;
}

.rarity-legendary { --dot: #ff8000; }
.rarity-legendary .rarity-dot { animation: collection-legendary-dot 2.5s linear infinite; }
@keyframes collection-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: collection-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 collection-rarity-wave {
  from { background-position: 0 0; }
  to { background-position: 200% 0; }
}



.collection-filter-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  gap: 8px;
}

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

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

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

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

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

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

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

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

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

.scroll-sentinel {
  width: 100%;
  height: 1px;
}

#load-more {
  display: none !important;
}


.card-variant {
  flex: none;
  padding: 1px 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #a8b1c2;
  font-size: 7px;
  font-weight: 600;
  white-space: nowrap;
}

.card-media {
  padding: var(--card-pad-roomy);
}

.card-media img {
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
}

/* Legacy demand chip; the colours come from the global --demand-* palette. */
.demand-pill.insane { background: color-mix(in srgb, var(--demand-insane) 12%, transparent); color: var(--demand-insane); }
.demand-pill.very-high { background: color-mix(in srgb, var(--demand-very-high) 12%, transparent); color: var(--demand-very-high); }
.demand-pill.high { background: color-mix(in srgb, var(--demand-high) 12%, transparent); color: var(--demand-high); }
.demand-pill.above-average { background: color-mix(in srgb, var(--demand-above-average) 12%, transparent); color: var(--demand-above-average); }
.demand-pill.average { background: color-mix(in srgb, var(--demand-medium) 12%, transparent); color: var(--demand-medium); }
.demand-pill.low { background: color-mix(in srgb, var(--demand-low) 12%, transparent); color: var(--demand-low); }
.demand-pill.very-low { background: color-mix(in srgb, var(--demand-very-low) 12%, transparent); color: var(--demand-very-low); }
.demand-pill.na { background: color-mix(in srgb, var(--demand-na) 10%, transparent); color: var(--demand-na); }


/* Card gap: demand flame and trend glyph indicators. */
.demand-pill svg.demand-icon {
  width: 12px;
  height: 12px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.trend {
  display: inline-flex;
  align-items: center;
}

.trend svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.trend[data-trend="rising"] { color: var(--trend-rising); }
.trend[data-trend="dropping"] { color: var(--trend-dropping); }
.trend[data-trend="unstable"] { color: var(--trend-unstable); }
.trend[data-trend="stable"],
.trend[data-trend="na"] { color: var(--trend-stable); }


/* Card demand matches the pet page: plain coloured flame text inline. */
.card-our-demand {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: var(--card-demand-size);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.card-our-demand .demand-score {
  flex: none;
}

/* Longest tier is "Above Average"; in a narrow card the word ellipsises
   instead of pushing the badge past the card edge. */
.card-our-demand .demand-tier {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-our-demand svg {
  width: var(--card-icon-size);
  height: var(--card-icon-size);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

/* Demand palette is declared once in base.v1.css (--demand-*), so cards,
   demand.gg, and the pet page cannot drift apart. */

.card-our-demand.insane { color: var(--demand-insane); }
.card-our-demand.very-high { color: var(--demand-very-high); }
.card-our-demand.high { color: var(--demand-high); }
.card-our-demand.above-average { color: var(--demand-above-average); }
.card-our-demand.average { color: var(--demand-medium); }
.card-our-demand.low { color: var(--demand-low); }
.card-our-demand.very-low { color: var(--demand-very-low); }
.card-our-demand.na { color: var(--demand-na); }

.demand-gg.low { color: var(--demand-low); }
.demand-gg.medium { color: var(--demand-medium); }
.demand-gg.high { color: var(--demand-high); }
.demand-gg.very-high { color: var(--demand-very-high); }
.demand-gg.insane { color: var(--demand-insane); }

.value-line .card-our-demand {
  margin-left: 2px;
}

/* Animated rarity borders reuse the existing rarity colour cycles. */
.pet-card {
  position: relative;
}

.pet-card::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 1px;
  border-radius: inherit;
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
}

.pet-card.rarity-legendary::after {
  background-image: linear-gradient(90deg, #ff0000, #ff8000, #ffff00, #00ff80, #0099ff, #ff0000);
  background-size: 200% 100%;
  animation: collection-rarity-wave 3.5s linear infinite;
}

.pet-card.rarity-celestial::after {
  background-image: linear-gradient(90deg, #9ddffd, #ff9bf7, #9ddffd);
  background-size: 200% 100%;
  animation: collection-rarity-wave 3.5s linear infinite;
}

.pet-card.rarity-infinity::after {
  background-image: linear-gradient(90deg, #ff0000, #6401ff, #ff0000);
  background-size: 200% 100%;
  animation: collection-rarity-wave 3.5s linear infinite;
}

.pet-card.rarity-void::after {
  background-image: linear-gradient(90deg, #2b0001, #2b00ff, #ea00ff, #2b00ff, #2b0001);
  background-size: 200% 100%;
  animation: collection-rarity-wave 3.5s linear infinite;
}

/* Hover highlight uses the pet's pre-computed dominant hex. */
.pet-card:hover,
.pet-card:focus-visible {
  border-color: color-mix(in srgb, var(--pet-hex, var(--dot, #ffffff)) 55%, transparent);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--pet-hex, var(--dot, #ffffff)) 22%, transparent),
    0 10px 26px -10px color-mix(in srgb, var(--pet-hex, var(--dot, #ffffff)) 55%, transparent);
}

.pet-card::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  background: radial-gradient(
    120% 90% at 50% 0%,
    color-mix(in srgb, var(--pet-hex, var(--dot, #ffffff)) 20%, transparent),
    transparent 62%
  );
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.pet-card:hover::before,
.pet-card:focus-visible::before {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .pet-card.rarity-legendary::after,
  .pet-card.rarity-celestial::after,
  .pet-card.rarity-infinity::after,
  .pet-card.rarity-void::after {
    animation: none;
  }
}

.pet-card-tag {
  max-width: 55%;
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #9aa3b4;
  font-size: 8px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.advanced-filter {
  position: relative;
  flex: none;
}

.advanced-filter summary {
  list-style: none;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.16);
  color: #c8d0dc;
  font-size: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.advanced-filter summary::-webkit-details-marker {
  display: none;
}

.advanced-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  z-index: 40;
  display: flex;
  min-width: 235px;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--popup-border);
  border-radius: var(--popup-radius);
  background: var(--popup-bg);
  box-shadow: var(--popup-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.advanced-panel label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #9aa3b4;
  font-size: 9px;
}

.advanced-panel input[type="color"] {
  width: 44px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.advanced-panel input[type="text"] {
  width: 90px;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.2);
  color: #e8ebf2;
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
}

.advanced-actions {
  display: flex;
  gap: 6px;
}

.advanced-actions button {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: #c8d0dc;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.advanced-actions button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.collection-toolbar {
  position: relative;
  z-index: 20;
  overflow: visible;
}

.advanced-filter:not([open]) .advanced-panel {
  display: none;
}

.advanced-filter[open] .advanced-panel {
  display: flex;
}

.advanced-filter[open] summary {
  border-color: rgba(124, 156, 255, 0.45);
  background: rgba(124, 156, 255, 0.1);
  color: #fff;
}

.collection-toolbar > .advanced-filter {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.collection-toolbar > .advanced-filter summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
}

.collection-toolbar > .advanced-filter summary svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.collection-filter-row {
  flex-wrap: wrap;
  overflow: visible;
}

.collection-toolbar > .advanced-filter summary,
.collection-filter-row .advanced-filter summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 7px;
}

.advanced-filter summary svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.advanced-filter {
  position: relative;
  display: inline-flex;
  flex: none;
}

.advanced-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  color: #fff;
  cursor: pointer;
}

.advanced-toggle:hover,
.advanced-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.advanced-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.advanced-panel[hidden] {
  display: none;
}

/* The control is a button/panel, not <details>. */
.advanced-filter .advanced-panel[hidden] {
  display: none;
}

.advanced-filter .advanced-panel:not([hidden]) {
  display: flex;
}

.advanced-panel {
  top: calc(100% + 6px);
  right: auto;
  left: 0;
  width: 280px;
  padding: 7px;
  border-color: color-mix(in srgb, var(--advanced-color, #ffd700) 32%, rgba(255, 255, 255, 0.12));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--advanced-color, #ffd700) 9%, transparent), transparent 55%),
    rgba(16, 19, 27, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.46);
}

.advanced-panel.open-left {
  right: 0;
  left: auto;
}

.advanced-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #f0f3f8;
  font: inherit;
  font-size: 11px;
  text-align: left;
  cursor: pointer;
}

.advanced-menu-item:hover,
.advanced-menu-item[aria-expanded="true"] {
  background: color-mix(in srgb, var(--advanced-color, #ffd700) 12%, rgba(255, 255, 255, 0.05));
}

.advanced-menu-item svg {
  width: 12px;
  height: 12px;
  margin-left: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  opacity: 0.65;
}

.advanced-swatch {
  width: 12px;
  height: 12px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  background: #ffd700;
}

.advanced-submenu {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 5px;
  padding: 8px 7px 6px;
  border-top: 1px solid color-mix(in srgb, var(--advanced-color, #ffd700) 20%, rgba(255, 255, 255, 0.08));
}

.advanced-submenu[hidden] {
  display: none;
}

.advanced-submenu label {
  color: #a8b1c2;
}

.advanced-panel {
  max-width: calc(100vw - 16px);
}

.advanced-panel {
  box-sizing: border-box;
}

.advanced-submenu {
  font-size: 11px;
}

.advanced-submenu label {
  color: #c0c7d4;
  font-size: 11px;
}

.advanced-panel input[type="color"] {
  width: 26px;
  height: 26px;
  padding: 2px;
  box-sizing: border-box;
}

.advanced-panel input[type="text"] {
  width: 74px;
  height: 26px;
  padding: 3px 6px;
  box-sizing: border-box;
  font-size: 11px;
}

.advanced-actions button {
  padding: 6px 9px;
  font-size: 10px;
}

.advanced-panel input[type="color"] {
  width: 74px;
}

.advanced-menu-item {
  font-size: 13px;
}

.advanced-submenu label {
  font-size: 12px;
}

.advanced-panel input[type="color"],
.advanced-panel input[type="text"] {
  width: 90px;
  height: 28px;
}

.advanced-panel input[type="text"] {
  font-size: 12px;
}

.advanced-actions button {
  font-size: 11px;
}

/* Slightly tighter selector bar, especially when the row wraps. */
.collection-toolbar {
  padding: 10px 12px;
}

.collection-row {
  min-height: 30px;
  gap: 7px;
}

.collection-filter-row {
  gap: 5px 7px;
}

.collection-toolbar {
  padding-top: 8px;
  padding-bottom: 8px;
}

.collection-filter-row {
  row-gap: 2px;
}

.collection-row {
  min-height: 28px;
}

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

/* Grid-density slider: two icon segments with a thumb that slides between
   them, so the active layout is visible at a glance. */
.grid-toggle {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  flex: none;
  height: var(--ctl-h, 32px);
  box-sizing: border-box;
  margin-left: auto;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.grid-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  /* A 26px segment *including* its border: without `border-box` the 1px border
     made the thumb 28px and it overhung the segment it was meant to sit in. */
  width: 26px;
  height: calc(100% - 4px);
  box-sizing: border-box;
  border: 1px solid rgba(var(--ui-accent-rgb), 0.38);
  border-radius: 6px;
  background: rgba(var(--ui-accent-rgb), 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    transform 220ms cubic-bezier(0.2, 0.9, 0.2, 1.1),
    background 160ms ease,
    border-color 160ms ease;
  pointer-events: none;
}

/* Segments are 26px wide and sit flush, so the pitch is 26px — translating by
   the thumb's own width lands it exactly on the second segment. */
.grid-toggle[data-mode="roomy"] .grid-toggle-thumb {
  transform: translateX(26px);
}

.grid-seg {
  position: relative;
  z-index: 1;
  display: grid;
  width: 26px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #7f889a;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 120ms ease;
}

.grid-seg:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #c3cad6;
}

.grid-seg:active {
  transform: scale(0.88);
}

.grid-seg[aria-pressed="true"] {
  color: #fff;
}

.grid-seg svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: none;
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.2, 1.1), opacity 160ms ease;
}

.grid-seg[aria-pressed="true"] svg {
  transform: scale(1.08);
}

@media (prefers-reduced-motion: reduce) {
  .grid-toggle-thumb {
    transition: none;
  }
}

/* Demand + trend badges.
   `display: contents` keeps the wrapper layout-transparent, so the roomy card
   is byte-for-byte the same as before: the badge sits after the value and the
   trend arrow keeps its `margin-left: auto` at the far right.

   Compact cards are nine across (~140px), where value + badges on one line
   overflow. Dropping the group to a full-width second row makes it fit at any
   width instead of relying on a breakpoint. */
.value-tags {
  display: inline-flex;
  order: -1;
  flex: 0 0 100%;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.collection-body.compact .value-tags {
  display: inline-flex;
  /* Above the value rather than below it, and full width so the arrow can sit
     at the right edge. `order` keeps the DOM the same for the roomy layout. */
  order: -1;
  flex: 0 0 100%;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

/* Every glyph is drawn inside a 24x24 box, so its visible ink starts 3.5px in
   at this size. Pull that back or the icon reads as indented from the value
   text below it. */
.collection-body.compact .value-tags .demand-icon {
  margin-left: -3.5px;
}

/* The badge row spans the card, so the arrow stays pinned to the right edge
   with the label on the left. */
.collection-body.compact .value-tags .trend {
  margin-left: auto;
}

.collection-body.compact .value-line {
  /* A little air between the value and the badge row beneath it. */
  row-gap: 5px;
}

/* Allow the label to shrink (and ellipsis) so a long tier cannot overflow. */
.collection-body.compact .value-tags .card-our-demand {
  flex: 0 1 auto;
  min-width: 0;
  /* The roomy row uses a 2px nudge to separate the badge from the value; on its
     own row that nudge only pushes the label out of line with the value text. */
  margin-left: 0;
}


@media (max-width: 760px) {
  .advanced-filter {
    position: static;
  }

  .advanced-panel {
    right: 0;
    left: 0;
    width: auto;
  }
}

/* The category/utility controls live in a wrapper so mobile can scroll them as
   one row while desktop keeps the original single-line order. */
.filter-scroll {
  display: contents;
}

.values-filter-row .filter-scroll > .segmented,
.collection-filter-row .filter-scroll > .segmented { order: 1; }
.values-filter-row .filter-scroll > .values-divider:nth-of-type(1),
.collection-filter-row .filter-scroll > .collection-divider:nth-of-type(1) { order: 2; }
.values-filter-row .filter-scroll > .rarity-switch,
.collection-filter-row .filter-scroll > .rarity-switch { order: 3; }
.values-filter-row .filter-scroll > .values-divider:nth-of-type(2),
.collection-filter-row .filter-scroll > .collection-divider:nth-of-type(2) { order: 4; }
.values-filter-row > .collection-search,
.collection-filter-row > .collection-search { order: 5; }
.values-filter-row > .collection-sort,
.collection-filter-row > .collection-sort { order: 6; }
.values-filter-row > .advanced-filter,
.collection-filter-row > .advanced-filter { order: 7; }
.values-filter-row .filter-scroll > #sort-dir,
.collection-filter-row .filter-scroll > #sort-dir { order: 8; }
.values-filter-row .filter-scroll > .switch-label,
.collection-filter-row .filter-scroll > .switch-label { order: 9; }
.values-filter-row .filter-scroll > .grid-toggle,
.collection-filter-row .filter-scroll > .grid-toggle { order: 10; }

@media (max-width: 760px) {
  .values-filter-row,
  .collection-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px 7px;
    overflow: visible;
  }

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

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

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

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

  .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;
  }

  .filter-scroll::-webkit-scrollbar {
    display: none;
  }

  .filter-scroll > * {
    flex: none;
    order: 0;
  }
}
