@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

*:focus { outline: none; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  touch-action: none;
  height: 100dvh;
  height: 100vh; /* fallback for older browsers */
  width: 100%;
}
@supports (height: 100dvh) {
  body { height: 100dvh; }
}

body.now-review { position: relative; }
body.now-review::after {
  position: fixed;
  content: '';
  display: block;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 150;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease-out;
}

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

.loading-content {
  text-align: center;
  color: #fff;
}

.loading-gif {
  width: 120px;
  height: 120px;
  mix-blend-mode: screen;
  margin-bottom: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
  opacity: 0;  /* Hidden until applyWebSettingsToLoading configures it */
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
  opacity: 0;  /* Hidden until applyWebSettingsToLoading configures it */
}

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

/* Start Modal */
.start-modal {
  display: flex;
  position: fixed;
  z-index: 99999;
  inset: 0;
  overflow: auto;
  background-color: #000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-in;
  pointer-events: auto;
}

.start-modal.hidden { display: none; }

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

.start-modal-content {
  background: transparent;
  padding: 40px;
  text-align: center;
  max-width: 85%;
  animation: slideUp 0.4s ease-out;
  pointer-events: auto;
  position: relative;
}

.start-modal-gif {
  width: 120px;
  height: 120px;
  mix-blend-mode: screen;
  margin-bottom: 24px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.start-modal-watermark {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 5px 10px 5px 7px;
  border-radius: 6px;
  pointer-events: auto;
  white-space: nowrap;
}

.ar-watermark {
  display: none;
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 9998;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  background: none;
  padding: 0;
  pointer-events: auto;
  white-space: nowrap;
}

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

.start-btn {
  background: linear-gradient(145deg, #fff 0%, #f0f0f0 50%, #e0e0e0 100%);
  color: #000;
  border: none;
  padding: 16px 48px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1.5px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    0 4px 20px rgba(255,255,255,0.2),
    0 8px 20px rgba(0,0,0,0.3);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  z-index: 999999;
  white-space: nowrap;
}

.start-btn:active {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #e0e0e0 0%, #d5d5d5 50%, #c8c8c8 100%);
  box-shadow:
    0 2px 10px rgba(255,255,255,0.15),
    0 4px 15px rgba(0,0,0,0.3);
}

.start-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.start-consent {
  margin: 16px auto 0;
  max-width: 260px;
}
.start-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
}
.start-consent-label input {
  margin-top: 2px;
  accent-color: #8ba3b5;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.start-consent-label a {
  color: #8ba3b5;
  text-decoration: underline;
}

/* AR Canvas */
#camerafeed {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  pointer-events: auto !important;
  z-index: 1 !important;
  opacity: 0;
  transition: opacity 0.3s ease-in;
  object-fit: cover;
}

#camerafeed.visible { opacity: 1; }
@supports (height: 100dvh) {
  #camerafeed { height: 100dvh !important; }
}

/* Capture Button */
.capture-btn-wrapper {
  position: fixed;
  display: none;
  width: 100%;
  bottom: 5%;
  justify-content: center;
  z-index: 200;
  pointer-events: none;
}

.capture-btn-wrapper.active { display: flex; }
.capture-btn-wrapper.preview { display: none; }

#capture-btn {
  border: none;
  background: linear-gradient(145deg, #4a4a4a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border-radius: 100%;
  width: 80px !important;
  height: 80px !important;
  cursor: pointer;
  padding: 0;
  display: block;
  position: relative;
  touch-action: manipulation;
  pointer-events: auto;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.35),
    0 3px 6px rgba(0,0,0,0.25),
    inset 0 -2px 6px rgba(0,0,0,0.4),
    inset 0 2px 6px rgba(255,255,255,0.12);
  transition: all 0.3s ease;
}

#capture-btn.btn-pressed {
  animation: btnPressScale 0.3s ease-out;
}

@keyframes btnPressScale {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

#capture-btn.now-recording {
  width: 100px !important;
  height: 100px !important;
  transition: 1s;
  background: linear-gradient(145deg, #5a5a5a 0%, #3a3a3a 50%, #2a2a2a 100%);
  box-shadow:
    0 8px 20px rgba(0,0,0,0.4),
    0 4px 8px rgba(0,0,0,0.3),
    inset 0 -3px 8px rgba(0,0,0,0.5),
    inset 0 3px 8px rgba(255,255,255,0.15);
}

.capture-btn-inner-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-btn-inner {
  display: block;
  width: 80%;
  height: 80%;
  border-radius: 100%;
  transition: 0.3s;
  background: linear-gradient(145deg, #fff 0%, #e8e8e8 50%, #d0d0d0 100%);
  box-shadow:
    0 4px 10px rgba(0,0,0,0.25),
    0 2px 4px rgba(0,0,0,0.2),
    inset 0 -2px 6px rgba(0,0,0,0.15),
    inset 0 2px 6px rgba(255,255,255,0.7);
}

.capture-btn-inner.rec-start {
  width: 70%;
  height: 70%;
  background: linear-gradient(145deg, #f55 0%, #f00 50%, #c00 100%);
  box-shadow:
    0 6px 18px rgba(255,0,0,0.7),
    0 3px 8px rgba(255,0,0,0.5),
    inset 0 -3px 8px rgba(0,0,0,0.6),
    inset 0 3px 8px rgba(255,150,150,0.7);
}

.capture-btn-inner.now-recording {
  width: 30%;
  height: 30%;
  border-radius: 4px;
  background: #f00;
  box-shadow: none;
}

/* Mute Toggle */
.mute-btn-wrapper {
  position: fixed;
  display: none;
  bottom: 6.5%;
  left: 0;
  justify-content: start;
  z-index: 201;
  pointer-events: none;
}

.mute-btn-wrapper.active { display: flex; }
.mute-btn-wrapper.preview { display: none; }

#mute-btn {
  border: none;
  background: transparent;
  margin-left: 24px;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.3s ease;
}

#mute-btn:active .mute-btn-inner {
  transform: scale(0.95);
}

.mute-btn-inner {
  display: inline-block;
  position: relative;
  width: 48px;
  height: 48px;
  background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border-radius: 50%;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.35),
    0 3px 6px rgba(0,0,0,0.25),
    inset 0 -2px 6px rgba(0,0,0,0.4),
    inset 0 2px 6px rgba(255,255,255,0.12);
  transition: all 0.3s ease;
}

.mute-btn-inner::before {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>') center/contain no-repeat;
  transition: background 0.2s;
}

.mute-btn-inner.muted::before {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>');
}

body.now-review .mute-btn-wrapper { display: none !important; }

/* Camera Switcher */
.camera-switcher-btn-wrapper {
  position: fixed;
  display: none;
  bottom: 6.5%;
  right: 0;
  justify-content: end;
  z-index: 201;
  transform: scale(1);
  transform-origin: center;
  pointer-events: none;
}

.camera-switcher-btn-wrapper.active { display: flex; }
.camera-switcher-btn-wrapper.preview { display: none; }

#camera-switcher {
  border: none;
  background: transparent;
  margin-right: 24px;
  pointer-events: auto;
  cursor: pointer;
  transition: all 0.3s ease;
}

#camera-switcher:active .camera-switcher-inner {
  transform: scale(0.95);
  box-shadow:
    0 6px 15px rgba(0,0,0,0.7),
    0 2px 6px rgba(0,0,0,0.5),
    inset 0 -2px 8px rgba(0,0,0,0.9),
    inset 0 2px 8px rgba(255,255,255,0.15);
}

.camera-switcher-inner {
  display: inline-block;
  vertical-align: middle;
  color: #fff;
  line-height: 1;
  position: relative;
  width: 48px;
  height: 48px;
  background: linear-gradient(145deg, #3a3a3a 0%, #2a2a2a 50%, #1a1a1a 100%);
  border-radius: 50%;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.35),
    0 3px 6px rgba(0,0,0,0.25),
    inset 0 -2px 6px rgba(0,0,0,0.4),
    inset 0 2px 6px rgba(255,255,255,0.12);
  transition: all 0.3s ease;
}

.camera-switcher-inner::before {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: url("./assets/camera-switch.png") center/contain no-repeat;
}

/* Preview: Captured Image */
#captured-image {
  display: none;
  pointer-events: none;
}

#captured-image.preview {
  position: fixed;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #000;
  border-radius: 16px;
  z-index: 200;
  max-width: 85vw;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  pointer-events: none;
  border: 4px solid #000;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.8),
    0 10px 30px rgba(0,0,0,0.6),
    inset 0 -3px 8px rgba(0,0,0,0.9),
    inset 0 3px 8px rgba(255,255,255,0.1);
}

/* Preview: Video */
#video {
  display: none;
  pointer-events: none;
}

#video.preview {
  position: fixed;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #000;
  border-radius: 16px;
  z-index: 200;
  max-width: 85vw;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  pointer-events: none;
  border: 4px solid #000;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.8),
    0 10px 30px rgba(0,0,0,0.6),
    inset 0 -3px 8px rgba(0,0,0,0.9),
    inset 0 3px 8px rgba(255,255,255,0.1);
}

/* Back Buttons (X icon via pseudo-elements) */
#pic-preview-back-btn,
#movie-preview-back-btn {
  position: fixed;
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto !important;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.6),
    0 1px 3px rgba(0,0,0,0.4),
    inset 0 -1px 4px rgba(0,0,0,0.8),
    inset 0 1px 4px rgba(255,255,255,0.15);
  z-index: 999 !important;
  padding: 0;
  color: transparent;
  font-size: 0;
}

#pic-preview-back-btn.preview,
#movie-preview-back-btn.preview {
  display: flex;
}

#pic-preview-back-btn {
  right: calc(10vw + 10px) !important;
  bottom: calc(14vh + 10px) !important;
}

#movie-preview-back-btn {
  right: calc(10vw + 10px) !important;
  bottom: calc(13vh + 10px) !important;
}

#pic-preview-back-btn::before,
#movie-preview-back-btn::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 1px;
}

#pic-preview-back-btn::after,
#movie-preview-back-btn::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background: #fff;
  transform: rotate(-45deg);
  border-radius: 1px;
}

#pic-preview-back-btn:active,
#movie-preview-back-btn:active {
  background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 50%, #000 100%);
  box-shadow:
    0 4px 15px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 2px 8px rgba(0,0,0,0.95),
    inset 0 -1px 4px rgba(255,255,255,0.1);
}

/* Share Buttons */
.pic-preview-btn-wrapper,
.movie-preview-btn-wrapper {
  display: none;
}

.pic-preview-btn-wrapper.preview,
.movie-preview-btn-wrapper.preview {
  display: flex;
  position: fixed;
  bottom: 5%;
  left: 0;
  right: 0;
  width: 100%;
  justify-content: center;
  align-items: center;
  z-index: 300;
  pointer-events: none;
}

#pic-preview-share-btn,
#movie-preview-share-btn {
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  border: none;
  color: #fff;
  border-radius: 100px;
  padding: 14px 32px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    0 8px 20px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 -2px 6px rgba(0,0,0,0.8),
    inset 0 2px 6px rgba(255,255,255,0.15);
  pointer-events: auto;
  position: relative;
  overflow: hidden;
}

#pic-preview-share-btn::before,
#movie-preview-share-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

#pic-preview-share-btn:active,
#movie-preview-share-btn:active {
  transform: translateY(-1px);
  background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 50%, #000 100%);
  box-shadow:
    0 4px 15px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 2px 8px rgba(0,0,0,0.95),
    inset 0 -1px 4px rgba(255,255,255,0.1);
}

/* Recording Timer */
.movie-record-cnt-wrapper {
  position: fixed;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  pointer-events: none;
  z-index: 300;
}

.movie-record-cnt-wrapper.now-recording {
  display: block;
}

.movie-record-cnt {
  font-size: 20px;
  background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  box-shadow:
    0 8px 20px rgba(0,0,0,0.6),
    0 2px 4px rgba(0,0,0,0.4),
    inset 0 -2px 6px rgba(0,0,0,0.8),
    inset 0 2px 6px rgba(255,255,255,0.15);
}

/* Hide controls during preview */
body.now-review .capture-btn-wrapper,
body.now-review .camera-switcher-btn-wrapper,
body.now-review .mute-btn-wrapper,
body.now-review .movie-record-cnt-wrapper {
  display: none !important;
}

/* Landscape adjustments */
@media (orientation: landscape) {
  #capture-btn {
    width: 56px !important;
    height: 56px !important;
  }
  #capture-btn.now-recording {
    width: 68px !important;
    height: 68px !important;
  }
  .capture-btn-wrapper { bottom: 3%; }
  .camera-switcher-btn-wrapper {
    bottom: 4%;
    transform: scale(1);
  }
  #camera-switcher { margin-right: 20px; }
  .camera-switcher-inner {
    width: 38px;
    height: 38px;
  }
  .mute-btn-wrapper { bottom: 4%; }
  #mute-btn { margin-left: 20px; }
  .mute-btn-inner {
    width: 38px;
    height: 38px;
  }
  #pic-preview-share-btn,
  #movie-preview-share-btn {
    padding: 10px 24px;
    font-size: 14px;
    letter-spacing: 1px;
  }
  #pic-preview-back-btn,
  #movie-preview-back-btn {
    width: 36px;
    height: 36px;
  }
  #pic-preview-back-btn {
    right: calc(26.5vw + 10px) !important;
    bottom: calc(24vh + 10px) !important;
  }
  #movie-preview-back-btn {
    right: calc(27vw + 10px) !important;
    bottom: calc(22.5vh + 10px) !important;
  }
  #pic-preview-back-btn::before,
  #movie-preview-back-btn::before,
  #pic-preview-back-btn::after,
  #movie-preview-back-btn::after {
    width: 16px;
    height: 2px;
  }
  #video.preview,
  #captured-image.preview {
    top: 42%;
    max-width: 45vw;
    max-height: 55vh;
  }
  .movie-record-cnt-wrapper { top: 2%; }
  .movie-record-cnt {
    font-size: 16px;
    padding: 5px 12px;
    letter-spacing: 1px;
  }
  .start-modal-content {
    padding: 20px 40px;
    max-width: 50%;
  }
  .start-btn {
    padding: 12px 30px;
    font-size: 16px;
    letter-spacing: 1px;
  }
}

@media (max-width: 480px) {
  .start-modal-content { padding: 40px 20px; }
  .start-btn {
    padding: 14px 40px;
    font-size: 18px;
    letter-spacing: 1px;
  }
}
