/* Panorama & Photosphere Modern Gallery & Viewer */
:root {
  --bg-primary: #090a0f;
  --bg-secondary: #12141c;
  --bg-surface: rgba(22, 26, 38, 0.75);
  --bg-surface-hover: rgba(32, 38, 56, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #f0f3f8;
  --text-secondary: #9aa5b8;
  --text-muted: #647087;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.35);
  --accent-photosphere: #8b5cf6;
  --accent-photosphere-glow: rgba(139, 92, 246, 0.35);
  --accent-panorama: #06b6d4;
  --accent-panorama-glow: rgba(6, 182, 212, 0.35);
  --success: #10b981;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
}

/* Header & Navigation */
header.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-top) + 12px) 20px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: rgba(9, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.brand-text h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* Hero Section */
.hero {
  padding: 40px 20px 24px;
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
}

.hero h2 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #ffffff 40%, #9aa5b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 650px;
  margin: 0 auto 28px;
}

/* Filter Controls */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.filter-count {
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
}

/* Gallery Grid */
.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px 80px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
}

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

/* Photo Card */
.photo-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  display: flex;
  flex-direction: column;
}

.photo-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.card-media {
  position: relative;
  width: 100%;
  padding-top: 50%; /* 2:1 default preview ratio */
  background: #000;
  overflow: hidden;
  cursor: pointer;
}

.card-media img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.photo-card:hover .card-media img {
  transform: scale(1.04);
}

.media-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.badge-photosphere {
  background: rgba(139, 92, 246, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.badge-panorama {
  background: rgba(6, 182, 212, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.photo-card:hover .play-overlay {
  opacity: 1;
}

.play-circle {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.9);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  font-size: 22px;
}

.card-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.btn {
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  flex-grow: 1;
}

.btn-primary:hover {
  background: #2563eb;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-icon-only {
  padding: 9px 12px;
}

/* ========================================================== */
/* STANDALONE PHOTO VIEWER PAGE (Optimized for Vertical Phone) */
/* ========================================================== */

body.viewer-mode {
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  display: flex;
  flex-direction: column;
}

.viewer-app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}

/* Floating Top Navigation Header */
.viewer-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: calc(var(--safe-top) + 12px) calc(var(--safe-right) + 16px) 14px calc(var(--safe-left) + 16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 70%, transparent 100%);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.viewer-header > * {
  pointer-events: auto;
}

.viewer-header.hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-round {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(18, 20, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-round:hover, .btn-round:active {
  background: rgba(35, 40, 58, 0.9);
  transform: scale(1.05);
}

.viewer-title-box {
  display: flex;
  flex-direction: column;
}

.viewer-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

@media (min-width: 600px) {
  .viewer-title {
    max-width: 400px;
  }
}

.viewer-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Photosphere Container (Pannellum) */
.photosphere-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

.photosphere-container .pnlm-container {
  width: 100% !important;
  height: 100% !important;
  background: #000 !important;
}

.photosphere-container .pnlm-load-box {
  display: none !important; /* using custom loader */
}

/* Canvas Viewport */
.viewport-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none; /* crucial for touch panning and gestures */
}

/* WebGL Photosphere Canvas */
canvas.photosphere-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Panorama Pan-Zoom Container */
.panorama-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}

.panorama-wrapper.grabbing {
  cursor: grabbing;
}

.panorama-canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  transform-origin: 0 0;
}

/* Mini-map Radar Bar for Panoramas */
.minimap-container {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(92vw, 460px);
  height: 38px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  pointer-events: auto;
  transition: opacity 0.3s ease;
}

.minimap-container.hidden {
  opacity: 0;
  pointer-events: none;
}

.minimap-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.65;
}

.minimap-viewport-indicator {
  position: absolute;
  top: 0;
  height: 100%;
  width: 25%;
  border: 2px solid var(--accent);
  background: rgba(59, 130, 246, 0.25);
  border-radius: 4px;
  cursor: ew-resize;
  transition: left 0.05s linear, width 0.05s linear;
}

/* Bottom Floating Control Bar */
.viewer-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  padding: 12px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 14px) calc(var(--safe-left) + 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.3) 70%, transparent 100%);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.viewer-controls-bar > * {
  pointer-events: auto;
}

.viewer-controls-bar.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.controls-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(18, 20, 28, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.control-btn {
  background: transparent;
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.control-btn:active {
  transform: scale(0.92);
}

.control-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* On-screen Instructions / Hint (Fades after 3 seconds) */
.gesture-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  animation: fadeOutHint 4s forwards;
}

@keyframes fadeOutHint {
  0% { opacity: 0; transform: translate(-50%, -40%); }
  15% { opacity: 1; transform: translate(-50%, -50%); }
  75% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}

/* Toast Notification (e.g. "Link copied!") */
.toast-msg {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 90px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(22, 26, 38, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Info & Map Modal / Drawer */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(94vw, 500px);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 20px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.85);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-embed-wrapper {
  width: 100%;
  height: 280px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-bottom: 14px;
  background: #111;
}

.map-embed-wrapper iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.info-table td {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.info-table td:first-child {
  color: var(--text-secondary);
  width: 38%;
}

.info-table td:last-child {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-all;
}

/* Loading Spinner */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #000;
  transition: opacity 0.4s ease;
}

.loading-screen.loaded {
  opacity: 0;
  pointer-events: none;
}

