/* style.css (CLEAN + MATCHES current HTML: #museum-viewport > #camera > #room > #lobby-img) */
/* Keeps ALL your features; only fixes conflicts + stacking + input */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden !important;
  background: #000;

  font-family: "Libre Baskerville", serif;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* prevents browser scroll restoring */
body{
  position: fixed;
  inset: 0;
}

/* Hard guarantee that hidden overlays do not intercept clicks */
[hidden] { display: none !important; }

/* ===== Root viewport ===== */
#museum-viewport{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

/* ===== Layer stacking (IMPORTANT) ===== */
/* Scene is: camera/room (input) + parallax + lighting + atmosphere (visual only) */

/* Camera receives input */
#camera{
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 10;
  pointer-events: auto;
  isolation: isolate; /* ✅ prevents stacking/blend weirdness affecting hit-testing */
}

/* World container (JS translates this element) */
#room{
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;  /* ✅ was hidden; can interfere with selection/hit testing */
  background: #000;
  z-index: 0;         /* ✅ establishes a clean local stacking order */
}

/* Lobby image MUST NOT steal clicks */
#lobby-img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  max-width: none;
  max-height: none;
  user-select: none;
  -webkit-user-drag: none;

  z-index: 1;
  pointer-events: none; /* ✅ important */
}

/* Prevent broken image icon */
#lobby-img:not([src]),
#lobby-img[src=""],
#lobby-img[src="about:blank"]{
  display: none !important;
}

/* Entities sit above lobby image */
#room > .entity{
  position: absolute;
  z-index: 2;
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/* ✅ DEBUG SAFETY NET:
   If anything is interfering, this forces entities to be clickable in debug mode */
body.debug #room > .entity{
  pointer-events: auto !important;
}

/* Parallax sits ABOVE camera/room but should never block input */
#parallax-far,
#parallax-near{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  background-repeat: repeat;
  background-size: 900px 900px;
  opacity: 0; /* off unless you set textures */
}

/* Lighting overlay - visual only */
#lighting-overlay{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: rgba(0,0,0,0);
  transition: background 220ms ease;
}
#lighting-overlay.night{
  background: rgba(0,0,0,0.52);
}

/* Atmosphere is final lens layer */
#atmosphere-overlay{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.06), rgba(0,0,0,0) 55%);
  mix-blend-mode: screen;
  opacity: 0.85;
}

/* ===== Selection outline (debug) ===== */
body.debug .entity.selected{
  outline: 2px solid rgba(255,255,255,0.92);
  outline-offset: 2px;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.18));
}

/* ===== Common entity cursors ===== */
.exhibit-door,
.artwork,
.spotlight,
.bench,
.plant{
  cursor: pointer;
}

/* Glow beam: non-blocking in normal mode */
.light-glow{ pointer-events: none; }
body.debug .light-glow{ pointer-events: auto; }

/* ===== Floor light pool ===== */
.light-floor{
  width: 320px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 245, 210, 0.55) 0%,
    rgba(255, 235, 180, 0.32) 35%,
    rgba(255, 220, 140, 0.18) 55%,
    rgba(0,0,0,0) 75%
  );
  mix-blend-mode: screen;
  pointer-events: none;
}
body.debug .light-floor{
  pointer-events: auto;
  outline: 1px dashed rgba(255,255,255,0.25);
}

/* ===== Plaque ===== */
.plaque{
  width: 300px;
  padding: 12px 14px;
  border-radius: 12px;
  position: absolute;

  background:
    linear-gradient(180deg, rgba(255,255,255,0.10), rgba(0,0,0,0.06)),
    rgba(18,18,18,0.72);

  border: 1px solid rgba(255,255,255,0.16);
  backdrop-filter: blur(4px);
  color: rgba(255,255,255,0.92);

  box-shadow:
    0 12px 28px rgba(0,0,0,0.45),
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 -10px 18px rgba(0,0,0,0.28) inset;
}
.plaque::before{
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 11px;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 20% 0%, rgba(255,255,255,0.10), rgba(255,255,255,0.00) 60%),
    radial-gradient(80% 60% at 80% 110%, rgba(0,0,0,0.35), rgba(0,0,0,0.00) 55%);
  opacity: 0.65;
}
.plaque-title{
  font-family: "Playfair Display", serif;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.plaque-body{
  white-space: pre-wrap;
  opacity: 0.92;
  line-height: 1.45;
}

/* ===== Wall text ===== */
.wall-text{
  width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10,10,10,0.68);
  backdrop-filter: blur(4px);
  position: absolute;

  box-shadow:
    0 14px 34px rgba(0,0,0,0.50),
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 -10px 20px rgba(0,0,0,0.30) inset;
}
.wall-text::after{
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 14px;
  pointer-events: none;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.06),
    0 1px 0 rgba(255,255,255,0.05);
  opacity: 0.65;
}
.wall-text-inner{
  color: rgba(255,255,255,0.92);
  font-size: 18px;
  line-height: 1.35;
  white-space: pre-wrap;
  letter-spacing: 0.01em;
}

/* ===== Bulletin ===== */
.bulletin{
  width: 520px;
  aspect-ratio: 5 / 3;
  background-size: cover;
  background-position: center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
  cursor: pointer;
  position: absolute;
}
.bulletin .pin{
  position: absolute;
  left: 20px;
  top: 20px;
  width: 120px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.18);
}
.bulletin .note{
  position: absolute;
  min-width: 140px;
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.92);
  font-size: 14px;
  line-height: 1.3;
  white-space: pre-wrap;
  backdrop-filter: blur(3px);
}
.bulletin .note[contenteditable="true"]{
  outline: 2px solid rgba(255,255,255,0.35);
  outline-offset: 2px;
}

/* ===== Hotspots ===== */
.hotspot{
  width: 90px;
  height: 70%;
  top: 15%;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.12);

  opacity: 0;
  pointer-events: auto;
}
body.debug .hotspot{
  opacity: 1;
  pointer-events: auto;
}

/* ===== Auto-scroll text window ===== */
.scroll-text{
  width: 520px;
  height: 160px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(10,10,10,0.70);
  backdrop-filter: blur(4px);
  overflow: hidden;
  position: absolute;

  box-shadow:
    0 16px 34px rgba(0,0,0,0.50),
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 -10px 20px rgba(0,0,0,0.30) inset;
}
.scroll-text .scroll-inner{
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  padding: 12px 14px;
  color: rgba(255,255,255,0.92);
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  will-change: transform;
}

/* ===== Artwork framing ===== */
.artwork.entity{
  border-radius: 8px;
  background: rgba(0,0,0,0.35);
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow:
    0 18px 34px rgba(0,0,0,0.55),
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -10px 18px rgba(0,0,0,0.35) inset;
  outline: 8px solid rgba(245,245,245,0.08);
  outline-offset: -8px;
}

/* ===== Benches + plants ===== */
.bench, .plant{
  opacity: 1;
  filter:
    saturate(0.82)
    contrast(0.92)
    brightness(0.96)
    drop-shadow(0 10px 10px rgba(0,0,0,0.35));
}
#lighting-overlay.night ~ #camera .plant,
#lighting-overlay.night ~ #camera .bench{
  filter:
    saturate(0.75)
    contrast(0.90)
    brightness(0.88)
    drop-shadow(0 10px 12px rgba(0,0,0,0.45));
}

/* ===== Ficus wrapper (your two-layer sway build) ===== */
.plant.ficus.entity{
  position: absolute;
  overflow: visible;

  --ficus-cut: 48%;
  --ficus-feather: 10%;
  --ficus-sway: 2.2deg;
  --ficus-speed: 5.8s;

  min-height: 120px;
}
.plant.ficus.entity::after{ content: none !important; }

.plant.ficus.entity .ficus-base,
.plant.ficus.entity .ficus-top{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.plant.ficus.entity .ficus-base{
  mask-image: linear-gradient(
    to top,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) calc(100% - var(--ficus-cut)),
    rgba(0,0,0,0) calc(100% - (var(--ficus-cut) - var(--ficus-feather))),
    rgba(0,0,0,0) 100%
  );
  mask-size: 100% 100%;
  mask-repeat: no-repeat;

  -webkit-mask-image: linear-gradient(
    to top,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) calc(100% - var(--ficus-cut)),
    rgba(0,0,0,0) calc(100% - (var(--ficus-cut) - var(--ficus-feather))),
    rgba(0,0,0,0) 100%
  );
  -webkit-mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
}

.plant.ficus.entity .ficus-top{
  mask-image: linear-gradient(
    to bottom,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) var(--ficus-cut),
    rgba(0,0,0,0) calc(var(--ficus-cut) + var(--ficus-feather)),
    rgba(0,0,0,0) 100%
  );
  mask-size: 100% 100%;
  mask-repeat: no-repeat;

  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0,0,0,1) 0%,
    rgba(0,0,0,1) var(--ficus-cut),
    rgba(0,0,0,0) calc(var(--ficus-cut) + var(--ficus-feather)),
    rgba(0,0,0,0) 100%
  );
  -webkit-mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;

  transform-origin: 50% calc(var(--ficus-cut) + 18%);
  animation: ficusTopSway var(--ficus-speed) ease-in-out infinite;
  will-change: transform;
}

@keyframes ficusTopSway{
  0%   { transform: rotate(calc(var(--ficus-sway) * -1)); }
  50%  { transform: rotate(var(--ficus-sway)); }
  100% { transform: rotate(calc(var(--ficus-sway) * -1)); }
}

.plant.ficus.entity:nth-of-type(2n){ --ficus-speed: 6.6s; --ficus-sway: 1.8deg; }
.plant.ficus.entity:nth-of-type(3n){ --ficus-speed: 5.0s; --ficus-sway: 2.6deg; }

.plant.ficus.entity::before{
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6%;
  width: 60%;
  height: 16%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(
    ellipse at center,
    rgba(0,0,0,0.45) 0%,
    rgba(0,0,0,0.28) 45%,
    rgba(0,0,0,0.12) 70%,
    rgba(0,0,0,0.0) 100%
  );
  filter: blur(6px);
  opacity: 0.75;
  pointer-events: none;
  z-index: -1;
}

/* ===== Door tag ===== */
.door-tag{
  position: absolute;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(10,10,10,0.68);
  backdrop-filter: blur(4px);
  color: rgba(255,255,255,0.92);
  text-align: center;
  cursor: pointer;

  box-shadow:
    0 14px 30px rgba(0,0,0,0.55),
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -10px 18px rgba(0,0,0,0.35) inset;
}
.door-tag .tag-title{
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.door-tag .tag-sub{
  display: block;
  margin-top: 4px;
  font-family: "Libre Baskerville", serif;
  font-weight: 400;
  font-size: 12px;
  opacity: 0.9;
}
.door-tag[data-wall="left"]  { transform: rotate(-2deg); }
.door-tag[data-wall="right"] { transform: rotate( 2deg); }

/* ===== Debug HUD ===== */
#debug-hud{
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 200;
  background: rgba(0,0,0,0.68);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  color: rgba(255,255,255,0.92);
  min-width: 280px;
}
#debug-hud strong{ display:block; margin-bottom:6px; }
#hud-room{ opacity:0.88; margin-bottom:8px; }
.hud-row{ font-size:12px; opacity:0.88; margin:2px 0; }

#reset-exhibit{
  margin-top: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.92);
  cursor: pointer;
}

/* ===== Error panel ===== */
#error-panel{
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 220;
  max-width: min(560px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,120,120,0.25);
  background: rgba(30,0,0,0.7);
  color: rgba(255,220,220,0.95);
  white-space: pre-wrap;
}

/* ===== Bulletin modal ===== */
#bulletin-modal{
  position: fixed;
  inset: 0;
  z-index: 500;
}
#bulletin-modal[hidden]{ display:none; }

#bulletin-modal-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
}
#bulletin-modal-content{
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 40px));
  background: rgba(14,14,14,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#bulletin-modal-topbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.bulletin-modal-title{
  color: rgba(255,255,255,0.92);
  font-weight: 700;
  font-family: "Playfair Display", serif;
  letter-spacing: 0.02em;
}
.bulletin-modal-hint{
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  opacity: 0.9;
}
.hint-chip{
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}
#bulletin-modal-close{
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  cursor: pointer;
}
#bulletin-modal-board{
  position: relative;
  flex: 1;
  padding: 14px;
}
.bulletin-zoom{
  position: absolute;
  inset: 14px;
  background-size: cover;
  background-position: center;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
}
.bulletin-zoom .pin{
  position: absolute;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
}
.bulletin-zoom .note{
  position: absolute;
  min-width: 160px;
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: rgba(255,255,255,0.92);
  font-size: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
  backdrop-filter: blur(3px);
}

/* ===== Museum popup (if you use it) ===== */
.museum-popup{
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}
.museum-popup[hidden]{ display:none; }

.museum-popup-card{
  width: min(560px, 92vw);
  border-radius: 18px;
  padding: 18px 18px 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(30,24,18,0.92), rgba(10,10,10,0.90));
  box-shadow: 0 18px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.10);
}
.museum-popup-title{
  font-family: "Playfair Display", serif;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-size: 20px;
  color: rgba(255,255,255,0.95);
  margin-bottom: 8px;
}
.museum-popup-body{
  font-size: 14px;
  line-height: 1.55;
  color: rgba(255,255,255,0.88);
  white-space: pre-wrap;
}
.museum-popup-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
#museum-popup-close{
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
}
#museum-popup-close:hover{
  background: rgba(255,255,255,0.12);
}

/* ==========================
   HARD CLICKABILITY FIX
   (put this at the VERY BOTTOM)
========================== */

/* The scene must accept clicks */
#museum-viewport,
#camera,
#room{
  pointer-events: auto !important;
}

/* All entities must accept clicks */
#room > .entity,
#room > .entity *{
  pointer-events: auto !important;
}

/* Visual-only layers must NEVER block clicks */
#lobby-img,
#parallax-far,
#parallax-near,
#lighting-overlay,
#atmosphere-overlay{
  pointer-events: none !important;
}

/* If any modal is hidden, it must not block clicks */
#bulletin-modal[hidden],
#museum-popup[hidden]{
  pointer-events: none !important;
}

#visitor-hud {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5000;
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(12, 12, 12, 0.78);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  font-family: "Libre Baskerville", serif;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}

#visitor-hud-hint {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.68);
}

#visitor-guide[hidden] {
  display: none !important;
}

#visitor-guide {
  position: fixed;
  inset: 0;
  z-index: 6000;
}

#visitor-guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
}

#visitor-guide-panel {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  margin: 10vh auto 0;
  padding: 22px;
  border-radius: 16px;
  background: rgba(20,20,20,0.96);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.92);
  font-family: "Libre Baskerville", serif;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

#visitor-guide-panel h2 {
  margin-top: 0;
}

#visitor-guide-panel button {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: white;
  cursor: pointer;
}
