/* MY LOCKED DOOR — shared layout, controls, transitions.
   Theme skins live in manor.css / singularity.css keyed off html[data-theme]. */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #000; }
body {
  font: 15px/1.5 Georgia, "Iowan Old Style", "Times New Roman", serif;
  color: #cfc9bc;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select { font: inherit; outline: none; }

/* the fx canvas floats over the room (dust) / behind the hall (stars) */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
html[data-scene="gallery"] #fx { z-index: 1; }

.scene { position: fixed; inset: 0; overflow: hidden; }
#scene-door { z-index: 4; }
#scene-gallery { z-index: 3; }

/* ── the room scaffold (skinned per theme) ─────────────────────────────── */
.room { position: absolute; inset: 0; }
.wall, .wall-age, .floor, .floor-pool, .vignette { position: absolute; pointer-events: none; }
.wall { inset: 0; }
.wall-age { inset: 0; }
.floor { left: 0; right: 0; bottom: 0; height: 30vh; }
.floor-pool { left: 0; right: 0; bottom: 0; height: 30vh; }
.vignette { inset: 0; }

.doorway {
  position: absolute; left: 50%; bottom: 27vh; transform: translateX(-50%);
  width: min(300px, 66vw); height: min(560px, 60vh);
  perspective: 1400px; z-index: 2;
}
.burst, .rays, .threshold { position: absolute; pointer-events: none; }
.dframe { position: absolute; inset: 0; transform-style: preserve-3d; }
.dgap { position: absolute; pointer-events: none; }
.door, .door-b {
  position: absolute; transform-style: preserve-3d;
  backface-visibility: hidden; will-change: transform;
}
.door { z-index: 3; }
.door-b { z-index: 3; display: none; }
.grain, .dpanel, .hinge, .knob, .keyhole, .seam, .etch { position: absolute; pointer-events: none; }

/* ── the lockbox ───────────────────────────────────────────────────────── */
#lockbox {
  position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%);
  width: min(400px, 92vw); z-index: 8; padding: 20px 22px 16px;
  transition: opacity .6s ease;
}
#lockbox .brand {
  text-align: center; letter-spacing: .55em; font-size: 13px; opacity: .8;
  margin-bottom: 12px; padding-left: .55em;
}
#lockbox .tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; }
#lockbox .tabs button {
  font-size: 11px; letter-spacing: .25em; padding: 5px 12px; opacity: .5;
}
#lockbox .tabs button.on { opacity: 1; }
#lockbox form { display: flex; flex-direction: column; gap: 10px; }
#lockbox input {
  width: 100%; padding: 11px 14px; border-radius: 3px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(160,150,130,.25);
  color: inherit; letter-spacing: .06em;
}
#lockbox input::placeholder { color: rgba(180,170,150,.4); font-style: italic; }
.pwrow { display: flex; gap: 10px; align-items: center; }
.pwrow input { flex: 1; }
.keybtn {
  flex: 0 0 96px; height: 42px; display: grid; place-items: center;
  transition: transform .25s ease, filter .25s ease;
}
.keybtn svg { width: 96px; height: 32px; display: block;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.8)); }
.keybtn:hover { transform: translateY(-1px); filter: brightness(1.25); }
.keybtn:active { transform: scale(.97); }
.forgebtn {
  padding: 11px; letter-spacing: .3em; font-size: 12px; border-radius: 3px;
  border: 1px solid rgba(180,160,120,.35);
}
.msg { min-height: 18px; font-size: 12.5px; text-align: center; font-style: italic;
  color: #b98f6a; }
.msg.bad { color: #c4574d; }

/* the quivering password box */
@keyframes quiver {
  0%, 100% { transform: translate(0,0) rotate(0); }
  8%  { transform: translate(-.6px,.3px) rotate(-.12deg); }
  22% { transform: translate(.5px,-.3px) rotate(.1deg); }
  36% { transform: translate(-.4px,-.4px) rotate(-.08deg); }
  52% { transform: translate(.6px,.2px) rotate(.14deg); }
  70% { transform: translate(-.5px,.4px) rotate(-.1deg); }
  86% { transform: translate(.3px,-.2px) rotate(.08deg); }
}
.quiver { animation: quiver 1.9s ease-in-out infinite; }
@keyframes denied {
  0%,100% { transform: translateX(0); }
  12% { transform: translateX(-9px); } 30% { transform: translateX(8px); }
  48% { transform: translateX(-6px); } 66% { transform: translateX(5px); }
  84% { transform: translateX(-3px); }
}
#lockbox.denied { animation: denied .5s ease; }
#lockbox.denied input { border-color: rgba(196,87,77,.7); }

/* the key turning in the lock */
@keyframes keyturn {
  0% { transform: rotate(0); } 35% { transform: rotate(-18deg) translateX(4px); }
  100% { transform: rotate(342deg) translateX(4px); }
}
.keybtn.turning svg { animation: keyturn 1s cubic-bezier(.6,.05,.3,1) forwards;
  transform-origin: 86px 20px; }

#door-theme {
  position: absolute; right: 18px; bottom: 16px; z-index: 9;
  font-size: 10.5px; letter-spacing: .3em; opacity: .35; padding: 8px;
  transition: opacity .3s;
}
#door-theme:hover { opacity: .9; }

/* the burst of light when the door opens */
#whiteout {
  position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 58%, #fff 0%, #fff8ea 45%, rgba(255,248,234,0) 72%);
  transform: scale(.4);
}
#scene-door.flooding #whiteout {
  opacity: 1; transform: scale(2.6);
  transition: opacity 1.1s ease-in, transform 1.4s ease-in;
}
#fromwhite { position: absolute; inset: 0; background: #fff; z-index: 30;
  pointer-events: none; opacity: 0; }
#fromwhite.fading { opacity: 1; animation: fromwhite 1.4s ease-out forwards; }
@keyframes fromwhite { from { opacity: 1; } to { opacity: 0; } }

/* ── the hall (gallery) ────────────────────────────────────────────────── */
.hallwall { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 22px;
}
#topbar .brand-sm { letter-spacing: .45em; font-size: 12px; padding-left: .45em; white-space: nowrap; }
#topbar .controls { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
#topbar .spacer { flex: 1; }
#topbar select, #topbar button {
  font-size: 10.5px; letter-spacing: .18em; padding: 7px 11px; border-radius: 3px;
  background: transparent; border: 1px solid transparent; white-space: nowrap;
}
#filters { display: flex; gap: 6px; flex-wrap: wrap; }
#filters .chip {
  font-size: 10px; letter-spacing: .14em; padding: 5px 10px; border-radius: 20px;
  opacity: .55; border: 1px solid transparent;
}
#filters .chip.on { opacity: 1; }

#hall {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; cursor: grab;
}
#hall::-webkit-scrollbar { display: none; }
#hall.dragging { cursor: grabbing; }
#rail {
  display: flex; align-items: center; gap: clamp(38px, 6vw, 90px);
  padding: 0 max(60px, 8vw); height: 100%;
}
.pic { position: relative; flex: 0 0 auto; }
.pic .x, .pic .share {
  position: absolute; top: -12px; z-index: 5; width: 30px; height: 30px;
  border-radius: 50%; color: #f4e9dc; font-size: 13px;
  display: none; place-items: center; box-shadow: 0 3px 8px rgba(0,0,0,.5);
}
.pic .x { right: -12px; background: #7e1f1f; }
.pic .share { left: -12px; background: #1f5e7e; }
#scene-gallery.deleting .pic .x, #scene-gallery.deleting .pic .share { display: grid; }
#scene-gallery.deleting .pic { animation: quiver 1.2s ease-in-out infinite; }

.share-list { display: flex; flex-direction: column; gap: 6px; }
.share-row { display: flex; align-items: center; justify-content: space-between;
  padding: 7px 12px; border-radius: 3px; border: 1px solid rgba(128,128,128,.3);
  font-size: 12.5px; letter-spacing: .08em; }
.share-row button { opacity: .55; font-size: 12px; }
.share-row button:hover { opacity: 1; }

#pulse {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; gap: 18px; justify-content: center; padding: 12px;
  font-size: 10px; letter-spacing: .22em;
}
#pulse .dot { display: inline-flex; align-items: center; gap: 6px; opacity: .6; }
#pulse .dot i { width: 7px; height: 7px; border-radius: 50%; background: #555; }
#pulse .dot.up i { background: #3f9d63; box-shadow: 0 0 8px rgba(63,157,99,.7); }

/* ── modal ─────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px); }
.modal-card { width: min(430px, 92vw); padding: 24px; border-radius: 6px;
  display: flex; flex-direction: column; gap: 10px; }
.modal-card h3 { font-size: 12px; letter-spacing: .3em; font-weight: normal;
  margin-bottom: 6px; }
.modal-card input, .modal-card select { padding: 10px 12px; border-radius: 3px; width: 100%; }
.modal-card .two { display: flex; gap: 10px; }
.modal-card .two > * { flex: 1; }
.modal-row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-row button { font-size: 11px; letter-spacing: .2em; padding: 9px 16px;
  border-radius: 3px; }

/* ── built-in app window ───────────────────────────────────────────────── */
#appwin { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px); }
.appwin-card {
  width: min(680px, 94vw); max-height: 84vh; border-radius: 8px;
  display: flex; flex-direction: column; overflow: hidden;
  animation: appin .45s cubic-bezier(.2,.9,.3,1);
}
@keyframes appin { from { transform: scale(.86); opacity: 0; } to { transform: none; opacity: 1; } }
.appwin-card header { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; font-size: 12px; letter-spacing: .3em; }
.appwin-card header button { font-size: 14px; opacity: .6; padding: 4px 8px; }
.appwin-card header button:hover { opacity: 1; }
#app-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
#app-body .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#app-body input, #app-body textarea { padding: 10px 12px; border-radius: 3px; width: 100%; }
#app-body textarea { min-height: 74px; resize: vertical; font: inherit; }
#app-body button.act { font-size: 11px; letter-spacing: .2em; padding: 9px 14px;
  border-radius: 3px; }
#app-body .list { display: flex; flex-direction: column; gap: 8px; }
#app-body .item { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 4px; }
#app-body .item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
#app-body .item .meta { font-size: 11px; opacity: .55; white-space: nowrap; }
#app-body .item button { opacity: .55; font-size: 12px; }
#app-body .item button:hover { opacity: 1; }
#app-body pre { white-space: pre-wrap; font: 13px/1.6 ui-monospace, Menlo, Consolas, monospace;
  padding: 12px; border-radius: 4px; max-height: 46vh; overflow-y: auto; }
#app-body .note-msg { font-size: 12px; font-style: italic; min-height: 16px; }
#app-body .note-msg.bad { color: #c4574d; }

/* ── the zoom into a picture ───────────────────────────────────────────── */
#zoomer { position: fixed; z-index: 50; pointer-events: none;
  transition: top .85s cubic-bezier(.5,.05,.2,1), left .85s cubic-bezier(.5,.05,.2,1),
              width .85s cubic-bezier(.5,.05,.2,1), height .85s cubic-bezier(.5,.05,.2,1);
  overflow: hidden; }
#zoomer-art { position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 18vmin; }
#zoomer-flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
#zoomer.flash #zoomer-flash { opacity: 1; transition: opacity .5s ease .45s; }

@media (max-width: 640px) {
  .doorway { bottom: 33vh; height: min(480px, 52vh); }
  #lockbox { bottom: 2.5vh; padding: 14px 16px 10px; }
  #topbar { padding: 10px 12px; }
}
