/*
 * Anon Army's motto under its badge in sign-up (ConnectingToCorp2,
 * Orientation2). Webapp sets SN Corp's one-line motto across the bottom of the
 * 192px logo slot; Anon Army's runs to two lines, centred.
 */
.snc-logo-wrapper .sui-text-header {
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  margin: 0 auto;
  text-align: center;
}

/*
 * Short screens. Webapp's logos are in a fixed 192px box: on the connecting
 * screens (ConnectingToCorp1 and 2) positioned with nothing around it
 * positioned, so it spills over the nav and the dialogue panel, outside the
 * screen's own scrolling; in Orientation2 cropped. Here the screen holds it and
 * it shrinks to fit; with no room for the motto, the badge stands alone, in the
 * middle.
 */
.sui-page-body-screen-content:has(> .connecting-logo-swap-container),
.full-screen-content-container:has(.snc-logo-wrapper) {
  position: relative;
  overflow: hidden;
  container: anon-logo / size;
}

.full-screen-content-container:has(.snc-logo-wrapper) .common-layout-col {
  padding-block: 0;
}

.connecting-logo-swap-container,
.snc-logo-wrapper {
  width: min(192px, 100cqh);
  height: min(192px, 100cqh);
}

.connecting-logo-swap-container .glitch-logo {
  box-sizing: border-box;
  width: 100%;
  padding: 16.667%;
}

.snc-logo {
  width: 100%;
}

@container anon-logo (max-height: 160px) {
  .snc-logo {
    transform: translateY(11%);
  }

  .snc-logo-wrapper .sui-text-header {
    display: none;
  }
}

/*
 * A player's own picture (anon/runtime/pfp.js), over the generated layers.
 * Webapp's layers are always 72px, centred and raised 4px, since the robot art
 * is drawn to be cropped by each portrait (40px in the HUD, 44px in result
 * rows, 72px in the profile and sign-up). A player's picture instead covers
 * whatever portrait holds it: whole, except an Anons NFT from this site's
 * gallery. Those are a character with room around it, faceless at 40px, so they
 * are zoomed to 140% from near the top, where the head (and any tall hat) is,
 * with the overflow hidden by the portrait. The extra `html` outranks webapp's
 * `.sui-screen-portrait-image .pfp-viewer-layer` and
 * `.sui-result-row-portrait img.pfp-viewer-layer` rules.
 */
html img.pfp-viewer-layer.anon-pfp-url {
  --anon-pfp-zoom: 100%;
  top: 50%;
  left: 50%;
  width: var(--anon-pfp-zoom);
  height: var(--anon-pfp-zoom);
  max-width: none;
  max-height: none;
  transform: translate(-50%, -50%);
  object-fit: cover;
}

html img.pfp-viewer-layer.anon-pfp-url.anon-mod-anon {
  --anon-pfp-zoom: 140%;
  top: -4%;
  transform: translate(-50%, 0);
}

/*
 * The Anon gallery (anon/runtime/gallery.js), over the sign-up profile screen
 * or the player's own profile. Its controls are SUI's own (the screen nav's
 * tabs, screen buttons, text input, close link); this lays it over the screen
 * as one edge-to-edge scroll per collection, and outlines the picture found by
 * number, and the one chosen, in the player's highlight colour.
 */
.anon-gallery-host {
  position: relative;
}

.anon-gallery {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--page-background);
  container: anon-gallery / size;
}

/* The page under an open gallery stays put: scrolled, it would carry the gallery off. */
#menu-page-screen-body:has(.anon-gallery) {
  overflow: hidden;
}

.anon-gallery-layout {
  box-sizing: border-box;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  padding: var(--spacing-lg) var(--spacing-xl);
}

.anon-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* The collections, as the menu's own nav tabs; scrolled sideways if narrow. */
.anon-gallery-tabs {
  justify-content: flex-start;
  gap: var(--spacing-sm);
  overflow-x: auto;
  scrollbar-width: none;
  flex: 0 0 auto;
}

.anon-gallery-tabs .sui-screen-nav-item,
.anon-gallery-tabs .sui-screen-nav-item:link,
.anon-gallery-tabs .sui-screen-nav-item:visited {
  color: var(--accent-primary);
  border-bottom: 2px solid transparent;
}

.anon-gallery-tabs .sui-screen-nav-item:hover,
.anon-gallery-tabs .sui-screen-nav-item.sui-mod-active {
  color: var(--accent-primary-active);
}

.anon-gallery-tabs .sui-screen-nav-item.sui-mod-active {
  border-bottom-color: var(--accent-primary-active);
}

.anon-gallery .common-inline-text-input-controls-container {
  justify-content: flex-start;
  gap: var(--spacing-md);
}

.anon-gallery-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* gallery.js keeps the view in place as rows are added above it. */
  overflow-anchor: none;
}

.anon-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0;
  /* Room for a found picture, lifted at the edge of the gallery. */
  padding: 10px;
}

.anon-gallery-tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: var(--surface-default);
  cursor: pointer;
}

.anon-gallery-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The outline sits inside the tile, so it never overlaps a neighbour. */
.anon-gallery-tile::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}

button.anon-gallery-tile:hover::after,
button.anon-gallery-tile:focus-visible::after {
  box-shadow: inset 0 0 0 2px var(--text-player-highlight);
}

.anon-gallery-tile.sui-mod-active {
  border-bottom: none;
}

.anon-gallery-tile.sui-mod-active::after {
  box-shadow: inset 0 0 0 3px var(--text-player-highlight);
}

/*
 * Found by number: lifted over its neighbours, with a solid border in the
 * player's highlight colour and a glow that pulses as it comes into view.
 */
.anon-gallery-tile.anon-mod-found {
  z-index: 2;
  transform: scale(1.15);
  box-shadow: 0 0 0 3px var(--text-player-highlight), 0 6px 16px 2px rgba(0, 0, 0, 0.7);
  transition: transform 0.2s ease-out;
}

.anon-gallery-tile.anon-mod-found::after {
  box-shadow: inset 0 0 0 2px var(--page-background);
  animation: anon-gallery-found 1s ease-in-out 3;
}

@keyframes anon-gallery-found {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--page-background), 0 0 0 3px var(--text-player-highlight); }
  50% { box-shadow: inset 0 0 0 2px var(--page-background), 0 0 0 3px var(--text-player-highlight), 0 0 18px 6px var(--accent-primary); }
}

@media (prefers-reduced-motion: reduce) {
  .anon-gallery-tile.anon-mod-found {
    transition: none;
  }

  .anon-gallery-tile.anon-mod-found::after {
    animation: none;
  }
}

/*
 * Little height, as on a phone held sideways: the pictures come first. The
 * title goes, the number field's label is only read aloud, and the tabs, the
 * field and the close link share one row (two, when it is narrow too).
 */
@container anon-gallery (max-height: 420px) {
  .anon-gallery-layout {
    display: grid;
    grid-template: 'tabs find close' auto 'scroll scroll scroll' minmax(0, 1fr) / auto minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--spacing-sm) var(--spacing-lg);
    padding: var(--spacing-sm) var(--spacing-lg);
  }

  /* Centred on the field beside them. */
  .anon-gallery-header,
  .anon-gallery-tabs {
    min-height: 40px;
    align-items: center;
  }

  .anon-gallery-header {
    grid-area: close;
  }

  .anon-gallery-header .sui-text-header {
    display: none;
  }

  .anon-gallery-tabs {
    grid-area: tabs;
    min-width: 0;
  }

  .anon-gallery .common-inline-text-input-group-container {
    grid-area: find;
  }

  .anon-gallery .common-inline-text-input-controls-container {
    flex-wrap: nowrap;
  }

  .anon-gallery .sui-input-text {
    min-width: 0;
  }

  .anon-gallery .sui-input-text span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .anon-gallery-scroll {
    grid-area: scroll;
    align-self: stretch;
  }
}

@container anon-gallery (max-height: 420px) and (max-width: 500px) {
  .anon-gallery-layout {
    grid-template: 'tabs close' auto 'find find' auto 'scroll scroll' minmax(0, 1fr) / minmax(0, 1fr) auto;
  }

  .anon-gallery-header,
  .anon-gallery-tabs {
    min-height: 0;
  }
}

/* The player's own profile: the edit button on the portrait's corner. */
.profile-header-image-container {
  position: relative;
}

.anon-profile-pfp-edit {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 1;
  display: flex;
  padding: 2px;
  background: var(--page-background);
  text-decoration: none;
}

.anon-profile-pfp-edit.sui-mod-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.anon-profile-pfp-status {
  margin-top: var(--spacing-sm);
}
