/* Decorations (decorations.js): webs, cocoons and the remains of those who
   came to the weaver, at the page's edges. A layer between the ASCII scene
   and the page's text. Everything is a glyph on the scene's own cell grid:
   no gradients, no blur, no painted shadows. It never takes the pointer,
   and nothing in it is readable text. */

.dz-layer {
  position: fixed;
  inset: 0;
  z-index: 0; /* after the scene's canvas in the DOM, so above it; .layout is z-index 1 */
  pointer-events: none;
  overflow: hidden;
}
/* narrow screens: a few pieces in the open space above the panels */
.stage { position: relative; }
.dz-stage { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* the verdict's overlay: a layer that scrolls with it, over her portrait and
   under the tablet (z-index 1) and the heap's pieces (z-index 10+) */
.dz-vd { position: absolute; left: 0; top: 0; width: 100%; z-index: 0; pointer-events: none; overflow: hidden; }

.dz-set {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.dz-set.dz-in { opacity: 1; }
/* the first time, wait for Arachne to finish dropping into her web */
.dz-set.dz-first.dz-in { animation: dz-arrive 2.4s ease both; }
@keyframes dz-arrive { 0%, 45% { opacity: 0; } 100% { opacity: 1; } }

.dz-piece { position: absolute; }
.dz-piece canvas { display: block; }

/* things hanging on a thread are pendulums (Swing in decorations.js): they
   sway from the top of their thread and swing when clicked or brushed */
.dz-hang { transform-origin: 50% 0; will-change: transform; }
/* the pointer shows they can be pushed (only set while over one, never over the UI) */
body.dz-grab { cursor: pointer; }

/* dew catching the light: the drop's cell flashes to a bright star now and then */
.dz-glint, .dz-flame {
  position: absolute;
  width: var(--cw, 6px);
  height: var(--fs, 10px);
  font: var(--fs, 10px) / var(--fs, 10px) "JetBrains Mono", ui-monospace, Menlo, monospace;
  font-style: normal;
  background: #0b0e18;
  opacity: 0;
}
.dz-glint::before { content: "*"; color: rgb(232, 206, 160); }
/* on a swinging piece the cell is off the scene's grid, so no ground of its own */
.dz-hang .dz-glint { background: none; }
.dz-glint { animation: dz-glint var(--d, 7s) steps(1, end) var(--dl, 0s) infinite; }
@keyframes dz-glint {
  0%, 70% { opacity: 0; }
  72%, 76% { opacity: 1; }
  78%, 100% { opacity: 0; }
}

/* a flame: its cell flickers between two glyphs */
.dz-flame::before { content: "^"; color: rgb(224, 170, 96); }
.dz-flame { animation: dz-flicker 1.9s steps(1, end) infinite; }
@keyframes dz-flicker {
  0%, 30% { opacity: 1; }
  32%, 52% { opacity: 0; }
  54%, 80% { opacity: 1; }
  82%, 100% { opacity: 0; }
}

/* The secret niche (decorations.js, Secret): a stone recess that slides up
   out of the latch relic. Frame in glyphs on a 14px/20px grid, an opaque
   face, real form controls. Opens in whole rows, like the scene. */
.dz-niche {
  position: fixed;
  z-index: 50; /* over the page (.layout is 1), under the verdict (100) */
  width: min(34ch, calc(100vw - 24px));
  padding: 40px 3ch 44px;
  font: 400 14px/20px "JetBrains Mono", ui-monospace, Menlo, monospace;
  color: var(--text-body, #efe6d4);
  pointer-events: auto;
  isolation: isolate;
}
.dz-niche[hidden] { display: none; }
.dz-niche-fr {
  position: absolute;
  inset: 0;
  z-index: -1;
  margin: 0;
  font: inherit;
  white-space: pre;
  overflow: hidden;
  color: var(--edge-stone, rgb(122, 136, 156));
  background: var(--face-stone, #141927);
  /* the frame's arch: the face shows only inside the glyphs */
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 30px, 100% 100%, 0 100%, 0 30px);
}
.dz-niche-in { animation: dz-niche-open 0.4s steps(8, end) both; }
@keyframes dz-niche-open { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
.dz-niche-form { display: grid; gap: 4px; }
.dz-niche-title { margin: 0 0 6px; color: var(--gold, #e3ae5f); letter-spacing: 0.12em; text-transform: uppercase; }
.dz-niche label { color: var(--text-muted, #b9c2d0); margin-top: 4px; }
.dz-niche input {
  font: inherit;
  color: var(--text-body, #efe6d4);
  background: #0b0e18;
  border: 1px solid var(--edge-stone, rgb(122, 136, 156));
  border-radius: 0;
  padding: 4px 1ch;
  min-height: 32px;
}
.dz-niche input:focus-visible, .dz-niche button:focus-visible { outline: 2px solid var(--focus, #ffd58f); outline-offset: 2px; }
.dz-niche-msg { margin: 4px 0 0; min-height: 20px; color: #ffb36b; }
.dz-niche-msg:empty { min-height: 0; }
.dz-niche-row { display: flex; justify-content: space-between; gap: 2ch; margin-top: 6px; }
.dz-niche button {
  font: inherit;
  background: none;
  border: 0;
  padding: 6px 0;
  min-height: 32px;
  cursor: pointer;
  color: var(--text-muted, #b9c2d0);
}
.dz-niche .dz-niche-go { color: var(--gold, #e3ae5f); font-weight: 700; }
.dz-niche button:hover { color: var(--text-body, #efe6d4); }
.dz-niche button:disabled { cursor: progress; opacity: 0.75; }

@media (prefers-reduced-motion: reduce) {
  .dz-niche-in { animation: none; }
  .dz-flame, .dz-set.dz-first.dz-in { animation: none; }
  .dz-glint { display: none; }
  .dz-set { transition: none; }
}

@media print { .dz-layer, .dz-stage { display: none; } }
