.responsive-image {
  width: 100%;
  max-width: 300px;
  height: auto;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
  color: #f18700;
  margin-bottom: 1rem;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  background: #f18700;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.top-wrapper {
  position: relative;

  .logo-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;

    .logo {
      width: 237px;

      @media (min-width: 1024px) {
        width: 343px;
      }
    }
  }

  .links {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .demo-select-link {
    display: flex;
    flex-wrap: nowrap;
    justify-content: left;
    gap: 10px;

    @media (min-width: 1024px) {
      position: absolute;
      left: 0;
      top: 0;
      margin-left: 40px;
      gap: 15px;
    }

    .link {
      color: #F18700;
      font-size: 14px;
      text-decoration: none;

      @media (min-width: 1024px) {
        font-size: 20px;
      }
    }

    .chevron {
      width: 6px;
      margin: 0;

      @media (min-width: 1024px) {
        width: 10px;
      }
    }
  }

  .website-link {
    display: flex;
    flex-wrap: nowrap;
    justify-content: right;
    gap: 10px;

    @media (min-width: 1024px) {
      position: absolute;
      right: 0;
      top: 0;
      margin-right: 40px;
      gap: 15px;
    }

    .link {
      color: #F18700;
      font-size: 14px;
      text-decoration: none;

      @media (min-width: 1024px) {
        font-size: 20px;
      }
    }

    .chevron {
      width: 6px;
      margin: 0;

      @media (min-width: 1024px) {
        width: 10px;
      }
    }
  }
}

.mb-4 {
  margin-bottom: 28px;

  @media (min-width: 1024px) {
    margin-bottom: 46px;
  }
}

.wrapper {
  width: 100%;
  max-width: 1080px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: #fffdf9;
  border-radius: 16px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  text-align: center;
  box-sizing: border-box;
}

.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.header img {
  max-width: 300px;
  height: auto;
  margin-top: 0.5rem;
}

.wasm:hover {
  opacity: 1;
  background-color: #ffe0b2;
}

#cameraContainer {
  position: relative;
  width: 100%;
  max-width: 1920px;
  aspect-ratio: 16/12;
  margin:auto;
  min-width: 320px;
  min-height: 180px;
}

#video,
#overlayCanvas,
#canvas,
#videoOverlay,
#videoLoading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
}

#videoOverlay {
  position: relative;
  max-width: 1080px;
  display: flex;
  z-index: 5;
  pointer-events: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  padding: 2vw;
}

#videoOverlay > * {
  pointer-events: auto; /* Allow interaction with children like status-text */
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 1080px;
  margin: auto;
  border-radius: 12px;
  overflow: hidden;
  background-color: #f5f2ee;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  margin-bottom: 1.5rem;
}

#canvas {
  border-radius: 12px;
}

#overlayCanvas {
  z-index: 10;
}

#video {
  aspect-ratio: 16/9;
  max-width: 1080px;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#videoLoading {
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
  flex-wrap: wrap;
}

#loadText {
  display: none;
  color: #f28005;
  background-color: rgba(255, 255, 255, 0.3);
  font-family: 'Arial', sans-serif;
  font-size: clamp(0.75rem, 2vw, 1.125rem);
  font-weight: bold;
  text-align: center;
  border-radius: 8px;
  padding: 0.3rem 1rem;
  outline: 1px dashed #f28005;
  width: fit-content;
  max-width: 90%;
  outline-offset: 1px;
  margin: 0 auto;
}

#loader {
  margin: 0 auto;
  padding: 0.1rem 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 6px solid #fff;
  border-top: 6px solid #eba50d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.outline {
  display: flex;
  position: relative;
  width: clamp(260px, 90%, 5400px);
  max-width: 95%;
  aspect-ratio: 1.6;
  border: 3px dashed rgba(204, 106, 0, 1);
  border-radius: 12px;
  margin-bottom: 0.4rem;
  transition: all 0.3s ease;
  background-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.status-text {
  color: #f28005;
  background-color: rgba(255, 255, 255, 1);
  font-family: 'Arial', sans-serif;
  font-size: clamp(0.75rem, 2vw, 1.125rem);
  font-weight: bold;
  text-align: center;
  border-radius: 8px;
  padding: 0.3rem 1rem;
  outline: 1px solid white;
  width: fit-content;
  max-width: 90%;
  outline-offset: 1px;
  margin: 0 auto;
}

.buttons {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: clamp(1rem, 2.5vw, 1.5rem);
}

/* Capture button */
#capture.main-action {
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: bold;
  padding: clamp(0.5em, 1.5vw, 0.7em) clamp(5em, 8vw, 6em);
  background-color: #F18700;
  color: #fff;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s;
  height: clamp(2.5rem, 6vw, 3rem);
  align-items: center;
  justify-content: center;
}

#capture.main-action:hover:not(.disabled) {
  background-color: #fd7e14;
  transform: scale(1.1);
}

/* Upload icon button style */
.file-icon {
  position: absolute;
  margin: 0 1rem;
  font-size: 1rem;
  cursor: pointer;
  color: #cc6a00;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: clamp(3rem, 6vw, 4rem);
  border: none;
}

.file-icon img {
  width: 85%;
  object-fit: contain;
}

.file-icon:hover:not(.disabled) {
  transform: scale(1.05);
  color: #a85600;
}

.file-icon[disabled], #capture[disabled],
.file-icon[disabled]:hover, #capture[disabled]:hover {
  background-color: #ccc;
  transform: scale(1);
  cursor: not-allowed;
  filter: none;
  opacity: 0.5;
  pointer-events: none;
}

button, select {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 16px;
  color: white;
  background-color: #f18700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  min-width: 140px;
  text-align: center;
}

button:hover, select:hover {
  background-color: #f18700;
}

button:active, select:active {
  background-color: #f18700;
}

select {
  appearance: none;
}

input[type="file"] {
  display: none;
}

hr {
  border: 2px dashed #ffb26b;
}

img {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  height: auto;
}

button:disabled {
  background-color: #ccc;
  color: #666;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Scan Results */
.output-wrapper {
  display: none;
  justify-content: center;
  align-items: center;
  min-height: 320px;
  padding: 1rem;
  box-sizing: border-box;
  flex-direction: column;
}

#output-front {
  display: flex;
  width: 100%;
  max-width: 600px;
  min-height: 320px;
  height: auto;
  border-radius: 14px;
  padding: 1.5rem;
  font-family: 'Segoe UI', sans-serif;
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  background: linear-gradient(to bottom right, #cce5ff, #fff2c4, #c8ffe4);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  position: relative;
  box-sizing: border-box;
  flex-direction: column;
  gap: 1.5rem;
}

#output-back {
  display: flex;
  width: 100%;
  max-width: 600px;
  min-height: 320px;
  height: auto;
  border-radius: 14px;
  font-family: 'Segoe UI', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.125rem);
  background: linear-gradient(to bottom right, #cce5ff, #fff2c4, #c8ffe4);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  position: relative;
  box-sizing: border-box;
  flex-direction: column;
  gap: 1.5rem;
}

/* Footer */
footer {
  width: 100%;
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  box-sizing: border-box;
}

.footer-content {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
}

.footer-content select,
#button-camera {
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #ccc;
  background-color: #fff;
  color: #444;
  min-width: 140px;

  max-width: 100%;
  box-sizing: border-box;
  appearance: none;
}

.footer-content select:focus {
  outline: none;
  border-color: #f18700;
  box-shadow: 0 0 0 2px rgba(255, 169, 77, 0.3);
}

#button-camera {
  border: 1px solid rgba(214, 148, 7, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background-color 0.3s ease, border 0.3s ease;
  outline: none;
}

#button-camera:hover,
#button-camera:focus {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: rgba(248, 140, 17, 0.795);
}

/* Footer info section */
.wasm {
  display: inline-block;
  font-size: clamp(0.75rem, 1.5vw, 0.875rem);
  padding: 0.5rem 0.75rem;
  background-color: #fff3e0;
  color: #cc6a00;
  border-radius: 8px;
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  opacity: 0.85;
  transition: all 0.3s ease;
  white-space: nowrap;
  box-sizing: border-box;
}

.footer-link {
  color: #666;
  text-decoration: none;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.footer-link:hover {
  text-decoration: underline;
}

/* Demo unavailable */
.demo-unavailable {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #cc6a00;
  padding: 0.5rem;
  border-radius: 12px;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  max-width: 400px;
  margin: 2rem auto;
}

.demo-unavailable.hidden {
  display: none;
}

.element {
  padding: 24px;
  text-align: left;
  border: 3px dashed #ffb26b;
  border-radius: 12px;
}

.output-data {
  margin-bottom: 4px;
}

.output-data span {
  overflow-wrap: anywhere;
}

.output-images b {
  margin-bottom: 4px;
}
