/* ========================================
   Modal Components
   ======================================== */

/* Photo Modal */
.photo-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  margin: 0;
}

.photo-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-modal-content {
  position: relative;
  max-width: 90%;
  max-height: 85vh; /* アクションボタンのスペースを確保 */
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
}

/* Navigation Buttons */
.nav-btn {
  position: absolute;
  top: 45%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.prev-btn {
  left: -50px; /* より外側に配置 */
}

.next-btn {
  right: -50px; /* より外側に配置 */
}

#modalImage {
  max-width: 100%;
  max-height: 70vh; /* アクションボタンのスペースを確保 */
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  object-fit: contain; /* アスペクト比を保持 */
  display: block;
}

.photo-modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
  gap: 15px;
  flex-shrink: 0; /* ボタンエリアが縮まないようにする */
  padding: 0 20px; /* 左右の余白を確保 */
  width: 100%;
  box-sizing: border-box;
}

.share-btn {
  background: #007AFF;
  color: white;
  border: none;
  padding: 10px 24px; /* 2025/09/10 change */
  border-radius: 25px;
  font-size: 14px; /* 2025/09/10 change */
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

.share-btn:hover {
  background: #0056CC;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

/* Mobile adjustments for action buttons */
@media (max-width: 480px) {
  .photo-modal-content {
    max-width: 95%;
    max-height: 90vh; /* モバイルでは少し余裕を持たせる */
  }
  
  #modalImage {
    max-height: 60vh; /* モバイルでは画像を小さくしてボタンエリアを確保 */
  }
  
  .photo-modal-actions {
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 15px;
    margin-top: 15px;
  }
  
  .share-btn {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    font-size: 15px;
    white-space: nowrap; /* テキストの改行を防ぐ */
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* 非常に小さな画面での対応 */
@media (max-width: 320px) {
  .photo-modal-content {
    max-width: 98%;
    max-height: 95vh;
  }
  
  #modalImage {
    max-height: 55vh;
  }
  
  .photo-modal-actions {
    padding: 0 10px;
    margin-top: 10px;
  }
  
  .share-btn {
    max-width: 280px;
    padding: 10px 12px;
    font-size: 14px;
  }
}



/* Sound Dialog */
.sound-dialog {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  backdrop-filter: blur(5px);
}

.sound-dialog.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-dialog-content {
  background: #1a1a1a;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  animation: dialogSlideIn 0.3s ease-out;
  border: 2px solid #ffffff;
}

@keyframes dialogSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sound-dialog-header {
  background: linear-gradient(45deg, #2196F3, #1976D2);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.front-page .sound-dialog-header h3 {
  margin: 0;
  font-size: 20px;
  font-family: "Itim", cursive;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sound-dialog-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

/* 起動時音声ダイアログ */
.startup-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

#startupDialog {
  margin: 0;
}

.startup-dialog.active {
  opacity: 1;
  visibility: visible;
}

.startup-dialog-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 20px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  transform: scale(0.8);
  transition: transform 0.3s ease;
}

.startup-dialog.active .startup-dialog-content {
  transform: scale(1);
}

body.front-page .startup-dialog-header h3 {
  color: #ffffff;
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 600;
  font-family: "Helvetica", "Helvetica Neue", Arial, sans-serif;
}

.startup-dialog-body {
  margin-bottom: 25px;
}

.startup-dialog-body p {
  color: #ffffff;
  margin: 0 0 10px 0;
  font-size: 14px;
  line-height: 1.5;
  font-family: "Helvetica", "Helvetica Neue", Arial, sans-serif;
}

/* 音声エラーダイアログのスタイル */
#audioErrorDialog .startup-dialog-body p,
#audioErrorDialog .startup-dialog-body li {
  color: #ffffff;
  font-family: "Helvetica", "Helvetica Neue", Arial, sans-serif;
}

#audioErrorDialog .startup-dialog-body ul {
  color: #ffffff;
}

#audioErrorDialog .startup-dialog-header h3 {
  color: #ffffff;
}

/* スタートアップダイアログのヘッダー文字色 */
#startupDialog .startup-dialog-header h3 {
  color: #ffffff !important;
}

.startup-dialog-footer {
  display: flex;
  justify-content: center;
}

.startup-dialog-btn {
  background: linear-gradient(45deg, #4CAF50, #45a049);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: "Helvetica", "Helvetica Neue", Arial, sans-serif;
}

.startup-dialog-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.startup-dialog-btn:active {
  transform: translateY(0);
}
