/**
 * 鎌倉御家人御用帳 — Interaction & Delight
 * v4.9.26
 * 操作時だけ短く反応する演出をまとめる。
 */

/* -------------------------------------------------------
 * 本日の務め：開帳
 * ------------------------------------------------------- */
body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening {
  transform-origin: 50% 0;
}

body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening::before {
  animation: gokenin-motion-ledger-line 760ms cubic-bezier(.22,.8,.24,1) both;
}

body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening .gokenin-gacha__result-title {
  animation: gokenin-motion-title-settle 620ms cubic-bezier(.2,.75,.22,1) 70ms both;
}

body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening .gokenin-gacha__result-gokenin.is-gokenin-motion-active {
  animation: gokenin-motion-gokenin-notice 820ms ease-out 150ms both;
}

@keyframes gokenin-motion-ledger-line {
  0% { opacity: 0; transform: scaleX(.18); }
  55% { opacity: .85; }
  100% { opacity: 1; transform: scaleX(1); }
}

@keyframes gokenin-motion-title-settle {
  0% { opacity: 0; transform: translateY(7px); letter-spacing: .035em; }
  100% { opacity: 1; transform: translateY(0); letter-spacing: normal; }
}

@keyframes gokenin-motion-gokenin-notice {
  0% { opacity: .25; transform: translateY(7px) rotate(-1deg); }
  55% { opacity: .95; transform: translateY(-2px) rotate(.7deg); }
  100% { opacity: .9; transform: translateY(0) rotate(0); }
}

/* -------------------------------------------------------
 * 章：開いた瞬間だけ反応
 * ------------------------------------------------------- */
@media (max-width: 640px) {
  body.gokenin-gacha-article-page .gokenin-story-chapter__summary::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--g-article-red, #a34b36), rgba(163, 75, 54, 0));
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 420ms cubic-bezier(.2,.75,.22,1);
  }

  body.gokenin-gacha-article-page .gokenin-story-chapter[open] > .gokenin-story-chapter__summary::before {
    transform: scaleX(1);
  }

  body.gokenin-gacha-article-page .gokenin-story-chapter[open] .gokenin-story-chapter__number {
    color: var(--g-article-red, #a34b36);
    transform: translateX(2px);
    transition: color 220ms ease, transform 260ms ease;
  }

  body.gokenin-gacha-article-page .gokenin-story-chapter.is-gokenin-chapter-awake .gokenin-story-chapter__body > * {
    animation: gokenin-motion-chapter-rise 520ms ease both;
  }

  body.gokenin-gacha-article-page .gokenin-story-chapter.is-gokenin-chapter-awake .gokenin-story-chapter__body > :nth-child(2) { animation-delay: 45ms; }
  body.gokenin-gacha-article-page .gokenin-story-chapter.is-gokenin-chapter-awake .gokenin-story-chapter__body > :nth-child(3) { animation-delay: 80ms; }
}

@keyframes gokenin-motion-chapter-rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------
 * 新着・関連記事：触ったときだけ少し楽しい
 * ------------------------------------------------------- */
body.gokenin-gacha-home-page .gokenin-gacha__card,
body.gokenin-gacha-article-page .gokenin-related-story {
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

body.gokenin-gacha-home-page .gokenin-gacha__card-mark,
body.gokenin-gacha-home-page .gokenin-gacha__card > a span,
body.gokenin-gacha-article-page .gokenin-related-story__link {
  transition: transform 220ms cubic-bezier(.2,.8,.24,1), opacity 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
  body.gokenin-gacha-home-page .gokenin-gacha__card:hover .gokenin-gacha__card-mark,
  body.gokenin-gacha-home-page .gokenin-gacha__card.is-gokenin-playful .gokenin-gacha__card-mark {
    transform: translateY(-2px) rotate(-4deg);
  }

  body.gokenin-gacha-home-page .gokenin-gacha__card:hover > a span,
  body.gokenin-gacha-home-page .gokenin-gacha__card.is-gokenin-playful > a span {
    transform: translateX(4px);
  }

  body.gokenin-gacha-article-page .gokenin-related-story:hover .gokenin-related-story__link,
  body.gokenin-gacha-article-page .gokenin-related-story.is-gokenin-playful .gokenin-related-story__link {
    transform: translateY(-1px);
  }
}

body.gokenin-gacha-home-page .gokenin-gacha__card.is-gokenin-tapped,
body.gokenin-gacha-article-page .gokenin-related-story.is-gokenin-tapped {
  animation: gokenin-motion-card-tap 360ms ease-out both;
}

body.gokenin-gacha-home-page .gokenin-gacha__card.is-gokenin-tapped .gokenin-gacha__card-mark {
  animation: gokenin-motion-mark-nod 360ms ease-out both;
}

@keyframes gokenin-motion-card-tap {
  0% { transform: scale(1); }
  45% { transform: scale(.992); }
  100% { transform: scale(1); }
}

@keyframes gokenin-motion-mark-nod {
  0%, 100% { transform: rotate(0); }
  45% { transform: rotate(-6deg) translateY(-1px); }
}

/* -------------------------------------------------------
 * キャラクター：一体だけ、呼吸程度
 * ------------------------------------------------------- */
.gokenin-character-slot.is-gokenin-motion-active.gokenin-character-motion--float,
.gokenin-character-slot.is-gokenin-motion-active.gokenin-character-motion--breathe {
  animation-duration: 7.4s !important;
}

.gokenin-character-slot.is-gokenin-motion-active.gokenin-character-motion--peek,
.gokenin-character-slot.is-gokenin-motion-active.gokenin-character-motion--look,
.gokenin-character-slot.is-gokenin-motion-active.gokenin-character-motion--tilt {
  animation-duration: 6.8s !important;
}

/* -------------------------------------------------------
 * Mobile restraint
 * ------------------------------------------------------- */
@media (max-width: 640px) {
  body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening .gokenin-gacha__result-title {
    animation-duration: 480ms;
  }

}

@media (prefers-reduced-motion: reduce) {
  body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening,
  body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening::before,
  body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening *,
  body.gokenin-gacha-article-page .gokenin-story-chapter__summary::before,
  body.gokenin-gacha-article-page .gokenin-story-chapter[open] .gokenin-story-chapter__number,
  body.gokenin-gacha-article-page .gokenin-story-chapter.is-gokenin-chapter-awake .gokenin-story-chapter__body > *,
  body.gokenin-gacha-home-page .gokenin-gacha__card,
  body.gokenin-gacha-home-page .gokenin-gacha__card *,
  body.gokenin-gacha-article-page .gokenin-related-story,
  body.gokenin-gacha-article-page .gokenin-related-story *,
  body.gokenin-gacha-article-page .gokenin-article-cta__aside,
  .gokenin-motion-ready body.gokenin-gacha-article-page .gokenin-article-cta__aside.is-gokenin-finish-visible {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }

  body.gokenin-gacha-article-page .gokenin-article-cta__aside {
    opacity: 1 !important;
  }
}


/* -------------------------------------------------------
 * v4.9.26 可愛い仕掛け：朱印・足跡・白猫のひょっこり
 * ------------------------------------------------------- */
body.gokenin-gacha-home-page .gokenin-gacha__result {
  isolation: isolate;
}

body.gokenin-gacha-home-page .gokenin-gacha__result::after {
  content: "済";
  position: absolute;
  top: clamp(18px, 3vw, 30px);
  right: clamp(18px, 3vw, 30px);
  z-index: 3;
  display: grid;
  place-items: center;
  width: clamp(48px, 7vw, 66px);
  aspect-ratio: 1;
  border: 3px double rgba(163, 75, 54, .72);
  border-radius: 50%;
  color: rgba(163, 75, 54, .82);
  background: rgba(255, 250, 241, .68);
  font-family: var(--gokenin-serif, serif);
  font-size: clamp(1.05rem, 2.3vw, 1.4rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: .08em;
  opacity: 0;
  transform: rotate(-11deg) scale(1.35);
  pointer-events: none;
}

body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-opening::after,
body.gokenin-gacha-home-page .gokenin-gacha__result.is-gokenin-fresh-draw::after {
  animation: gokenin-motion-stamp 620ms cubic-bezier(.2,.85,.22,1) 180ms both;
}

@keyframes gokenin-motion-stamp {
  0% { opacity: 0; transform: rotate(-16deg) scale(1.5); }
  62% { opacity: .95; transform: rotate(-9deg) scale(.92); }
  78% { transform: rotate(-11deg) scale(1.04); }
  100% { opacity: .9; transform: rotate(-11deg) scale(1); }
}

.gokenin-footprints {
  position: fixed;
  z-index: 99998;
  width: 66px;
  height: 38px;
  pointer-events: none;
  opacity: 0;
}

.gokenin-footprints::before,
.gokenin-footprints::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 17px;
  border-radius: 52% 52% 46% 46%;
  background: rgba(163, 75, 54, .52);
  box-shadow:
    -5px -6px 0 -3px rgba(163, 75, 54, .52),
     0 -8px 0 -3px rgba(163, 75, 54, .52),
     5px -6px 0 -3px rgba(163, 75, 54, .52);
  transform: rotate(-18deg);
}

.gokenin-footprints::before { left: 8px; bottom: 4px; }
.gokenin-footprints::after { right: 8px; top: 3px; transform: rotate(18deg); }

.gokenin-footprints.is-gokenin-footprints-visible {
  animation: gokenin-motion-footprints 900ms ease-out both;
}

@keyframes gokenin-motion-footprints {
  0% { opacity: 0; transform: translate(-4px, 6px) scale(.86); }
  28% { opacity: .78; }
  72% { opacity: .62; }
  100% { opacity: 0; transform: translate(8px, -8px) scale(1); }
}

.gokenin-peek-cat {
  position: fixed;
  right: -8px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 9997;
  width: clamp(72px, 15vw, 104px);
  height: auto;
  pointer-events: none;
  filter: drop-shadow(0 10px 18px rgba(35, 29, 22, .16));
  opacity: 0;
  transform: translateX(78%) rotate(2deg);
}

.gokenin-peek-cat.is-gokenin-peeking {
  animation: gokenin-motion-cat-peek 3.4s cubic-bezier(.2,.75,.24,1) both;
}

@keyframes gokenin-motion-cat-peek {
  0% { opacity: 0; transform: translateX(82%) rotate(3deg); }
  18% { opacity: .95; transform: translateX(8%) rotate(-1deg); }
  72% { opacity: .95; transform: translateX(8%) rotate(-1deg); }
  100% { opacity: 0; transform: translateX(82%) rotate(2deg); }
}

@media (max-width: 640px) {
  body.gokenin-gacha-home-page .gokenin-gacha__result::after {
    top: 14px;
    right: 14px;
    width: 48px;
    font-size: 1rem;
  }

  .gokenin-peek-cat {
    width: 76px;
    right: -6px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  body.gokenin-gacha-home-page .gokenin-gacha__result::after {
    opacity: .82;
    transform: rotate(-11deg) scale(1);
    animation: none !important;
  }

  .gokenin-footprints,
  .gokenin-peek-cat {
    display: none !important;
    animation: none !important;
  }
}


/* v4.9.27: pigeon guide, knowing calico, and forgotten zori */
.gokenin-route-map__pigeon.is-gokenin-pigeon-step { animation: gokenin-pigeon-step .52s ease both; }
@keyframes gokenin-pigeon-step { 0%{transform:translateY(0) rotate(0)}45%{transform:translateY(-4px) rotate(-2deg)}100%{transform:translateY(0) rotate(1deg)} }
.gokenin-practical-section__calico.is-gokenin-calico-knowing { animation: gokenin-calico-knowing 1.15s ease-out both; }
@keyframes gokenin-calico-knowing { 0%{opacity:.12;transform:translateY(8px) rotate(1deg)}55%{opacity:.54;transform:translateY(0) rotate(-1deg)}100%{opacity:.34;transform:translateY(0) rotate(0)} }
.gokenin-article-cta.is-gokenin-zori-paired .gokenin-article-cta__zori--two { animation: gokenin-zori-arrive .72s cubic-bezier(.2,.85,.2,1) .12s both; }
@keyframes gokenin-zori-arrive { from{opacity:0;transform:translateX(-10px) rotate(8deg)} to{opacity:.38;transform:translateX(0) rotate(8deg)} }
@media (prefers-reduced-motion: reduce) {
  .gokenin-route-map__pigeon.is-gokenin-pigeon-step,
  .gokenin-practical-section__calico.is-gokenin-calico-knowing,
  .gokenin-article-cta.is-gokenin-zori-paired .gokenin-article-cta__zori--two { animation:none!important; }
  .gokenin-practical-section__calico.is-gokenin-calico-knowing { opacity:.28; }
  .gokenin-article-cta.is-gokenin-zori-paired .gokenin-article-cta__zori--two { opacity:.38; transform:rotate(8deg); }
}


/* v4.9.28: coordinated character roles and restrained delight frequency */
.gokenin-character-slot[data-gokenin-image-failed="true"],
.gokenin-peek-cat[data-gokenin-image-failed="true"] {
  display: none !important;
}

/* Dedicated characters only move through their own interaction state. */
.gokenin-route-map__pigeon.is-gokenin-motion-active,
.gokenin-practical-section__calico.is-gokenin-motion-active,
.gokenin-article-cta__zori.is-gokenin-motion-active,
.gokenin-gacha-404-companion__signpost.is-gokenin-motion-active {
  animation: none !important;
}

/* Prevent several decorative reactions from competing visually. */
html[data-gokenin-active-delight] .gokenin-character-slot:not(.is-gokenin-motion-active) {
  animation-play-state: paused !important;
}

body.gokenin-gacha-home-page .gokenin-peek-cat {
  max-width: min(22vw, 104px);
}

body.gokenin-gacha-article-page .gokenin-practical-section__calico,
body.gokenin-gacha-article-page .gokenin-route-map__pigeon,
body.gokenin-gacha-article-page .gokenin-article-cta__zori {
  pointer-events: none;
}

@media (max-width: 640px) {
  body.gokenin-gacha-home-page .gokenin-peek-cat {
    max-width: 74px;
  }

  body.gokenin-gacha-article-page .gokenin-practical-section__calico {
    max-width: 76px;
    opacity: .28;
  }

  body.gokenin-gacha-article-page .gokenin-route-map__pigeon {
    max-width: 52px;
  }

  body.gokenin-gacha-article-page .gokenin-article-cta__zori {
    max-width: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html[data-gokenin-active-delight] .gokenin-character-slot,
  .gokenin-route-map__pigeon,
  .gokenin-practical-section__calico,
  .gokenin-article-cta__zori,
  .gokenin-peek-cat,
  .gokenin-footprints {
    animation: none !important;
    transition: none !important;
  }
}


/* v4.9.29: brief cover-opening response */
.gokenin-article-cover {
  transform-origin: 0 50%;
  transition: transform .42s cubic-bezier(.2,.8,.2,1), box-shadow .42s ease;
}
.gokenin-article-cover.is-gokenin-cover-opened {
  transform: perspective(1200px) rotateY(-2.5deg) translateX(3px);
  box-shadow: 0 18px 42px rgba(45,35,24,.11);
}
.gokenin-article-cover.is-gokenin-cover-opened .gokenin-article-cover__seal {
  animation: gokenin-cover-seal .45s ease both;
}
@keyframes gokenin-cover-seal {
  0% { transform: rotate(-8deg) scale(1); }
  45% { transform: rotate(-5deg) scale(1.08); }
  100% { transform: rotate(-8deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .gokenin-article-cover,
  .gokenin-article-cover.is-gokenin-cover-opened,
  .gokenin-article-cover.is-gokenin-cover-opened .gokenin-article-cover__seal {
    transition: none !important;
    animation: none !important;
    transform: none !important;
  }
}
