/* メインイメージ線画アニメーション */

/* クリティカルCSS - アニメーション即座開始用 */
html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
}

.mainimage-svg-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  min-height: 800px;
  overflow: hidden;
  background-color: transparent;
  display: block !important;
  visibility: visible !important;
  pointer-events: none;
}

.mainimage-svg-container svg {
  width: 100%;
  max-width: 100%;
  height: 100%;
  display: block !important;
  position: absolute;
  top: 0;
  left: 0;
  visibility: visible !important;
  opacity: 1 !important;
  z-index: 1;
}

.mainimage {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  display: block !important;
  visibility: visible !important;
  pointer-events: none;
  overflow: hidden;
}

.st2 {
  fill: none;
  stroke: #001400;
  stroke-miterlimit: 10;
  stroke-width: 8px;
}

.st3 {
  fill: #d2d2d2;
}

.st1 {
  fill: #fff;
  stroke: #001400;
  stroke-miterlimit: 10;
  fill-rule: evenodd;
  stroke-width: 3px;
}

.st0 {
  fill: #001400;
  fill-rule: evenodd;
}

#first-line {
  opacity: 1;
  animation: fadeOut 2s ease-in-out 19.5s forwards !important;
  animation-play-state: running !important;
}

#first-line .st2 {
  stroke-dasharray: 4000;
  stroke-dashoffset: -4000;
  animation: drawFirstLine 18s linear 0s forwards !important;
  animation-play-state: running !important;
  will-change: stroke-dashoffset;
}

#tree {
  opacity: 1;
  animation: fadeOut 2s ease-in-out 19.5s forwards;
}

#tree .st2 {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: drawTree 10s ease-in-out 5s forwards;
}

#second-line {
  opacity: 1;
  animation: fadeOut 2s ease-in-out 19.5s forwards;
}

#second-line .st2 {
  stroke-dasharray: 350;
  stroke-dashoffset: 350;
  animation: drawSecondLine 2.5s ease-in-out 15.8s forwards;
}

.final-state {
  opacity: 0;
  animation: fadeIn 2s ease-in-out 23.5s forwards;
}

#nock {
  opacity: 0;
  animation: knock3Times 3s ease-in-out 25.5s forwards;
}

.mainimage-character {
  position: absolute;
  bottom: 20%;
  left: 30%;
  transform: translateX(-30%);
  width: 200px;
  height: auto;
  opacity: 0;
  animation: fadeIn 2s ease-in-out 23.5s forwards;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.3s ease;
  pointer-events: none;
}

.mainimage-character:hover {
  transform: translateX(-30%) scale(1.05);
}

.mainimage-moon {
  position: absolute;
  top: 5%;
  left: 5%;
  width: 120px;
  height: auto;
  opacity: 0;
  animation: fadeIn 2s ease-in-out 23.5s forwards;
  z-index: 10;
  pointer-events: none;
}

#door {
  transform: translateY(1px);
}

@keyframes drawFirstLine {
  0% {
    stroke-dashoffset: -4000;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes drawTree {
  0% {
    stroke-dashoffset: 2000;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes drawSecondLine {
  0% {
    stroke-dashoffset: 350;
  }

  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes knock3Times {

  0%,
  10% {
    opacity: 0;
  }

  15%,
  25% {
    opacity: 1;
  }

  30%,
  40% {
    opacity: 0;
  }

  45%,
  55% {
    opacity: 1;
  }

  60%,
  70% {
    opacity: 0;
  }

  75%,
  100% {
    opacity: 1;
  }
}

/* 別ページから戻ったとき：アニメーション終了状態で表示 */
body.top-anime-done #first-line,
body.top-anime-done #tree,
body.top-anime-done #second-line {
  opacity: 0 !important;
  animation: none !important;
}

body.top-anime-done #first-line .st2,
body.top-anime-done #tree .st2,
body.top-anime-done #second-line .st2 {
  animation: none !important;
  stroke-dashoffset: 0;
}

body.top-anime-done .final-state,
body.top-anime-done #nock,
body.top-anime-done .mainimage-character,
body.top-anime-done .mainimage-moon {
  opacity: 1 !important;
  animation: none !important;
}

body.top-anime-done .mainimage-character {
  pointer-events: auto;
}

/* 経過秒数表示（アニメーション確認用） */
.animation-timer {
  position: fixed;
  top: 16px;
  right: 16px;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-family: monospace;
  font-size: 18px;
  font-weight: bold;
  border-radius: 6px;
  z-index: 9999;
  pointer-events: none;
}

@media (max-width: 768px) {
  .mainimage {
    max-width: 100vw;
    overflow-x: hidden;
  }

  .mainimage-svg-container {
    width: 100%;
    max-width: 100vw;
    height: 60vh;
    min-height: 500px;
    overflow-x: hidden;
  }

  .mainimage-svg-container svg {
    width: 100%;
    max-width: 100%;
    height: auto;
    position: relative;
  }

  .mainimage-character {
    width: 180px;
  }

  .mainimage-moon {
    width: 80px;
    top: 3%;
    left: 3%;
  }

  .st2 {
    stroke-width: 10px;
  }

  .st1 {
    stroke-width: 4px;
  }

  .animation-timer {
    top: 8px;
    right: 8px;
    font-size: 14px;
    padding: 6px 10px;
  }
}

@media only screen and (max-width: 599px) {
  .mainimage-svg-container {
    width: 100%;
    max-width: 100vw;
    height: 40vh;
    min-height: 300px;
    overflow-x: hidden;
  }

  .mainimage-character {
    width: 70px;
    bottom: 27%;
    left: 25%;
    transform: translateX(-25%);
  }

  .mainimage-moon {
    width: 50px;
  }
}