/* ---------------------------------------------------------
   binary stars — liminal space letter hunt
   palette pulled from the background: pale institutional
   walls, sick fluorescent glow, dark void, overgrown grass.
--------------------------------------------------------- */

:root{
  --wall: #cfc8b4;
  --void: #060606;
  --glow: #f7f1df;
  --glow-dim: #cbb98a;
  --ink: #17140f;
  --paper: #ece6d3;

  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  background: var(--void);
  color: var(--wall);
  font-family: "Courier New", ui-monospace, Menlo, Consolas, monospace;
  overflow: hidden;
}

button{ font-family: inherit; }

/* ambient grain over everything */
.noise-overlay{
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  opacity: .05;
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 40;
}

/* top-right controls */
.controls{
  position: fixed;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 100;
}

.ghost-btn{
  background: transparent;
  border: 1px solid rgba(247,241,223,.28);
  color: rgba(247,241,223,.75);
  text-transform: lowercase;
  letter-spacing: .07em;
  font-size: .68rem;
  padding: .55em 1em;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.ghost-btn:hover{
  border-color: rgba(247,241,223,.6);
  color: var(--glow);
  background: rgba(247,241,223,.06);
}

/* the scene, letterboxed to the background's own aspect ratio
   so item coordinates (in %) always line up regardless of
   window size/shape */
.scene-wrap{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--void);
}

.scene{
  position: relative;
  aspect-ratio: 16 / 9;
  width: min(100vw, 100vh * 16 / 9);
  height: min(100vh, 100vw * 9 / 16);
}

.scene-bg{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
}

.item-layer{
  position: absolute;
  inset: 0;
}

/* individual items */
.item{
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.item img{
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.55));
}
.item.dragging{
  cursor: grabbing;
  filter: brightness(1.15);
  z-index: 999 !important;
}
.item.found{ opacity: .6; }
.item.visited{ opacity: .82; }

/* placeholder items — used while art hasn't arrived yet */
.item.placeholder{
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-size: .62rem;
  line-height: 1.2;
  letter-spacing: .03em;
  color: rgba(247,241,223,.75);
  background: rgba(0,0,0,.3);
  border: 1px dashed rgba(247,241,223,.45);
  border-radius: 4px;
}

/* inventory — a row of glowing window slits echoing the
   background's own lights */
.inventory{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  /* wide enough that adjacent name labels (e.g. vincent / wolfstar)
     clear each other instead of overlapping */
  gap: clamp(10px, 3.2vw, 46px);
  justify-content: center;
  align-items: flex-end;
  padding: 18px clamp(10px, 3vw, 36px) 22px;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
}

.inv-slot{
  position: relative;
  width: clamp(12px, 1.8vw, 20px);
  height: clamp(46px, 8vw, 82px);
  border-radius: 2px;
  background: #0c0c0c;
  border: 1px solid rgba(247,241,223,.16);
  transition: background .7s ease, box-shadow .7s ease, border-color .7s ease;
}

.inv-slot.lit{
  /* a touch brighter and cooler than --glow, to sit closer to the
     fluorescent light in the background photo */
  background: linear-gradient(#fbfaf2, #dcd6be);
  border-color: rgba(250,248,238,.55);
  box-shadow:
    0 0 11px 2px rgba(250,248,238,.9),
    0 0 36px 9px rgba(248,247,240,.34);
  cursor: pointer;
}

.inv-slot .inv-name{
  position: absolute;
  bottom: -1.5em;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: .54rem;
  letter-spacing: .03em;
  color: rgba(247,241,223,.8);
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.inv-slot.lit .inv-name{ opacity: 1; }

/* letter / clue popup */
.popup-overlay{
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4,4,5,.78);
  backdrop-filter: blur(2px);
}

.popup{
  position: relative;
  width: 100%;
  max-width: 30rem;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  padding: 2.4rem 1.9rem 1.9rem;
  box-shadow: 0 24px 70px rgba(0,0,0,.65);
  border: 1px solid rgba(0,0,0,.15);
}

.popup-kicker{
  font-size: .68rem;
  text-transform: lowercase;
  letter-spacing: .14em;
  opacity: .55;
  margin-bottom: .7rem;
}

.popup-body{
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 1rem;
}

.popup-close{
  position: absolute;
  top: .4rem;
  right: .6rem;
  background: none;
  border: none;
  color: inherit;
  font-size: 1.5rem;
  line-height: 1;
  opacity: .55;
  cursor: pointer;
}
.popup-close:hover{ opacity: 1; }

/* ending */
.ending-overlay{
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(2,2,2,.92);
  animation: fade-in .8s ease;
}

.ending-panel{
  max-width: 34rem;
  text-align: center;
}
.ending-panel h1{
  font-weight: normal;
  text-transform: lowercase;
  letter-spacing: .1em;
  font-size: 1.4rem;
  margin-bottom: 1.2rem;
  color: var(--glow);
}
.ending-panel p{
  line-height: 1.7;
  color: rgba(247,241,223,.85);
  white-space: pre-wrap;
  margin-bottom: 1.6rem;
}

@keyframes fade-in{
  from{ opacity: 0; }
  to{ opacity: 1; }
}

[hidden]{ display: none !important; }

/* ---------------------------------------------------------
   layout/authoring mode — index.html?edit=1 only.
   never shown on the plain link.
--------------------------------------------------------- */

.edit-mode .item{ outline: 1px dashed rgba(255,80,80,.55); cursor: move; }
.edit-mode .item.selected{ outline: 1px solid rgba(255,220,80,.9); }

.edit-tag{
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 9px;
  line-height: 1.2;
  padding: 1px 4px;
  background: rgba(0,0,0,.75);
  color: #ffe27a;
  pointer-events: none;
  z-index: 1000;
}

.edit-hud{
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 100;
  font-size: .68rem;
  letter-spacing: .03em;
  color: #ffe27a;
  background: rgba(0,0,0,.65);
  border: 1px solid rgba(255,226,122,.35);
  padding: .5em .8em;
  max-width: 60vw;
}

.edit-toast{
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  z-index: 400;
  background: rgba(0,0,0,.85);
  color: #ffe27a;
  border: 1px solid rgba(255,226,122,.4);
  padding: .6em 1em;
  font-size: .72rem;
  letter-spacing: .03em;
  animation: fade-in .2s ease;
}
