/* Page layout: top bar, the wall, panels, the preview controls and notices. */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--ink);
  color: var(--paper);
  font: var(--fs-text) / var(--lh-text) var(--font-text);
  overflow: hidden;
  cursor: url("../sprites/cursor-arrow.png") 0 0, default;
}

button,
input,
select {
  font-family: inherit;
}

/* ---- top bar ------------------------------------------------------------------------ */

.topbar {
  --focus: var(--highlight);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 16px;
  background: var(--ink);
  border-bottom: 4px solid var(--muted);
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font: var(--fs-title) / var(--lh-title) var(--font-title);
  color: var(--highlight);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar .btn {
  filter: none;
}

.who {
  background-color: var(--ink);
  color: var(--paper);
}

/* "I am old enough and have read the privacy policy" at sign-up. */
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.check input {
  margin-top: 8px;
  accent-color: var(--action);
}

/* ---- banners ------------------------------------------------------------------------ */

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  padding: 4px 16px;
  background: var(--highlight);
  color: var(--ink);
  border-bottom: 4px solid var(--ink);
}

.banner-warning {
  background: var(--danger);
  color: var(--paper);
}

/* ---- the wall ----------------------------------------------------------------------- */

.viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--ink);
  /* The wall is moved and zoomed by our own handlers, so the browser must not scroll or zoom. */
  touch-action: none;
}

/* Panels sit inside the viewport and still scroll their lists. */
.panel {
  touch-action: pan-y;
}

.wall {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background-color: var(--wall);
  background-image: url("../sprites/brick.png");
  background-size: 64px 64px;
  image-rendering: pixelated;
  box-shadow: 0 0 0 4px var(--muted);
}

/* Posters keep their real look: the wall's pixelated rendering must not reach them. */
.poster,
.preview {
  image-rendering: auto;
}

.poster {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  cursor: url("../sprites/cursor-hand.png") 16 0, pointer;
}

@media (hover: hover) {
  .poster:hover {
    outline: 4px solid var(--highlight);
  }
}

/* Pixel mode: a small copy of the poster, scaled up with hard edges. */
.poster.is-pixelated {
  image-rendering: pixelated;
}

/* "Show on wall" in the dashboard marks the poster for a moment. */
.poster.is-located {
  outline: 4px solid var(--highlight);
  outline-offset: 4px;
}

.preview {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  pointer-events: none;
  z-index: 2147483000;
  outline: 4px dashed var(--highlight);
  will-change: transform;
}

body.is-placing .viewport {
  cursor: crosshair;
}

body.is-placing .poster {
  pointer-events: none;
}

body.is-dragging-file .viewport::after {
  content: "Drop an image to post it";
  position: absolute;
  inset: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px dashed var(--highlight);
  background: rgba(26, 28, 44, 0.8);
  color: var(--highlight);
  font: var(--fs-title) / var(--lh-title) var(--font-title);
  z-index: 5;
  pointer-events: none;
}

/* ---- status bar --------------------------------------------------------------------- */

.statusbar {
  --focus: var(--highlight);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--statusbar-h);
  padding: 0 16px;
  background: var(--ink);
  border-top: 4px solid var(--muted);
  z-index: 10;
}

.statusbar-zoom {
  display: flex;
  align-items: center;
  gap: 12px;
}

.statusbar-privacy {
  margin-left: auto;
  color: var(--paper);
}

.statusbar .btn[aria-pressed="true"] {
  background-color: var(--highlight);
}

.statusbar .btn {
  filter: none;
}

.coords {
  margin: 0;
  color: var(--paper);
  white-space: pre;
}

/* ---- preview controls --------------------------------------------------------------- */

.preview-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--statusbar-h) + 16px);
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 32px);
}

.preview-bar .window-body {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
}

.preview-bar input[type="range"] {
  width: 200px;
  accent-color: var(--action);
}

/* ---- side panels -------------------------------------------------------------------- */

.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 360px;
  max-height: calc(100% - 32px);
  z-index: 8;
}

.panel-wide {
  width: 480px;
}

.panel .window-body {
  flex: 1;
}

.panel .list {
  max-height: 50vh;
}

/* ---- moderation dashboard: a window over the whole wall ----------------------------- */

.dashboard {
  left: 16px;
  bottom: 16px;
  width: auto;
  max-height: none;
  z-index: 9;
}

.dashboard-body {
  flex: 1;
  overflow: hidden;
}

.dashboard-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.dashboard .list {
  max-height: none;
  flex-shrink: 0;
}

.section-title {
  margin: 0;
  font: var(--fs-title) / var(--lh-title) var(--font-title);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border: 4px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: url("../sprites/cursor-hand.png") 16 0, pointer;
}

.stat:hover,
.stat-alert {
  background: var(--highlight);
}

.stat-value {
  font: var(--fs-title) / var(--lh-title) var(--font-title);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.filter {
  display: flex;
  flex-direction: column;
}

.filter-grow {
  flex: 1;
  min-width: 200px;
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  border: 4px solid var(--ink);
  background: var(--paper);
}

.card-image {
  width: 100%;
  height: 160px;
  object-fit: contain;
  background: var(--wall);
  border-bottom: 4px solid var(--ink);
  /* Thumbnails are photos, not pixel art; windows set pixelated for their frames. */
  image-rendering: auto;
}

.card-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Users tab: the accounts list, and the selected account's details beside it. */
.users-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.users-layout.has-selection {
  grid-template-columns: minmax(320px, 2fr) 3fr;
}

.users-pane,
.account-pane,
.account-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.users-pane,
.account-pane {
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

/* The panes scroll; what is inside them keeps its height instead of shrinking to fit. */
.users-pane > *,
.account-pane > * {
  flex-shrink: 0;
}

.account-pane {
  border-left: 4px solid var(--muted);
  padding-left: 16px;
}

.account-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.item.is-selected {
  box-shadow: inset 8px 0 0 var(--highlight);
}

.item-selectable {
  cursor: url("../sprites/cursor-hand.png") 16 0, pointer;
}

.item-selectable:hover {
  background: var(--muted);
}

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

.address + .address {
  margin-left: 12px;
}

.activity-row .tag {
  margin-left: 8px;
}

.connection-head .tag,
.connection-path .tag {
  margin-left: 8px;
}

.connection-ip,
.connection-path,
.connection-agent {
  overflow-wrap: anywhere;
}

.connection-requests .list {
  max-height: 320px;
  overflow-y: auto;
}

/* Narrow screens: the details take the list's place, and Close brings the list back. */
@media (max-width: 900px) {
  .users-layout.has-selection {
    grid-template-columns: 1fr;
  }

  .users-layout.has-selection .users-pane {
    display: none;
  }

  .account-pane {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 640px) {
  .panel,
  .panel-wide {
    position: fixed;
    inset: 0;
    width: auto;
    max-height: none;
    border-width: 0;
    border-image: none;
    filter: none;
    z-index: 30;
  }

  .panel .list {
    max-height: none;
  }

  .preview-bar {
    bottom: var(--statusbar-h);
    max-width: 100vw;
    width: 100%;
  }

  .topbar nav {
    margin-left: 0;
  }

  .statusbar {
    gap: 8px;
    padding: 0 8px;
  }

  .statusbar-zoom {
    gap: 8px;
  }

  .coords {
    font-size: var(--fs-small);
  }

  /* The coordinates need the room; the policy is linked from the sign-in overlay. */
  .statusbar-privacy {
    display: none;
  }
}

/* ---- popup, queue items ------------------------------------------------------------- */

.popup-image {
  align-self: center;
  max-width: 100%;
  max-height: 240px;
  border: 4px solid var(--ink);
  background: var(--wall);
  image-rendering: auto;
}

.meta {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 12px;
}

.meta dt {
  color: var(--action);
}

.meta dd {
  margin: 0;
}

.item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 12px;
  padding: 12px;
  border-bottom: 4px solid var(--muted);
  background: var(--paper);
}

.item-plain {
  grid-template-columns: 1fr;
}

.item:last-child {
  border-bottom: 0;
}

/* Items wrapped one per list entry are each the last child of their entry, so the divider
   follows the entry instead. */
.list > li > .item {
  border-bottom: 4px solid var(--muted);
}

.list > li:last-child > .item {
  border-bottom: 0;
}

.item img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: var(--wall);
  border: 4px solid var(--ink);
  image-rendering: auto;
}

.item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 0 8px;
  background: var(--muted);
  color: var(--ink);
}

.tag-illegal,
.tag-reported,
.tag-banned {
  background: var(--danger);
  color: var(--paper);
}

.tag-visible {
  background: var(--success);
}

.tag-pending {
  background: var(--highlight);
}

.tag-admin {
  background: var(--action);
  color: var(--paper);
}

/* ---- toasts ------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(480px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  animation: pop 160ms steps(2) both;
  pointer-events: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

noscript .msg {
  margin: 16px;
}
