/* /badges/: the badges page as one centred card. Folder-tab
   title above the card with the filter box beside it; inside, the tile grid
   on the left (the one in-card scroll region) and the selected badge's
   detail on the right. Below 820px the panes stack and the page scrolls. */

.badges-beta-search {
  display: block;
  width: min(16rem, 100%);
}

.badges-beta-tools {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

@media (min-width: 820px) {
  .badges-beta-tools {
    flex-wrap: nowrap;
    justify-content: flex-end;
  }

  .badges-beta-search {
    width: 12.5rem;
  }
}

.badges-beta-sort > summary.btn {
  height: 2rem;
  min-height: 0;
  padding-block: 0;
  white-space: nowrap;
}

.badges-beta-search .rares-filter-input {
  width: 100%;
  max-width: none;
  height: 2rem;
  min-height: 0;
  padding-block: 0;
  font-size: 0.84rem;
}

/* Tiles: a lattice square with the badge art; the open one takes the accent. */
.badges-beta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.badges-beta-tile {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid var(--content-box-border);
  /* A faint 8px pixel grid behind each badge, drawn from the box border
     colour so it reads on both the dark and the light floor. */
  --badges-tile-line: color-mix(in srgb, var(--content-box-border) 70%, transparent);
  background-color: var(--stage-floor);
  background-image:
    linear-gradient(to right, var(--badges-tile-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--badges-tile-line) 1px, transparent 1px);
  background-size: 8px 8px;
  background-position: center;
  box-shadow: var(--control-shadow-soft);
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

/* Native pixels, centered in the tile. A fixed box stretches non-square
   art (HC1 is 33x39, FSH is 40x31) and scales pixel art by a fraction. */
.badges-beta-tile img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  pointer-events: none;
}

.badges-beta-tile:hover,
.badges-beta-tile:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--content-box-border));
  outline: none;
}

.badges-beta-tile.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent), var(--control-shadow-soft);
}

.badges-beta-tile[hidden] {
  display: none;
}

.badges-beta-nomatch {
  margin: 0.5rem 0 0;
}

/* Detail pane: the badge's room. A stage the width of the pane with a wall
   strip (code plate, hotels, Open) over a lattice floor where the badge
   stands at three times its pixels, its name on a plaque at its feet. Then
   the facts strip, the owners chart with its last days as chips, and the
   recent owners as two rows of heads on a shelf. Plates and the hover tip
   are dark in both themes, like the site header. The detail is a size
   container: the facts strip and the shelf pick their columns from its
   width, so the stacked phone layout and the desktop pane share one sheet. */
.badges-beta-detail {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.badges-beta-stage,
.badges-beta-shelf {
  --badges-lobby-line: color-mix(in srgb, var(--fg) 14%, transparent);
  position: relative;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid var(--control-border);
  background-color: var(--stage-floor);
  background-image:
    linear-gradient(26.57deg, transparent 49.4%, var(--badges-lobby-line) 49.4% 50.6%, transparent 50.6%),
    linear-gradient(-26.57deg, transparent 49.4%, var(--badges-lobby-line) 49.4% 50.6%, transparent 50.6%);
  background-size: 64px 32px, 64px 32px;
  overflow: hidden;
}

.badges-beta-shelf {
  background-size: 32px 16px, 32px 16px;
}

.badges-beta-stage-wall,
.badges-beta-shelf-wall {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
  padding: 0 0.45rem;
  background: color-mix(in srgb, var(--fg) 7%, var(--control-bg));
  border-bottom: 2px solid rgba(0, 0, 0, 0.28);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
}

.badges-beta-stage-wall {
  height: 34px;
}

.badges-beta-shelf-wall {
  height: 22px;
}

.badges-beta-plate {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 1 auto;
  height: 16px;
  min-width: 0;
  margin: 0;
  padding: 0 0.45rem;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: #1e242c;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  color: #e8eef4;
  font-size: 0.6rem;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges-beta-plate .badges-beta-code {
  letter-spacing: 0.08em;
}

.badges-beta-plate-sep {
  opacity: 0.55;
}

.badges-beta-code {
  font-family: var(--font-pixel);
  -webkit-font-smoothing: none;
}

.badges-beta-stage-hotels {
  display: inline-flex;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.badges-beta-stage-hotels .badges-chip {
  padding: 0.08rem 0.35rem;
  font-size: 0.6rem;
}

.badges-beta-open {
  flex: 0 0 auto;
  min-height: 1.5rem;
  padding: 0 0.5rem;
  font-size: 0.7rem;
}

.badges-beta-stage-floor {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 0.75rem 0.75rem;
}

/* No accent tile under the badge (owner's call, 2026-11-14). */
/* Three times the badge's pixels (twice on a short viewport): the art keeps
   its own size and is scaled by a whole number, so a 33×39 badge is not
   stretched into a square and every pixel stays square. */
.badges-beta-stage-mark {
  --badges-mark-scale: 3;
  position: relative;
  display: grid;
  place-items: center;
  width: calc(48px * var(--badges-mark-scale));
  /* A little under the tallest art; the few 48px badges lean into the
     floor's padding instead of every badge standing in a taller room. */
  height: calc(44px * var(--badges-mark-scale));
}

.badges-beta-stage-mark img {
  width: auto;
  height: auto;
  max-width: 48px;
  max-height: 48px;
  transform: scale(var(--badges-mark-scale));
  transform-origin: center;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.badges-beta-stage-fallback {
  font-size: 1.2rem;
  color: var(--muted);
}

.badges-beta-stage-name {
  position: relative;
  max-width: 100%;
  margin: 0.4rem 0 0;
  padding: 0.15rem 0.8rem;
  border-radius: 3px;
  border: 1px solid var(--control-border);
  background: var(--content-box-bg, var(--surface-inset));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  font-size: 1.05rem;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.badges-beta-desc {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Facts strip: owners, first seen, and the hotel scope as three cells with
   a rule between them. In a narrow detail the scope drops to its own row. */
.badges-beta-facts {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) auto;
  margin: 0;
  border-radius: 6px;
  border: 1px solid var(--content-box-border);
  background: var(--inset-bg);
}

.badges-beta-facts > div {
  min-width: 0;
  padding: 0.45rem 0.75rem 0.5rem;
}

.badges-beta-facts > div + div {
  border-left: 1px solid var(--content-box-border);
}

.badges-beta-facts dt {
  margin: 0 0 0.2rem;
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  -webkit-font-smoothing: none;
}

.badges-beta-facts dd {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 0.95rem;
  line-height: 1.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-font-smoothing: none;
}

.badges-beta-facts-switch dd {
  overflow: visible;
}

.badges-beta-facts-switch .hotel-switch {
  gap: 0.2rem;
}

.badges-beta-facts-switch .hotel-switch .btn {
  min-height: 1.5rem;
  padding: 0 0.5rem;
  font-size: 0.7rem;
}

@container (max-width: 380px) {
  .badges-beta-facts {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  }

  .badges-beta-facts > .badges-beta-facts-switch {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding-block: 0.35rem;
    border-left: 0;
    border-top: 1px solid var(--content-box-border);
  }

  .badges-beta-facts-switch dt {
    margin: 0;
  }
}

.badges-beta-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0 0.35rem;
}

.badges-beta-section-head h3 {
  flex: 0 0 auto;
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
}

.badges-beta-section-head > span,
.badges-beta-section-head > a {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.badges-beta-chart.rare-price-history-chart {
  height: 6rem;
  margin: 0 0 0.4rem;
}

/* The last days as chips: date, new owners, running total. However many
   there are, they share the row. */
.badges-beta-days {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges-beta-day {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "date new"
    "total new";
  align-items: center;
  column-gap: 0.35rem;
  min-width: 0;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--content-box-border);
  background: var(--inset-bg);
  -webkit-font-smoothing: none;
}

/* A narrow detail has room for three: the oldest of four sits out. */
@container (max-width: 419px) {
  .badges-beta-day:nth-last-child(n + 4) {
    display: none;
  }
}

.badges-beta-day-date {
  grid-area: date;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badges-beta-day-total {
  grid-area: total;
  font-size: 0.72rem;
}

.badges-beta-day-new {
  grid-area: new;
  font-size: 0.86rem;
  color: var(--success);
}

.badges-beta-more {
  flex: 0 0 auto;
  font-size: 0.6rem;
  line-height: 1;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}

.badges-beta-more:hover,
.badges-beta-more:focus-visible {
  color: var(--fg);
  text-decoration: none;
}

.badges-beta-more:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.badges-beta-empty {
  margin: 0.25rem 0 0;
}

.badges-beta-shelf-empty {
  margin: 0;
  padding: 0.6rem 0.5rem;
}

/* Owners: heads on the floor, a name plaque each; the badge pinned to the
   head of anyone wearing it, a green dot on anyone online. Two rows: six
   to a row when the detail is wide enough, otherwise five (the page sends
   twelve, so the last two sit out). */
.badges-beta-shelf-floor {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  row-gap: 0.55rem;
  margin: 0;
  padding: 0.6rem 0.2rem 0.5rem;
  list-style: none;
}

.badges-beta-stand:nth-child(n + 11) {
  display: none;
}

@container (min-width: 420px) {
  .badges-beta-shelf-floor {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .badges-beta-stand:nth-child(n + 11) {
    display: flex;
  }
}

.badges-beta-stand {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.badges-beta-owner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}

.badges-beta-owner:hover,
.badges-beta-owner:focus-visible {
  text-decoration: none;
}

.badges-beta-owner:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.badges-beta-owner-head {
  position: relative;
  width: 36px;
  height: 36px;
}

.badges-beta-owner-head img:first-child,
.badges-beta-owner-blank {
  display: block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--control-border);
  background: var(--surface-raised);
  image-rendering: pixelated;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.badges-beta-owner:hover .badges-beta-owner-head img:first-child,
.badges-beta-owner:focus-visible .badges-beta-owner-head img:first-child {
  border-color: var(--accent);
}

.badges-beta-owner-pin {
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: auto;
  height: 16px;
  max-width: 20px;
  image-rendering: pixelated;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.5));
}

.badges-beta-owner-head.is-online::after {
  content: "";
  position: absolute;
  left: -1px;
  bottom: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--stage-floor);
  background: var(--success);
}

.badges-beta-owner-name {
  max-width: 100%;
  margin-top: 2px;
  padding: 0 4px;
  border-radius: 3px;
  border: 1px solid var(--control-border);
  background: var(--content-box-bg, var(--surface-inset));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  font-size: 0.6rem;
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-font-smoothing: none;
}

/* Hotel, last seen and state, above the head on hover or focus. Edge
   stands pin it to the shelf's side so it is not cut by the overflow. */
.badges-beta-tip {
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: #1e242c;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.62rem;
  line-height: 1.2;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.badges-beta-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -5px;
  margin-left: -5px;
  border: 5px solid transparent;
  border-top-color: #1e242c;
  border-bottom: 0;
}

.badges-beta-stand:nth-child(5n + 1) .badges-beta-tip {
  left: 0;
  transform: none;
}

.badges-beta-stand:nth-child(5n + 1) .badges-beta-tip::after {
  left: 18px;
}

.badges-beta-stand:nth-child(5n) .badges-beta-tip {
  left: auto;
  right: 0;
  transform: none;
}

.badges-beta-stand:nth-child(5n) .badges-beta-tip::after {
  left: auto;
  right: 13px;
}

/* Six to a row: the edge stands are the 1st and 6th of each row instead. */
@container (min-width: 420px) {
  .badges-beta-stand:nth-child(n) .badges-beta-tip {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }

  .badges-beta-stand:nth-child(n) .badges-beta-tip::after {
    left: 50%;
    right: auto;
  }

  .badges-beta-stand:nth-child(6n + 1) .badges-beta-tip {
    left: 0;
    transform: none;
  }

  .badges-beta-stand:nth-child(6n + 1) .badges-beta-tip::after {
    left: 18px;
  }

  .badges-beta-stand:nth-child(6n) .badges-beta-tip {
    left: auto;
    right: 0;
    transform: none;
  }

  .badges-beta-stand:nth-child(6n) .badges-beta-tip::after {
    left: auto;
    right: 13px;
  }
}

.badges-beta-owner:hover .badges-beta-tip,
.badges-beta-owner:focus-visible .badges-beta-tip {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: reduce) {
  .badges-beta-tip {
    transition: none;
  }
}

.badges-beta-pane.is-loading {
  opacity: 0.6;
}

/* The card, once there is room for two panes. */
@media (min-width: 820px) {
  body.badges-centered-page {
    display: flex;
    flex-direction: column;
  }

  .badges-centered-page .badges-wrap {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: min(980px, calc(100% - 2rem));
    margin: 0 auto;
    padding: var(--habbend-page-top, 1.5rem) 0 2rem;
  }

  .badges-centered-page .badges-wrap > .site-header,
  .badges-centered-page .badges-wrap > .site-footer {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .badges-centered-page .badges-wrap > .site-footer {
    margin-top: 0;
    padding-bottom: 1.25rem;
  }

  /* The card grows with the grid so every badge shows; a filtered-down
     list still keeps the card height. */
  .badges-centered-page .badges-centered-main {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: var(--badges-centered-card-h, 579px);
  }

  .badges-centered-page .badges-centered-card {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    /* Near half each: the tiles only need room for 48px art, the detail
       needs the width for its chart, facts and two rows of owners. */
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    /* clip, not hidden: hidden would make the card a scroll container and
       pin the sticky detail pane to it instead of the viewport. */
    overflow: clip;
    background: var(--content-box-bg);
    border: 1px solid var(--content-box-border);
    border-radius: var(--content-box-radius);
    box-shadow: var(--content-box-shadow);
  }

  /* Title strip across both panes, the filter box at its right. */
  .badges-centered-page .badges-beta-toolbar {
    margin: 0 0 1rem;
    padding: 0;
    background: transparent;
    border-bottom: 0;
    align-items: center;
  }

  .badges-centered-page .badges-beta-pane {
    min-width: 0;
    min-height: 0;
    padding: 0.8rem 0.9rem;
  }

  /* Every badge shows; the page scrolls, not the pane. */
  .badges-centered-page .badges-beta-pane--grid {
    border-right: 1px solid var(--content-box-border);
    background: var(--field-bg);
  }

  .badges-centered-page .badges-beta-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.4rem;
  }

  /* The detail rides along as the grid scrolls past, and scrolls on its
     own only when it is taller than the viewport. */
  .badges-centered-page .badges-beta-pane--detail {
    position: sticky;
    top: 0.75rem;
    align-self: start;
    max-height: calc(100dvh - 1.5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

/* A short desktop viewport: the badge back at twice its pixels and one row
   of owners, so the sticky detail still fits without its own scrollbar. */
@media (min-width: 820px) and (max-height: 800px) {
  .badges-centered-page .badges-beta-stage-mark {
    --badges-mark-scale: 2;
  }

  .badges-centered-page .badges-beta-stand:nth-child(n + 6) {
    display: none;
  }

  @container (min-width: 420px) {
    .badges-centered-page .badges-beta-stand:nth-child(6) {
      display: flex;
    }

    .badges-centered-page .badges-beta-stand:nth-child(n + 7) {
      display: none;
    }
  }
}
