/**
 * Creative Text Styles
 * Phase 4: Typography Art
 */

/* ================================
   テキストスプリット - ベーススタイル
   ================================ */

.text-split {
  display: inline-block;
}

.text-split .char {
  display: inline-block;
  opacity: 0;
  transform-origin: center center;
}

.text-split .char-space {
  width: 0.25em;
}

/* アニメーション前の初期状態 */
.text-split:not(.text-split-active) .char {
  opacity: 0;
}

/* アニメーション開始 */
.text-split.text-split-active .char {
  animation-fill-mode: forwards;
  animation-duration: 0.6s;
  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================================
   アニメーションバリエーション
   ================================ */

/* Default / Slide Up */
.text-split.text-split-active .char,
.text-split.text-split-slide-up.text-split-active .char {
  animation-name: char-slide-up;
}

@keyframes char-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px) rotate(-5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
}

/* Fade In */
.text-split.text-split-fade-in.text-split-active .char {
  animation-name: char-fade-in;
}

@keyframes char-fade-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Rotate */
.text-split.text-split-rotate.text-split-active .char {
  animation-name: char-rotate;
}

@keyframes char-rotate {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0);
  }
  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

/* Bounce */
.text-split.text-split-bounce.text-split-active .char {
  animation-name: char-bounce;
  animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes char-bounce {
  0% {
    opacity: 0;
    transform: translateY(-50px) scale(0.5);
  }
  50% {
    transform: translateY(10px) scale(1.1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Random */
.text-split.text-split-random.text-split-active .char:nth-child(odd) {
  animation-name: char-random-left;
}

.text-split.text-split-random.text-split-active .char:nth-child(even) {
  animation-name: char-random-right;
}

@keyframes char-random-left {
  from {
    opacity: 0;
    transform: translate(-30px, -20px) rotate(-45deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

@keyframes char-random-right {
  from {
    opacity: 0;
    transform: translate(30px, -20px) rotate(45deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
}

/* Wave */
.text-split.text-split-wave.text-split-active .char {
  animation-name: char-wave;
}

@keyframes char-wave {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  50% {
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 3D Rotate */
.text-split.text-split-rotate-3d {
  perspective: 1000px;
}

.text-split.text-split-rotate-3d.text-split-active .char {
  animation-name: char-rotate-3d;
}

@keyframes char-rotate-3d {
  from {
    opacity: 0;
    transform: rotateY(-90deg) rotateX(-20deg) translateZ(-50px);
  }
  to {
    opacity: 1;
    transform: rotateY(0deg) rotateX(0deg) translateZ(0);
  }
}

/* Glitch */
.text-split.text-split-glitch.text-split-active .char {
  animation-name: char-glitch;
  animation-duration: 0.4s;
}

@keyframes char-glitch {
  0% {
    opacity: 0;
    transform: translate(0, 0);
  }
  10% {
    opacity: 0.3;
    transform: translate(-5px, 5px);
  }
  20% {
    opacity: 0.5;
    transform: translate(5px, -5px);
  }
  30% {
    opacity: 0.7;
    transform: translate(-3px, -3px);
  }
  40% {
    opacity: 0.9;
    transform: translate(3px, 3px);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0);
  }
}

/* ================================
   アウトラインテキストエフェクト
   ================================ */

.outlined-text {
  position: relative;
  font-size: var(--text-5xl);
  font-weight: var(--font-extrabold);
  color: transparent;
  -webkit-text-stroke: 2px var(--primary-500);
  text-stroke: 2px var(--primary-500);
  line-height: 1.2;
  display: inline-block;
}

.outlined-text::before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary-500);
  -webkit-text-stroke: 0;
  text-stroke: 0;
  clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%);
  animation: fill-text 3s ease-in-out infinite;
  z-index: 1;
}

@keyframes fill-text {
  0%, 100% {
    clip-path: polygon(0 0, 100% 0, 100% 0%, 0 0%);
  }
  50% {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  }
}

/* ダークモード対応 */
[data-theme="dark"] .outlined-text {
  -webkit-text-stroke: 2px var(--primary-400);
  text-stroke: 2px var(--primary-400);
}

[data-theme="dark"] .outlined-text::before {
  color: var(--primary-400);
}

/* グラデーションアウトライン */
.outlined-text-gradient {
  -webkit-text-stroke: 0;
  text-stroke: 0;
  color: transparent;
  background: linear-gradient(
    135deg,
    var(--accent-pink),
    var(--accent-purple),
    var(--accent-cyan)
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
  position: relative;
}

.outlined-text-gradient::after {
  content: attr(data-text);
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: -1;
  -webkit-text-stroke: 2px rgba(0, 0, 0, 0.1);
  text-stroke: 2px rgba(0, 0, 0, 0.1);
  color: transparent;
}

/* ================================
   多重シャドウテキスト
   ================================ */

.layered-text {
  position: relative;
  font-size: var(--text-4xl);
  font-weight: var(--font-extrabold);
  color: var(--primary-500);
  text-shadow:
    3px 3px 0 var(--accent-pink),
    6px 6px 0 var(--accent-purple),
    9px 9px 0 var(--accent-cyan);
  transition: all 0.3s ease;
}

.layered-text:hover {
  transform: translate(-2px, -2px);
  text-shadow:
    5px 5px 0 var(--accent-pink),
    10px 10px 0 var(--accent-purple),
    15px 15px 0 var(--accent-cyan);
}

[data-theme="dark"] .layered-text {
  color: var(--primary-400);
}

/* ================================
   ネオンテキストエフェクト
   ================================ */

.neon-text {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--accent-cyan);
  text-shadow:
    0 0 10px var(--accent-cyan),
    0 0 20px var(--accent-cyan),
    0 0 30px var(--accent-cyan),
    0 0 40px var(--accent-cyan);
  animation: neon-flicker 3s ease-in-out infinite;
}

@keyframes neon-flicker {
  0%, 100% {
    text-shadow:
      0 0 10px var(--accent-cyan),
      0 0 20px var(--accent-cyan),
      0 0 30px var(--accent-cyan),
      0 0 40px var(--accent-cyan);
  }
  50% {
    text-shadow:
      0 0 5px var(--accent-cyan),
      0 0 10px var(--accent-cyan),
      0 0 15px var(--accent-cyan),
      0 0 20px var(--accent-cyan);
  }
}

/* メンバーカラーのネオンバリエーション */
.neon-text-pink {
  color: var(--accent-pink);
  text-shadow:
    0 0 10px var(--accent-pink),
    0 0 20px var(--accent-pink),
    0 0 30px var(--accent-pink);
}

.neon-text-purple {
  color: var(--accent-purple);
  text-shadow:
    0 0 10px var(--accent-purple),
    0 0 20px var(--accent-purple),
    0 0 30px var(--accent-purple);
}

.neon-text-yellow {
  color: var(--accent-yellow);
  text-shadow:
    0 0 10px var(--accent-yellow),
    0 0 20px var(--accent-yellow),
    0 0 30px var(--accent-yellow);
}

/* ================================
   創造的レイアウト
   ================================ */

/* 斜めテキスト */
.diagonal-text {
  transform: rotate(-3deg);
  display: inline-block;
  transition: transform 0.3s ease;
}

.diagonal-text:hover {
  transform: rotate(0deg);
}

/* 垂直テキスト */
.vertical-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* アーチ状テキスト（シンプル版） */
.arch-text {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
}

.arch-text .char {
  display: inline-block;
  transform-origin: center bottom;
}

.arch-text .char:nth-child(1) { transform: rotate(-20deg) translateY(-10px); }
.arch-text .char:nth-child(2) { transform: rotate(-15deg) translateY(-7px); }
.arch-text .char:nth-child(3) { transform: rotate(-10deg) translateY(-5px); }
.arch-text .char:nth-child(4) { transform: rotate(-5deg) translateY(-2px); }
.arch-text .char:nth-child(5) { transform: rotate(0deg) translateY(0); }
.arch-text .char:nth-child(6) { transform: rotate(5deg) translateY(-2px); }
.arch-text .char:nth-child(7) { transform: rotate(10deg) translateY(-5px); }
.arch-text .char:nth-child(8) { transform: rotate(15deg) translateY(-7px); }
.arch-text .char:nth-child(9) { transform: rotate(20deg) translateY(-10px); }

/* ================================
   テキストマスクエフェクト
   ================================ */

.text-mask {
  position: relative;
  font-size: var(--text-6xl);
  font-weight: var(--font-black);
  background: linear-gradient(
    135deg,
    var(--accent-pink) 0%,
    var(--accent-purple) 50%,
    var(--accent-cyan) 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 5s ease infinite;
}

.text-mask::before {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  background: var(--gray-200);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: blur(10px);
  opacity: 0.5;
}

[data-theme="dark"] .text-mask::before {
  background: var(--gray-700);
}

/* ================================
   レスポンシブ調整
   ================================ */

@media (max-width: 768px) {
  .outlined-text {
    font-size: var(--text-3xl);
    -webkit-text-stroke: 1.5px var(--primary-500);
    text-stroke: 1.5px var(--primary-500);
  }

  .layered-text {
    font-size: var(--text-2xl);
    text-shadow:
      2px 2px 0 var(--accent-pink),
      4px 4px 0 var(--accent-purple),
      6px 6px 0 var(--accent-cyan);
  }

  .neon-text {
    font-size: var(--text-xl);
  }

  .text-mask {
    font-size: var(--text-4xl);
  }
}

/* ================================
   アクセシビリティ: モーション削減
   ================================ */

@media (prefers-reduced-motion: reduce) {
  .text-split.text-split-active .char {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .outlined-text::before,
  .neon-text {
    animation: none;
  }

  .text-mask {
    animation: none;
  }
}
