/* 360° tour viewer page */

.tour-body {
  --glass: rgba(20, 20, 22, 0.42);
  --glass-strong: rgba(20, 20, 22, 0.62);
  --glass-line: rgba(255, 255, 255, 0.28);
  --text: #f5f5f7;
  --muted: rgba(245, 245, 247, 0.72);

  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#tour-viewer {
  position: fixed;
  inset: 0;
}

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-line);
}

/* ---------- Top bar ---------- */

.tour-top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 32px calc(18px + env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0));
  pointer-events: none;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

.tour-top > * { pointer-events: auto; }

.tour-brand {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.tour-title {
  margin: 0;
  font-size: 15px;
  text-align: right;
  min-width: 0;
}

.tour-title span { display: block; font-size: 13px; color: var(--muted); }
.tour-title strong { display: block; font-weight: 500; }

/* ---------- Link markers in the panorama ---------- */

.tour-link {
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 20, 22, 0.38);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 180ms ease-out, background-color 180ms ease-out;
}

.tour-link svg { width: 22px; height: 22px; }

.tour-link:hover {
  transform: scale(1.1);
  background: rgba(20, 20, 22, 0.6);
}

.tour-link:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* room name shown when hovering a link */
.tour-body .psv-tooltip {
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-radius: 999px;
  box-shadow: none;
  font-family: inherit;
}

.tour-body .psv-tooltip-content { padding: 6px 12px; font-size: 13px; font-weight: 500; }
.tour-body .psv-tooltip-arrow { display: none; }

/* ---------- Bottom bar: rooms + buttons, no solid panel ---------- */

.tour-bottom {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  background: linear-gradient(to top, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.tour-bottom > * { pointer-events: auto; }

.tour-rooms {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 2px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.tour-rooms::-webkit-scrollbar { display: none; }
.tour-rooms li { flex: none; }

.tour-room {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease-out, background-color 160ms ease-out;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid transparent;
}

.tour-room:hover { color: var(--text); }
.tour-room[aria-current="true"] { color: #000; background: rgba(245, 245, 247, 0.92); }

.tour-tools { display: flex; gap: 8px; flex: none; }

.tour-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
  transition: background-color 160ms ease-out, color 160ms ease-out;
}

.tour-btn svg { width: 20px; height: 20px; }
.tour-btn:hover { background: var(--glass-strong); }
.tour-btn[aria-pressed="true"] { background: rgba(245, 245, 247, 0.92); color: #000; }
.tour-btn[hidden] { display: none; }

.tour-room:focus-visible,
.tour-btn:focus-visible,
.plan-dot:focus-visible,
.plan-expand:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Floor plan ---------- */

.tour-plan {
  position: fixed;
  z-index: 20;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(82px + env(safe-area-inset-bottom));
  width: min(300px, 32vw);
  border-radius: 18px;
  padding: 6px;
  transition: width 220ms ease-out;
}

.tour-plan[data-state="closed"] { display: none; }

.plan-frame {
  position: relative;
  border-radius: 13px;
  overflow: hidden;
  background: #fff;
}

.plan-frame img { display: block; width: 100%; height: auto; }

.plan-expand {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  cursor: pointer;
}
.plan-expand svg { width: 16px; height: 16px; }
.plan-expand .i-shrink { display: none; }
.tour-plan[data-state="open"] .plan-expand .i-grow { display: none; }
.tour-plan[data-state="open"] .plan-expand .i-shrink { display: block; }

.plan-dot {
  position: absolute;
  z-index: 2;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.plan-dot::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #1d1d1f;
  border: 2px solid #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
  transition: transform 160ms ease-out;
}

.plan-dot:hover::after { transform: scale(1.25); }
.plan-dot[aria-current]::after { background: #fff; border-color: #1d1d1f; inset: 5px; }

.plan-cone {
  position: absolute;
  z-index: 1;
  width: 120px;
  height: 120px;
  pointer-events: none;
}
.plan-cone svg { width: 100%; height: 100%; }
.plan-cone path { fill: rgba(29, 29, 31, 0.28); }
.plan-cone[hidden] { display: none; }

.plan-backdrop { display: none; }

/* floor switch (tours with more than one floor) */
.plan-floors { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 0 6px; }
.plan-floors[hidden] { display: none; }
.plan-floor {
  min-height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.plan-floor:hover { background: rgba(255, 255, 255, 0.2); }
.plan-floor[aria-pressed="true"] { background: rgba(245, 245, 247, 0.92); color: #000; }
.plan-floor:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.plan-dot[hidden] { display: none; }

/* big plan */
.tour-plan[data-state="open"] {
  width: auto;
  inset: calc(64px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) calc(82px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.tour-plan[data-state="open"] { grid-template-rows: auto auto; align-content: center; }
.tour-plan[data-state="open"] .plan-floors { justify-content: center; padding-bottom: 10px; }
.tour-plan.has-floors { --floors-h: 48px; }
.tour-plan[data-state="open"] .plan-floor { min-height: 34px; padding: 0 16px; font-size: 14px; background: rgba(20, 20, 22, 0.7); }
.tour-plan[data-state="open"] .plan-floor[aria-pressed="true"] { background: rgba(245, 245, 247, 0.95); }
.tour-plan[data-state="open"] .plan-frame {
  width: min(100%, calc((100dvh - 150px - var(--floors-h, 0px) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * var(--plan-ar, 1.5)));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.tour-plan[data-state="open"] .plan-cone { width: 180px; height: 180px; }
.tour-plan[data-state="open"] .plan-dot { width: 32px; height: 32px; margin: -16px 0 0 -16px; }
.tour-plan[data-state="open"] .plan-dot::after { inset: 8px; }
.tour-plan[data-state="open"] .plan-dot[aria-current]::after { inset: 6px; }

.tour-plan[data-state="open"] .plan-backdrop {
  display: block;
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* phones: the plan is a button; it opens big */
@media (max-width: 700px), (max-height: 500px) {
  .tour-plan[data-state="card"] { display: none; }
  .tour-plan[data-state="open"] { inset: calc(64px + env(safe-area-inset-top)) 12px calc(76px + env(safe-area-inset-bottom)); }
  .tour-plan[data-state="open"] .plan-expand { display: none; }
  .tour-bottom { gap: 8px; }
  .tour-btn { width: 36px; height: 36px; }
  .tour-room { min-height: 34px; padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-link, .tour-room, .tour-btn, .tour-plan, .plan-dot::after { transition: none; }
}

/* ---------- Embedded on a client's site ---------- */
.tour-embed .tour-top { padding-top: 12px; background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0)); }
.tour-embed .tour-brand { font-size: 12px; font-weight: 500; opacity: 0.8; }
.tour-embed .tour-title span { display: none; }
.tour-no-credit .tour-brand { display: none; }

/* ---------- VR ---------- */
.tour-vr { position: fixed; inset: 0; z-index: 1000; background: #000; display: grid; place-items: center; }
.tour-vr canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.tour-vr-note { margin: 0; color: rgba(245, 245, 247, 0.8); font-size: 17px; }
.tour-vr-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(20, 20, 22, 0.6);
  color: #fff;
  cursor: pointer;
}
.tour-vr-close svg { width: 18px; height: 18px; }
