/**
 * ローディング画面CSS（修正版）
 */

/* Google Fontsの読み込み */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;700&family=Roboto:wght@300;400;700&family=Open+Sans:wght@300;400;700&family=Lato:wght@300;400;700&family=Montserrat:wght@300;400;700&family=Poppins:wght@300;400;700&display=swap");

/* フォントファミリーのCSS変数 */
:root {
  --font-noto-sans: "Noto Sans JP", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-hiragino: "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3",
    sans-serif;
  --font-yu-gothic: "Yu Gothic Medium", "游ゴシック Medium", sans-serif;
  --font-meiryo: "Meiryo", "メイリオ", sans-serif;
  --font-roboto: "Roboto", sans-serif;
  --font-open-sans: "Open Sans", sans-serif;
  --font-lato: "Lato", sans-serif;
  --font-montserrat: "Montserrat", sans-serif;
  --font-poppins: "Poppins", sans-serif;
}

/* ローディング画面コンテナ */
#loading-screen-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: 99999;
  overflow: hidden;
  pointer-events: none;
}

/* ローディング画面 */
.loading-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity 1.2s cubic-bezier(0.23, 1, 0.32, 1),
    transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
}

/* 最初の画面（黒背景） */
.loading-screen.phase-1 {
  background-color: var(--loading-bg-color1, #000000);
  opacity: 1;
  visibility: visible;
  z-index: 1000;
  transform: translate3d(0, 0, 0);
}

/* セカンド画面（赤背景） - 初期状態で上に隠れている */
.loading-screen.phase-2 {
  background-color: var(--loading-bg-color2, #e74c3c);
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, -100%, 0);
  z-index: 1001;
  transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1);
  will-change: transform;
}

/* セカンド画面がスライドダウンした状態 */
.loading-screen.phase-2.slide-down {
  transform: translate3d(0, 0, 0);
}

/* 修正：両画面を同時にフェードアウト */
.loading-screen.fade-out {
  opacity: 0 !important;
  visibility: hidden;
  transition: opacity 1s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s linear 1s;
}

/* 非表示状態（従来のスライドアウトは削除） */
.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s linear 1s;
}

/* フェードアウトアニメーション */
@keyframes fadeOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.05);
  }
}

/* ローディング画面全体のフェードアウト */
#loading-screen-container.fade-out {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1s cubic-bezier(0.23, 1, 0.32, 1), visibility 0s linear 1s;
}

/* ローディングテキスト */
.loading-text {
  color: var(--loading-text-color, #ffffff);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-align: center;
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  font-family: var(--loading-font-family, inherit);
  will-change: transform, opacity, filter;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ドット要素を強制的に非表示 */
.loading-text .loading-dots,
.loading-text::after,
.loading-dots {
  display: none !important;
  content: none !important;
  visibility: hidden !important;
}

/* タイトル表示 */
.loading-title {
  color: var(--loading-text-color, #ffffff);
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-align: center;
  opacity: 0;
  transform: translate3d(0, 30px, 0);
  font-family: var(--loading-font-family, inherit);
  animation: fadeInTitle 1.2s ease-out forwards;
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ロゴ画像 */
.loading-logo {
  max-width: 200px;
  max-height: 100px;
  width: auto;
  height: auto;
  opacity: 0;
  transform: translate3d(0, 0, 0) scale(0.8);
  animation: fadeInLogo 1.2s ease-out forwards;
  will-change: transform, opacity;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ソフトフェードアニメーション */
.loading-text.soft-fade {
  animation: softFadeInSmooth 2s ease-out forwards;
  animation-delay: 0.5s;
}

/* ジェントルフェードアニメーション */
.loading-text.gentle-fade {
  animation: gentleFadeInSmooth 2.5s ease-out forwards;
  animation-delay: 0.8s;
}

/* バウンスフェードアニメーション */
.loading-text.bounce-fade {
  animation: bounceFadeInSmooth 1.8s cubic-bezier(0.68, -0.25, 0.265, 1.25)
    forwards;
  animation-delay: 0.5s;
}

/* スケールフェードアニメーション */
.loading-text.scale-fade {
  animation: scaleFadeInSmooth 2s ease-out forwards;
  animation-delay: 0.5s;
}

/* スライドフェードアニメーション */
.loading-text.slide-fade {
  animation: slideFadeInSmooth 2s ease-out forwards;
  animation-delay: 0.5s;
}

/* アニメーション定義 - ぼかしなし、スムーズ */
@keyframes softFadeInSmooth {
  0% {
    opacity: 0;
    transform: translate3d(0, 25px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes gentleFadeInSmooth {
  0% {
    opacity: 0;
    transform: translate3d(0, 35px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes bounceFadeInSmooth {
  0% {
    opacity: 0;
    transform: translate3d(0, 40px, 0) scale(0.9);
  }
  60% {
    opacity: 0.9;
    transform: translate3d(0, -5px, 0) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes scaleFadeInSmooth {
  0% {
    opacity: 0;
    transform: translate3d(0, 20px, 0) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes slideFadeInSmooth {
  0% {
    opacity: 0;
    transform: translate3d(-40px, 15px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* タイトルフェードインアニメーション */
@keyframes fadeInTitle {
  0% {
    opacity: 0;
    transform: translate3d(0, 30px, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ロゴフェードインアニメーション */
@keyframes fadeInLogo {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

/* ドット点滅アニメーション */
.loading-dots {
  display: inline-block;
  margin-left: 0.5em;
}

.loading-dots::after {
  content: "";
  animation: dots 1.5s infinite;
}

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

/* レスポンシブ対応 */
@media screen and (max-width: 768px) {
  .loading-text {
    font-size: 1.5rem;
    letter-spacing: 0.1em;
  }

  .loading-title {
    font-size: 2rem;
    letter-spacing: 0.05em;
  }

  .loading-logo {
    max-width: 150px;
    max-height: 75px;
  }
}

@media screen and (max-width: 480px) {
  .loading-text {
    font-size: 1.2rem;
    letter-spacing: 0.05em;
    padding: 0 1rem;
  }

  .loading-title {
    font-size: 1.5rem;
    padding: 0 1rem;
  }

  .loading-logo {
    max-width: 120px;
    max-height: 60px;
  }
}

/* アクセシビリティ：motion reduceに対応 */
@media (prefers-reduced-motion: reduce) {
  .loading-screen,
  .loading-text,
  .loading-title,
  .loading-logo {
    animation: none !important;
    transition: opacity 0.5s ease !important;
    will-change: auto !important;
  }

  .loading-text {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
  }

  .loading-title {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) !important;
  }

  .loading-logo {
    opacity: 1 !important;
    transform: translate3d(0, 0, 0) scale(1) !important;
  }

  .loading-screen.phase-2 {
    transition: transform 0.5s ease !important;
  }

  .loading-screen.phase-2.slide-down {
    transform: translate3d(0, 0, 0) !important;
  }

  /* motion reduce時も同時フェードアウトを維持 */
  .loading-screen.fade-out,
  .loading-screen.hidden,
  #loading-screen-container.fade-out {
    transition: opacity 0.5s ease !important;
  }
}

/* スムーズなスクロール無効化（ローディング中） */
body.loading-active {
  overflow: hidden;
  height: 100vh;
}

/* 高解像度ディスプレイ対応 */
@media screen and (-webkit-min-device-pixel-ratio: 2),
  screen and (min-resolution: 192dpi) {
  .loading-logo {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}
