/* /random: photos and poems pop up as little windows, framed like the email box, each with
   its title in a bar under the title bar. The frame follows light/dark mode (--fg on
   --bg); the photos themselves are never recolored. */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The "desktop" the windows sit on: the whole screen below the nav words. */
.desktop {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* .item is positioned and stacked by random.js; the .window inside it keeps the shared
   frame, whose dithered shadow then sits behind its own window. */
.item {
  position: absolute;
  pointer-events: auto;
}

.item .titlebar {
  cursor: grab;
  touch-action: none;
}

.item.is-dragging .titlebar { cursor: grabbing; }

.item-window img {
  display: block;
  max-width: none;
}

/* A poem window: the poem as written, as wide as its longest line (so lines don't wrap and
   change the poem's shape) within limits. Long ones scroll inside. */
.item-poem {
  width: max-content;
  min-width: min(220px, calc(100vw - 32px));
  max-width: min(400px, calc(100vw - 32px));
}

.item-poem-text {
  max-height: min(46vh, 400px);
  margin: 0;
  padding: 14px 16px 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: var(--fg) var(--bg);
}

/* The title, in a bar just under the title bar (styled like the email box's "ready." line). */
.item .statusbar {
  padding: 8px 14px 9px;
  border-top: 0;
  border-bottom: 2px solid var(--fg);
}

.item .status {
  overflow: hidden;
  font-weight: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The left title bar box closes the window: an X, reversed out of a filled box on hover. */
.item-close {
  position: relative;
  margin: 0;
  padding: 0;
  border-radius: 0;
  color: var(--fg);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.item-close::before,
.item-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.item-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.item-close:hover {
  background: var(--fg);
  color: var(--bg);
}
.item-close:focus { outline: none; }
.item-close:focus-visible { outline: 2px dashed var(--fg); outline-offset: 3px; }

/* Chunky retro pop in and out. */
@keyframes item-pop {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.item.is-opening { animation: item-pop 0.18s steps(4) both; }
.item.is-closing { animation: item-pop 0.14s steps(3) reverse both; }

@media (prefers-reduced-motion: reduce) {
  .item.is-opening,
  .item.is-closing { animation: none; }
}
