:root {
  --ink: rgba(24, 20, 16, .82);
  --paper: rgba(255, 253, 248, .84);
  --paper-line: rgba(255, 255, 255, .48);
  --shadow: 0 24px 70px rgba(10, 8, 6, .16);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-hard: cubic-bezier(.76, 0, .24, 1);

  /* scroll timeline版：JSが実測してpxで上書きします。
     スマホではアドレスバー出入りでdvhが変わるため、JS固定値を優先します。 */
  --revival-viewport-height: 100vh;
  --revival-header-offset: 0px;
  --revival-stage-height: calc(var(--revival-viewport-height, 100vh) - var(--revival-header-offset, 0px));
  --revival-slot-height: var(--revival-viewport-height, 100vh);
  --revival-reader-height: min(78vh, 760px);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

.fallback-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px 24px;
  background: #fff;
}

.fallback-content section + section {
  margin-top: 64px;
}

.fallback-content p {
  font-size: 16px;
  line-height: 2;
  letter-spacing: .04em;
  margin: 0 0 1.8em;
}

html.is-enhanced #content-source.scrolly-source {
  display: none;
}

/*
  WP組み込み用：slot方式。
  #content-source は本文データとして非表示にし、その直後の #revival-story-slot が
  通常フロー上の表示予約枠になります。footer はこの slot の下に配置されるため、
  fixed 表示中の stage の裏へ食い込まない構造にしています。
*/
html.is-revival-ready,
html.is-revival-ready body {
  min-height: 100%;
}

.revival-story-slot {
  position: relative;
  height: var(--revival-slot-height, 100vh);
  min-height: 520px;
  overflow: hidden;
  background: #15120f;
  isolation: isolate;
}

html.is-enhanced .revival-story-slot {
  display: block;
}

.stage[hidden] {
  display: none;
}

.stage {
  position: fixed;
  top: var(--revival-header-offset, 0px);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--revival-stage-z, 7000);
  width: 100vw;
  height: var(--revival-stage-height, calc(100vh - var(--revival-header-offset, 0px)));
  min-height: 0;
  overflow: hidden;
  background: #15120f;
  contain: layout paint style;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .28s var(--ease), visibility .28s var(--ease);
}

/*
  通常時は fixed でヘッダー下に固定表示。
  最終シーン末尾からフッターへ抜ける時だけ .is-released を付け、
  slot 内の absolute に切り替えて、通常スクロールで自然に上へ流します。
*/
.stage:not(.is-active):not(.is-released) {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.stage.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.stage.is-released {
  position: absolute;
  top: 0;
  right: 0;
  bottom: auto;
  left: 0;
  opacity: 1;
  visibility: visible;
  pointer-events: none;
  transition: none;
}

.bg-slot,
.stage__veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg-slot {
  opacity: 0;
  transform: scale(1.012);
  transition: opacity .75s var(--ease), transform 1.15s var(--ease);
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  will-change: opacity, transform;
}

.bg-slot::before,
.bg-slot::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/*
  背景のぼかし感は固定レイヤーだけで作ります。
  本文やシーン切替には blur を使わないため、描画負荷を抑えています。
  さらに軽くしたい場合は filter 行を削除してください。
*/
.bg-slot::before {
  background: inherit;
  background-size: cover;
  background-position: center;
  filter: blur(16px);
  transform: scale(1.055);
  opacity: .35;
}

.bg-slot::after {
  background: rgba(0,0,0,.5);
}

.bg-slot.is-active {
  opacity: 1;
  transform: scale(1);
}

.stage__veil {
  background:
    radial-gradient(circle at 72% 28%, rgba(255,255,255,.12), transparent 40%),
    linear-gradient(110deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0));

  background: rgba(0,0,0,.7);
  mix-blend-mode: screen;
  opacity: .62;
}

.stage__layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(190px, 24vw) minmax(0, 1fr);
  gap: clamp(20px, 4vw, 72px);
  width: min(1540px, calc(100vw - 56px));
  min-height: var(--revival-stage-height, calc(100vh - var(--revival-header-offset, 0px)));
  margin: 0 auto;
  padding: clamp(28px, 5vh, 72px) 0;
  align-items: center;
}

.reader-side {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: rgba(255,255,255,.82);
  text-shadow: 0 2px 22px rgba(0,0,0,.28);
}

.reader-side__eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .78;
}

.reader-side__count {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 0 0 30px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 72px);
  line-height: 1;
}

.reader-side__count span:nth-child(2),
.reader-side__count span:nth-child(3) {
  font-size: .38em;
  opacity: .62;
}

.reader-side__title {
  margin: 0;
  font-size: clamp(18px, 2.1vw, 42px);
  font-weight: 500;
  letter-spacing: .08em;
  /* writing-mode: vertical-rl; */
  max-height: 42vh;
  font-family: serif;
  line-height: 1.5em;
}


.reader-panel {
  min-width: 0;
  perspective: 1500px;
}

.reader-window {
  position: relative;
  height: var(--revival-reader-height, min(78vh, 760px));
  min-height: min(520px, var(--revival-reader-height, 520px));
  overflow: visible;
  transform: translateZ(0);
}

/*
  テキスト領域＝カード自体を動かす版。
  reader-window 側をただのステージにし、背景・枠・影・フェードは scene-card 側に持たせる。
  これにより、切り替え時に「本文の中身」だけでなく「本文領域そのもの」が動いて見える。
*/
.scene-card {
  position: absolute;
  inset: 0;
  overflow: hidden;  
  backdrop-filter: blur(10px);
  background: rgba(255, 253, 248, .7);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate3d(8vw, 3vh, 0) scale(1.018) rotateY(3deg);
  transform-origin: center center;
  transition: opacity .62s var(--ease), transform .72s var(--ease);
  will-change: opacity, transform;
  backface-visibility: hidden;
  pointer-events: none;
  contain: paint;
}

.scene-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  border-radius: inherit;
  background:
    linear-gradient(to bottom, rgba(255,253,248,.90), rgba(255,253,248,0) 72px),
    linear-gradient(to top, rgba(255,253,248,.90), rgba(255,253,248,0) 72px),
    linear-gradient(115deg, rgba(255,255,255,.18), transparent 38%, rgba(255,255,255,.08));
}

.scene-card.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1) rotateY(0deg);
  pointer-events: auto;
}

.scene-card.is-exiting-next {
  opacity: 0;
  transform: translate3d(-7vw, -2vh, 0) scale(.97) rotateY(-3deg);
}

.scene-card.is-exiting-prev {
  opacity: 0;
  transform: translate3d(7vw, 2vh, 0) scale(.97) rotateY(3deg);
}

.scene-card.is-entering-next {
  opacity: 0;
  transform: translate3d(9vw, 3.2vh, 0) scale(1.02) rotateY(3.5deg);
}

.scene-card.is-entering-prev {
  opacity: 0;
  transform: translate3d(-9vw, -3.2vh, 0) scale(1.02) rotateY(-3.5deg);
}

.scene-card__flow {
  position: relative;
  z-index: 1;
  /*
    上下の白いボカシは演出として残しつつ、
    冒頭文がボカシに巻き込まれないように上paddingを厚めにしています。
  */
  padding: clamp(82px, 6.2vw, 104px) clamp(38px, 6.5vw, 104px) clamp(52px, 5.4vw, 86px);
  transform: translate3d(0, var(--flow-y, 0px), 0);
  will-change: transform;
}

.scene-card__flow p {
  margin: 0 0 1.85em;
  font-size: clamp(14.5px, 1.14vw, 16.8px);
  line-height: 2.16;
  letter-spacing: .055em;
  text-align: justify;
  overflow-wrap: anywhere;
}

.scene-card__flow p:last-child {
  margin-bottom: 0;
}

.reader-nav {
  position: absolute;
  z-index: 5;
  right: clamp(18px, 3vw, 42px);
  bottom: clamp(18px, 3vw, 38px);
  display: flex;
  gap: 10px;

  display: none;
}

.reader-nav button {
  appearance: none;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  padding: 11px 16px;
  background: rgba(0,0,0,.28);
  color: rgba(255,255,255,.9);
  font: inherit;
  font-size: 13px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .2s, transform .2s, opacity .2s;
}

.reader-nav button:hover {
  background: rgba(0,0,0,.42);
  transform: translateY(-1px);
}

.reader-nav button:disabled {
  opacity: .38;
  cursor: default;
  transform: none;
}

.scroll-spacer {
  height: 100vh;
}

html.is-enhanced .scroll-spacer {
  display: none;
}

@media (max-width: 1023px) {
  .revival-story-placeholder {
    min-height: 520px;
  }

  .stage__layout {
    grid-template-columns: 1fr;
    gap: 16px;
    width: min(100vw - 24px, 720px);
    padding: 18px 0 76px;
    align-content: center;
  }

  .reader-side {
    align-self: auto;
    display: grid;
    grid-template-columns: auto 1fr auto;    
    gap: 12px;
    min-height: 0;
  }

  .reader-side__eyebrow {
    margin: 0;
    font-size: 10px;
  }

  .reader-side__count {
    margin: 0;
    justify-content: center;
    font-size: 28px;
  }

  .reader-side__title {
    writing-mode: horizontal-tb;
    max-height: none;
    font-size: 22px;       
  }

  .reader-window {
    height: var(--revival-reader-height, calc(100vh - var(--revival-header-offset, 0px) - 156px));
    min-height: min(420px, var(--revival-reader-height, 420px));
    border-radius: 20px;
  }

  .scene-card::before {
    inset: 14px;    
  }

  .scene-card__flow {
    padding: 76px 26px 42px;
  }

  .scene-card__flow p {
    font-size: 14.5px;
    line-height: 2.05;
    text-align: left;
  }

  .reader-nav {
    left: 12px;
    right: 12px;
    bottom: 12px;
    justify-content: space-between;
  }

  .reader-nav button {
    width: calc(50% - 5px);
    padding: 12px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .bg-slot,
  .scene-card,
  .reader-nav button {
    transition: none !important;
  }
}


/* scroll timeline版の補助。通常スクロールを使うため、touch/wheelはJSで奪いません。 */
html.is-revival-timeline .stage,
html.is-revival-timeline .scene-card,
html.is-revival-timeline .bg-slot {
  /* JS側で無段階制御するため、該当要素のtransitionはJSでnoneにします。 */
}

html.is-revival-timeline .reader-side__label,
html.is-revival-timeline #scene-label {
  display: none !important;
}
