/*
 * Stickers window (#desk-stickers) and the stickers placed on the desktop. The window shows a preview board, a
 * tray of stickers, action and selection buttons and a status line; placed stickers (.desktop-sticker) peel in,
 * lift on hover, and can be selected, dragged and removed. hyd-object-controls.css loads later and takes over
 * the hit box of a placed sticker and its editing panel.
 */

/* A little peel-and-stick sheet inside the existing desktop window. */
.portal-collage #desk-stickers {
  width: 306px;
  max-width: calc(100% - 20px);
}

.portal-collage #desk-stickers .sticker-play {
  padding: 10px;
  background: #21162e;
  max-height: min(460px, calc(100svh - 160px));
  overflow: auto;
  scrollbar-color: #a899bb #21162e;
  scrollbar-width: thin;
}

/* --- Preview board --- */
.portal-collage #desk-stickers .sticker-board {
  /* min-height: the board grows with bigger text instead of cutting off the sticker’s name. */
  height: auto;
  min-height: 65px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  transform: none;
  background: radial-gradient(ellipse at 25% 30%, #634f795c, transparent 70%), #181020;
  border: 1px solid #78618b;
  border-radius: 3px;
  box-shadow: inset 0 1px 5px #0b0715;
  color: #f2eafa;
  text-align: left;
}

.portal-collage #desk-stickers .sticker-board > .sticker-preview-art {
  position: static;
  display: block;
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  transform: rotate(-8deg);
  font: inherit;
  letter-spacing: normal;
  opacity: 1;
}

.sticker-preview-art :is(svg, img) {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(1px 3px 2px #09040f88);
}

.sticker-preview-copy {
  display: grid;
  gap: 5px;
}

.sticker-preview-copy b {
  font: 700 calc(13 * var(--px))/1.2 var(--desktop-font,Tahoma,Arial,sans-serif);
  color: #f3eafb;
}

.sticker-preview-copy small {
  font: calc(10 * var(--px))/1.3 var(--desktop-font,Tahoma,Arial,sans-serif);
  color: #cbb5dc;
  max-width: 150px;
}

/* --- Sticker tray --- */
.portal-collage #desk-stickers .sticker-tray {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 9px 0;
}

.portal-collage #desk-stickers .sticker-tray > button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  height: auto;
  padding: 3px 1px 4px;
  border: 1px solid #7a678a;
  border-radius: 3px;
  background: linear-gradient(#43314f, #2e203c 55%, #291b36);
  color: #ede2f7;
  box-shadow:
    inset 0 1px #c1a4d14d,
    0 1px 1px #0a0515;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.portal-collage #desk-stickers .sticker-tray > button :is(svg, img) {
  width: 44px;
  height: 44px;
  display: block;
  filter: drop-shadow(0 2px 1px #08050e66);
  transition: transform 0.18s ease-out;
  pointer-events: none;
}

.portal-collage #desk-stickers .sticker-tray > button > span {
  font: calc(10 * var(--px))/1.2 var(--desktop-font,Tahoma,Arial,sans-serif);
  letter-spacing: 0;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
  min-height: 24px;
  max-width: 100%;
  pointer-events: none;
}

.portal-collage #desk-stickers .sticker-tray > button:hover,
.portal-collage #desk-stickers .sticker-tray > button.is-selected {
  background: linear-gradient(#674b77, #442d58);
  border-color: #c2a0d6;
}

.portal-collage #desk-stickers .sticker-tray > button:hover :is(svg, img) {
  transform: translateY(-2px) rotate(-6deg);
}

.portal-collage #desk-stickers .sticker-tray > button:active {
  box-shadow: inset 0 2px 4px #10091b;
  transform: translateY(1px);
}

.portal-collage #desk-stickers button:focus-visible {
  outline: 2px solid #eac1ff;
  outline-offset: 2px;
}

/* --- Action and selection buttons --- */
.sticker-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-top: 1px;
}

.portal-collage #desk-stickers :is(.sticker-actions, .sticker-selection-actions) button {
  font: calc(11 * var(--px))/1 var(--desktop-font,Tahoma,Arial,sans-serif);
  min-height: 27px;
  padding: 5px 9px;
  color: var(--paper-text,#21192f);
  border: 1px solid var(--paper-edge,#9c91b2);
  border-radius: 2px;
  background: var(--paper-panel,#d8d3de);
  box-shadow:
    inset 1px 1px #fff7,
    inset -1px -1px #0002;
  cursor: pointer;
}

html[data-theme] #home #desk-stickers :is(.sticker-actions, .sticker-selection-actions) button {
  background: var(--paper-panel);
  color: var(--paper-text);
}

.portal-collage
  #desk-stickers
  :is(.sticker-actions, .sticker-selection-actions)
  button:is(:active, [aria-pressed='true']):not(:disabled) {
  background: var(--paper-inset,#c7bfce);
  box-shadow:
    inset 1px 1px #0003,
    inset -1px -1px #fff6;
}

.portal-collage #desk-stickers :is(.sticker-actions, .sticker-selection-actions) button:disabled {
  opacity: 0.45;
  cursor: default;
}

.portal-collage #desk-stickers .sticker-selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 8px 0 3px;
  text-align: left;
}

.portal-collage #desk-stickers .sticker-selection-actions > small {
  flex-basis: 100%;
  font: calc(10 * var(--px))/1.3 var(--desktop-font,Tahoma,Arial,sans-serif);
  color: var(--paper-muted,#cbb5dc);
}

.portal-collage #desk-stickers .sticker-play > #sticker-status {
  display: block;
  min-height: 26px;
  margin: 8px 1px 0;
  color: #cebadf;
  text-align: left;
  font: calc(10 * var(--px))/1.35 var(--desktop-font,Tahoma,Arial,sans-serif);
}

/* --- Stickers placed on the desktop --- */
.desktop-sticker.illustrated-sticker {
  width: 78px;
  height: 78px;
  padding: 3px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-shadow: none;
  filter: drop-shadow(1px 3px 2px #08031177);
  animation: sticker-peel 0.22s ease-out both;
  transition:
    scale 0.16s,
    filter 0.16s;
}

.desktop-sticker.illustrated-sticker :is(svg, img) {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.desktop-sticker.illustrated-sticker:hover {
  scale: 1.07;
}

.desktop-sticker.illustrated-sticker.is-selected {
  outline: 1px dashed var(--paper-text,#f5defe);
  outline-offset: 3px;
}

.desktop-sticker.illustrated-sticker.is-dragging {
  z-index: 99;
  scale: 1.09;
  filter: drop-shadow(3px 6px 4px #08031177);
  cursor: grabbing;
}

.desktop-sticker.illustrated-sticker:focus-visible {
  outline: 2px dashed #f5defe;
  outline-offset: 2px;
}

.portal-collage .desktop-sticker-remove {
  position: absolute;
  z-index: 100;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--paper-edge,#87778e);
  border-radius: 2px;
  background: var(--paper-panel,#ddd6e2);
  box-shadow:
    inset 1px 1px #fff8,
    inset -1px -1px #0002;
  color: var(--paper-text,#281d30);
  font: calc(16 * var(--px))/1 var(--desktop-font,Tahoma,Arial,sans-serif);
  cursor: pointer;
  touch-action: manipulation;
}

.portal-collage .desktop-sticker-remove[hidden] {
  display: none;
}

.portal-collage .desktop-sticker-remove:focus-visible {
  outline: 2px solid var(--paper-text,#f5defe);
  outline-offset: 2px;
}

.portal-collage .desktop-sticker-remove:active {
  box-shadow: inset 1px 1px #0003;
}

/* Peel-in: a new sticker fades in while scaling up from 82%. */
@keyframes sticker-peel {
  from {
    opacity: 0;
    scale: 0.82;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@media (max-width: 620px) {
  .portal-collage #desk-stickers {
    width: 100%;
    max-width: none;
  }

  .portal-collage #desk-stickers .sticker-play {
    max-height: none;
  }

  .portal-collage #desk-stickers .sticker-tray > button {
    min-height: 63px;
  }

  .portal-collage #desk-stickers .sticker-tray > button :is(svg, img) {
    width: 40px;
    height: 40px;
  }

  .desktop-sticker.illustrated-sticker {
    width: 67px;
    height: 67px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .desktop-sticker.illustrated-sticker,
  .portal-collage #desk-stickers .sticker-tray > button,
  .portal-collage #desk-stickers .sticker-tray > button :is(svg, img) {
    /*
     * !important: reduced motion switches off the peel-in animation and the tray transitions even where other
     * rules set their own.
     */
    animation: none !important;
    transition: none !important;
  }
}

.motion-off .desktop-sticker.illustrated-sticker,
.motion-off #desk-stickers .sticker-tray > button :is(svg, img) {
  /* !important: same switch-off for the motion-off setting. */
  animation: none !important;
  transition: none !important;
}

/* Wide screens: the window starts lower on the desktop. */
@media (min-width: 621px) {
  .portal-collage #desk-stickers {
    top: 190px;
  }
}

/* Keep the frequently used actions tappable without enlarging fine-pointer chrome. */
@media (pointer: coarse) {
  #world #home #desk-stickers :is(.sticker-actions, .sticker-selection-actions) button {
    min-height: 44px;
    min-width: 44px;
  }
}
