/* app-ghostie.css — the composed ghostie mascot and the closet screen.
 *
 * The renderer emits every layer as a percentage of the composed frame (see
 * app-ghostie.js), so nothing here may change the frame's internal geometry:
 * the rules below only place the frame, tint it and dress the closet chrome.
 * `--ghostie-size` is the ghost-body width in px, set inline on `.ghostie`.
 */

/* ---------------------------------------------------------- composed ghostie */

.ghostie {
  position: relative;
  /* A hat legitimately pokes out of the top of the frame, exactly as it does
     in GhostieView (SwiftUI frames do not clip). Never clip this box. */
  overflow: visible;
  isolation: isolate;
  flex: none;
}

.ghostie-body-wrap {
  position: absolute;
  filter: drop-shadow(
    0 calc(var(--ghostie-size, 96px) * 0.06) calc(var(--ghostie-size, 96px) * 0.17)
      rgba(61, 56, 53, 0.16)
  );
}

.ghostie-body {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ghostie-layer {
  position: absolute;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.ghostie-layer.is-missing {
  display: none;
}

/* ---------------------------------------------------------- podium avatars */

.xp-podium-ghostie {
  /* The frame reserves headroom around the body (1.55 x 1.75 of it). Claw most
     of that back so a podium card stays a podium card — the hat still shows. */
  margin: calc(var(--ghostie-size, 64px) * -0.14) auto calc(var(--ghostie-size, 64px) * -0.1);
}

/* --------------------------------------------------------------- closet */

body.in-telegram #app[data-screen="closet"] {
  padding-top: calc(var(--safe-top) + 46px);
}

/* CharacterCustomizationView's split: the stage sits on the bare paper and the
   drawer is a white sheet pulled up over the bottom edge of the screen. The
   grid inside it is the one thing with no ceiling, and it is the only scroller. */
.closet-shell {
  gap: 0;
}

.closet-stage {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
}

.closet-stage-figure {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  transform: rotate(-2deg);
}

.closet-back {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
}

/* A short viewport shrinks the stage, never the drawer: the grid keeps its
   three rows and the ghostie's hat still has headroom. */
@media (max-height: 740px) {
  .closet-stage-figure {
    transform: rotate(-2deg) scale(0.82);
  }

  .closet-stage {
    gap: 6px;
  }
}

.closet-name-pill {
  position: relative;
  z-index: 3;
  flex: none;
  padding: 7px 15px;
  border-radius: var(--radius-pill);
  background: var(--butter);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  transform: rotate(-1.5deg);
  box-shadow: var(--shadow-sticker);
}

.closet-drawer {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  flex: 0 0 58%;
  min-height: 0;
  /* Bleeds through #app's padding so the sheet reaches all three edges. */
  margin: 0 -16px calc(-1 * (var(--safe-bottom) + 12px));
  border-radius: 36px 36px 0 0;
  background: var(--surface);
  box-shadow: 0 -8px 24px rgba(61, 56, 53, 0.12);
  overflow: hidden;
}

.closet-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 18px 4px calc(var(--safe-bottom) + 18px);
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
  scrollbar-width: none;
}

.closet-rail::-webkit-scrollbar,
.closet-grid::-webkit-scrollbar,
.closet-swatches::-webkit-scrollbar {
  display: none;
}

.closet-shelf {
  display: grid;
  gap: 4px;
  flex: none;
  justify-items: center;
  padding: 0;
  color: var(--ink-soft);
}

.closet-shelf-tile {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-feather);
  transition: background 140ms ease, color 140ms ease;
}

.closet-shelf svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.closet-shelf-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
}

.closet-shelf.is-active {
  color: var(--ink);
}

.closet-shelf.is-active .closet-shelf-tile {
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow-action);
}

.closet-shelf.is-active .closet-shelf-label {
  font-weight: 900;
}

.closet-shelf-new {
  position: absolute;
  top: -6px;
  right: -8px;
  padding: 2px 5px;
  border-radius: var(--radius-pill);
  background: var(--pink);
  color: var(--ink);
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.04em;
}

/* The title stays put and only the grid scrolls (ClosetContentView), with the
   same soft fade over its bottom edge. */
.closet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.closet-panel::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: calc(var(--safe-bottom) + 26px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface));
  pointer-events: none;
}

.closet-panel-head {
  display: flex;
  flex: none;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 12px;
}

.closet-panel-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
}

.closet-panel-count {
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
}

.closet-panel-empty {
  display: grid;
  gap: 10px;
  padding: 18px 16px;
}

.closet-panel-empty .serif-title {
  font-size: 19px;
}

.closet-grid,
.closet-swatches {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 16px calc(var(--safe-bottom) + 26px);
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  align-content: start;
}

.closet-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.closet-item {
  position: relative;
  display: grid;
  gap: 5px;
  align-content: center;
  justify-items: center;
  min-height: 84px;
  padding: 10px 6px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: var(--bg);
  text-align: center;
  transition: transform 120ms ease;
}

.closet-item:active {
  transform: scale(0.96);
}

.closet-item-art {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 34px;
}

.closet-item-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.closet-item-img.is-missing {
  display: none;
}

/* One or the other, never both: the dashed outline is the stand-in for art
   that has not shipped, so it goes as soon as the real sticker is there. */
.closet-item-art.has-art .closet-item-placeholder {
  visibility: hidden;
}

.closet-item-placeholder {
  width: 100%;
  height: 100%;
  fill: rgba(61, 56, 53, 0.05);
  stroke: rgba(61, 56, 53, 0.28);
  stroke-width: 1.6;
  stroke-dasharray: 5 4;
  vector-effect: non-scaling-stroke;
}

.closet-item-placeholder * {
  vector-effect: non-scaling-stroke;
}

.closet-item-name {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.closet-item.is-selected {
  border-color: var(--ink);
  background: var(--surface);
}

/* "Coming soon", not a padlock: unavailable art is art that has not shipped,
   never a reward waiting behind a challenge. */
.closet-item.is-locked .closet-item-art,
.closet-item.is-pending .closet-item-art {
  opacity: 0.4;
}

.closet-item.is-locked .closet-item-name {
  color: rgba(61, 56, 53, 0.35);
}

.closet-item.is-pending {
  opacity: 0.72;
}

.closet-item-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  padding: 3px 6px;
  border-radius: var(--radius-pill);
  background: var(--wash);
  color: rgba(61, 56, 53, 0.5);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
}

.closet-item[disabled] {
  cursor: default;
}

.closet-item.is-skeleton {
  background: linear-gradient(90deg, var(--wash), rgba(255, 255, 255, 0.7), var(--wash));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.closet-swatches {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.closet-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  background-clip: padding-box;
  box-shadow: 0 3px 6px rgba(61, 56, 53, 0.1);
  transition: transform 120ms ease;
}

.closet-swatch:active {
  transform: scale(0.92);
}

.closet-swatch.is-selected {
  border-color: var(--ink);
}
