/* ========================================
   アニメーションスタイルシート
   桜ヶ丘市立図書館 蔵書検索システム
   ======================================== */

/* ========================================
   グリッチエフェクト
   ======================================== */

@keyframes glitch {
  0% {
    transform: translate(0);
    filter: none;
    opacity: 1;
  }
  10% {
    transform: translate(-2px, 2px);
    filter: hue-rotate(90deg);
    opacity: 0.9;
  }
  20% {
    transform: translate(2px, -2px);
    filter: hue-rotate(180deg);
    opacity: 0.95;
  }
  30% {
    transform: translate(-2px, -2px);
    filter: hue-rotate(270deg);
    opacity: 0.85;
  }
  40% {
    transform: translate(2px, 2px);
    filter: hue-rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: translate(-1px, 1px);
    filter: hue-rotate(45deg);
    opacity: 0.9;
  }
  60% {
    transform: translate(1px, -1px);
    filter: hue-rotate(135deg);
    opacity: 0.95;
  }
  70% {
    transform: translate(-1px, -1px);
    filter: hue-rotate(225deg);
    opacity: 0.85;
  }
  80% {
    transform: translate(1px, 1px);
    filter: hue-rotate(315deg);
    opacity: 1;
  }
  90% {
    transform: translate(-2px, 2px);
    filter: hue-rotate(0deg);
    opacity: 0.9;
  }
  100% {
    transform: translate(0);
    filter: none;
    opacity: 1;
  }
}

.glitch-effect {
  animation: glitch 0.5s linear;
}

.glitch-effect-loop {
  animation: glitch 2s linear infinite;
}

/* グリッチエフェクト（テキスト用） */
@keyframes glitch-text {
  0% {
    text-shadow: 0 0 0 transparent;
  }
  25% {
    text-shadow: -2px 0 0 rgba(255, 0, 0, 0.7),
                 2px 0 0 rgba(0, 255, 255, 0.7);
  }
  50% {
    text-shadow: 2px 0 0 rgba(255, 0, 0, 0.7),
                 -2px 0 0 rgba(0, 255, 255, 0.7);
  }
  75% {
    text-shadow: -2px 0 0 rgba(0, 255, 0, 0.7),
                 2px 0 0 rgba(255, 0, 255, 0.7);
  }
  100% {
    text-shadow: 0 0 0 transparent;
  }
}

.glitch-text {
  animation: glitch-text 0.3s linear;
}

/* ========================================
   テキストフリッカー（ちらつき）
   ======================================== */

@keyframes flicker {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.95;
  }
}

.flicker-effect {
  animation: flicker 0.1s ease-in-out;
}

.flicker-loop {
  animation: flicker 5s ease-in-out infinite;
}

/* ランダムフリッカー（JavaScriptから制御） */
.random-flicker {
  transition: opacity 0.1s;
}

/* ========================================
   パルス（脈動）エフェクト
   ======================================== */

@keyframes pulse {
  0%, 100% {
    opacity: 0.9;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

.pulse-effect {
  animation: pulse 1s ease-in-out infinite;
}

/* 背景パルス */
@keyframes pulse-bg {
  0%, 100% {
    background-color: rgba(0, 0, 0, 0);
  }
  50% {
    background-color: rgba(66, 135, 245, 0.05);
  }
}

.pulse-bg-effect {
  animation: pulse-bg 2s ease-in-out infinite;
}

/* ========================================
   フェードイン・アウト
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-in;
}

.fade-in-slow {
  animation: fadeIn 2s ease-in;
}

.fade-out {
  animation: fadeOut 0.5s ease-out;
}

/* ========================================
   スライドイン
   ======================================== */

@keyframes slideInFromTop {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

@keyframes slideInFromLeft {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInFromRight {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-in-top {
  animation: slideInFromTop 0.5s ease-out;
}

.slide-in-bottom {
  animation: slideInFromBottom 0.5s ease-out;
}

.slide-in-left {
  animation: slideInFromLeft 0.5s ease-out;
}

.slide-in-right {
  animation: slideInFromRight 0.5s ease-out;
}

/* ========================================
   タイピングエフェクト
   ======================================== */

@keyframes typing {
  from {
    width: 0;
  }
  to {
    width: 100%;
  }
}

@keyframes blink-caret {
  from, to {
    border-color: transparent;
  }
  50% {
    border-color: var(--primary-text, #2c2c2c);
  }
}

.typing-effect {
  overflow: hidden;
  border-right: 2px solid;
  white-space: nowrap;
  animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

/* ========================================
   ローディングアニメーション
   ======================================== */

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

.loading-spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top: 4px solid #4287f5;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

/* プログレスバー */
@keyframes progress {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
}

.progress-bar {
  width: 100%;
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  margin: 20px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4287f5 0%, #42f5a7 100%);
  width: 0%;
  transition: width 0.5s ease;
  animation: pulse 2s ease-in-out infinite;
}

/* ドット読み込み */
@keyframes dot-flashing {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.loading-dots span {
  animation: dot-flashing 1.4s infinite;
  display: inline-block;
  margin: 0 2px;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ========================================
   シェイク（振動）エフェクト
   ======================================== */

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

.shake-effect {
  animation: shake 0.5s ease-in-out;
}

/* ========================================
   フロート（浮遊）エフェクト
   ======================================== */

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.float-effect {
  animation: float 3s ease-in-out infinite;
}

/* ========================================
   バウンス
   ======================================== */

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.bounce-effect {
  animation: bounce 1s ease-in-out;
}

/* ========================================
   ブラー（ぼかし）エフェクト
   ======================================== */

@keyframes blur-in {
  from {
    filter: blur(10px);
    opacity: 0;
  }
  to {
    filter: blur(0);
    opacity: 1;
  }
}

@keyframes blur-out {
  from {
    filter: blur(0);
    opacity: 1;
  }
  to {
    filter: blur(10px);
    opacity: 0;
  }
}

.blur-in {
  animation: blur-in 1s ease-in;
}

.blur-out {
  animation: blur-out 1s ease-out;
}

/* 微妙なブラー（読みづらさの演出） */
.subtle-blur {
  filter: blur(0.3px);
}

/* ========================================
   色変化エフェクト
   ======================================== */

@keyframes color-shift {
  0%, 100% {
    filter: hue-rotate(0deg);
  }
  33% {
    filter: hue-rotate(120deg);
  }
  66% {
    filter: hue-rotate(240deg);
  }
}

.color-shift-effect {
  animation: color-shift 3s linear infinite;
}

/* 背景色の段階的変化（JavaScriptで制御） */
.bg-transition {
  transition: background-color 3s ease;
}

/* ========================================
   テキストの暗転エフェクト
   ======================================== */

@keyframes darken {
  from {
    color: var(--primary-text, #2c2c2c);
    background-color: transparent;
  }
  to {
    color: #ffffff;
    background-color: #1a1a2e;
  }
}

.darken-effect {
  animation: darken 3s ease forwards;
}

/* ========================================
   数字カウントアップ効果（CSSのみ）
   ======================================== */

@keyframes number-count {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.count-up {
  animation: number-count 1s ease-out;
}

/* ========================================
   点滅（ブリンク）
   ======================================== */

@keyframes blink {
  0%, 49%, 100% {
    opacity: 1;
  }
  50%, 99% {
    opacity: 0;
  }
}

.blink-effect {
  animation: blink 1s step-start infinite;
}

.blink-slow {
  animation: blink 2s step-start infinite;
}

/* ========================================
   スキャンライン（古いモニター風）
   ======================================== */

@keyframes scanline {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

.scanline-container {
  position: relative;
  overflow: hidden;
}

.scanline-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  animation: scanline 3s linear infinite;
}

/* ========================================
   ノイズエフェクト
   ======================================== */

@keyframes noise {
  0%, 100% {
    background-position: 0 0;
  }
  10% {
    background-position: -5% -10%;
  }
  20% {
    background-position: -15% 5%;
  }
  30% {
    background-position: 7% -25%;
  }
  40% {
    background-position: 20% 25%;
  }
  50% {
    background-position: -25% 10%;
  }
  60% {
    background-position: 15% 5%;
  }
  70% {
    background-position: 0 15%;
  }
  80% {
    background-position: 25% 35%;
  }
  90% {
    background-position: -10% 10%;
  }
}

.noise-effect {
  position: relative;
}

.noise-effect::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0.06) 1px, rgba(0, 0, 0, 0.06) 1px, rgba(0, 0, 0, 0.06) 2px);
  opacity: 0.03;
  animation: noise 0.2s infinite;
  pointer-events: none;
}

/* ========================================
   ホバーエフェクト
   ======================================== */

.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(66, 135, 245, 0.5);
  transition: box-shadow 0.3s ease;
}

/* ========================================
   遅延アニメーション（順番に表示）
   ======================================== */

.delay-100 {
  animation-delay: 0.1s;
}

.delay-200 {
  animation-delay: 0.2s;
}

.delay-300 {
  animation-delay: 0.3s;
}

.delay-500 {
  animation-delay: 0.5s;
}

.delay-1000 {
  animation-delay: 1s;
}

/* ========================================
   アニメーション制御クラス
   ======================================== */

.no-animation {
  animation: none !important;
}

.pause-animation {
  animation-play-state: paused !important;
}

/* アニメーション完了後も最終状態を維持 */
.animation-fill-forwards {
  animation-fill-mode: forwards;
}

/* アクセシビリティ: アニメーション無効化の設定を尊重 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   Immersion Effects
   ======================================== */

@keyframes immersion-drift {
  0% { transform: translate3d(0, 0, 0); opacity: 0.35; }
  50% { transform: translate3d(0, -6px, 0); opacity: 0.45; }
  100% { transform: translate3d(0, 0, 0); opacity: 0.35; }
}

@keyframes immersion-scanline {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@keyframes whisper-fade {
  0% { opacity: 0; transform: translateY(6px); }
  15% { opacity: 0.9; }
  80% { opacity: 0.6; }
  100% { opacity: 0; transform: translateY(-6px); }
}

.immersion-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9990;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 0, 0, 0.08), transparent 45%),
    radial-gradient(circle at 80% 70%, rgba(0, 140, 255, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.6));
  mix-blend-mode: multiply;
  animation: immersion-drift 12s ease-in-out infinite;
}

.immersion-scanlines {
  position: fixed;
  top: -100%;
  left: 0;
  width: 100%;
  height: 200%;
  pointer-events: none;
  z-index: 9991;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.04) 0,
    rgba(255, 255, 255, 0.04) 1px,
    rgba(0, 0, 0, 0.06) 1px,
    rgba(0, 0, 0, 0.06) 2px
  );
  opacity: 0.07;
  animation: immersion-scanline 6s linear infinite;
}

.immersion-overlay.immersion-intense {
  opacity: 0.5;
}

.immersion-scanlines.immersion-intense {
  opacity: 0.12;
}

.observer-whisper {
  position: fixed;
  z-index: 9992;
  pointer-events: none;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(255, 80, 80, 0.85);
  text-shadow: 0 0 12px rgba(255, 0, 0, 0.35);
  animation: whisper-fade 8s ease-in-out forwards;
}

