/* 鳥居のむこう（仮） — 演出の層（TORII.fx） */
/* #layer-fx の中の重ね順：canvas → 青み → ふちの暗さ → 一点の明かり → 光 → まぶた（fx.js がこの順に並べる） */

#layer-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
#layer-fx > * {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 粒（風・息・雪・ちり・青い炎）。下の絵に光として重なる */
#fx-canvas {
  width: 100%;
  height: 100%;
  display: block;
  mix-blend-mode: screen;
}

/* 冷え（chill）：彩度は fx.js が絵の filter で落とす。ここは青み */
#layer-fx .fx-tint {
  background: rgb(18, 40, 92);
  opacity: 0;
}

/* ふちの暗さ */
#layer-fx .fx-vignette {
  background:
    radial-gradient(ellipse 78% 62% at 50% 44%, rgba(0, 0, 0, 0) 52%, rgba(2, 2, 8, 0.55) 80%, rgba(0, 0, 0, 0.92) 100%);
  opacity: 0;
  transition: opacity 0.9s ease;
}

/* 発見の瞬間（focus）：背景は fx.js が書く */
#layer-fx .fx-focus {
  opacity: 0;
}

/* 一瞬の光 */
#layer-fx .fx-flash {
  background: #fff;
  opacity: 0;
}

/* まぶた（上下から閉じる・ふちはやわらかく） */
#layer-fx .fx-eyelid-top,
#layer-fx .fx-eyelid-bottom {
  height: 52%;
  transform: scaleY(0);
  will-change: transform;
}
#layer-fx .fx-eyelid-top {
  inset: 0 0 auto 0;
  transform-origin: 50% 0;
  background: linear-gradient(to bottom, #000 0%, #000 86%, rgba(0, 0, 0, 0) 100%);
}
#layer-fx .fx-eyelid-bottom {
  inset: auto 0 0 0;
  transform-origin: 50% 100%;
  background: linear-gradient(to top, #000 0%, #000 86%, rgba(0, 0, 0, 0) 100%);
}

/* 動きを減らす設定の人には、ふちの暗さもすっと切りかえる */
@media (prefers-reduced-motion: reduce) {
  #layer-fx .fx-vignette { transition: opacity 0.3s linear; }
}

/* ---------------------------------------------------------------- 第2段：しるし（fx.js の stamp・inkspread）
   #layer-fx の中にも、ほかの要素（o.parent）の中にも置ける。位置・大きさは fx.js が書く。 */
.fx-stamp,
.fx-ink {
  position: absolute;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 5;
}
#layer-fx > .fx-stamp,
#layer-fx > .fx-ink { inset: auto; }

/* 朱印：朱の枠＋字。押した瞬間に大きく→少しつぶれる→落ち着く。インクのむらは重ねたグラデーションで */
.fx-stamp {
  --fx-stamp: #c8372d;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fx-stamp);
  border: 0.075em solid var(--fx-stamp);
  border-radius: 12%;
  background:
    radial-gradient(circle at 28% 72%, rgba(255, 255, 255, 0.10) 0 9%, transparent 22%),
    radial-gradient(circle at 74% 30%, rgba(255, 255, 255, 0.08) 0 7%, transparent 18%),
    radial-gradient(circle at 50% 50%, rgba(200, 55, 45, 0.16), rgba(200, 55, 45, 0.06) 70%);
  box-shadow: inset 0 0 0 0.035em rgba(255, 240, 230, 0.12), 0 0 0.12em rgba(200, 55, 45, 0.35);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  font-weight: 700;
  line-height: 1;
  rotate: var(--fx-rot, -6deg);
  opacity: 0;
  transform: scale(1.7);
  will-change: transform, opacity;
}
.fx-stamp-in {
  font-size: 0.56em;
  letter-spacing: 0;
  text-shadow: 0 0 0.02em var(--fx-stamp);
}
.fx-stamp-in.is-v {
  writing-mode: vertical-rl;
  font-size: 0.36em;
  letter-spacing: 0.04em;
}
/* 押したときに外へ広がる、うすい朱の輪 */
.fx-stamp::after {
  content: "";
  position: absolute;
  inset: -0.08em;
  border-radius: 16%;
  border: 0.03em solid var(--fx-stamp);
  opacity: 0;
}
.fx-stamp.is-in { animation: fx-stamp-press 0.42s cubic-bezier(0.3, 0.7, 0.4, 1) forwards; }
.fx-stamp.is-in::after { animation: fx-stamp-ring 0.6s ease-out 0.12s forwards; }
.fx-stamp.is-calm.is-in { animation: fx-stamp-calm 0.24s ease-out forwards; }
.fx-stamp.is-calm.is-in::after { animation: none; }
.fx-stamp.is-now.is-in { animation: none; opacity: 0.94; transform: none; }
.fx-stamp.is-out, .fx-stamp.is-calm.is-out, .fx-stamp.is-now.is-out { animation: fx-mark-out 0.65s ease forwards; transform: none; }
.fx-stamp.is-out::after { animation: none; opacity: 0; }
@keyframes fx-stamp-press {
  0%   { opacity: 0;    transform: scale(1.7); }
  45%  { opacity: 0.96; transform: scale(0.93); }
  70%  { opacity: 0.94; transform: scale(1.03); }
  100% { opacity: 0.94; transform: scale(1); }
}
@keyframes fx-stamp-ring {
  0%   { opacity: 0.5; transform: scale(1); }
  100% { opacity: 0;   transform: scale(1.35); }
}
@keyframes fx-stamp-calm {
  0%   { opacity: 0;    transform: scale(1.08); }
  100% { opacity: 0.94; transform: scale(1); }
}

/* 墨のにじみ：小さな点から、ふちを不ぞろいにしながら広がる（絵は fx.js が作る） */
.fx-ink {
  background: center / 100% 100% no-repeat;
  opacity: 0;
  transform: scale(0.12);
  rotate: var(--fx-rot, 0deg);
  filter: blur(2px);
  will-change: transform, opacity, filter;
}
.fx-ink.is-in { animation: fx-ink-spread var(--fx-ink-ms, 900ms) cubic-bezier(0.15, 0.7, 0.3, 1) forwards; }
.fx-ink.is-calm.is-in { animation-name: fx-ink-calm; }
.fx-ink.is-now.is-in { animation: none; opacity: 0.88; transform: none; filter: blur(0.4px); }
.fx-ink.is-out, .fx-ink.is-calm.is-out, .fx-ink.is-now.is-out { animation: fx-mark-out 0.65s ease forwards; transform: none; filter: blur(0.8px); }
@keyframes fx-mark-out {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}
@keyframes fx-ink-spread {
  0%   { opacity: 0;    transform: scale(0.12); filter: blur(2px); }
  25%  { opacity: 0.85; }
  100% { opacity: 0.88; transform: scale(1);    filter: blur(0.4px); }
}
@keyframes fx-ink-calm {
  0%   { opacity: 0;    transform: scale(0.7); filter: blur(1px); }
  100% { opacity: 0.88; transform: scale(1);   filter: blur(0.4px); }
}

@media (prefers-reduced-motion: reduce) {
  .fx-stamp.is-in:not(.is-out):not(.is-now) { animation: fx-stamp-calm 0.2s ease-out forwards; }
  .fx-stamp.is-in::after { animation: none; }
  .fx-ink.is-in:not(.is-out):not(.is-now) { animation-name: fx-ink-calm; }
}
