/* --- Global layout --- */
html,
body {
  height: 100%;
  margin: 0;
  font-family: "Playfair Display", serif;
  background-color: #5b4568; /* base purple tone */
  overflow: hidden;
}

/* --- Main room --- */
.room {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: url("droom-bg.png");
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transition: opacity 0.4s ease;
  z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: -340px;
  width: 340px;
  height: 100vh;
  background: linear-gradient(180deg, #3b2a4a, #2a1f38 70%);
  color: white;
  transition: left 0.5s ease;
  backdrop-filter: blur(10px);
  z-index: 5;
  box-shadow: 3px 0 12px rgba(0, 0, 0, 0.3);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding-top: 80px;
}

/* inner scroll area keeps the grid layout */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 16px 120px; /* add bottom room for last row */
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: min-content;
  gap: 12px;
  align-content: start;
}

.sidebar.active {
  left: 0;
}

/* optional subtle fade at bottom */
.sidebar-content::after {
  content: "";
  position: sticky;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(to bottom, transparent, rgba(43, 31, 56, 0.95));
  pointer-events: none;
}

/* optional scrollbar styling */
.sidebar-content::-webkit-scrollbar {
  width: 8px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

/* --- Object cards --- */
.object-card {
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  transition: all 0.25s ease;
  cursor: pointer;
}

.object-card:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.object-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s ease;
}

.object-card:hover img {
  transform: scale(1.05);
}

.object-info h3,
.object-info h6,
.object-info p {
  margin: 2px 0;
}

.object-info h3 {
  font-family: "Playfair Display", serif;
  font-size: 14px;
  margin: 6px 0 2px;
  color: #fff;
}

.object-info p {
  font-size: 11.5px;
  line-height: 1.3em;
  color: rgba(255, 255, 255, 0.75);
  margin: 0 4px 6px;
}
/* --- Dropped items --- */
.dropped {
  position: absolute;
  cursor: move;
  user-select: none;
  z-index: 3;
}
.dropped.selected {
  outline: 2px dashed rgba(255, 255, 255, 0.7);
}
.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #333;
  border-radius: 2px;
  cursor: se-resize;
  transform: translate(50%, 50%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.dropped:hover .resize-handle {
  opacity: 1;
}

/* --- Buttons (top & bottom controls) --- */
.instruction-btn,
.screenshot-btn,
.qr-btn,
.back-btn {
  position: fixed;
  padding: 8px 16px;
  background-color: rgba(65, 65, 65, 0.85);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  z-index: 10;
  transition: all 0.3s ease;
}
.instruction-btn:hover,
.screenshot-btn:hover,
.qr-btn:hover,
.back-btn:hover {
  background-color: white;
  color: black;
}

/* --- Button placement --- */
.toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  padding: 8px 16px;
  background-color: rgba(65, 65, 65, 0.85);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 16px;
  z-index: 15;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.toggle:hover {
  background-color: white;
  color: black;
}
.instruction-btn {
  top: 20px;
  right: 15px;
}
.screenshot-btn {
  top: 70px;
  right: 15px;
}
.qr-btn {
  top: 120px;
  right: 15px;
}
.back-btn {
  bottom: 20px;
  right: 20px;
}

/* --- Room background selector --- */
#bgSelector {
  position: fixed;
  top: 180px;
  right: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}
#bgSelector img {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.25s ease, border 0.25s ease;
}
#bgSelector img:hover {
  transform: scale(1.1);
  border-color: white;
}

/* 📸 Softer, natural camera flash */
#flash-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 248, 240, 0.9); /* warm soft light */
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity 0.8s ease-out; /* 👈 smooth fade-out */
}

/* when active */
#flash-overlay.active {
  opacity: 1;
  transition: opacity 0.2s ease-in; /* 👈 quick burst in */
}

/* --- Screenshot modal (Polaroid preview) --- */
.photo-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(40, 30, 50, 0.65);
  backdrop-filter: blur(5px);
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}
.photo-modal.active {
  display: flex;
  opacity: 1;
}

.photo-content img {
  background: transparent; /* no double paper layer */
  padding: 0; /* Polaroid padding comes from JS */
  border-radius: 0; /* keep straight Polaroid edges */
  box-shadow: none; /* ❌ remove outer frame/shadow */
  transform: rotate(-1deg);
  max-width: 80vw;
  max-height: 70vh;
  object-fit: contain;
  transition: transform 0.3s ease;
  margin-bottom: 40px; /* adjust spacing above buttons */
}

.photo-content img:hover {
  transform: rotate(0deg) scale(1.02);
  box-shadow: 0 30px 50px rgba(0, 0, 0, 0.4);
}
.photo-buttons {
  display: flex;
  justify-content: center;
  gap: 40px;
}
.photo-buttons button {
  background-color: rgb(83, 70, 102);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.25s;
}
.photo-buttons button:hover {
  background-color: rgb(50, 40, 70);
}

/* --- QR code modal --- */
#qrOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 80;
  justify-content: center;
  align-items: center;
}
#qrModal {
  background: #fdf8f1;
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.35);
  text-align: center;
  width: 320px;
  animation: fadeIn 0.3s ease;
}
#qrModal button {
  background-color: rgb(83, 70, 102);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  margin-top: 15px;
  cursor: pointer;
}
#qrModal button:hover {
  background-color: rgb(50, 40, 70);
}

/* --- Instruction panel --- */
.instruction-panel {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  z-index: 100;
}
.instruction-panel.active {
  display: flex;
}
.instruction-content {
  background: #fdf8f1;
  color: #333;
  padding: 25px 40px;
  border-radius: 10px;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.35);
  max-width: 420px;
  width: 80%;
  text-align: left;
}
.instruction-content h3 {
  text-align: center;
  margin-top: 0;
}
.instruction-content ul {
  list-style: none;
  padding: 0;
}
.instruction-content li {
  margin: 6px 0;
  line-height: 1.4;
}
.instruction-content button {
  margin-top: 16px;
  background: rgb(83, 70, 102);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.25s;
}
.instruction-content button:hover {
  background: rgb(50, 40, 70);
}

/* --- Room change warning modal --- */
.warning-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 120;
  justify-content: center;
  align-items: center;
}
.warning-modal.active {
  display: flex;
}
.warning-box {
  background: #fdf8f1;
  padding: 30px 40px;
  border-radius: 12px;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.35);
  text-align: center;
  max-width: 360px;
  animation: fadeIn 0.3s ease;
}
.warning-box h3 {
  margin-top: 0;
  color: #2b2b2b;
}
.warning-box p {
  font-size: 16px;
  color: #333;
  margin-bottom: 25px;
  line-height: 1.5;
}
.warning-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}
.warning-buttons button {
  background: rgb(83, 70, 102);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.25s;
}
.warning-buttons button:hover {
  background: rgb(50, 40, 70);
}

/* --- Animations --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.rotate-handle {
  position: absolute;
  top: -20px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #333;
  border-radius: 50%;
  cursor: grab;
  transform: translate(-50%, 0);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.dropped:hover .rotate-handle {
  opacity: 1;
}
