/* ============================================================
   MIND MATTER — Virtual Art Gallery (fullscreen overlay)
   ============================================================ */

#g3dRoot {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0c0f16;
}
#g3dRoot.open { display: block; }

.g3d-stage,
.g3d-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.g3d-stage,
.g3d-stage canvas {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- HUD ---------- */
.g3d-hud { pointer-events: none; position: absolute; inset: 0; }

.g3d-topbar {
  pointer-events: auto;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 4; /* stays clickable above the start/pause card */
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: linear-gradient(to bottom, rgba(8, 10, 14, 0.72), rgba(8, 10, 14, 0.2) 70%, transparent);
}
.g3d-brand {
  font-family: 'Cinzel', serif;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(242, 236, 223, 0.92);
}
.g3d-brand b { color: #ff2d6f; font-weight: 600; }
.g3d-wayfind {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: rgba(233, 228, 216, 0.55);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 20, 0.45);
  white-space: nowrap;
}
.g3d-cart,
.g3d-mute,
.g3d-quality {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(242, 236, 223, 0.85);
  background: rgba(14, 16, 22, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.g3d-quality.is-high {
  border-color: rgba(245, 215, 110, 0.45);
  color: #f5d76e;
}
.g3d-cart.has-items {
  border-color: rgba(255, 45, 111, 0.55);
  color: #ff9db8;
}
.g3d-cart:hover,
.g3d-mute:hover,
.g3d-quality:hover {
  border-color: rgba(255, 45, 111, 0.5);
  color: #fff;
}
.g3d-help {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(242, 236, 223, 0.9);
  background: rgba(255, 45, 111, 0.12);
  border: 1px solid rgba(255, 45, 111, 0.4);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.g3d-help:hover {
  background: rgba(255, 45, 111, 0.22);
  border-color: #ff2d6f;
}
.g3d-exit {
  margin-left: auto;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(242, 236, 223, 0.88);
  background: rgba(14, 16, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.g3d-exit:hover {
  background: rgba(255, 45, 111, 0.14);
  border-color: rgba(255, 45, 111, 0.55);
  color: #fff;
}

.g3d-crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(233, 228, 216, 0.75);
  font-size: 20px;
  font-weight: 300;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  transition: opacity 0.3s;
}

.g3d-hint {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(233, 228, 216, 0.5);
  background: rgba(8, 10, 14, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 9px 20px;
  border-radius: 999px;
  white-space: nowrap;
  transition: opacity 0.3s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ---------- Start screen ---------- */
.g3d-start {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 18, 0.78);
  /* Keep the start card legible without blurring the rendered room heavily. */
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 2;
}
.g3d-start-card {
  text-align: center;
  max-width: 440px;
  padding: 48px 44px 40px;
  background: linear-gradient(160deg, rgba(18, 20, 26, 0.97), rgba(8, 10, 14, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-top: 1px solid rgba(255, 45, 111, 0.45);
  border-radius: 4px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.g3d-start-kicker {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: #ff2d6f;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.g3d-start-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #f2ecdf;
  margin: 0 0 14px;
}
.g3d-start-card p {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(233, 228, 216, 0.7);
  margin: 0 0 24px;
}
.g3d-keys {
  display: block;
  margin-top: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: rgba(233, 228, 216, 0.4);
}

.g3d-exit-home {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 11px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #e9e4d8;
  background: rgba(20, 24, 34, 0.75);
  border: 1px solid rgba(233, 228, 216, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.g3d-exit-home:hover {
  background: rgba(255, 45, 111, 0.15);
  border-color: #ff2d6f;
  color: #ff2d6f;
}

.g3d-start-guide {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 11px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #e9e4d8;
  background: rgba(255, 45, 111, 0.12);
  border: 1px solid rgba(255, 45, 111, 0.4);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.g3d-start-guide:hover {
  background: rgba(255, 45, 111, 0.22);
  border-color: #ff2d6f;
  color: #ff2d6f;
}

/* ---------- First-run guide overlay (button styles live with topbar) ---------- */
.g3d-guide {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding-top: 56px;
  box-sizing: border-box;
  background: rgba(7, 10, 18, 0.72);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 3; /* above start card, below topbar so Exit / Guide stay clickable */
  cursor: pointer; /* dimmed screen is clickable to dismiss */
  pointer-events: auto;
}
.g3d-guide.show {
  display: flex;
}
.g3d-guide-card {
  width: min(540px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  text-align: left;
  padding: 36px 38px 30px;
  background: linear-gradient(145deg, rgba(24, 26, 32, 0.97), rgba(10, 13, 20, 0.97));
  border: 1px solid rgba(233, 228, 216, 0.18);
  border-top-color: rgba(255, 45, 111, 0.5);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  animation: g3dGuideIn 0.3s cubic-bezier(0.2, 0.8, 0.25, 1);
  cursor: default;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}
.g3d-guide-actions,
.g3d-guide-actions .btn-gold,
.g3d-guide-skip {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
@keyframes g3dGuideIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.g3d-guide-kicker {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: #ff2d6f;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.g3d-guide-card h2 {
  font-family: 'Cinzel', serif;
  font-size: 26px;
  color: #f2ecdf;
  margin: 0 0 8px;
}
.g3d-guide-intro {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: rgba(233, 228, 216, 0.65);
  margin: 0 0 22px;
}
.g3d-guide-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 26px;
}
.g3d-guide-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.g3d-guide-num {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  color: #ff2d6f;
  background: rgba(255, 45, 111, 0.12);
  border: 1px solid rgba(255, 45, 111, 0.35);
  border-radius: 8px;
}
.g3d-guide-row-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.g3d-guide-row-body strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  letter-spacing: 0.04em;
  color: #f2ecdf;
}
.g3d-guide-desc {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12.5px;
  line-height: 1.55;
  color: rgba(233, 228, 216, 0.62);
}
.g3d-guide-desc b { color: #e9e4d8; font-weight: 500; }
.g3d-guide-desc kbd {
  display: inline-block;
  min-width: 22px;
  padding: 2px 6px;
  margin: 0 1px;
  text-align: center;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #e9e4d8;
  background: rgba(20, 24, 34, 0.9);
  border: 1px solid rgba(233, 228, 216, 0.3);
  border-bottom-width: 2px;
  border-radius: 5px;
}
.g3d-guide-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.g3d-guide-actions .btn-gold { flex: 1 1 auto; }
.g3d-guide-skip {
  background: none;
  border: none;
  padding: 8px 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: rgba(233, 228, 216, 0.55);
  cursor: pointer;
  transition: color 0.2s;
}
.g3d-guide-skip:hover { color: #e9e4d8; }
.g3d-guide-note {
  display: block;
  margin-top: 16px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: rgba(233, 228, 216, 0.38);
}

/* ---------- Focus plaque ---------- */
.g3d-plaque {
  position: absolute;
  right: 34px;
  bottom: 34px;
  width: 320px;
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.25, 1);
  z-index: 3;
}
.g3d-plaque.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.g3d-plaque-inner {
  background: rgba(13, 17, 26, 0.94);
  border: 1px solid rgba(255, 45, 111, 0.3);
  border-radius: 12px;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.g3d-plaque-label {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: #ff2d6f;
  text-transform: uppercase;
}
.g3d-plaque-inner h3 {
  font-family: 'Cinzel', serif;
  font-size: 20px;
  color: #f2ecdf;
  margin: 10px 0 4px;
}
.g3d-plaque-inner p {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(233, 228, 216, 0.55);
  margin: 0 0 16px;
}
.g3d-plaque-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.g3d-plaque-price {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #ff2d6f;
}
.g3d-back {
  margin-top: 16px;
  width: 100%;
  background: none;
  border: none;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(233, 228, 216, 0.5);
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s;
}
.g3d-back:hover { color: #e9e4d8; }

/* ---------- Touch omnidirectional stick ---------- */
.g3d-stick {
  display: none;
  position: absolute;
  left: 22px;
  bottom: 28px;
  width: 118px;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  z-index: 3;
}
.g3d-stick-base {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: rgba(14, 16, 22, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.g3d-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  background: rgba(255, 45, 111, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 16px rgba(255, 45, 111, 0.35);
  transition: transform 0.05s linear;
}
.g3d-stick span {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(233, 228, 216, 0.5);
}
.g3d-browse {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.g3d-browse[hidden] { display: none !important; }
.g3d-browse-btn {
  flex: 1;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e9e4d8;
  background: rgba(20, 24, 34, 0.85);
  border: 1px solid rgba(233, 228, 216, 0.2);
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
}
.g3d-browse-btn:hover {
  border-color: #ff2d6f;
  color: #ff2d6f;
}

/* VR entry removed — hide any leftover Three VRButton / “VR NOT SUPPORTED” chrome */
.g3d-vrbtn,
#VRButton,
button.VRButton,
a.VRButton {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Hidden-attribute guards: component classes set display, which would
   otherwise override the hidden attribute on non-editor sessions. */
.g3d-modes[hidden],
.g3d-editorbar[hidden],
.g3d-tray[hidden],
.g3d-edit-actions[hidden] {
  display: none !important;
}
/* Guide button must never be force-hidden via [hidden] — HARD FREEZE */

/* ---------- Editor: walk/edit mode toggle ---------- */
.g3d-modes {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(20, 24, 34, 0.75);
  border: 1px solid rgba(233, 228, 216, 0.18);
  border-radius: 8px;
}
.g3d-mode {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(233, 228, 216, 0.6);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.g3d-mode:hover { color: #e9e4d8; }
.g3d-mode.on {
  color: #0a0d14;
  background: #ff2d6f;
  box-shadow: 0 0 14px rgba(255, 45, 111, 0.45);
}

/* ---------- Editor: toolbar (save / reset / add works) ---------- */
.g3d-editorbar {
  position: absolute;
  bottom: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(13, 17, 26, 0.92);
  border: 1px solid rgba(255, 45, 111, 0.3);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
  z-index: 3;
}
.g3d-editorbar-title {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(233, 228, 216, 0.55);
  margin-right: 4px;
}

/* ---------- Editor: tray of unshelved works ---------- */
.g3d-tray {
  position: absolute;
  left: 50%;
  bottom: 128px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  max-height: 200px;
  overflow: auto;
  background: rgba(13, 17, 26, 0.94);
  border: 1px solid rgba(255, 45, 111, 0.3);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  padding: 12px;
  z-index: 3;
}
.g3d-tray-head {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(233, 228, 216, 0.55);
  margin-bottom: 10px;
}
.g3d-tray-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.g3d-tray-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(20, 24, 34, 0.8);
  border: 1px solid rgba(233, 228, 216, 0.14);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: #e9e4d8;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  text-align: left;
}
.g3d-tray-item:hover {
  border-color: #ff2d6f;
  background: rgba(255, 45, 111, 0.1);
}
.g3d-tray-item img {
  width: 100%;
  height: 64px;
  object-fit: cover;
  border-radius: 4px;
}
.g3d-tray-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.g3d-tray-size {
  font-family: 'Space Mono', monospace !important;
  font-size: 9px !important;
  letter-spacing: 0.06em;
  color: rgba(233, 228, 216, 0.5) !important;
}

/* Empty tray is a real state with a way out, not a blank panel */
.g3d-tray-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 2px 2px;
  font-family: 'Space Grotesk', sans-serif;
}
.g3d-tray-empty[hidden] { display: none; }
.g3d-tray-empty b {
  font-size: 13px;
  color: #e9e4d8;
  letter-spacing: 0.01em;
}
.g3d-tray-empty span {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(233, 228, 216, 0.6);
}
.g3d-tray-empty .btn {
  margin-top: 2px;
}

/* Reset arms itself before it clears the room — a native confirm() would
   drop pointer lock and break the 3D feel */
#g3dReset.armed {
  border-color: #ff2d6f;
  background: rgba(255, 45, 111, 0.16);
  color: #fff;
}

/* ---------- Editor: plaque actions ---------- */
.g3d-edit-actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 14px;
}
.g3d-edit-actions button {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  color: #e9e4d8;
  background: rgba(20, 24, 34, 0.85);
  border: 1px solid rgba(233, 228, 216, 0.22);
  border-radius: 6px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.g3d-edit-actions button:hover {
  border-color: #ff2d6f;
  color: #ff2d6f;
}
.g3d-edit-actions button.danger:hover {
  background: rgba(255, 45, 111, 0.18);
}

/* ---------- Entry button on main site ---------- */
.enter-gallery3d {
  position: relative;
  overflow: hidden;
}

@media (max-width: 1024px) {
  .g3d-topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .g3d-hint { bottom: 18px; font-size: 9px; max-width: 92vw; white-space: normal; text-align: center; }
  .g3d-mute { display: none; }
  .g3d-quality { font-size: 10px; padding: 7px 10px; }
}

@media (max-width: 720px) {
  .g3d-plaque { right: 16px; bottom: 118px; width: calc(100% - 32px); max-width: 320px; }
  .g3d-topbar { padding: 10px 12px; gap: 8px; }
  .g3d-brand { font-size: 11px; letter-spacing: 0.1em; }
  .g3d-exit { padding: 8px 11px; font-size: 10px; }
  .g3d-wayfind { font-size: 9px; padding: 5px 10px; }
  .g3d-hint { display: none; }
  .g3d-help { padding: 7px 12px; } /* keep Guide visible on phone */
  .g3d-guide-card { padding: 28px 24px 24px; }
  .g3d-guide-card h2 { font-size: 22px; }
  .g3d-guide-actions .btn-gold { width: 100%; }
  .g3d-editorbar { bottom: 118px; }
  .g3d-editorbar-title { display: none; }
  .g3d-tray { bottom: 168px; }
  .g3d-stick { left: 14px; bottom: 22px; }
}
