/* ========================================
   Camera Section
   ======================================== */

/* ビューポート対応 */
html.front-page, body.front-page {
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  /* iOS Safari ビューポート対応 */
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  background-color: #000; /* 撮影画面の背景を黒に */
}

/* PWAモードでのビューポート調整 */
.mode-pwa html.front-page, 
.mode-pwa body.front-page {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  min-width: 100vw;
}

/* カメラ画面でのスクロール制御 */
#cameraTab {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  max-height: 100vh;
  max-height: calc(var(--vh, 1vh) * 100);
  position: relative;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  background-color: #000; /* 背景黒 */
}

/* PWAモードでのカメラタブ調整 */
.mode-pwa #cameraTab {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  min-width: 100vw;
  max-height: none;
  max-width: none;
}

/* タブ全体のスクロール制御 */
.tab-content {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  max-height: 100vh;
  max-height: calc(var(--vh, 1vh) * 100);
}

/* アプリケーション全体のビューポート対応 */
#app {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  max-height: 100vh;
  max-height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  max-width: 100vw;
  position: relative;
  overflow: hidden;
  background-color: #000; /* 背景黒 */
}

/* PWAモードでのアプリケーション全体調整 */
.mode-pwa #app {
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  width: 100vw;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  min-width: 100vw;
  max-height: none;
  max-width: none;
}

/* Powered by CapFan テキスト */
.powered-by-text {
  position: fixed;
  bottom: 0; /* 画面の最下部に固定 */
  left: 0;
  right: 0;
  width: 100%;
  background-color: #000000;
  color: #ffffff;
  padding: 8px 16px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  z-index: 95;
  white-space: nowrap;
  height: 40px;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: none;
  outline: none;
  margin: 0;
}

@media (orientation: landscape){
  .powered-by-text {
    background-color: rgba(0,0,0,0.5);
  }
}

/* PWAモード時: 最下部の安全領域も含めて左右へフル伸長 */
@media (orientation: landscape) {
  .mode-pwa .powered-by-text {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: env(safe-area-inset-bottom);
    left: 0;
    right: 0;
    margin-bottom: 0;
    margin-left: -env(safe-area-inset-left);
  }
}

/* スマホでのPowered by CapFan調整は JavaScript で動的に制御 */

#cameraTab .camera-container {
  height: 100%;
  max-height: 100vh;
  padding-bottom: 140px; /* 撮影ボタン + Powered by CapFanエリア用の余白 */
}

/* コンテナのpadding-bottomもJavaScriptで動的に制御 */

/* スマホでのカメラ画面制御 */
@media (max-width: 768px) {
  #cameraTab {
    height: 100vh;
    max-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: none;
    -webkit-overflow-scrolling: touch;
  }
  
  #cameraTab .camera-container {
    height: 100vh;
    max-height: 100vh;
    padding-bottom: 120px; /* スマホでの撮影ボタン用の余白 */
  }
  
  /* ビデオ要素のスクロール制御 */
  #cameraTab video {
    max-height: 100vh;
    object-fit: cover;
  }
  
  /* キャンバス要素のスクロール制御 */
  #cameraTab canvas {
    max-height: 100vh;
  }
  
}

/* 音声アニメーション */
.audio-animation {
  position: absolute; /* ボタン内中央に固定 */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 1px;
  width: 44px; /* ボタン内に収まるサイズ */
  height: 26px;
  z-index: 2;
}

.audio-square {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 3px;
  opacity: 0.8;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  /* アニメーション用の初期状態 */
  transform: scaleX(0.2) scaleY(0.2);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.3);
}

/* 音声レベルに応じたアニメーション（縦方向のみズーム） */
.audio-square.level-1 { 
  transform: scaleX(0.6) scaleY(0.6); 
  opacity: 1.0; 
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}
.audio-square.level-2 { 
  transform: scaleX(0.8) scaleY(0.8); 
  opacity: 1.0; 
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}
.audio-square.level-3 { 
  transform: scaleX(1.0) scaleY(1.0); 
  opacity: 1.0; 
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
}
.audio-square.level-4 { 
  transform: scaleX(1.2) scaleY(1.2); 
  opacity: 1.0; 
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}
.audio-square.level-5 { 
  transform: scaleX(1.4) scaleY(1.4); 
  opacity: 1.0; 
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.9);
}

/* 個別のドットアニメーション */
.audio-dot:nth-child(1) { animation-delay: 0s; }
.audio-dot:nth-child(2) { animation-delay: 0.08s; }
.audio-dot:nth-child(3) { animation-delay: 0.16s; }
.audio-dot:nth-child(4) { animation-delay: 0.24s; }
.audio-dot:nth-child(5) { animation-delay: 0.32s; }

/* パルスアニメーション（縦方向のみズーム） */
@keyframes pulse {
  0% { transform: scaleX(0.2) scaleY(0.2); }
  50% { transform: scaleX(1.0) scaleY(1.0); }
  100% { transform: scaleX(0.2) scaleY(0.2); }
}

/* 音声再生中の特別なエフェクト */
.shutter-button.playing-audio .audio-square {
  animation: pulse 0.6s ease-in-out infinite;
}

/* 個別のパルス遅延（6個の波形用） */
.shutter-button.playing-audio .audio-square:nth-child(1) { animation-delay: 0s; }
.shutter-button.playing-audio .audio-square:nth-child(2) { animation-delay: 0.12s; }
.shutter-button.playing-audio .audio-square:nth-child(3) { animation-delay: 0.24s; }
.shutter-button.playing-audio .audio-square:nth-child(4) { animation-delay: 0.08s; }
.shutter-button.playing-audio .audio-square:nth-child(5) { animation-delay: 0.2s; }
.shutter-button.playing-audio .audio-square:nth-child(6) { animation-delay: 0.16s; }

/* リアルタイム波形分析用のスタイル */
.wave-bar {
  /* 高さと透明度はJavaScriptで動的に制御 */
  position: relative;
  transform-origin: center;
}

/* 音声再生中の撮影ボタンスタイル */
.shutter-button.playing-audio {
  background: linear-gradient(45deg, #FF9800, #F57C00);
}

.shutter-button.playing-audio img {
  opacity: 0.3;
}

.webcam {
  position: relative;
  width: 100vw;
  height: 100vh; /* JavaScriptで動的に調整される */
  height: calc(var(--vh, 1vh) * 100); /* フォールバック */
  background-color: #000; /* 背景黒 */
}

#video, #canvas {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh; /* JavaScriptで動的に調整される */
  height: calc(var(--vh, 1vh) * 100); /* フォールバック */
  object-fit: cover;
  z-index: 1;
  min-width: 100vw;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
}

/* PWAモードでのビデオ・キャンバス調整 */
.mode-pwa #video, 
.mode-pwa #canvas {
  width: 100vw;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  min-width: 100vw;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  max-width: none;
  max-height: none;
  background-color: #000; /* メディア要素の背景も黒に */
}

/* Countdown Display */
.countdown-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 20px;
  padding: 30px 50px;
  text-align: center;
}

.countdown-text {
  font-size: 80px;
  font-weight: bold;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}



/* Camera Controls */
.camera-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 120px; /* ボタンエリアの高さ */
  z-index: 100;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px; /* ボタン間の間隔 */
}

/* Shutter Button を中央配置 */
.shutter-button {
  position: relative;
  z-index: 101; /* 他のボタンより上に */
  order: 2; /* Flexbox内での順序：撮影ボタンが中央 */
}

/* スマホの横向きでの調整 */
@media (max-height: 400px) and (orientation: landscape) {
  /* .camera-controls の位置はJavaScriptで制御 */
  
  .shutter-button {
    width: 60px;
    height: 60px;
  }
  
  .controls{
    position: fixed;
    justify-content: end;
    height: 100vh;
    top:0;
  }
  .controls_layout{
    flex-direction: column;
    bottom:auto;
    right: 0;
    top:0;
    width: 100px !important;
    align-items: center;
    height: 80vh !important;
    padding-top: 0px;
    padding-bottom: 60px;
  }

/* PWAモードで画面を横にした時の.controls_layoutの調整 */
@media (orientation: landscape) {
  .mode-pwa .controls_layout {
    padding-bottom: 0px;
  }
}
}


.shutter-button {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: transparent;
  color: white;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative; /* 波アニメーションをボタン内基準に配置 */
}

/* カメラ切り替えボタン */
#switchCameraBtn.switch-camera-button {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  order: 3; /* Flexbox内での順序：カメラ切り替えボタンが右端 */
  border: 1px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
}

#switchCameraBtn.switch-camera-button:hover {
  background: rgba(0,0,0,0.75);
}


/* Material Iconsのスタイル調整 */
#switchCameraBtn.switch-camera-button .material-icons {
  font-size: 24px;
  color: #ffffff;
}


.shutter-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.shutter-button:hover {
  transform: scale(1.1);
}

/* 音声再生中はホバーを無効にする */
.shutter-button.playing-audio:hover {
  transform: scale(1);
  cursor: default;
  pointer-events: none;
}

/* 音声再生中のホバー効果を完全に無効化 */
.shutter-button.playing-audio:hover,
.shutter-button.playing-audio:focus,
.shutter-button.playing-audio:focus-visible {
  transform: scale(1);
  outline: none;
}

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

/* 音声再生中はアクティブ状態も無効にする */
.shutter-button.playing-audio:active {
  transform: scale(1);
}

.shutter-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: scale(1);
}

.shutter-button:disabled:hover {
  transform: scale(1);
}

/* Stamp Selection Buttons */
.buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0 20px;
}

.buttonList {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 20px;
  width: 100%;
  max-width: 400px;
}

.buttonList-item {
  width: 120px;
  height: 140px;
  border: solid #333333 2px;
  border-radius: 4px;
  background-color: #ffffff;
  box-shadow: 2px 2px 0 rgb(51 51 51);
}

.button {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 2px 1px #c4c4c4);
}

.current {
  border-radius: 2px;
  outline: solid #fcacf1 3px;
}

.button-white {
  filter: drop-shadow(2px 2px 1px #888888);
}

.button > img {
  height: auto;
}

.stamp-container .buttonList {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 15px;
  justify-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stamp-container .buttonList-item {
  margin: 0;
}

.stamp-container .button {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stamp-container .button:hover {
  border-color: rgba(255, 255, 255, 0.6);
  transform: scale(1.05);
}

.stamp-container .button.current {
  border-color: #4CAF50;
  background: rgba(76, 175, 80, 0.2);
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

/* Expression Display */
.expression-display {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 20px;
  padding: 15px 25px;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 150px;
  font-size: 18px;
  font-weight: bold;
  color: #4CAF50;
  transition: all 0.3s ease;
}

/* Logo Display */
.logo-display {
  position: relative;
  display: none; /* 撮影中の画面からロゴを非表示 */
  align-items: center;
  /* iOS Safari対応 */
  will-change: transform;
  height: 40px;
  z-index: 10001;
}

/* Camera Logo Overlay - 撮影中の画面に撮影画像と同じ位置にロゴを表示 */
.camera-logo-overlay {
  position: absolute;
  bottom: 2%; /* 下端から2% */
  left: 2%; /* 左端から2% */
  z-index: 150; /* より高いz-indexで確実に表示 */
  pointer-events: auto; /* クリックを有効化 */
  opacity: 1.0;
  /* display は JavaScript で制御するため削除 */
  cursor: pointer; /* マウスオーバー時にポインターカーソル */
}

.camera-logo-overlay img {
  /* 撮影画像のロゴサイズと合わせる: Math.min(compW, compH) * 0.6 */
  height: min(60vw, 60vh); /* 画面サイズの60%に相当 */
  max-height: 100px; /* 統一された最大サイズ */
  min-height: 60px; /* 最小サイズを保証 */
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* スマホでのロゴサイズ調整 */
@media (max-width: 768px) {
  .camera-logo-overlay img {
    height: min(15vw, 15vh); /* スマホでは15%に縮小 */
    max-height: 100px; /* 統一された最大サイズ */
    min-height: 40px; /* スマホでの最小サイズ */
  }
}

/* スマホ縦画面時の特別調整 */
@media (max-width: 768px) and (orientation: portrait) {
  .camera-logo-overlay {
    bottom: 10%; /* 縦画面では少し下に移動 */
    left: 2%; /* 左位置は維持 */
  }
  
  .camera-logo-overlay img {
    height: min(18vw, 18vh); /* 縦画面時は18%に拡大 */
    max-height: 100px; /* 統一された最大サイズ */
    min-height: 45px; /* 縦画面時の最小サイズを拡大 */
  }
}

/* さらに小さな画面用の調整 */
@media (max-width: 480px) {
  .camera-logo-overlay img {
    height: min(12vw, 12vh); /* 小画面では12%に縮小 */
    max-height: 100px; /* 統一された最大サイズ */
    min-height: 30px; /* 小画面での最小サイズ */
  }
}

/* 小画面縦画面時の特別調整 */
@media (max-width: 480px) and (orientation: portrait) {
  .camera-logo-overlay {
    bottom: 12%; /* 小画面縦では少し下に移動 */
    left: 2%;
  }
  
  .camera-logo-overlay img {
    height: min(16vw, 16vh); /* 小画面縦では16%に拡大 */
    max-height: 100px; /* 統一された最大サイズ */
    min-height: 40px; /* 小画面縦の最小サイズを拡大 */
  }
}

/* スマホ横向き時の調整 */
@media (max-width: 768px) and (orientation: landscape) {
  .camera-logo-overlay {
    bottom: 25%; /* フッターに被らないよう上に移動 */
    left: 2%; /* 左位置は維持 */
  }
  
  .camera-logo-overlay img {
    height: min(20vw, 20vh); /* 横向き時は20%に拡大 */
    max-height: 100px; /* 横向き時の最大サイズ */
    min-height: 50px; /* 横向き時の最小サイズ */
  }
}

/* 小画面の横向き時の調整 */
@media (max-width: 480px) and (orientation: landscape) {
  .camera-logo-overlay {
    bottom: 30%; /* さらに上に移動 */
    left: 2%;
  }
  
  .camera-logo-overlay img {
    height: min(18vw, 18vh); /* 小画面横向きでは18% */
    max-height: 100px; /* 統一された最大サイズ */
    min-height: 40px;
  }
}

/* スマホ横画面時の撮影ボタンコントロール調整 */
@media (max-width: 768px) and (orientation: landscape) {
  .controls {
    margin-bottom: 50px !important; /* 撮影ボタン類をやや上に移動 */
  }
}

/* 設定画面のロゴ非表示プランバナー */
.logo-removal-banner {
  margin: 0 0 20px 0;
  padding: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.logo-removal-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.banner-content {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.banner-icon {
  font-size: 24px;
  line-height: 1;
  flex-shrink: 0;
}

.banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.banner-title {
  color: white;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.banner-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  line-height: 1.2;
}

.banner-button {
  flex-shrink: 0;
}

.banner-upgrade-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  padding: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner-upgrade-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

/* モバイル対応 */
@media (max-width: 480px) {
  .banner-content {
    padding: 10px 12px;
    gap: 10px;
  }
  
  .banner-icon {
    font-size: 20px;
  }
  
  .banner-title {
    font-size: 13px;
  }
  
  .banner-subtitle {
    font-size: 11px;
  }
  
  .banner-upgrade-btn {
    padding: 6px;
    font-size: 14px;
    width: 28px;
    height: 28px;
  }
}

/* 横回転時の表示サイズ制御 */
@media screen and (orientation: landscape) {
  html, body {
    overflow-x: hidden;
    width: 100vw;
    max-width: 100vw;
  }
  
  #app {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
}

/* iOS Safari での横回転時のズーム防止 */
@supports (-webkit-overflow-scrolling: touch) {
  @media screen and (orientation: landscape) {
    html {
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
    }
    
    body {
      -webkit-text-size-adjust: 100%;
      text-size-adjust: 100%;
      zoom: 1;
    }
  }
}
