/*
 * 大気 — 煙と狐火
 *
 * 考え方：細い筋を何本も並べるのではなく、一点から立った煙が
 * ふくらみながら画面いっぱいに広がっていく、という見え方を主役にする。
 * 画面に固定するので、スクロールしても煙の中を進んでいるように見える。
 *
 * 動かすのは transform と opacity だけ。SVG は静止テクスチャとして使う。
 */

/* 初回描画の間は消しておく。JS が読み込み後に .atmos-on を付けて立ち上げる。
   （画面いっぱいの装飾が LCP に数えられて指標を悪くするのを避ける） */
.smoke,
.kitsunebi {
  opacity: 0;
  transition: opacity 1.4s var(--ease-out);
}
.atmos-on .smoke,
.atmos-on .kitsunebi { opacity: 1; }

.smoke {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

/* 画面に固定する層。本文の上・ヘッダー(100)の下に置く */
.smoke--global {
  position: fixed;
  z-index: 80;
  contain: layout paint style;
}

/* ══ ひとふくらみの煙 ══════════════════════════
   下の一点から立ち上がり、上へ向かってふくらんで散る。
   transform-origin を足元に置くことで、拡大がそのまま
   「広がり」として読める。
   ══════════════════════════════════════════════ */
.smoke__puff {
  --puff-size: min(190vw, 2000px);
  position: absolute;
  bottom: -34%;
  left: 50%;
  width: var(--puff-size);
  height: var(--puff-size);
  margin-left: calc(var(--puff-size) / -2);
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 480 520'%3E%3Cdefs%3E%3Cfilter id='b' x='-25%25' y='-25%25' width='150%25' height='150%25'%3E%3CfeGaussianBlur stdDeviation='15'/%3E%3C/filter%3E%3CradialGradient id='g'%3E%3Cstop offset='0%25' stop-color='%23fff' stop-opacity='.95'/%3E%3Cstop offset='60%25' stop-color='%23fff' stop-opacity='.4'/%3E%3Cstop offset='100%25' stop-color='%23fff' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cg filter='url(%23b)' fill='url(%23g)'%3E%3Ccircle cx='240' cy='440' r='26'/%3E%3Ccircle cx='232' cy='415' r='34'/%3E%3Ccircle cx='262' cy='392' r='30'/%3E%3Ccircle cx='206' cy='372' r='40'/%3E%3Ccircle cx='250' cy='330' r='52'/%3E%3Ccircle cx='176' cy='316' r='44'/%3E%3Ccircle cx='296' cy='306' r='46'/%3E%3Ccircle cx='238' cy='262' r='62'/%3E%3Ccircle cx='160' cy='240' r='48'/%3E%3Ccircle cx='318' cy='234' r='50'/%3E%3Ccircle cx='244' cy='196' r='66'/%3E%3Ccircle cx='166' cy='168' r='46'/%3E%3Ccircle cx='322' cy='162' r='44'/%3E%3Ccircle cx='248' cy='130' r='58'/%3E%3Ccircle cx='190' cy='108' r='38'/%3E%3Ccircle cx='300' cy='104' r='36'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0;
  transform-origin: 50% 92%;
  will-change: transform, opacity;
  animation: billow 30s var(--ease-out) infinite;
}

@keyframes billow {
  0%   { opacity: 0;    transform: translate3d(0, 22%, 0)    scale(0.16) rotate(0deg); }
  12%  { opacity: 0.34; }
  46%  { opacity: 0.24; transform: translate3d(-3%, -6%, 0)  scale(0.85) rotate(6deg); }
  100% { opacity: 0;    transform: translate3d(5%, -34%, 0)  scale(2.3)  rotate(16deg); }
}

/* 立ち上がる位置と間合いをずらして、途切れなく続かせる */
.smoke__puff:nth-of-type(1) { left: 28%; animation-delay:  0s;   animation-duration: 30s; }
.smoke__puff:nth-of-type(2) { left: 62%; animation-delay: -11s;  animation-duration: 36s; }
.smoke__puff:nth-of-type(3) { left: 45%; animation-delay: -22s;  animation-duration: 33s; --puff-size: min(150vw, 1600px); }

/* ══ 立ち上がりの筋 ════════════════════════════
   ふくらみの手前にひと筋だけ残し、「どこから出ているか」を示す
   ══════════════════════════════════════════════ */
.smoke__wisp {
  position: absolute;
  bottom: -12%;
  width: clamp(100px, 12vw, 210px);
  height: clamp(360px, 78svh, 820px);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 380'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='1' x2='0' y2='0'%3E%3Cstop offset='0%25' stop-color='%23fff' stop-opacity='0'/%3E%3Cstop offset='14%25' stop-color='%23fff' stop-opacity='.85'/%3E%3Cstop offset='56%25' stop-color='%23fff' stop-opacity='.4'/%3E%3Cstop offset='100%25' stop-color='%23fff' stop-opacity='0'/%3E%3C/linearGradient%3E%3Cfilter id='b' x='-30%25' y='-10%25' width='160%25' height='120%25'%3E%3CfeGaussianBlur stdDeviation='4'/%3E%3C/filter%3E%3C/defs%3E%3Cg fill='none' stroke='url(%23g)' filter='url(%23b)' stroke-linecap='round'%3E%3Cpath d='M60 356 C 36 312 84 288 60 244 C 36 200 84 176 60 132 C 40 96 76 68 62 28' stroke-width='9'/%3E%3C/g%3E%3C/svg%3E");
  opacity: 0;
  transform-origin: 50% 100%;
  will-change: transform, opacity;
  animation: wisp 20s var(--ease-in-out) infinite;
}

@keyframes wisp {
  0%   { opacity: 0;    transform: translate3d(0, 16%, 0)    scale(0.45) rotate(-5deg); }
  16%  { opacity: 0.30; }
  52%  { opacity: 0.20; transform: translate3d(-8%, -44%, 0) scale(1)    rotate(7deg); }
  100% { opacity: 0;    transform: translate3d(6%, -120%, 0) scale(1.6)  rotate(-8deg); }
}

.smoke--global .smoke__wisp:nth-of-type(4) { left: 24%; animation-delay:  -4s; }
.smoke--global .smoke__wisp:nth-of-type(5) { left: 66%; animation-delay: -13s; scale: -1 1; }

/* ══ たなびく層 ════════════════════════════════
   ふくらんだ煙が横へ流れて消えていく残り
   ══════════════════════════════════════════════ */
.smoke__drift {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 42vmax;
  filter: blur(40px);
  opacity: 0;
  will-change: transform, opacity;
  animation: drift 38s var(--ease-in-out) infinite;
}
.smoke--global .smoke__drift:nth-of-type(6) { top: 12%; animation-delay:   0s; background: radial-gradient(ellipse 50% 60% at 34% 50%, rgba(255,255,255,0.10), transparent 70%); }
.smoke--global .smoke__drift:nth-of-type(7) { top: 56%; animation-delay: -19s; background: radial-gradient(ellipse 55% 60% at 62% 50%, rgba(255,255,255,0.08), transparent 70%); }

@keyframes drift {
  0%   { opacity: 0;   transform: translate3d(-12%, 0, 0)  scale(0.9); }
  25%  { opacity: 0.9; }
  70%  { opacity: 0.6; }
  100% { opacity: 0;   transform: translate3d(14%, -8%, 0) scale(1.3); }
}

/* ══ ヒーローの煙 ══════════════════════════════
   最初の一画面だけは濃く、大きく
   ══════════════════════════════════════════════ */
.hero .smoke__puff {
  animation-name: billow-hero;
  animation-duration: 24s;
}
@keyframes billow-hero {
  0%   { opacity: 0;    transform: translate3d(0, 22%, 0)   scale(0.16) rotate(0deg); }
  12%  { opacity: 0.46; }
  46%  { opacity: 0.34; transform: translate3d(-3%, -6%, 0) scale(0.85) rotate(6deg); }
  100% { opacity: 0;    transform: translate3d(5%, -34%, 0) scale(2.3)  rotate(16deg); }
}
.hero .smoke__puff:nth-of-type(1) { left: 34%; animation-delay:  0s;  }
.hero .smoke__puff:nth-of-type(2) { left: 66%; animation-delay: -12s; }
.hero .smoke__wisp:nth-of-type(3) { left: 46%; animation-delay:  -3s; animation-duration: 22s; }

/* ══ 狐火 ══════════════════════════════════════ */
.kitsunebi {
  position: fixed;
  inset: 0;
  z-index: 79;
  overflow: hidden;
  pointer-events: none;
  contain: layout paint style;
}
.kitsunebi span {
  position: absolute;
  bottom: -6vh;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
  background: var(--hi-core, #FFB84D);
  box-shadow: 0 0 14px 4px var(--hi-glow, rgba(255, 184, 77, 0.75));
  animation: hi-rise 19s linear infinite;
}
@keyframes hi-rise {
  0%   { opacity: 0;    transform: translate3d(0, 0, 0)          scale(0.5); }
  10%  { opacity: 0.9;  }
  45%  {                transform: translate3d(22px, -46vh, 0)   scale(1); }
  75%  { opacity: 0.55; }
  100% { opacity: 0;    transform: translate3d(-18px, -108vh, 0) scale(0.6); }
}
.kitsunebi span:nth-child(1)  { left:  6%; animation-delay:  -1s; animation-duration: 21s; }
.kitsunebi span:nth-child(2)  { left: 15%; animation-delay:  -4s; animation-duration: 17s; }
.kitsunebi span:nth-child(3)  { left: 27%; animation-delay:  -8s; animation-duration: 24s; }
.kitsunebi span:nth-child(4)  { left: 36%; animation-delay: -11s; animation-duration: 19s; }
.kitsunebi span:nth-child(5)  { left: 47%; animation-delay:  -2s; animation-duration: 23s; }
.kitsunebi span:nth-child(6)  { left: 58%; animation-delay: -14s; animation-duration: 18s; }
.kitsunebi span:nth-child(7)  { left: 68%; animation-delay:  -6s; animation-duration: 26s; }
.kitsunebi span:nth-child(8)  { left: 77%; animation-delay: -17s; animation-duration: 20s; }
.kitsunebi span:nth-child(9)  { left: 86%; animation-delay:  -9s; animation-duration: 22s; }
.kitsunebi span:nth-child(10) { left: 94%; animation-delay: -13s; animation-duration: 25s; }

/* ══ 端末負荷と好みへの配慮 ════════════════════ */
@media (max-width: 767px) {
  .smoke--global .smoke__puff:nth-of-type(3) { display: none; }
  .smoke--global .smoke__wisp:nth-of-type(5) { display: none; }
  .smoke--global .smoke__drift:nth-of-type(7) { display: none; }
  .kitsunebi span:nth-child(n+7) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .smoke--global,
  .kitsunebi { display: none; }
}
