/* style.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

:root {
  --primary-color: #ff2a5f;
  --bg-dark: #121212;
  --text-light: #f5f5f7;
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
}

#scene-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  background-color: #101118; /* ARカメラ起動前の画面真っ白化を防止 */
}

/* Loader Overlay */
.full-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loader-content {
  text-align: center;
  color: white;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #00f2fe;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.full-screen-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

.glass-panel {
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-light);
}

/* UI Container over the AR Canvas */
#ui-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  /* Let touches pass through to canvas by default */
  display: none;
}

/* Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Instruction Text */
#instruction {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  width: 80%;
  max-width: 320px;
  transition: opacity 0.5s ease;
}

#instruction p {
  margin: 0;
  line-height: 1.4;
}

/* Capture Button */
.capture-btn {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: 4px solid white;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  /* Enable touch for button */
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
  padding: 0;
  outline: none;
}

.capture-btn:active {
  transform: translateX(-50%) scale(0.92);
}

.capture-btn .inner-circle {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: white;
  transition: background-color 0.2s ease;
}

.capture-btn:active .inner-circle {
  background: #e0e0e0;
}

/* Full Screen Overlays */
.full-screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
}

.error-box {
  padding: 30px;
  text-align: center;
  max-width: 80%;
}

.error-box h2 {
  color: var(--primary-color);
  margin-top: 0;
}

/* Flash Effect */
#flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.1s ease-out;
}

/* A-Frame canvas should be full screen */
.a-canvas {
  width: 100% !important;
  height: 100% !important;
}

/* 撮影プレビューモーダルのスタイル */
.custom-preview-overlay.hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important;
}

#preview-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  /* 他のすべての要素の最前面に表示 */
  background: rgba(0, 0, 0, 0.85) !important;
  backdrop-filter: blur(15px) !important;
  -webkit-backdrop-filter: blur(15px) !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

#preview-modal.active {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

.preview-box {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(0.9) !important;
  transform-origin: center center;
  width: 90%;
  max-width: 400px;
  max-height: 95vh;
  overflow-y: auto;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#preview-modal.active .preview-box {
  transform: translate(-50%, -50%) scale(1) !important;
}

.preview-box h3 {
  font-size: 20px;
  margin: 0;
  color: var(--text-light);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.preview-box .image-container {
  width: 100%;
  max-height: 50vh;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--glass-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  background: rgba(0, 0, 0, 0.2);
}

.preview-box img {
  width: 100%;
  height: auto;
  max-height: 50vh;
  display: block;
  object-fit: contain;
  -webkit-user-select: auto;
  /* iOSでの画像長押し選択を許可 */
  user-select: auto;
}

.modal-instruction {
  font-size: 13px;
  color: #b3b3b7;
  line-height: 1.5;
  margin: 0;
  padding: 0 10px;
}

.modal-actions {
  display: flex;
  width: 100%;
  gap: 12px;
  margin-top: 8px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.primary-btn {
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
}

.primary-btn:active {
  transform: scale(0.96);
  opacity: 0.9;
}

.secondary-btn {
  background: var(--glass-bg);
  color: var(--text-light);
  border: 1px solid var(--glass-border);
}

.secondary-btn:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.96);
}

/* Start Dialog Overlay Style */
#camera-consent-overlay {
  z-index: 200000;
  display: none;
}

#start-dialog-overlay {
  z-index: 200000;
  display: none;
}

.start-dialog-content {
  padding: 30px;
  border-radius: 16px;
  max-width: 340px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.start-dialog-content h2 {
  margin-bottom: 15px;
  color: white;
  font-size: 20px;
}

.start-dialog-text-bold {
  margin-bottom: 10px;
  color: #f5f5f7;
  font-size: 14px;
  line-height: 1.6;
  font-weight: bold;
}

.start-dialog-warning {
  margin-bottom: 25px;
  color: var(--primary-color);
  font-size: 12px;
  font-weight: bold;
  line-height: 1.4;
}

#start-btn,
#camera-consent-btn {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: bold;
  width: 100%;
  max-width: 280px;
  box-sizing: border-box;
  cursor: pointer;
}

/* Loader overlay hidden by default */
#model-loader-overlay {
  display: none;
  z-index: 10000;
}

#error-screen {
  display: none;
}

/* Transform Info Debug Panel */
#transform-info {
  display: none;
  position: absolute;
  top: 120px;
  left: 10px;
  padding: 10px;
  font-family: monospace;
  font-size: 14px;
  pointer-events: auto;
  user-select: text;
  max-width: 250px;
  overflow-y: auto;
  max-height: 60vh;
}

#debug-controls {
  display: none;
  margin-top: 10px;
}

#debug-controls hr {
  border-color: rgba(255, 255, 255, 0.2);
}

#debug-controls input[type="range"] {
  width: 100%;
}

/* Animation Debug Panel */
#anim-debug-panel {
  position: absolute;
  bottom: 85px;
  left: 10px;
  padding: 12px;
  font-family: monospace;
  font-size: 13px;
  z-index: 1000000;
  pointer-events: auto;
  display: none;
  width: calc(100% - 20px);
  max-width: 320px;
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border-radius: 8px;
}

.anim-debug-header {
  font-weight: bold;
  margin-bottom: 8px;
  color: #00ff00;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#anim-debug-close {
  background: none;
  border: none;
  color: #ff3b30;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
}

.anim-debug-row {
  margin-bottom: 8px;
  font-size: 12px;
}

#anim-debug-name {
  font-weight: bold;
  color: #ffeb3b;
}

.anim-debug-controls-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  font-size: 12px;
}

#anim-debug-play-pause {
  padding: 4px 8px;
  cursor: pointer;
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
}

#anim-debug-time {
  color: #00ff00;
}

.anim-debug-slider-container {
  margin-bottom: 8px;
}

#anim-debug-slider {
  width: 100%;
  cursor: pointer;
}

.anim-debug-btn-row {
  display: flex;
  gap: 8px;
}

#anim-debug-copy-sec {
  flex: 1;
  padding: 6px;
  cursor: pointer;
  background: #007afc;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

#anim-debug-copy-frame {
  flex: 1;
  padding: 6px;
  cursor: pointer;
  background: #e040fb;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

/* A-Frameのパーミッションモーダル（標準のダイアログ）の非表示 */
.a-permission-modal,
#a-permission-modal {
  display: none !important;
}

/* 8th Wall / XRExtras のパーミッション・ローディング画面のチラつき防止と遅延表示 */
/* エラー系のコンテナは遅延させず、ロード中やセンサープロンプトのみを遅延させます */
#loadingContainer,
.prompt-box-8w {
  opacity: 0 !important;
  animation: fadeInPrompt 0.1s forwards !important;
  animation-delay: 0.8s !important; /* 0.8秒未満のチラつき（事前許可されている場合）を完全に隠す */
}

@keyframes fadeInPrompt {
  to {
    opacity: 1 !important;
  }
}

/* --- 8th Wall / XRExtras の英語表示を日本語に変更するスタイル --- */

/* 1. iOSのジャイロセンサー（デバイスモーション）要求プロンプトの日本語化 */
.prompt-box-8w p {
  font-size: 0 !important;
}
.prompt-box-8w p::before {
  content: "AR体験を開始するには、デバイスのモーションセンサーへのアクセスを許可する必要があります。" !important;
  font-size: 14px !important;
  line-height: 1.6 !important;
  color: #f5f5f7 !important;
  display: block !important;
}

.prompt-button-8w {
  font-size: 0 !important;
}
.prompt-button-8w::before {
  content: "許可する" !important;
  font-size: 16px !important;
  font-weight: bold !important;
  color: white !important;
}

/* 2. XRExtrasのカメラ要求プロンプトの日本語化 */
#requestingCameraPermissions {
  font-size: 0 !important;
}
#requestingCameraPermissions::before {
  content: "カメラへのアクセスを許可してください" !important;
  font-size: 18px !important;
  font-weight: bold !important;
  color: white !important;
  display: block !important;
}

/* 3. エラー画面などのテキスト日本語化 */
#cameraPermissionsErrorAppleMessage {
  font-size: 0 !important;
}
#cameraPermissionsErrorAppleMessage::before {
  content: "カメラのアクセス許可が必要です。ブラウザの設定でカメラへのアクセスを許可して、ページを再読み込みしてください。" !important;
  font-size: 16px !important;
  color: white !important;
  display: block !important;
  line-height: 1.6 !important;
}

#motionPermissionsErrorAppleMessage {
  font-size: 0 !important;
}
#motionPermissionsErrorAppleMessage::before {
  content: "モーションセンサーへのアクセス許可が必要です。設定アプリからSafariの「モーションと画面の向きのアクセス」を有効にして再読み込みしてください。" !important;
  font-size: 16px !important;
  color: white !important;
  display: block !important;
  line-height: 1.6 !important;
}