/* Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Roboto Slab", serif;
}

body {
  overflow: hidden;
  background: #0a0a0a;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%; /* Firefox compatibility */
  /* Fix for mobile Safari */
  -webkit-overflow-scrolling: touch;
  height: 100vh;
  width: 100vw;
  position: fixed;
  /* Firefox positioning fix */
  top: 0;
  left: 0;
}

/* Loading Container */
.loading-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Use 100vh and 100dvh for better mobile support */
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for modern browsers */
  background: url("../images/background.png") no-repeat center center;
  background-size: cover;
  background-attachment: scroll; /* Changed from fixed - causes issues on mobile */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
  text-align: center;
  padding: min(3vw, 1.25rem);
  transition: opacity 0.5s ease-out;
  /* Prevent zoom on double tap */
  touch-action: manipulation;
  /* Firefox scrollbar fix */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.loading-container::-webkit-scrollbar {
  display: none;
}

.loading-container.fade-out {
  opacity: 0;
}

/* Firefox-specific viewport fixes */
@-moz-document url-prefix() {
  .loading-container {
    background-attachment: scroll !important;
    height: 100vh !important;
    /* Firefox flexbox prefix support */
    display: -moz-box;
    display: flex;
    -moz-box-orient: vertical;
    -moz-box-direction: normal;
    flex-direction: column;
    -moz-box-pack: center;
    justify-content: center;
    -moz-box-align: center;
    align-items: center;
  }

  body {
    height: 100vh !important;
  }
}

/* Desktop and Large Screens */
@media only screen and (min-width: 1025px) {
  .loading-container {
    background-attachment: fixed; /* Only use fixed on desktop */
    padding: min(3vw, 2rem);
  }
}

/* Mobile-specific fixes */
@media only screen and (max-width: 1024px) {
  .loading-container {
    background-attachment: scroll;
    /* Use safer viewport units */
    min-height: 100vh;
    min-height: 100dvh;
    /* Firefox mobile fallback */
    min-height: -moz-available;
  }
}

/* Titles - Mobile-first approach */
.title {
  font-size: max(1.5rem, min(5vw, 3rem));
  margin-top: max(1rem, min(5vh, 4rem));
  margin-bottom: max(0.75rem, min(3vh, 2rem));
  font-weight: 600;
  color: #125371;
  text-align: center;
  line-height: 1.2;
  max-width: 90vw;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
  /* Prevent text selection issues on mobile */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Sub-container - Enhanced mobile support */
.sub-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: white;
  color: black;
  font-size: 0.625rem;
  padding: max(1rem, min(4vw, 3.75rem));
  border-radius: max(0.75rem, min(2vw, 1.25rem));
  width: max(280px, min(85vw, 320px));
  min-height: max(150px, min(25vh, 200px));
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* Prevent tap highlighting */
  -webkit-tap-highlight-color: transparent;
  -moz-tap-highlight-color: transparent;
  /* Firefox box-sizing */
  -moz-box-sizing: border-box;
}

/* Firefox flexbox support for sub-container */
@-moz-document url-prefix() {
  .sub-container {
    display: -moz-box;
    display: flex;
    -moz-box-align: center;
    align-items: center;
    -moz-box-pack: center;
    justify-content: center;
  }
}

.sub-container p {
  line-height: 1.6;
  font-size: max(0.85rem, min(2.5vw, 1.1rem));
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
}

/* Info Container - Mobile-first responsive */
.info-container {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: #fff;
  color: #333;
  border-radius: max(0.75rem, min(2vw, 1.25rem));
  width: max(280px, min(90vw, 400px));
  padding: max(1rem, min(4vw, 2.5rem));
  margin: 0 auto;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  /* Mobile Safari fixes */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  /* Firefox box-sizing */
  -moz-box-sizing: border-box;
}

/* Firefox flexbox support for info-container */
@-moz-document url-prefix() {
  .info-container {
    display: -moz-box;
    display: flex;
    -moz-box-orient: vertical;
    -moz-box-direction: normal;
    flex-direction: column;
  }
}

.sub-container::before,
.info-container::before {
  content: "";
  position: absolute;
  inset: 0; /* same as top/left/right/bottom: 0 */
  /* Firefox fallback for inset */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  padding: 0.25rem; /* border thickness */
  background: linear-gradient(135deg, #f44336, #ff9800, #4caf50, #2196f3);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  /* Firefox mask support */
  -moz-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -moz-mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
}

/* Fallback for browsers without mask support */
@supports not (mask-composite: exclude) and not (-webkit-mask-composite: xor) {
  .sub-container::before,
  .info-container::before {
    /* Create border effect without mask */
    background: linear-gradient(135deg, #f44336, #ff9800, #4caf50, #2196f3);
    border-radius: inherit;
    inset: -0.25rem;
    top: -0.25rem;
    left: -0.25rem;
    right: -0.25rem;
    bottom: -0.25rem;
  }

  .sub-container,
  .info-container {
    position: relative;
    z-index: 1;
  }
}

.info-title {
  font-size: max(1.5rem, min(5vw, 3rem));
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: max(0.5rem, min(2vw, 1rem));
  text-align: left;
  line-height: 1.2;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
}

.info-heading {
  font-weight: 700;
  margin-top: max(0.4rem, min(1.5vw, 0.8rem));
  margin-bottom: max(0.2rem, min(1vw, 0.4rem));
  color: #000000;
  font-size: max(0.85rem, min(2vw, 1.1rem));
  text-align: left;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
}

/* Paragraph text - Mobile optimized */
.info-container p {
  margin: max(0.2rem, min(1vw, 0.4rem)) 0;
  font-size: max(0.8rem, min(2vw, 1rem));
  color: #333;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
}

/* Bullet list - Mobile optimized */
.info-container ul {
  padding-left: max(1rem, min(3vw, 1.5rem));
  margin: max(0.3rem, min(1.5vw, 0.8rem)) 0 max(0.5rem, min(2vw, 1.2rem)) 0;
  /* Firefox list padding */
  -moz-padding-start: max(1rem, min(3vw, 1.5rem));
}

.info-container li {
  margin-bottom: max(0.25rem, min(1vw, 0.5rem));
  font-size: max(0.8rem, min(2vw, 1rem));
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
  margin-left: max(0.75rem, min(2vw, 1.25rem));
  /* Firefox list item margin */
  -moz-margin-start: max(0.75rem, min(2vw, 1.25rem));
}

/* Continue Button - Mobile-first */
.continue-button {
  margin-top: max(1.5rem, min(4vh, 3rem));
  padding: max(0.75rem, min(3vw, 1.2rem)) max(1.5rem, min(5vw, 2.5rem));
  border-radius: max(0.75rem, min(2vw, 1rem));
  background-color: #f06053;
  color: white;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: max(0.9rem, min(2.5vw, 1.1rem));
  font-weight: 500;
  transition: all 0.3s ease;
  align-self: center;
  min-width: max(120px, min(25vw, 150px));
  /* Mobile touch improvements */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -moz-tap-highlight-color: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Firefox button box-sizing */
  -moz-box-sizing: border-box;
}

.continue-button:hover {
  background-color: #e55347;
  transform: translateY(-1px);
}

.continue-button:active {
  transform: scale(0.98) translateY(0);
}

/* Firefox button focus fix */
.continue-button::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/* Status Indicator - Mobile optimized */
.status-indicator {
  position: fixed;
  top: max(0.5rem, min(2vh, 1rem));
  right: max(0.5rem, min(2vw, 1rem));
  padding: max(0.4rem, min(1.5vw, 0.7rem)) max(0.6rem, min(2vw, 1rem));
  border-radius: max(0.75rem, min(2vw, 1.25rem));
  font-size: max(0.6rem, min(1.8vw, 0.8rem));
  font-weight: bold;
  z-index: 1000;
  transition: all 0.3s ease;
  max-width: min(35vw, 200px);
  text-align: center;
  word-wrap: break-word;
  line-height: 1.2;
  /* Firefox box-sizing */
  -moz-box-sizing: border-box;
}

.status-searching {
  background: rgba(255, 165, 0, 0.9);
  color: white;
}

.status-found {
  background: rgba(0, 255, 0, 0.9);
  color: white;
}

.status-lost {
  background: rgba(255, 0, 0, 0.9);
  color: white;
}

/* Error Message - Mobile optimized */
.error-message {
  background: rgba(255, 0, 0, 0.1);
  border: 0.125rem solid #ff4444;
  border-radius: max(0.5rem, min(1.5vw, 0.75rem));
  padding: max(0.75rem, min(3vw, 1.25rem));
  margin-top: max(0.75rem, min(2vw, 1.25rem));
  max-width: min(90vw, 500px);
  font-size: max(0.8rem, min(2.2vw, 1rem));
  line-height: 1.5;
  width: 100%;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  word-wrap: break-word;
}

/* AR Button - Mobile-first approach */
.ar-button {
  position: fixed;
  bottom: max(2rem, min(6vh, 4rem));
  left: 50%;
  transform: translateX(-50%);
  padding: max(1rem, min(3vw, 1.5rem)) max(1.5rem, min(5vw, 2.5rem));
  font-size: max(1rem, min(3vw, 1.4rem));
  background: #ff4444;
  color: white;
  border: none;
  border-radius: max(0.75rem, min(2vw, 1.25rem));
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  min-width: max(140px, min(30vw, 180px));
  white-space: nowrap;
  z-index: 10000;
  /* Mobile improvements */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -moz-tap-highlight-color: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Firefox button box-sizing */
  -moz-box-sizing: border-box;
}

.ar-button:hover {
  background: #e63939;
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.ar-button:active {
  transform: translateX(-50%) scale(0.98);
}

/* Firefox button focus fix */
.ar-button::-moz-focus-inner {
  border: 0;
  padding: 0;
}

/* Hide A-Frame VR button */
.a-enter-vr-button {
  display: none !important;
}

/* Spinner Animation */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Firefox animation support */
@-moz-keyframes spin {
  0% {
    -moz-transform: rotate(0deg);
  }
  100% {
    -moz-transform: rotate(360deg);
  }
}

/* Specific Mobile Device Fixes */

/* iPhone and small mobile devices */
@media only screen and (max-width: 480px) {
  .loading-container {
    padding: 1rem;
    /* Firefox mobile viewport */
    height: 100vh;
    min-height: 100vh;
  }

  .info-container {
    width: calc(100vw - 2rem);
    max-width: 400px;
    padding: 1.5rem;
  }

  .continue-button {
    width: 100%;
    max-width: 200px;
  }
}

/* Tablet adjustments */
@media only screen and (min-width: 768px) and (max-width: 1024px) {
  .info-container {
    width: min(70vw, 600px);
    padding: 2rem;
  }

  .ar-button {
    bottom: 3rem;
    padding: 1.2rem 2rem;
    font-size: 1.3rem;
  }
}

/* Safari-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* This targets Safari */
  .loading-container {
    height: -webkit-fill-available;
  }

  body {
    height: -webkit-fill-available;
  }

  /* Fix for Safari's viewport height issues */
  @media screen and (max-width: 1024px) {
    .loading-container {
      min-height: -webkit-fill-available;
    }
  }
}

/* Firefox viewport height support */
@supports (-moz-appearance: none) {
  .loading-container {
    height: 100vh;
    min-height: 100vh;
  }

  body {
    height: 100vh;
  }

  @media screen and (max-width: 1024px) {
    .loading-container {
      min-height: 100vh;
      height: 100vh;
    }
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-appearance: none) and (not (-ms-ime-align: auto)) {
  .continue-button,
  .ar-button {
    -webkit-appearance: none;
    border-radius: max(
      0.75rem,
      min(2vw, 1.25rem)
    ); /* Ensure border radius is applied */
  }
}

/* High DPI / Retina Display Adjustments */
@media only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi) {
  .sub-container::before,
  .info-container::before {
    top: -0.125rem;
    left: -0.125rem;
    right: -0.125rem;
    bottom: -0.125rem;
  }
}

/* Accessibility and reduced motion */
@media (prefers-reduced-motion: reduce) {
  .continue-button,
  .ar-button,
  .loading-container {
    transition: none;
  }

  @keyframes spin {
    0%,
    100% {
      transform: rotate(0deg);
    }
  }

  @-moz-keyframes spin {
    0%,
    100% {
      -moz-transform: rotate(0deg);
    }
  }
}

/* Focus states for accessibility */
.continue-button:focus,
.ar-button:focus {
  outline-offset: 2px;
}

/* Firefox focus outline enhancement */
.continue-button:focus::-moz-focus-inner,
.ar-button:focus::-moz-focus-inner {
  border: 0;
}
