/* Motion: Keyframes, Notice Card Choreography, Reduced-Motion Fallbacks */

#dlgNext {
  animation: bob 0.8s steps(2) infinite;
}

@keyframes bob {
  50% {
    transform: translateY(3px);
  }
}

#callin {
  animation: knock 0.5s steps(2) infinite;
}

@keyframes knock {
  50% {
    transform: translate(-50%, -50%) rotate(-3deg);
  }
}

/* ロゴ：影絵で待ち、サーチライトが横切ると光が当たる。最後に「怪盗」がスタンプで入り、「〜」がひるがえる */
.lg-face {
  -webkit-mask: linear-gradient(100deg, #000 0 42%, transparent 58%) 0 0 / 300% 100% no-repeat;
  mask: linear-gradient(100deg, #000 0 42%, transparent 58%) 0 0 / 300% 100% no-repeat;
}

#title.intro .lg-face {
  animation: lgLight 1.15s cubic-bezier(0.45, 0, 0.3, 1) 0.35s both;
}

@keyframes lgLight {
  from { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}

#title.intro .lg-sh,
#title.intro .lg-ol {
  animation: lgRise 0.5s ease-out both;
}

@keyframes lgRise {
  from { opacity: 0; }
}

#title.intro .lg-kai .l {
  animation: lgStamp 0.34s cubic-bezier(0.25, 1.5, 0.5, 1) both;
  animation-delay: calc(1.25s + var(--i) * 0.13s);
}

@keyframes lgStamp {
  from { transform: scale(2.1) rotate(9deg); opacity: 0; }
}

.lg-wave .l {
  animation: lgWave 4.6s ease-in-out 2s infinite;
}

@keyframes lgWave {
  0%, 76%, 100% { transform: none; }
  84% { transform: translateY(-5px) rotate(-7deg) scaleX(1.05); }
  92% { transform: translateY(2px) rotate(4deg); }
}

#title.intro .t-main,
#title.intro .t-sub,
#title.intro .title-links {
  animation: sheetIn 0.45s ease-out both;
  animation-delay: 1.45s;
}

#title.intro .t-sub { animation-delay: 1.58s; }
#title.intro .title-links { animation-delay: 1.7s; }

#gate.ready .g-go {
  animation: hintBlink 2s ease-in-out infinite;
}

#gate.ready .g-pupil {
  animation: gateLook 5s ease-in-out 1s infinite;
}

@keyframes gateLook {
  0%, 30%, 100% { transform: none; }
  38%, 52% { transform: translateX(-13px); }
  60%, 78% { transform: translateX(13px); }
}

.ov:not([hidden]) {
  animation: ovFadeIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ov:not([hidden]) > .sheet {
  animation: sheetIn 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

@keyframes sheetIn {
  from { opacity: 0.05; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

#result:not([hidden]) .rank {
  animation: rankStamp 320ms cubic-bezier(0.2, 1.5, 0.4, 1) 120ms both;
}

@keyframes rankStamp {
  0% { transform: rotate(-10deg) scale(1.8); opacity: 0; }
  100% { transform: rotate(-2deg) scale(1); opacity: 1; }
}

#card .beam.b1 {
  animation: sweepL 5.5s ease-in-out infinite alternate;
}

#card .beam.b2 {
  animation: sweepR 6.5s ease-in-out infinite alternate;
}

@keyframes sweepL {
  from { transform: rotate(-28deg); }
  to { transform: rotate(18deg); }
}

@keyframes sweepR {
  from { transform: rotate(26deg); }
  to { transform: rotate(-20deg); }
}

#card.play .notice.in {
  animation: noticeIn 0.78s cubic-bezier(0.2, 0.75, 0.3, 1) both;
}

@keyframes noticeIn {
  0% {
    transform: perspective(900px) translate(-55vw, -75vh) rotate(-210deg) rotateY(170deg) scale(0.45);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  68% {
    transform: perspective(900px) translate(0, 0) rotate(5deg) rotateY(0) scale(1.05, 0.95);
  }
  84% {
    transform: rotate(-4deg) scale(0.98, 1.02);
  }
  100% {
    transform: rotate(-2deg);
  }
}

#card.play .h span {
  animation: hPop 0.38s cubic-bezier(0.3, 1.7, 0.5, 1) both;
  animation-delay: calc(0.62s + var(--i) * 0.09s);
}

@keyframes hPop {
  from {
    transform: scale(2.6) rotate(-14deg);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

#card.play .sig,
#card.play .ps {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.35s, transform 0.35s;
}

#card.play.signed .sig {
  opacity: 1;
  transform: none;
}

#card.play.signed .ps {
  opacity: 1;
  transform: none;
  transition-delay: 0.35s;
}

#card.play .mark path,
#card.play .mark circle,
#card.play .swish path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

#card.play.signed .mark path,
#card.play.signed .mark circle,
#card.play.signed .swish path {
  animation: draw 0.5s ease-out forwards;
}

#card.play.signed .mark .p2 {
  animation-delay: 0.12s;
}

#card.play.signed .mark .p3 {
  animation-delay: 0.22s;
}

#card.play.signed .mark circle {
  animation-delay: 0.3s;
}

#card.play.signed .swish path {
  animation-delay: 0.36s;
  animation-duration: 0.4s;
}

@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

#card.play.ready .hint {
  opacity: 0.75;
  animation: hintBlink 1.4s ease-in-out 0.2s infinite;
}

@keyframes hintBlink {
  50% {
    opacity: 0.3;
  }
}

#card.stamped .stamp {
  animation: stampIn 0.26s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}

#card.stamped .stamp::after {
  animation: inkRing 0.45s ease-out 0.12s both;
}

@keyframes inkRing {
  0% {
    transform: scale(0.7);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

@keyframes stampIn {
  0% {
    transform: scale(3.4) rotate(-30deg);
    opacity: 0;
  }
  55% {
    transform: scale(0.9) rotate(-6deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(-8deg);
    opacity: 1;
  }
}

#card .notice.hit {
  animation: cardHit 0.28s ease-out;
}

@keyframes cardHit {
  0% { transform: rotate(-2deg); }
  25% { transform: rotate(-2.8deg) translate(2px, 4px) scale(0.985); }
  60% { transform: rotate(-1.4deg) translate(-2px, -1px); }
  100% { transform: rotate(-2deg); }
}

#card.play.ready.stamped .hint {
  animation: none;
  opacity: 0;
  transition: opacity 0.15s;
}

#card.out .notice {
  animation: noticeOut 0.62s cubic-bezier(0.55, 0, 0.8, 0.45) both;
}

@keyframes noticeOut {
  0% { transform: rotate(-2deg); }
  22% { transform: translate(-2vw, 2.5vh) rotate(-7deg) scale(1.03); }
  100% { transform: translate(48vw, -80vh) rotate(38deg) scale(0.1); opacity: 0.2; }
}

#card.out .spark {
  animation: spark 0.7s ease-out both;
  animation-delay: calc(0.12s + var(--k) * 0.05s);
}

@keyframes spark {
  0% { transform: translate(0, 0) scale(0); opacity: 0; }
  25% { opacity: 1; transform: translate(calc(var(--dx) * 0.3), calc(var(--dy) * 0.3)) scale(1.2); }
  100% { transform: translate(var(--dx), var(--dy)) scale(0.3) rotate(90deg); opacity: 0; }
}

#card.out .twinkle {
  animation: twinkle 0.5s ease-out 0.5s both;
}

@keyframes twinkle {
  0% { transform: scale(0) rotate(0); opacity: 0; }
  40% { transform: scale(1.4) rotate(45deg); opacity: 1; }
  100% { transform: scale(0) rotate(120deg); opacity: 0; }
}

#cine .bar {
  animation: barIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes barIn {
  from {
    transform: scaleY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #callin,
  #title.intro *,
  .lg-wave .l,
  #gate *,
  .ov:not([hidden]),
  .ov:not([hidden]) > .sheet,
  #result:not([hidden]) .rank,
  #cine .bar,
  #dlgNext {
    animation: none;
  }
  #fade,
  #nightCue,
  #vignette {
    transition: none;
  }
  #card *,
  #card .notice.in,
  #card .notice.hit {
    animation: none !important;
    transition: none !important;
  }
  #card .beam {
    display: none;
  }
  #card.stamped .stamp {
    opacity: 1;
  }
  #card.play .mark path,
  #card.play .mark circle,
  #card.play .swish path {
    stroke-dashoffset: 0;
  }
}
