/* ── Reset & Base Styles ── */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #0b0d13;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#pano {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ── Top Bar (Scene Name) ── */
#titleBar {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 65%, transparent 100%);
  color: #fff;
  padding: 14px 24px;
  padding-top: max(14px, env(safe-area-inset-top));
  z-index: 10;
  display: flex;
  align-items: center;
  pointer-events: none;
}

#titleBar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90vw;
}

/* ── Hotspots (General & Exhibits) ── */
.hotspot {
  width: 44px;
  height: 44px;
  background-color: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
  pointer-events: auto;
}

.hotspot:hover {
  transform: scale(1.15);
  background-color: rgba(255, 255, 255, 0.4);
}

.hotspot:active {
  transform: scale(0.95);
}

.hotspot.exhibit-hotspot {
  position: relative;
}

.hotspot.exhibit-hotspot::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3Cline x1='11' y1='8' x2='11' y2='14'%3E%3C/line%3E%3Cline x1='8' y1='11' x2='14' y2='11'%3E%3C/line%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.hotspot-tooltip {
  position: absolute;
  top: -34px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 18, 25, 0.9);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: white;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  display: none;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
}

@media (hover: hover) {
  .hotspot:hover .hotspot-tooltip {
    display: block;
  }
}

/* ── Floor Navigation Hotspot (Arrows) ── */
.floor-nav-hotspot {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transform: translateX(-50%);
  user-select: none;
  pointer-events: auto;
  padding: 8px;
}

.floor-nav-hotspot .floor-arrow-ring {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.35), 0 6px 20px rgba(0,0,0,0.5);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
  animation: floor-pulse 2s ease-in-out infinite;
}

.floor-nav-hotspot:hover .floor-arrow-ring {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.4);
  animation: none;
}

.floor-nav-hotspot:active .floor-arrow-ring {
  transform: scale(0.92);
}

.floor-nav-hotspot .floor-arrow-ring svg {
  width: 26px;
  height: 26px;
  fill: white;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.floor-nav-hotspot .floor-label {
  margin-top: 8px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  white-space: nowrap;
  background: rgba(12, 15, 22, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 3px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes floor-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,255,255,0.55), 0 4px 16px rgba(0,0,0,0.4); }
  60%  { box-shadow: 0 0 0 14px rgba(255,255,255,0), 0 4px 16px rgba(0,0,0,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(255,255,255,0), 0 4px 16px rgba(0,0,0,0.4); }
}

/* ── Info Panel (Desktop Layout) ── */
#infoPanelWrapper {
  position: absolute;
  top: 65px;
  left: 20px;
  width: 360px;
  max-width: 36%;
  height: calc(100% - 90px);
  z-index: 15;
  pointer-events: none;
}

#infoPanel {
  width: 100%;
  height: 100%;
  background: rgba(15, 18, 25, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  overflow: hidden;
  transition: opacity 0.25s, transform 0.25s;
}

.sheet-drag-handle {
  display: none; /* Only on mobile */
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.95);
}

#toggleInfoBtn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  transition: background-color 0.2s, transform 0.2s;
  padding: 0;
}

#toggleInfoBtn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

#infoPanelContent {
  padding: 20px;
  font-size: 15px;
  line-height: 1.65;
  color: rgba(255, 255, 255, 0.9);
  overflow-y: auto;
  flex-grow: 1;
  user-select: text;
  -webkit-user-select: text;
}

#infoPanelContent p {
  margin: 0 0 16px 0;
}
#infoPanelContent p:last-child {
  margin-bottom: 0;
}

/* Custom Scrollbar */
#infoPanelContent::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
  width: 6px;
}
#infoPanelContent::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 4px;
}

/* ── Show Info Button (Pill) ── */
#showInfoBtn {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  transition: transform 0.2s, background-color 0.2s;
}

#showInfoBtn:hover {
  background: rgba(25, 30, 42, 0.95);
  transform: scale(1.04);
}

#showInfoBtn:active {
  transform: scale(0.96);
}

.info-icon {
  font-size: 16px;
  opacity: 0.9;
}

/* ── Navigation Buttons (Back Button) ── */
#navButtons {
  position: absolute;
  bottom: 24px;
  right: 24px;
  padding-bottom: env(safe-area-inset-bottom);
  padding-right: env(safe-area-inset-right);
  display: flex;
  gap: 12px;
  z-index: 20;
  pointer-events: none;
}

#navButtons button {
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 10px 20px;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.2s, transform 0.2s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

#navButtons button:hover {
  background: rgba(25, 30, 42, 0.95);
  transform: scale(1.04);
}

#navButtons button:active {
  transform: scale(0.96);
}

/* ── Onboarding Hint ── */
#onboardingHint {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  pointer-events: none;
  animation: hint-appear 0.5s ease forwards, hint-disappear 0.5s ease 6s forwards;
  width: auto;
  max-width: 90vw;
}

@keyframes hint-appear {
  from { opacity: 0; transform: translateX(-50%) translateY(15px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes hint-disappear {
  from { opacity: 1; }
  to   { opacity: 0; }
}

#onboardingHintInner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 18px;
  padding: 12px 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}

.hint-arrow-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: floor-pulse 2s ease-in-out infinite;
}

.hint-arrow-icon svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.hint-text {
  color: white;
  font-size: 14px;
  line-height: 1.45;
}

.hint-mouse {
  font-size: 12.5px;
  opacity: 0.8;
  display: inline;
}

.hint-touch {
  font-size: 12.5px;
  opacity: 0.8;
  display: none;
}

/* ── Rotate Hint (Top-Right) ── */
#rotatehint {
  position: absolute;
  top: 60px;
  right: 20px;
  z-index: 15;
  pointer-events: all;
  animation: rh-fadein 0.7s ease 0.3s both;
  transition: opacity 0.4s;
}

@keyframes rh-fadein {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

#rotatehintClose {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.6);
  color: white;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 16;
  transition: background 0.2s;
  padding: 0;
}

#rotatehintClose:hover {
  background: rgba(255,255,255,0.5);
}

#rotatehintInner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(15, 18, 25, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  padding: 12px 16px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.45);
  pointer-events: none;
}

#rotatehintSvg {
  width: 64px;
  height: 64px;
  animation: rh-spin 3s ease-in-out infinite;
  overflow: visible;
}

@keyframes rh-spin {
  0%   { transform: rotate(-18deg); }
  50%  { transform: rotate(18deg); }
  100% { transform: rotate(-18deg); }
}

.rh-arc {
  animation: rh-arc-pulse 1.5s ease-in-out infinite alternate;
}
.rh-arc:last-child {
  animation-delay: 0.75s;
}

@keyframes rh-arc-pulse {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

#rotatehintLabel {
  color: rgba(255,255,255,0.9);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* ── Modal (Exhibits & Details) ── */
.modal {
  display: none; 
  position: fixed; 
  z-index: 200; 
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; 
  background-color: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-content {
  background-color: #fff;
  color: #1a1a1a;
  margin: auto;
  padding: 24px;
  border: none;
  width: 90%;
  max-width: 680px;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
  user-select: text;
  -webkit-user-select: text;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.close-btn {
  color: #555;
  background: rgba(0, 0, 0, 0.07);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  transition: background-color 0.2s, color 0.2s;
  padding: 0;
}

.close-btn:hover {
  background: rgba(0, 0, 0, 0.15);
  color: #000;
}

#modalImage {
  display: none;
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: 12px;
  background: #f4f4f6;
  margin-top: 6px;
}

#modalText {
  margin-top: 18px;
  font-size: 15px;
  line-height: 1.6;
  color: #2c3038;
}

/* ==========================================================================
   MOBILE & RESPONSIVE ADAPTATIONS (<= 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
  
  /* Top Bar */
  #titleBar {
    padding: max(10px, env(safe-area-inset-top)) 16px 8px;
    background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 75%, transparent 100%);
  }
  
  #titleBar h1 {
    font-size: 15px;
    font-weight: 600;
    max-width: calc(100vw - 32px);
    line-height: 1.35;
  }

  /* Hotspots Touch Targets */
  .hotspot {
    width: 46px;
    height: 46px;
  }
  
  .floor-nav-hotspot .floor-arrow-ring {
    width: 48px;
    height: 48px;
  }
  .floor-nav-hotspot .floor-arrow-ring svg {
    width: 24px;
    height: 24px;
  }
  .floor-nav-hotspot .floor-label {
    font-size: 11.5px;
    padding: 3px 10px;
    max-width: 160px;
  }

  /* Rotate Hint Mobile */
  #rotatehint {
    top: max(54px, calc(env(safe-area-inset-top) + 44px));
    right: 12px;
  }
  #rotatehintInner {
    padding: 8px 10px 6px;
    border-radius: 12px;
  }
  #rotatehintSvg {
    width: 42px;
    height: 42px;
  }
  #rotatehintLabel {
    font-size: 10px;
  }

  /* Mobile Bottom Sheet for Info Panel */
  #infoPanelWrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  #infoPanel {
    width: 100%;
    height: auto;
    max-height: 72vh;
    border-radius: 20px 20px 0 0;
    background: rgba(14, 17, 24, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    animation: sheetSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); opacity: 0.5; }
    to   { transform: translateY(0); opacity: 1; }
  }

  .sheet-drag-handle {
    display: block;
    width: 38px;
    height: 4px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    margin: 10px auto 4px;
  }

  .panel-header {
    padding: 8px 18px 12px;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .panel-title {
    font-size: 16px;
  }

  #toggleInfoBtn {
    width: 32px;
    height: 32px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.15);
  }

  #infoPanelContent {
    padding: 16px 20px 24px;
    font-size: 14.5px;
    line-height: 1.6;
    -webkit-overflow-scrolling: touch;
  }

  /* Show Info Button - Bottom Left Mobile Pill */
  #showInfoBtn {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
    top: auto;
    z-index: 25;
    padding: 9px 16px;
    font-size: 13.5px;
    border-radius: 20px;
    background: rgba(14, 17, 24, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  /* Back Button - Bottom Right Mobile Pill */
  #navButtons {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: 16px;
    z-index: 25;
    padding: 0;
  }

  #navButtons button {
    padding: 9px 18px;
    font-size: 13.5px;
    border-radius: 20px;
    background: rgba(14, 17, 24, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  /* Onboarding Hint Mobile */
  #onboardingHint {
    bottom: max(85px, calc(env(safe-area-inset-bottom) + 75px));
    width: calc(100% - 32px);
    max-width: 340px;
  }

  #onboardingHintInner {
    padding: 10px 14px;
    gap: 12px;
    border-radius: 14px;
  }

  .hint-arrow-icon {
    width: 30px;
    height: 30px;
  }
  .hint-arrow-icon svg {
    width: 15px;
    height: 15px;
  }
  .hint-text {
    font-size: 13px;
  }
  .hint-mouse {
    display: none;
  }
  .hint-touch {
    display: inline;
  }

  /* Modal Mobile */
  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    margin-bottom: env(safe-area-inset-bottom);
    padding: 16px;
    border-radius: 18px;
    max-height: 85vh;
  }

  #modalImage {
    max-height: 42vh;
  }

  #modalText {
    font-size: 14px;
    line-height: 1.55;
    margin-top: 14px;
  }

  .close-btn {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    font-size: 22px;
  }
}

/* ── Landscape mode on mobile devices ── */
@media screen and (max-height: 500px) and (orientation: landscape) {
  #titleBar {
    padding: max(6px, env(safe-area-inset-top)) 16px 6px;
  }
  #titleBar h1 {
    font-size: 13.5px;
  }
  #rotatehint {
    display: none; /* Hide in horizontal orientation */
  }
  #infoPanel {
    max-height: 82vh;
  }
  #modalImage {
    max-height: 36vh;
  }
  #onboardingHint {
    bottom: 60px;
  }
}
