/* カスタムスタイル */

/* スムーズなページ遷移 */
.page {
  animation: fadeIn 0.3s ease-in;
}

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

/* ナビゲーションボタン */
.nav-btn {
  transition: all 0.2s ease;
  /* スマホ向けタップ領域拡大 */
  min-width: 60px;
  min-height: 60px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.nav-btn:hover {
  transform: scale(1.05);
}

.nav-btn:active {
  transform: scale(0.95);
}

/* タッチ操作の最適化 */
.touch-manipulation {
  touch-action: manipulation;
}

/* タッチデバイス用のタップハイライト削除 */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* ボタンのタップ時の視覚フィードバック */
button:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* 数値入力のスピナー非表示 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* スマホ用の大きなフォーム要素 */
input, button, select, textarea {
  /* iOSのデフォルトスタイルを無効化 */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* フォーカス時のズームを防止（フォントサイズ16px以上） */
  font-size: 16px;
}

/* 体重入力の大きなフィールド（例外的に大きく） */
#weight-input {
  font-size: 3rem !important;
}

/* プログレスバーのアニメーション */
#progress-bar {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ボタン */
button {
  user-select: none;
  cursor: pointer;
}

/* ローディングアニメーション */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading {
  animation: spin 1s linear infinite;
}

/* スクロールバーのカスタマイズ（Webkit） */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #9333ea;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #7e22ce;
}

/* スマホ向け: セーフエリア対応 */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  nav {
    padding-top: env(safe-area-inset-top);
  }
}

/* スマホ向け: スクロールの慣性 */
body {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* インストールバナーのアニメーション */
#install-banner {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* スマホ: ナビゲーションをコンパクトに */
@media (max-width: 640px) {
  .nav-btn {
    min-width: 56px;
    min-height: 56px;
    font-size: 0.75rem;
  }
  
  .nav-btn i {
    font-size: 1.125rem;
  }
  
  h1 {
    font-size: 1.125rem;
  }
  
  /* スマホで体重入力を少し小さく */
  #weight-input {
    font-size: 2.5rem !important;
  }
}

/* 超小型スマホ対応 */
@media (max-width: 375px) {
  .nav-btn {
    min-width: 50px;
    min-height: 50px;
    font-size: 0.7rem;
    gap: 0.125rem;
  }
  
  .nav-btn i {
    font-size: 1rem;
  }
}

/* タブレット以上: ナビゲーションを広く */
@media (min-width: 768px) {
  .nav-btn {
    padding: 0.5rem 1rem;
  }
}

/* PWAがスタンドアロンモードで起動された場合 */
@media (display-mode: standalone) {
  body {
    background-attachment: fixed;
  }
}

/* フォーカス時のアウトライン強化（アクセシビリティ） */
*:focus-visible {
  outline: 3px solid #9333ea;
  outline-offset: 2px;
}

/* タッチデバイスでのホバー効果を無効化 */
@media (hover: none) {
  .nav-btn:hover,
  button:hover {
    transform: none;
  }
}
