/* ==========================================================================
   NewMemo Animations - Handcrafted Stroke & Wow-Factor Micro-Interactions
   ========================================================================== */

/* =========================================
   1. Scroll Reveal (和紙にインクが染み渡る優美な登場モーション)
   ========================================= */
.reveal-on-scroll {
  opacity: 0;
  filter: blur(8px);
  transform: translateY(22px) scale(0.985);
  transition: opacity 1.1s cubic-bezier(0.16, 1, 0.3, 1),
              filter 1.1s cubic-bezier(0.16, 1, 0.3, 1),
              transform 1.1s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, filter, transform;
}

.reveal-on-scroll.is-revealed {
  opacity: 1;
  filter: blur(0px);
  transform: translateY(0) scale(1);
}

.reveal-delay-1 { transition-delay: 0.15s; }
.reveal-delay-2 { transition-delay: 0.30s; }
.reveal-delay-3 { transition-delay: 0.45s; }

/* =========================================
   1.5. Ink Flow Typography (見出しテキスト限定の軽量インクボカシ ＆ インク流動)
   ========================================= */
.ink-flow-text {
  background-image: linear-gradient(
    90deg,
    #2B2721 0%,
    #3B4E32 20%,
    #A66426 40%,
    #2E425E 60%,
    #2B2721 80%,
    rgba(60, 52, 44, 0.22) 100%
  );
  background-size: 280% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
  filter: blur(3.5px);
  transition: background-position 1.4s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: background-position, filter;
}

.is-revealed .ink-flow-text,
.ink-flow-text.is-ink-flowed {
  background-position: 0% 0;
  filter: blur(0px);
  -webkit-text-fill-color: #2B2721;
  transition: background-position 1.4s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.9s cubic-bezier(0.16, 1, 0.3, 1),
              -webkit-text-fill-color 0.3s ease 1.2s;
}

/* 『AIで日記に新たな価値を。』専用：アニメーション後も黒に戻らず美しいカラフルなグラデーションを維持 */
.ink-flow-text.ink-flow-vibrant {
  background-image: linear-gradient(
    100deg,
    #32462C 0%,
    #A25F20 25%,
    #243B56 50%,
    #883428 75%,
    #32462C 100%
  );
  background-size: 260% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent !important;
  transition: background-position 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.is-revealed .ink-flow-text.ink-flow-vibrant,
.ink-flow-text.ink-flow-vibrant.is-ink-flowed {
  background-position: 0% 0;
  -webkit-text-fill-color: transparent !important;
}

/* 見出しの下にさらりと流れる水彩インクの筆跡ライン (文字の幅だけにぴったり追従) */
.ink-flow-underline {
  position: relative;
  display: inline-block;
  width: fit-content;
  max-width: 100%;
}

.ink-flow-underline::after {
  content: "";
  position: absolute;
  left: -2%;
  bottom: -2px;
  width: 104%;
  height: 8px;
  background: linear-gradient(
    90deg,
    rgba(120, 155, 105, 0) 0%,
    rgba(120, 155, 105, 0.45) 15%,
    rgba(215, 150, 75, 0.50) 50%,
    rgba(70, 110, 150, 0.42) 75%,
    rgba(120, 155, 105, 0) 100%
  );
  border-radius: 4px;
  filter: blur(1.5px);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1) 0.35s;
  pointer-events: none;
  z-index: -1;
}

.is-revealed .ink-flow-underline::after,
.ink-flow-underline.is-ink-flowed::after {
  transform: scaleX(1);
}

/* =========================================
   2. Real-time Highlighter Draw
   ========================================= */
@keyframes markerDraw {
  0% {
    background-size: 0% 100%;
  }
  100% {
    background-size: 100% 100%;
  }
}

.animate-marker {
  background-image: linear-gradient(var(--marker-yellow), var(--marker-yellow));
  background-repeat: no-repeat;
  background-position: left 85%;
  background-size: 0% 40%;
  transition: background-size 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.animate-marker.is-marked {
  background-size: 100% 40%;
}

/* =========================================
   3. Time-travel Page Flip Effect
   ========================================= */
@keyframes pageFlipQuick {
  0% { transform: rotateY(0deg); opacity: 1; }
  50% { transform: rotateY(-70deg) scale(0.95); opacity: 0.4; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

.is-flipping {
  animation: pageFlipQuick 0.45s ease-in-out;
  transform-style: preserve-3d;
}

/* =========================================
   4. Draggable / Clickable neu Mascot
   ========================================= */
@keyframes neuBounceJoy {
  0%, 100% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-18px) scale(1.08, 0.92) rotate(-4deg); }
  60% { transform: translateY(-4px) scale(0.96, 1.04) rotate(3deg); }
}

.neu-clickable {
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.neu-clickable:hover {
  transform: scale(1.08) translateY(-4px);
}

.neu-clickable.is-bouncing {
  animation: neuBounceJoy 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes neuBreath {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.04, 0.96) translateY(-4px); }
}

@keyframes neuBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.neu-avatar-svg {
  animation: neuBreath 4s ease-in-out infinite;
  transform-origin: bottom center;
}

.neu-eye {
  animation: neuBlink 4.5s infinite;
  transform-origin: center;
}

/* =========================================
   5. Organic Blob Motion
   ========================================= */
@keyframes blobWobble {
  0%, 100% {
    border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    transform: rotate(0deg);
  }
  33% {
    border-radius: 70% 30% 46% 54% / 30% 29% 71% 70%;
    transform: rotate(3deg);
  }
  66% {
    border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%;
    transform: rotate(-3deg);
  }
}

.animate-blob {
  animation: blobWobble 14s ease-in-out infinite;
}

.animate-float {
  animation: gentleFloat 5s ease-in-out infinite;
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(1deg); }
}

/* =========================================
   6. Hero Phone Stage Infinite Loop Marquee (ファーストビューの自動横スクロール)
   ========================================= */
@keyframes heroPhoneMarqueeAnim {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    /* 7台分（カード幅210px + gap26px = 236px × 7 = 1652px）を正確に移動して完全シームレスループ */
    transform: translate3d(calc(-7 * (var(--hero-phone-w, 210px) + var(--hero-phone-gap, 26px))), 0, 0);
  }
}

/* =========================================
   7. Gallery Infinite Loop Marquee (画面集の自動横スクロール)
   ========================================= */
@keyframes galleryLoopScroll {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    /* 7枚分（250px + 28px = 278px × 7 = 1946px）を正確に移動 */
    transform: translate3d(calc(-7 * (var(--gallery-card-w, 250px) + var(--gallery-gap, 28px))), 0, 0);
  }
}
