/**
 * AR Farm & Animal Gallery Styles
 * Retro 8-bit theme matching game.css
 */

/* AR/VR Canvas (visible in XR mode) */
#ar-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  z-index: 1000;
  touch-action: none;
}

/* Unified AR Button */
#ar-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(145deg, #8844ff, #6622dd);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9em;
  padding: 15px 25px;
  border: 4px solid #000;
  border-radius: 8px;
  box-shadow: 0 6px 0 #4411bb, 0 8px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: none;
  z-index: 200; /* Above AR canvas and game */
  transition: all 0.3s ease;
  pointer-events: auto; /* Ensure button is clickable even when AR is active */
}

#ar-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #4411bb, 0 10px 16px rgba(0, 0, 0, 0.5);
}

#ar-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #4411bb, 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* Gallery Button */
#gallery-button {
  position: fixed;
  bottom: 100px;
  right: 20px;
  background: linear-gradient(145deg, #ff00ff, #cc00cc);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9em;
  padding: 15px 25px;
  border: 4px solid #000;
  border-radius: 8px;
  box-shadow: 0 6px 0 #990099, 0 8px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: block;
  z-index: 200; /* Above AR canvas */
  transition: transform 0.1s, box-shadow 0.1s;
  pointer-events: auto; /* Ensure clickable in AR mode */
}

#gallery-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #990099, 0 10px 16px rgba(0, 0, 0, 0.5);
}

#gallery-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #990099, 0 4px 8px rgba(0, 0, 0, 0.4);
}

/* AR Overlay (for UI in AR mode) */
#ar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1001;
}

/* AR Notification (non-intrusive) */
#ar-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 255, 65, 0.95);
  color: #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8em;
  padding: 12px 24px;
  border: 3px solid #000;
  border-radius: 8px;
  box-shadow: 0 4px 0 #00cc33, 0 6px 12px rgba(0, 0, 0, 0.5);
  display: none;
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 1002;
  pointer-events: none;
}

/* Animal Gallery Modal */
#animal-gallery {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: none;
  z-index: 500;
  overflow-y: auto;
  padding: 20px;
}

#gallery-header {
  text-align: center;
  margin-bottom: 30px;
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.95);
  padding: 20px;
  z-index: 10;
  border-bottom: 3px solid #00ff41;
}

#gallery-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41, 0 0 20px #00ff41;
  margin-bottom: 20px;
}

#gallery-controls {
  margin: 20px 0;
}

.gallery-control-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.gallery-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 400px;
  padding: 12px 15px;
  background: rgba(0, 255, 65, 0.1);
  border: 2px solid #00ff41;
  border-radius: 8px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  transition: all 0.3s;
}

.gallery-search-input:focus {
  outline: none;
  background: rgba(0, 255, 65, 0.2);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.gallery-search-input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.gallery-sort-select {
  padding: 12px 15px;
  background: rgba(0, 255, 65, 0.1);
  border: 2px solid #00ff41;
  border-radius: 8px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s;
}

.gallery-sort-select:hover {
  background: rgba(0, 255, 65, 0.2);
}

.gallery-sort-select:focus {
  outline: none;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.view-mode-buttons {
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 8px;
  border: 2px solid rgba(0, 255, 65, 0.3);
}

.view-mode-btn {
  padding: 10px 15px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.2em;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
}

.view-mode-btn:hover {
  color: #00ff41;
  background: rgba(0, 255, 65, 0.1);
}

.view-mode-btn.active {
  color: #00ff41;
  background: rgba(0, 255, 65, 0.2);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

.gallery-stats-row {
  text-align: center;
  font-family: 'Courier New', monospace;
  color: #00ff41;
  font-size: 0.9em;
}

#gallery-close {
  background: linear-gradient(145deg, #ff0055, #cc0044);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9em;
  padding: 12px 24px;
  border: 3px solid #000;
  border-radius: 8px;
  box-shadow: 0 4px 0 #990033, 0 6px 12px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s;
  margin-top: 15px;
}

#gallery-close:hover {
  transform: translateY(-2px);
}

#gallery-close:active {
  transform: translateY(2px);
}

/* Gallery Grid */
#gallery-grid,
.gallery-grid-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

/* List View Mode */
.gallery-grid-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 900px;
  margin: 0 auto;
}

.gallery-grid-list .animal-card {
  display: flex;
  flex-direction: row;
  max-width: 100%;
}

.gallery-grid-list .animal-image-container {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

.gallery-grid-list .animal-info {
  flex: 1;
  padding: 20px;
}

.gallery-grid-list .animal-facts {
  display: block;
}

/* Empty State */
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  font-family: 'Press Start 2P', monospace;
  color: #00ff41;
}

.gallery-empty p {
  font-size: 1.1em;
  margin: 20px 0;
  line-height: 1.8;
}

/* Animal Card */
.animal-card {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border: 4px solid #00ff41;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 0 #00cc33, 0 12px 24px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
}

.animal-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 0 #00cc33, 0 16px 32px rgba(0, 255, 65, 0.3);
}

/* Card Action Buttons */
.animal-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
}

.animal-card:hover .animal-card-actions {
  opacity: 1;
}

.card-action-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #000;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 1.2em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

.card-action-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.6);
}

.view-btn {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.8), rgba(0, 204, 51, 0.8));
}

.view-btn:hover {
  background: linear-gradient(145deg, rgba(0, 255, 65, 1), rgba(0, 204, 51, 1));
}

.delete-btn {
  background: linear-gradient(145deg, rgba(255, 0, 85, 0.8), rgba(204, 0, 68, 0.8));
}

.delete-btn:hover {
  background: linear-gradient(145deg, rgba(255, 0, 85, 1), rgba(204, 0, 68, 1));
}

.card-action-btn:active {
  transform: scale(0.95);
}

/* Animal Image */
.animal-image-container {
  width: 100%;
  height: 250px;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

/* Image Loading Indicator */
.image-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  text-align: center;
  z-index: 10;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animal-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}

.animal-image-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
}

/* Animal Info */
.animal-info {
  padding: 20px;
}

.animal-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.2em;
  color: #00ff41;
  text-shadow: 0 0 8px #00ff41;
  margin: 0 0 15px 0;
  text-transform: capitalize;
}

.animal-facts {
  list-style: none;
  padding: 0;
  margin: 0;
}

.animal-facts li {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  color: #fff;
  line-height: 1.6;
  margin-bottom: 10px;
  padding-left: 20px;
  position: relative;
}

.animal-facts li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #00ff41;
  font-weight: bold;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #ar-button,
  #gallery-button {
    font-size: 0.7em;
    padding: 12px 18px;
  }

  #ar-button {
    bottom: 15px;
  }

  #gallery-button {
    bottom: 75px;
    right: 15px;
  }

  #gallery-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .animal-card {
    border-width: 3px;
  }

  .animal-name {
    font-size: 1em;
  }

  .animal-facts li {
    font-size: 0.75em;
  }

  #gallery-title {
    font-size: 1.2em;
  }
}

/* XR Active State */
body.xr-active #game-container {
  opacity: 0.3;
  pointer-events: none;
}

body.xr-active #ar-canvas {
  display: block;
}

body.xr-active #ar-button,
body.xr-active #gallery-button {
  display: none;
}

/* Animal Detail Modal */
#animal-detail-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 600;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-modal-content {
  background: linear-gradient(145deg, #1a1a2e, #16213e);
  border: 4px solid #00ff41;
  border-radius: 16px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 0 #00cc33, 0 16px 32px rgba(0, 255, 65, 0.4);
  position: relative;
  padding: 30px;
}

.detail-close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: #ff0055;
  color: #fff;
  border: 3px solid #000;
  border-radius: 50%;
  width: 45px;
  height: 45px;
  font-size: 1.5em;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #cc0044;
  transition: transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.detail-close-btn:hover {
  transform: scale(1.1);
}

.detail-close-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #cc0044;
}

.detail-header {
  text-align: center;
  margin-bottom: 30px;
}

.detail-animal-image {
  width: 300px;
  height: 300px;
  object-fit: cover;
  border: 4px solid #00ff41;
  border-radius: 12px;
  box-shadow: 0 8px 0 #00cc33, 0 12px 24px rgba(0, 0, 0, 0.6);
  margin-bottom: 20px;
}

.detail-animal-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.8em;
  color: #00ff41;
  text-shadow: 0 0 12px #00ff41;
  text-transform: capitalize;
  margin: 0;
}

.detail-section {
  margin: 30px 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid #00ff41;
  border-radius: 8px;
}

.detail-section h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1em;
  color: #00ff41;
  margin: 0 0 15px 0;
}

.tree-path {
  font-family: 'Courier New', monospace;
  color: #fff;
  line-height: 1.8;
  font-size: 0.95em;
}

.tree-step {
  margin: 10px 0;
  padding: 10px;
  background: rgba(0, 255, 65, 0.1);
  border-left: 3px solid #00ff41;
  padding-left: 15px;
}

.tree-step.answer-yes {
  border-left-color: #00ff88;
}

.tree-step.answer-no {
  border-left-color: #ff0055;
}

.tree-step-question {
  font-weight: bold;
  color: #00ff41;
  margin-bottom: 5px;
}

.tree-step-answer {
  color: #fff;
  font-size: 0.9em;
}

.detail-facts-list {
  list-style: none;
  padding: 0;
  margin: 15px 0 0 0;
}

.detail-facts-list li {
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
  color: #fff;
  line-height: 1.8;
  margin: 10px 0;
  padding-left: 25px;
  position: relative;
}

.detail-facts-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: #00ff41;
  font-weight: bold;
  font-size: 1.2em;
}

.detail-instructions {
  font-family: 'Courier New', monospace;
  color: #ccc;
  font-size: 0.9em;
  margin: 10px 0;
  line-height: 1.6;
}

.audio-button {
  background: linear-gradient(145deg, #00ff88, #00cc66);
  color: #000;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85em;
  padding: 12px 20px;
  border: 3px solid #000;
  border-radius: 8px;
  box-shadow: 0 4px 0 #009944;
  cursor: pointer;
  transition: transform 0.1s;
  margin: 10px 0;
  display: inline-block;
}

.audio-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #009944;
}

.audio-button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #009944;
}

.audio-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.qa-history {
  margin-top: 20px;
}

.qa-item {
  margin: 15px 0;
  padding: 15px;
  background: rgba(0, 255, 65, 0.05);
  border: 2px solid rgba(0, 255, 65, 0.3);
  border-radius: 8px;
}

.qa-question {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.85em;
  color: #00ff88;
  margin-bottom: 10px;
}

.qa-answer {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #fff;
  line-height: 1.6;
  padding-left: 20px;
  border-left: 3px solid #00ff41;
}

/* Make cards clickable */
.animal-card {
  cursor: pointer;
  user-select: none;
}

.animal-card:active {
  transform: translateY(-4px);
}

/* Visual Tree Map Styles */
.tree-visual-map {
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.1), rgba(0, 255, 65, 0.05));
  border: 2px solid rgba(0, 255, 65, 0.3);
  border-radius: 12px;
  animation: fadeInUp 0.5s ease-out;
}

.tree-minimap {
  text-align: center;
}

.minimap-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  margin-bottom: 20px;
  animation: pulse 2s infinite;
}

.minimap-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.minimap-root {
  margin-bottom: 10px;
}

.minimap-node {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(145deg, #00ff41, #00cc33);
  border: 3px solid #000;
  border-radius: 8px;
  box-shadow: 0 4px 0 #009922, 0 6px 12px rgba(0, 255, 65, 0.4);
  animation: bounceIn 0.6s ease-out;
}

.node-icon {
  font-size: 1.3em;
}

.node-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8em;
  color: #000;
}

.minimap-branches {
  display: flex;
  justify-content: center;
  gap: 40px;
  width: 100%;
  max-width: 400px;
}

.minimap-branch {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  transition: all 0.3s ease;
}

.minimap-branch.active-branch {
  background: rgba(0, 255, 65, 0.3);
  border-color: #00ff41;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
  animation: pulseGlow 1.5s infinite;
}

.branch-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7em;
  color: #fff;
}

.yes-branch .branch-label {
  color: #00ff88;
}

.no-branch .branch-label {
  color: #ff0055;
}

.active-branch .branch-label {
  color: #00ff41;
  font-weight: bold;
}

.minimap-animals {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.minimap-animal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  transition: all 0.3s ease;
}

.minimap-animal.target-animal {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.3), rgba(0, 255, 65, 0.2));
  border-color: #00ff41;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.6);
  transform: scale(1.1);
}

.animal-icon {
  font-size: 1.2em;
}

.animal-text {
  font-family: 'Courier New', monospace;
  font-size: 0.85em;
  color: #fff;
  text-transform: capitalize;
}

.target-animal .animal-text {
  color: #00ff41;
  font-weight: bold;
}

.minimap-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid rgba(0, 255, 65, 0.3);
}

.legend-item {
  font-family: 'Courier New', monospace;
  font-size: 0.75em;
  color: #ccc;
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-yes {
  color: #00ff88;
}

.legend-no {
  color: #ff0055;
}

.legend-target {
  font-size: 1.2em;
}

/* Tree Path Steps Container */
.tree-path-steps {
  margin-top: 20px;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.5);
  }
  50% {
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.8);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.pulse-glow {
  animation: pulseGlowContinuous 2s infinite;
}

@keyframes pulseGlowContinuous {
  0%, 100% {
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 255, 65, 0.8);
  }
}

/* Fact Reading Highlights */
.detail-facts-list li.reading-fact {
  background: rgba(0, 255, 65, 0.2);
  border-left: 4px solid #00ff41;
  padding-left: 21px;
  transform: translateX(5px);
  transition: all 0.3s ease;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
  animation: pulseHighlight 1s infinite;
}

.detail-facts-list li.fact-read {
  opacity: 0.7;
  transition: opacity 0.5s ease;
}

@keyframes pulseHighlight {
  0%, 100% {
    background: rgba(0, 255, 65, 0.2);
  }
  50% {
    background: rgba(0, 255, 65, 0.3);
  }
}

/* Smooth modal entrance */
#animal-detail-modal {
  animation: fadeIn 0.3s ease-out;
}

.detail-modal-content {
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animal card hover improvements */
.animal-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.animal-card:hover {
  transform: translateY(-8px) scale(1.02);
}

/* Gallery card entrance animations */
.card-entrance {
  animation: cardSlideIn 0.6s ease-out forwards;
  opacity: 0;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Name entrance animation */
.name-entrance {
  animation: nameSlideIn 0.5s ease-out forwards;
  opacity: 0;
}

@keyframes nameSlideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Facts list fade-in */
.facts-entrance .fact-item {
  animation: factFadeIn 0.4s ease-out forwards;
  opacity: 0;
}

@keyframes factFadeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Gallery loading state */
.gallery-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Mobile Responsive for Detail Modal */
@media (max-width: 768px) {
  .detail-modal-content {
    padding: 20px;
    max-height: 95vh;
  }

  .detail-animal-image {
    width: 200px;
    height: 200px;
  }

  .detail-animal-name {
    font-size: 1.3em;
  }

  .detail-section h3 {
    font-size: 0.9em;
  }

  .audio-button {
    font-size: 0.7em;
    padding: 10px 16px;
  }

  .tree-visual-map {
    padding: 15px;
  }

  .minimap-title {
    font-size: 0.8em;
  }

  .minimap-branches {
    flex-direction: column;
    gap: 10px;
    max-width: 200px;
  }

  .minimap-animals {
    gap: 8px;
  }

  .minimap-animal {
    padding: 6px 10px;
  }

  .branch-label,
  .animal-text {
    font-size: 0.65em;
  }
}

/* Enhanced Tree Graph Styles */
.tree-minimap.enhanced {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.08), rgba(0, 255, 65, 0.03));
  border: 3px solid rgba(0, 255, 65, 0.4);
  padding: 25px;
}

.minimap-subtitle {
  display: block;
  font-size: 0.5em;
  color: #00cc33;
  margin-top: 10px;
  font-weight: normal;
  text-shadow: none;
}

.tree-graph {
  margin: 20px 0;
  padding: 20px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  overflow-x: auto;
}

.tree-node {
  margin: 15px 0;
  animation: fadeInUp 0.4s ease-out;
}

.node-content {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.node-content.root-question {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.3), rgba(0, 255, 65, 0.2));
  border-color: #00ff41;
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
}

.question-node.on-path > .node-content {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.25), rgba(0, 255, 65, 0.15));
  border-color: #00ff88;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.3);
}

.node-label {
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
  color: #fff;
  font-weight: 500;
}

.animal-node .node-label {
  color: #00ff41;
  font-weight: bold;
  text-transform: capitalize;
}

.animal-node.target-node .node-content {
  background: linear-gradient(145deg, rgba(0, 255, 65, 0.4), rgba(0, 255, 65, 0.3));
  border: 3px solid #00ff41;
  box-shadow: 0 0 25px rgba(0, 255, 65, 0.6);
  transform: scale(1.05);
}

.node-branches {
  margin-left: 30px;
  margin-top: 10px;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
  padding-left: 20px;
}

.branch-container {
  margin: 10px 0;
  position: relative;
}

.branch-line {
  position: absolute;
  left: -20px;
  top: 20px;
  width: 15px;
  height: 2px;
  background: rgba(255, 255, 255, 0.3);
}

.branch-label-box {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65em;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  border: 2px solid;
}

.yes-label {
  background: rgba(0, 255, 136, 0.2);
  border-color: #00ff88;
  color: #00ff88;
}

.no-label {
  background: rgba(255, 0, 85, 0.2);
  border-color: #ff0055;
  color: #ff0055;
}

.branch-container.active-branch .branch-line {
  background: #00ff41;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
  height: 3px;
}

.branch-container.active-branch .branch-label-box {
  background: rgba(0, 255, 65, 0.3);
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.4);
  animation: pulseGlow 1.5s infinite;
}

.legend-question {
  font-size: 1.2em;
}

/* Smooth scrolling for tree graph */
.tree-graph::-webkit-scrollbar {
  height: 8px;
}

.tree-graph::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
}

.tree-graph::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 65, 0.5);
  border-radius: 4px;
}

.tree-graph::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 255, 65, 0.7);
}

/* Mobile responsive for enhanced tree */
@media (max-width: 768px) {
  .tree-minimap.enhanced {
    padding: 15px;
  }
  
  .minimap-subtitle {
    font-size: 0.45em;
  }
  
  .tree-graph {
    padding: 10px;
  }
  
  .node-content {
    padding: 8px 12px;
    gap: 6px;
  }
  
  .node-label {
    font-size: 0.75em;
  }
  
  .branch-label-box {
    font-size: 0.55em;
    padding: 3px 8px;
  }
  
  .node-branches {
    margin-left: 15px;
    padding-left: 10px;
  }
}

/* Loading Indicator */
.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 20px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(0, 255, 65, 0.2);
  border-top-color: #00ff41;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  animation: pulse 2s infinite;
}

/* AR Enhanced Controls Panel */
#ar-controls-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.85);
  border: 3px solid #00ff41;
  border-radius: 12px;
  padding: 15px;
  min-width: 250px;
  z-index: 1003;
  pointer-events: auto;
  box-shadow: 0 8px 0 #00cc33, 0 12px 24px rgba(0, 0, 0, 0.6);
  font-family: 'Courier New', monospace;
  color: #00ff41;
  backdrop-filter: blur(10px);
}

.ar-controls-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  margin-bottom: 15px;
  text-align: center;
}

.ar-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px 0;
  font-size: 0.85em;
}

.ar-control-label {
  color: #fff;
  flex: 1;
}

.ar-control-button {
  background: linear-gradient(145deg, #00ff41, #00cc33);
  border: 2px solid #000;
  border-radius: 6px;
  padding: 6px 12px;
  color: #000;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.8em;
}

.ar-control-button:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0, 255, 65, 0.6);
}

.ar-control-button:active {
  transform: scale(0.95);
}

.ar-control-button.danger {
  background: linear-gradient(145deg, #ff0055, #cc0044);
  color: #fff;
}

.ar-control-toggle {
  display: flex;
  gap: 5px;
}

.ar-control-toggle button {
  padding: 4px 10px;
  font-size: 0.75em;
}

.ar-control-toggle button.active {
  background: linear-gradient(145deg, #00ff88, #00cc66);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

.ar-slider {
  flex: 1;
  margin-left: 10px;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 255, 65, 0.3);
  border-radius: 2px;
  outline: none;
}

.ar-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #00ff41;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

.ar-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #00ff41;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
  border: none;
}

/* AR Model Info Overlay */
#ar-model-info {
  position: fixed;
  bottom: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.85);
  border: 3px solid #00ff41;
  border-radius: 12px;
  padding: 15px 20px;
  max-width: 300px;
  z-index: 1003;
  pointer-events: none;
  box-shadow: 0 8px 0 #00cc33, 0 12px 24px rgba(0, 0, 0, 0.6);
  font-family: 'Courier New', monospace;
  color: #fff;
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.3s;
}

#ar-model-info.visible {
  opacity: 1;
}

.ar-info-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 1em;
  color: #00ff41;
  text-shadow: 0 0 10px #00ff41;
  margin-bottom: 10px;
  text-transform: capitalize;
}

.ar-info-details {
  font-size: 0.85em;
  line-height: 1.6;
}

.ar-info-row {
  margin: 5px 0;
}

.ar-info-label {
  color: #00ff88;
}

.ar-info-value {
  color: #fff;
  margin-left: 5px;
}

/* Keyboard controls help */
#ar-keyboard-help {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.85);
  border: 3px solid #00ff41;
  border-radius: 12px;
  padding: 15px;
  max-width: 300px;
  z-index: 1003;
  pointer-events: none;
  box-shadow: 0 8px 0 #00cc33, 0 12px 24px rgba(0, 0, 0, 0.6);
  font-family: 'Courier New', monospace;
  color: #fff;
  backdrop-filter: blur(10px);
  font-size: 0.8em;
  line-height: 1.6;
}

.ar-help-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9em;
  color: #00ff41;
  margin-bottom: 10px;
}

.ar-help-key {
  display: inline-block;
  background: rgba(0, 255, 65, 0.2);
  border: 2px solid #00ff41;
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0 2px;
  font-weight: bold;
  color: #00ff41;
}

/* Mobile responsive AR controls */
@media (max-width: 768px) {
  #ar-controls-panel {
    top: 10px;
    right: 10px;
    min-width: 200px;
    padding: 10px;
  }

  .ar-controls-title {
    font-size: 0.65em;
  }

  .ar-control-row {
    font-size: 0.75em;
  }

  #ar-model-info {
    bottom: 10px;
    left: 10px;
    max-width: 250px;
    padding: 10px 15px;
  }

  #ar-keyboard-help {
    display: none; /* Hide on mobile */
  }
}
