/* SceneSmith 3D Viewer Styles */

/* Viewer container */
.viewer-box {
  position: relative;
  height: 600px;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
}

.viewer-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Floating controls */
.viewer-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.viewer-controls .button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.viewer-controls .button:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.2);
}

/* Progress bar */
.progress-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  max-width: 300px;
  z-index: 20;
}

.progress-wrapper.is-hidden {
  display: none;
}

/* Indeterminate progress bar animation (no Content-Length header) */
.progress-wrapper progress:indeterminate {
  animation: progress-indeterminate 1.5s ease infinite;
}

@keyframes progress-indeterminate {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.progress-wrapper .progress-text {
  text-align: center;
  margin-bottom: 0.5rem;
  color: #666;
  font-size: 0.875rem;
}

/* Selection panel */
.selection-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.selection-panel .no-selection {
  text-align: center;
  padding: 2rem 1rem;
  color: #888;
}

.selection-panel .object-name {
  font-weight: 600;
  margin-bottom: 0.5rem;
  word-break: break-word;
}

/* Isolated viewer */
.isolated-viewer-wrapper {
  position: relative;
  margin-top: 1rem;
}

.isolated-viewer {
  aspect-ratio: 1;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
}

.isolated-viewer canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.isolated-fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.isolated-fullscreen-btn:hover {
  background: #fff !important;
  border-color: rgba(0, 0, 0, 0.2) !important;
}

/* Isolated viewer fullscreen modal */
#isolated-fullscreen-modal .modal-background {
  background-color: rgba(0, 0, 0, 0.86);
  cursor: pointer;
}

#isolated-fullscreen-modal .modal-content {
  width: 90vh !important;
  max-width: 90vw !important;
  height: 90vh !important;
  max-height: none !important;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

#isolated-fullscreen-modal .modal-content > * {
  pointer-events: auto;
}

#isolated-fullscreen-modal .isolated-fullscreen-name {
  color: #fff;
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

#isolated-fullscreen-modal .fullscreen-isolated-canvas {
  flex: 1;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

#isolated-fullscreen-modal .fullscreen-isolated-canvas canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#isolated-fullscreen-modal .viewer-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
}

#isolated-fullscreen-modal .viewer-controls .button {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#isolated-fullscreen-modal .viewer-controls .button:hover {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.2);
}

#isolated-fullscreen-modal .viewer-controls .button.is-active {
  background: #3273dc;
  color: #fff;
  border-color: #3273dc;
}

#isolated-fullscreen-modal .modal-close {
  z-index: 1100;
  position: fixed;
  top: 20px;
  right: 20px;
}

/* Scene selector */
.scene-selector-wrapper {
  margin-bottom: 1.5rem;
}

.scene-selector-wrapper .field {
  margin-bottom: 0.5rem;
}

/* Prompt display */
.prompt-display {
  margin-bottom: 1.5rem;
}

.prompt-display .prompt-text {
  font-style: italic;
  line-height: 1.5;
}

.prompt-display .prompt-placeholder {
  color: #888;
  font-style: italic;
}

/* Fullscreen modal */
#viewer-fullscreen-modal .modal-background {
  background-color: rgba(0, 0, 0, 0.86);
  cursor: pointer;
}

#viewer-fullscreen-modal .modal-content {
  width: 95vw !important;
  max-width: none !important;
  height: 90vh !important;
  max-height: none !important;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

#viewer-fullscreen-modal .modal-content > * {
  pointer-events: auto;
}

#viewer-fullscreen-modal .fullscreen-viewer {
  flex: 1;
  background: #f5f5f5;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

#viewer-fullscreen-modal .fullscreen-viewer .viewer-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
}

#viewer-fullscreen-modal .fullscreen-viewer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#viewer-fullscreen-modal .fullscreen-prompt {
  margin-bottom: 1rem;
  font-style: italic;
}

#viewer-fullscreen-modal .modal-close {
  z-index: 1100;
  position: fixed;
  top: 20px;
  right: 20px;
}

/* Help tooltip */
.help-tooltip {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.75rem;
  z-index: 10;
  max-width: 280px;
  display: none;
}

.help-tooltip.is-visible {
  display: block;
}

.help-tooltip ul {
  margin: 0;
  padding-left: 1rem;
}

.help-tooltip li {
  margin-bottom: 0.25rem;
}

.help-tooltip strong {
  color: #fff;
}

.help-tooltip kbd {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-family: monospace;
}

/* Loading overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(245, 245, 245, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.loading-overlay.is-hidden {
  display: none;
}

/* Fullscreen mode */
.viewer-box:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #1a1a1a;
}

.viewer-box:fullscreen canvas {
  width: 100% !important;
  height: 100% !important;
}

.viewer-box:fullscreen .viewer-controls {
  top: 20px;
  right: 20px;
}

.viewer-box:fullscreen .help-tooltip {
  bottom: 20px;
  left: 20px;
}

/* Webkit fullscreen support */
.viewer-box:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #1a1a1a;
}

/* Responsive adjustments */
@media screen and (max-width: 768px) {
  .viewer-box {
    height: 400px;
  }

  .viewer-controls {
    top: 5px;
    right: 5px;
    gap: 4px;
  }

  .viewer-controls .button {
    padding: 0.25rem 0.5rem;
  }

  .isolated-viewer {
    aspect-ratio: 4/3;
  }
}

/* Section styling */
.viewer-section {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.viewer-section .quality-note {
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* Metadata display */
.meta-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  word-break: break-word;
}

.meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.meta-tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.meta-tag.type-tag {
  background: #e8f0fe;
  color: #1a73e8;
}

.meta-tag.articulated-tag {
  background: #fce8e6;
  color: #d93025;
}

.meta-mass {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.5rem;
}

/* Overlay controls */
.overlay-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.overlay-controls .button.is-active {
  background: #3273dc;
  color: #fff;
  border-color: #3273dc;
}

/* Joint controls */
.joint-controls {
  margin-top: 0.75rem;
}

.joint-controls-title {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.joint-slider-group {
  margin-bottom: 0.5rem;
}

.joint-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 0.15rem;
}

.joint-slider-label .joint-name {
  font-weight: 600;
}

.joint-slider-label .joint-type-badge {
  display: inline-block;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
}

.joint-type-badge.revolute {
  background: #f39c12;
}

.joint-type-badge.prismatic {
  background: #9b59b6;
}

.joint-slider-value {
  font-size: 0.7rem;
  color: #888;
  text-align: right;
}

.joint-slider-group input[type="range"] {
  width: 100%;
  margin: 0;
  height: 18px;
  cursor: pointer;
  touch-action: none;   /* prevent scroll/pan from stealing the drag */
}

/* Keyboard hint */
.keyboard-hints {
  font-size: 0.75rem;
  color: #888;
  margin-top: 0.5rem;
}

.keyboard-hints kbd {
  background: #eee;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-family: monospace;
  font-size: 0.7rem;
}

/* Drag hint overlay */
.drag-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.drag-hint.is-visible {
  opacity: 1;
}

.drag-hint.is-fading {
  opacity: 0;
}

.drag-hint-icon {
  display: inline-block;
  font-size: 1.1rem;
  animation: drag-hint-swipe 2s ease-in-out infinite;
}

@keyframes drag-hint-swipe {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(8px); }
  60% { transform: translateX(-8px); }
}
