/* Your soul: the door a seller opens with their key file. Page layout only. */

.keyroom {
  position: relative; isolation: isolate; overflow: clip;
  padding: 30px clamp(18px, 4vw, 56px) 40px;
  background: radial-gradient(60% 55% at 26% 40%, rgba(246, 181, 68, .1), transparent 70%), radial-gradient(70% 55% at 22% 8%, #3a2654 0%, transparent 70%), var(--night);
}
.keyroom::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0; background: var(--grain); background-size: 180px; mix-blend-mode: overlay; opacity: .2; }
.scenery { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hang-star { position: absolute; top: 0; display: flex; flex-direction: column; align-items: center; transform-origin: 50% 0; }
.hang-star .thread-line { height: var(--len); background: rgba(251, 241, 225, .3); }
.hang-star svg { width: 30px; height: 30px; margin-top: -2px; }
.hang-star.s1 { left: 4%; } .hang-star.s2 { right: 5%; }

.keyroom-grid {
  position: relative; z-index: 2; display: grid; align-items: center;
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr); gap: clamp(28px, 5vw, 80px);
  max-width: 1240px; margin: 0 auto; min-height: min(calc(100svh - 150px), 760px);
}

/* ---------- the door: FLORA renders in the shared .keydrop component ---------- */
.door-stage { --dw: min(32vw, 440px); --pad: 50px; position: relative; display: grid; place-items: center; padding: 50px 0 40px; align-self: start; }
@media (min-width: 900px) { .door-stage { position: sticky; top: 10px; } }
.doorway { width: var(--dw); cursor: pointer; }
.doorway .kd-room .felt-ghost { position: absolute; width: 96%; left: 2%; bottom: 3%; }
.doorway .kd-room .fg-shadow { bottom: -3%; }
.doorway.is-open .kd-room .felt-ghost { animation: ghost-in 1s .45s var(--soft) both; }
@keyframes ghost-in { from { opacity: 0; translate: 0 18%; } }
body[data-state="deleted"] .doorway .kd-room .felt-ghost { animation: ghost-out .9s var(--soft) both; }
@keyframes ghost-out { to { opacity: 0; translate: 0 -30%; } }
body[data-state="open"] .doorway, body[data-state="delete"] .doorway, body[data-state="deleted"] .doorway { cursor: default; }
/* the felt key, hanging by the door */
.hung-key { position: absolute; top: 0; left: calc(50% + 170px); width: clamp(96px, 10vw, 150px); display: flex; flex-direction: column; align-items: center; transform-origin: 50% 0; transition: opacity .5s; z-index: 3; }
.hung-key .thread-line { height: 70px; background: rgba(251, 241, 225, .45); }
.hung-key img { width: 100%; height: auto; margin-top: -6%; filter: drop-shadow(0 12px 14px rgba(8, 3, 16, .5)); transition: transform .5s var(--squish), filter .3s; }
body[data-state="dragging"] .hung-key img { transform: scale(1.08) rotate(-8deg); filter: drop-shadow(0 0 18px rgba(246, 181, 68, .7)); }
/* reduced motion: no flight, so the key turns where it hangs */
@media (prefers-reduced-motion: reduce) { body[data-state="checking"] .hung-key img { transform: rotate(-90deg); } }
/* the key in flight: its thread stays, the key leaves it */
.hung-key.is-flying .thread-line { opacity: .35; }
.hung-key.is-flying img { filter: drop-shadow(0 8px 10px rgba(8, 3, 16, .55)); }
body[data-state="open"] .hung-key, body[data-state="delete"] .hung-key, body[data-state="deleted"] .hung-key { opacity: 0; transition-duration: .3s; }
/* the clunk: the lock gives, the keyhole flares */
.doorway.is-clunk { animation: clunk .32s ease-out; }
.doorway.is-clunk .kd-glow { opacity: 1; scale: 1.5; transition: opacity .1s, scale .2s; }
@keyframes clunk { 0% { scale: 1; } 35% { scale: 1.025 .975; } 100% { scale: 1; } }
/* light spills from the open door onto the floor */
.kd-spill { position: absolute; left: 4%; right: 0; top: 93%; height: 30%; pointer-events: none; z-index: -1; opacity: 0;
  background: radial-gradient(62% 80% at 54% 0%, rgba(255, 200, 115, .8), rgba(255, 165, 75, .3) 50%, transparent 80%);
  clip-path: polygon(24% 0, 80% 0, 100% 100%, 0 100%); filter: blur(4px); transition: opacity 1s .4s; }
.doorway.is-open .kd-spill { opacity: 1; }

/* ---------- the copy column ---------- */
.key-copy { max-width: 640px; padding: 20px 0; }
.key-copy .title { font-size: clamp(54px, 5.6vw, 90px); }
.key-copy .title-md { font-size: clamp(46px, 4.6vw, 72px); }
.key-copy .title-sm { font-size: clamp(32px, 3vw, 42px); margin-bottom: .3em; }
.paste { margin-top: 26px; display: grid; gap: 8px; }
.paste-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.paste-row .felt-input { flex: 1 1 260px; }
.paste input { font-family: var(--mono); letter-spacing: .12em; }
.key-status { min-height: 1.5em; margin: 14px 0 0; font-weight: 800; color: var(--amber); }
#key-banner:not(:empty) { margin-top: 6px; }
.warn { margin-top: 28px; }
.soul-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 18px; }
.soul-name { margin: 0; font: 400 42px/1 var(--display); }
.soul-trade { flex-basis: 100%; margin: 0; color: var(--lilac-text); }
.payout { margin-top: 18px; }
.block-part { margin-top: 36px; }
.block-part .dropzone { margin-top: 6px; }
.block-part .muted { margin: 0 0 14px; }

@media (max-width: 899px) {
  .keyroom { padding: 16px 16px 30px; }
  .keyroom-grid { grid-template-columns: 1fr; gap: 6px; min-height: 0; }
  .door-stage { padding: 30px 0 18px; }
  .door-stage { --dw: 264px; --pad: 30px; }
  .hung-key { width: 80px; left: calc(50% + 92px); }
  .hung-key .thread-line { height: 40px; }
  .key-copy { padding: 6px 0; }
  .key-copy .title { font-size: 50px; }
  .key-copy .title-md { font-size: 44px; }
  .paste-row .patch { width: 100%; }
}

/* ---------- the garland: stats as felt tags strung across the door frame ---------- */
.door-stage .garland { left: 50%; top: var(--pad); width: var(--dw); height: calc(var(--dw) * 1.2744); translate: -50% 0; z-index: 4; font-size: 15px; }
.door-stage .garland-thread { top: 6.5%; height: 8%; }
.door-stage .garland li { animation: tag-in .8s var(--squish) both; }
.door-stage .garland li:nth-child(2) { animation-delay: .9s; } .door-stage .garland li:nth-child(1) { animation-delay: .75s; } .door-stage .garland li:nth-child(3) { animation-delay: 1.05s; }
@keyframes tag-in { from { opacity: 0; translate: -50% -40px; } }
@media (max-width: 899px) {
  .door-stage .garland { font-size: 12px; }
  .door-stage .garland .stat-tag { min-width: 0; padding: 7px 7px 8px; width: 84px; }
  .door-stage .garland .stat-tag b { font-size: 25px; margin-top: 9px; }
  .door-stage .garland .stat-tag span { font-size: 12px; }
}
