/* The avatar picker (ProfilePicker variant of the blue popup): theme sections, tiles, preview and CTA. Units via --u. */

.profile__scroll {
  position: relative; /* the tiles' offsetParent (Profile.js useWholeRows measures layout positions) */
  padding: calc(52 * var(--u)) calc(48 * var(--u)) calc(44 * var(--u));
  scroll-padding-top: calc(52 * var(--u));
  /* the rail below stands in for the browser's scroll bar */
  scrollbar-width: none;
}
.profile__scroll::-webkit-scrollbar {
  display: none;
}
/* The area ends on whole tile rows (Profile.js useWholeRows), so at rest nothing is faded; once it has scrolled,
   rows pass under its edges and the lower edge softens them like the upper one */
.fade-scroll.profile__scroll.has-more:not(.is-scrolled) {
  --fade-bottom: 0px;
}
.fade-scroll.profile__scroll.has-more.is-scrolled {
  --fade-bottom: calc(40 * var(--u));
}
/* The scroll rail (Profile.js useRail): a slim track and thumb in the white panel's right margin, beside the tile
   grid, so a picker that ends on a whole row still shows that more rows follow */
/* the scroll rail (.scroll-rail, components.css) in this panel's right margin */
.profile-rail {
  right: calc(15 * var(--u));
}
.profile-theme + .profile-theme {
  margin-top: calc(41 * var(--u));
}
/* AvatarThemeSection: a 48 unit header (Rubik SemiBold 30, upper case, character spacing 12), 16 units of spacing,
   then the tile grid with 24 units between tiles */
.profile-theme h2 {
  height: calc(48 * var(--u));
  display: flex;
  align-items: center;
  font-weight: var(--w-semibold);
  font-size: calc(30 * var(--u));
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5f6877;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: calc(24 * var(--u));
  margin-top: calc(16 * var(--u));
}

/* a tile: pale square, the avatar, a price chip flush with its lower edge, a check once picked (AvatarTile.prefab) */
.avatar-tile {
  position: relative;
  container-type: inline-size; /* the price badge is sized in cqw, a share of the tile's width */
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: calc(30 * var(--u));
  background: #eef3fb;
  transition: background var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.avatar-tile:hover {
  background: #e3ecf9;
}
.avatar-tile:active {
  transform: scale(0.96);
}
.avatar-tile.is-selected {
  background: #d3eedb;
}
/* The 3:2 avatar art (its drawing fills the art's height) centred in the tile at about 60 % of the tile's
   height, as in the native picker; with a price badge it rises and is a little smaller, so the drawing ends well
   above the badge (the badge never covers a face). */
.avatar-tile__img {
  position: absolute;
  left: 2%;
  top: 19%;
  width: 96%;
  height: 62%;
  object-fit: contain;
  animation: fade-in var(--t-fast) var(--ease-out) both;
}
.reduced-motion .avatar-tile__img {
  animation: none;
}
.avatar-tile.has-price .avatar-tile__img {
  top: 5%;
  height: 56%;
}
/* The price badge (AvatarTile.prefab PriceChip: a dark pill that sits 8 units above the tile's foot, 34 units high
   on a 153 unit tile, padding 12 left and 14 right, 5 between the 22 unit coin and the 22 unit Bold price). Drawn
   in cqw on the tile: fully inside it with its own rounded corners, the padding balanced optically (the coin's art
   has air of its own on its left, the digits none on their right). */
.avatar-tile__price {
  position: absolute;
  left: 50%;
  bottom: 6.5cqw;
  transform: translateX(-50%);
  height: 24cqw;
  padding: 0 9cqw 0 7.5cqw;
  display: flex;
  align-items: center;
  gap: 3.5cqw;
  border-radius: 8cqw;
  background: rgba(23, 28, 38, 0.9);
  white-space: nowrap;
  transition: opacity var(--t-fast) var(--ease-out);
}
/* a price badge waits for its avatar (no badge on an empty tile) and appears with it */
.avatar-tile.is-pending .avatar-tile__price {
  opacity: 0;
}
.avatar-tile__price img {
  width: 16cqw;
  height: 16cqw;
  object-fit: contain;
  flex: none;
}
.avatar-tile__price b {
  font-weight: var(--w-bold);
  font-size: 17cqw;
  line-height: 1;
  color: #ffc93c;
  font-variant-numeric: tabular-nums;
}
.avatar-tile__check {
  position: absolute;
  right: calc(10 * var(--u));
  top: calc(10 * var(--u));
  width: calc(40 * var(--u));
  height: calc(40 * var(--u));
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--brand-green);
  box-shadow: 0 calc(2 * var(--u)) calc(4 * var(--u)) rgba(27, 37, 89, 0.2);
  animation: pop-in var(--t-med) var(--ease-spring);
}
.avatar-tile__check svg {
  width: 70%;
  height: 70%;
}

/* ---- footer: the preview, the one CTA and its error line ------------------------------------------------ */
/* the footer shares the grid's side margins, so the preview line starts on the grid's left edge and the CTA
   spans the grid's width; under the CTA only the frame's own white margin remains (about 90 units, native) */
.profile-footer {
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: calc(19 * var(--u));
  padding: calc(26 * var(--u)) calc(48 * var(--u)) calc(24 * var(--u));
}
.profile-preview {
  display: flex;
  align-items: center;
  gap: calc(28 * var(--u));
  height: calc(100 * var(--u));
  padding: 0;
  font-weight: var(--w-medium);
  font-size: calc(40 * var(--u));
  color: #1a2933;
}
.profile-preview.is-empty {
  color: rgba(26, 41, 51, 0.45);
}
.profile-preview__img {
  width: calc(96 * var(--u));
  height: calc(96 * var(--u));
  object-fit: contain;
}
.profile-footer .btn {
  --btn-h: calc(80 * var(--u));
  --btn-font: calc(34 * var(--u));
  width: 100%;
}
.profile-cta.is-short {
  cursor: default;
}
.profile-cta.is-short .btn__cost {
  color: #e5483a;
  text-shadow: none;
}
.profile-cta.is-short .btn__cost img {
  filter: grayscale(1) brightness(0.8);
}
.profile-error {
  text-align: center;
  font-weight: var(--w-medium);
  font-size: calc(26 * var(--u));
  color: #e0503f;
}
.profile-error[hidden] {
  display: none;
}

@media (max-width: 759px) {
  /* four columns, as the native picker: twelve PEOPLE and the ANIMAL heading peeking under them */
  .profile-grid { gap: 10px; }
}

/* ---- wide: a larger frame where the window is tall enough ---------------------------------------------- */
/* The popup is drawn at 0.46 to 0.52 px per unit on a wide screen (settings.css); the picker has the most to
   show, so on a tall window it takes up to 0.66 px (tiles of about 100 px) and the scrolling area shows more whole
   rows. Shorter windows keep the 0.46 px floor. */
.layout-wide .blue-popup.profile {
  --u: clamp(0.46px, calc((var(--vh, 100dvh) - 48px) / 1500), 0.66px);
}

/* A landscape window of 1000 px and more has the room for a wider frame with six columns (two rows of PEOPLE, one
   row for each other theme): more avatars in view, in whole rows. */
@media (min-width: 1000px) and (orientation: landscape) {
  .layout-wide .blue-popup.profile {
    --pw: min(calc(100vw - 196px), calc(1180 * var(--u)));
  }
  .layout-wide .profile-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
