/* 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); } }
/* while the key is in the lock, or on its way there or back, only its thread hangs here */
.hung-key.is-away .thread-line { opacity: .35; }
.hung-key.is-away img { visibility: hidden; }
body[data-state="open"] .hung-key, body[data-state="delete"] .hung-key, body[data-state="deleted"] .hung-key { opacity: 0; transition-duration: .3s; }
/* the shut door holds still on this page: the key does the checking and the refusing */
.page-key .keydrop[data-state="checking"] .kd-closed, .page-key .keydrop[data-state="error"] .kd-closed { animation: none; }
/* the click at the end of the turn: the bolt goes back and the door gives a little */
.doorway.is-clunk { transform-origin: 50% 95%; animation: clunk .3s ease-out; }
@keyframes clunk { 0% { scale: 1; } 30% { scale: 1.012 .988; } 100% { scale: 1; } }

/* ---------- the key in the lock: a solid felt key in the door's own 3D space ----------
   #lock-key is the leaf's box and turns with the leaf (inside .kd-hang), so the key rides the door when it
   swings. .lk is an anchor on the keyhole at the door's surface; key.js gives it the key's pose (a
   matrix3d). In its frame y runs along the key's shaft into the door and z is the normal of the key's
   plate. The key is the felt art (prop-soul-key, 520 x 600) cut out seven times, 3.67 art px apart along
   that normal and the inner six darker, so its edge shows whenever it is seen at an angle. Each cut-out
   (.lk-c) is a box whose lower edge is the door's surface: the art slides inside it along the shaft, and
   what has gone in past the surface is not drawn (the last few px fade, into the dark of the hole). The
   art sits so its shaft point (346.1, 368.2) is the anchor and the shaft runs straight along y (21.2deg).
   .lk-shade is the key's shadow: the same cut-out flattened onto the door by key.js. .lk-tag is the paper
   tag cut from the same art, its string's end (180, 238) the point key.js hangs it from.
   --u is one art px in the leaf's px (set by key.js). Keep these numbers in step with key.js. */
.kd-lock { position: absolute; inset: 0; pointer-events: none; visibility: hidden; transform-style: preserve-3d; transform-origin: var(--hinge) 50%;
  transform: rotateY(0deg); transition: transform 1.3s cubic-bezier(.55, .05, .2, 1); }
.keydrop.has-key .kd-hang { z-index: 3; }
.keydrop.has-key .kd-lock { visibility: visible; }
.keydrop.has-slab.is-swung .kd-lock { transform: rotateY(-66deg); }
.lk, .lk-shade { position: absolute; left: 45.3%; top: 44.21%; width: 0; height: 0; transform-origin: 0 0; transform-style: preserve-3d; }
.lk-shade { filter: brightness(0) blur(2px); opacity: .5; }
.lk-c { position: absolute; left: calc(-170 * var(--u)); top: calc(-740 * var(--u)); width: calc(360 * var(--u)); height: calc(740 * var(--u)); overflow: hidden;
  transform: translateZ(calc(var(--i) * var(--u) * -3.667));
  -webkit-mask-image: linear-gradient(to top, transparent, #000 calc(34 * var(--u))); mask-image: linear-gradient(to top, transparent, #000 calc(34 * var(--u))); }
.lk-c img { position: absolute; max-width: none; left: calc(-176.1 * var(--u)); top: calc(371.8 * var(--u)); width: calc(520 * var(--u)); height: calc(600 * var(--u));
  transform-origin: 66.56% 61.37%; transform: rotate(21.2deg);
  clip-path: polygon(evenodd, -10% -10%, 110% -10%, 110% 110%, -10% 110%, -10% -10%,
  -5% 28.33%, 25.58% 28.33%, 26.73% 31.33%, 27.12% 32.67%, 28.65% 35.33%, 29.81% 36.83%, 31.15% 38%, 32.5% 39.5%, 34.04% 40.67%, 36.15% 41.5%,
  38.08% 42.33%, 39.81% 43%, 41.15% 43.67%, 43.65% 44.33%, 46.15% 45%, 46.92% 46%, 46.92% 105%, -5% 105%, -5% 28.33%); }
.lk .lk-c:not(.lk-face) img { filter: brightness(.5) saturate(.85); }
.lk-tag { position: absolute; left: calc(-180 * var(--u)); top: calc(-238 * var(--u)); width: calc(520 * var(--u)); height: calc(600 * var(--u));
  transform-origin: calc(180 * var(--u)) calc(238 * var(--u)); }
.lk-tag img { width: 100%; height: 100%; max-width: none; clip-path: polygon(-5% 28.33%, 25.58% 28.33%, 26.73% 31.33%, 27.12% 32.67%, 28.65% 35.33%, 29.81% 36.83%, 31.15% 38%, 32.5% 39.5%, 34.04% 40.67%, 36.15% 41.5%,
  38.08% 42.33%, 39.81% 43%, 41.15% 43.67%, 43.65% 44.33%, 46.15% 45%, 46.92% 46%, 46.92% 105%, -5% 105%); }

/* ---------- light: it comes from the room behind the door ----------
   Nothing glows while the door is shut (the render's own warm line at the gap is all). As the leaf swings
   open, the room's light falls out of the doorway, over the sill and onto the floor in front of it: a soft
   wedge as wide as the part of the opening the leaf has cleared, widening and fading away from the door,
   strongest on the right, because the leaf, open towards us on the left, shades the rest. The jambs round
   the opening, the leaf's edge and the side of its face nearest the opening catch a little of it. Each part
   grows with the swing: 1.3 s like the leaf, on a curve that keeps pace with the leaf's free edge. */
.kd-spill { position: absolute; left: 0; right: 0; top: 90%; height: 26%; z-index: -1; pointer-events: none; visibility: hidden; filter: blur(4px); }
.keydrop.is-open .kd-spill { visibility: visible; }
.kd-spill::before { content: ""; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(rgba(255, 210, 138, .95) 18%, rgba(255, 188, 104, .62) 40%, rgba(255, 166, 78, .24) 66%, transparent 92%);
  -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, .35) 26%, #000 64%); mask-image: linear-gradient(90deg, rgba(0, 0, 0, .35) 26%, #000 64%);
  clip-path: polygon(79% 8%, 80% 8%, 86% 92%, 84% 92%);
  transition: clip-path 1.3s cubic-bezier(.71, 0, .17, .85), opacity 1.3s cubic-bezier(.71, 0, .17, .85); }
.keydrop.is-swung .kd-spill::before { opacity: 1; clip-path: polygon(44% 8%, 80% 8%, 90% 92%, 14% 92%); }
.kd-jamb { position: absolute; left: 23%; right: 19%; top: 13%; bottom: 15.5%; border-radius: 50% 50% 6px 6px / 34% 34% 6px 6px; pointer-events: none;
  visibility: hidden; opacity: 0; mix-blend-mode: soft-light; box-shadow: 5px 3px 22px 4px rgba(255, 150, 50, .95), 0 6px 14px 0 rgba(255, 150, 50, .6);
  transition: opacity 1.3s cubic-bezier(.71, 0, .17, .85); }
.keydrop.is-open .kd-jamb { visibility: visible; }
.keydrop.is-swung .kd-jamb { opacity: 1; }
.kd-leaflight { position: absolute; inset: 0; pointer-events: none; opacity: 0; transform-origin: var(--hinge) 50%; transform: translateZ(.6px);
  background: linear-gradient(270deg, rgba(255, 178, 92, .85) 18%, rgba(255, 178, 92, 0) 56%);
  -webkit-mask: url(../img/prop-soul-door-leaf.webp) center / 100% 100% no-repeat; mask: url(../img/prop-soul-door-leaf.webp) center / 100% 100% no-repeat;
  transition: transform 1.3s cubic-bezier(.55, .05, .2, 1), opacity 1.3s cubic-bezier(.71, 0, .17, .85); }
.keydrop.has-slab.is-swung .kd-leaflight { transform: rotateY(-66deg) translateZ(.6px); opacity: .3; }
.keydrop.has-slab .kd-slab { transition: transform 1.3s cubic-bezier(.55, .05, .2, 1), filter 1.3s cubic-bezier(.71, 0, .17, .85); }
.keydrop.has-slab.is-swung .kd-slab { filter: brightness(.44) sepia(.45) saturate(1.3); }

/* ---------- 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: 6px; display: grid; gap: 8px; }
.payout input { font-family: var(--mono); }
.payout-form .patch-row { margin-top: 12px; }
.ledger { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 6px 0 12px; }
.ledger > div { padding: 12px 14px; border-radius: 14px 16px 12px 15px; background: rgba(251, 241, 225, .07); }
.ledger dt { font-size: 14px; color: var(--lilac-text); }
.ledger dd { margin: 4px 0 0; font: 400 32px/1 var(--display); color: var(--amber); }
.blockers { margin: 10px 0 0; padding-left: 1.2em; display: grid; gap: 6px; }
.blockers:empty { display: none; }
.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); }
  .kd-spill { height: 21%; }                 /* the copy starts just under the door here */
  .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; }
}
