/* バスケットボールローディングアニメーション */

/* ローディングオーバーレイ */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}

/* ローディングコンテナ */
#loading-container {
  text-align: center;
  position: relative;
  width: 400px;
  height: 200px;
  overflow: hidden;
  margin: 0 auto;
}

/* バスケットボール - SVG用 */
body #loading-overlay .basketball,
body #initial-loading .basketball,
body .basketball,
#loading-overlay .basketball,
#initial-loading .basketball,
.basketball {
  width: 45px;
  height: 45px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -22.5px 0 0 -22.5px;
  animation: bounceAndRoll 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

.basketball-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* SVG用の追加スタイル */
.basketball-svg {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

/* SVG用のアニメーション調整 */

/* バウンス＆ロールアニメーション */
@keyframes bounceAndRoll {
  0% {
    transform: translateX(-120px) translateY(0) rotate(0deg);
  }
  5% {
    transform: translateX(-105px) translateY(-25px) rotate(18deg);
  }
  10% {
    transform: translateX(-90px) translateY(-50px) rotate(36deg);
  }
  15% {
    transform: translateX(-75px) translateY(-30px) rotate(54deg);
  }
  20% {
    transform: translateX(-60px) translateY(0) rotate(72deg);
  }
  25% {
    transform: translateX(-45px) translateY(-35px) rotate(90deg);
  }
  30% {
    transform: translateX(-30px) translateY(-40px) rotate(108deg);
  }
  35% {
    transform: translateX(-15px) translateY(-20px) rotate(126deg);
  }
  40% {
    transform: translateX(0) translateY(0) rotate(144deg);
  }
  45% {
    transform: translateX(15px) translateY(-25px) rotate(162deg);
  }
  50% {
    transform: translateX(30px) translateY(-30px) rotate(180deg);
  }
  55% {
    transform: translateX(45px) translateY(-15px) rotate(198deg);
  }
  60% {
    transform: translateX(60px) translateY(0) rotate(216deg);
  }
  65% {
    transform: translateX(75px) translateY(-18px) rotate(234deg);
  }
  70% {
    transform: translateX(90px) translateY(-20px) rotate(252deg);
  }
  75% {
    transform: translateX(105px) translateY(-8px) rotate(270deg);
  }
  80% {
    transform: translateX(120px) translateY(0) rotate(288deg);
  }
  85% {
    transform: translateX(135px) translateY(-12px) rotate(306deg);
  }
  90% {
    transform: translateX(150px) translateY(-10px) rotate(324deg);
  }
  95% {
    transform: translateX(165px) translateY(-3px) rotate(342deg);
  }
  100% {
    transform: translateX(180px) translateY(0) rotate(360deg);
  }
}

/* ローディングテキスト */
#loading-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ローディングドット */
#loading-dots {
  display: inline-block;
  margin-left: 5px;
}

#loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* バスケットボールが転がるアニメーション（ページ遷移時） */
.basketball-rolling {
  position: fixed;
  width: 30px;
  height: 30px;
  z-index: 10000;
  animation: roll 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.basketball-rolling .basketball-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

/* 転がるボール用の追加スタイル */

@keyframes roll {
  0% {
    left: -50px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
  }
  20% {
    left: 20%;
    top: 35%;
    transform: translateY(-50%) rotate(72deg);
  }
  40% {
    left: 40%;
    top: 50%;
    transform: translateY(-50%) rotate(144deg);
  }
  60% {
    left: 60%;
    top: 35%;
    transform: translateY(-50%) rotate(216deg);
  }
  80% {
    left: 80%;
    top: 50%;
    transform: translateY(-50%) rotate(288deg);
  }
  100% {
    left: 100%;
    top: 50%;
    transform: translateY(-50%) rotate(360deg);
  }
}

/* ページ読み込み完了時のフェードアウト */
.page-loaded #loading-overlay {
  opacity: 0;
  visibility: hidden;
}

/* レスポンシブデザイン */
@media screen and (max-width: 768px) {
  #loading-container {
    width: 300px;
    height: 150px;
  }
  
  .basketball {
    width: 38px;
    height: 38px;
    margin: -19px 0 0 -19px;
  }
  
  #loading-text {
    font-size: 1rem;
    bottom: 45px;
  }
  
  #loading-progress {
    width: 150px;
    bottom: 25px;
  }
  
  #loading-message {
    bottom: 8px;
    font-size: 0.8rem;
  }
  
  .basketball-rolling {
    width: 25px;
    height: 25px;
  }
}

@media screen and (max-width: 480px) {
  #loading-container {
    width: 250px;
    height: 120px;
  }
  
  .basketball {
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
  }
  
  #loading-text {
    font-size: 0.9rem;
    bottom: 35px;
  }
  
  #loading-progress {
    width: 120px;
    bottom: 20px;
  }
  
  #loading-message {
    bottom: 5px;
    font-size: 0.7rem;
  }
  
  .basketball-rolling {
    width: 20px;
    height: 20px;
  }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
  #loading-overlay {
    background: rgba(0, 0, 0, 0.9);
  }
  
  #loading-text {
    color: #fff;
  }
  
  .basketball {
    background: transparent;
  }
  
  .basketball::before,
  .basketball::after,
  .basketball .curve {
    background: #ffffff;
    border-color: #ffffff;
  }
  
  .basketball-rolling {
    background: transparent;
  }
  
  .basketball-rolling::before,
  .basketball-rolling::after {
    background: #ffffff;
  }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
  .basketball,
  #loading-text,
  .basketball-rolling {
    animation: none;
  }
  
  .basketball {
    transform: none;
  }
  
  #loading-text {
    opacity: 1;
  }
}

/* ローディング状態の表示 */
#loading-state {
  position: relative;
  overflow: hidden;
}

#loading-state::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
  z-index: 1;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* ボタンのローディング状態 */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* フォーム送信時のローディング */
.form-loading {
  position: relative;
}

.form-loading #loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 10;
}

.form-loading #loading-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* アニメーションの遅延 */
#loading-item:nth-child(1) { animation-delay: 0s; }
#loading-item:nth-child(2) { animation-delay: 0.1s; }
#loading-item:nth-child(3) { animation-delay: 0.2s; }
#loading-item:nth-child(4) { animation-delay: 0.3s; }
#loading-item:nth-child(5) { animation-delay: 0.4s; }

/* カスタムローディングメッセージ */
#loading-message {
  font-size: 0.9rem;
  color: #666;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  font-style: italic;
}

/* プログレスバー付きローディング */
#loading-progress {
  width: 200px;
  height: 4px;
  background: #e0e0e0;
  border-radius: 2px;
  overflow: hidden;
  position: absolute;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
}

#loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #000000, #333333);
  border-radius: 2px;
  animation: progress 3s ease-in-out infinite;
}

@keyframes progress {
  0% {
    width: 0%;
  }
  50% {
    width: 70%;
  }
  100% {
    width: 100%;
  }
}

/* SVG用の最終調整 - 疑似要素を完全に無効化 */
.basketball::before,
.basketball::after,
.basketball .curve {
  display: none !important;
  content: none !important;
}
