:root {
  --engine-ink: #f4f1eb;
  --engine-muted: rgba(244, 241, 235, 0.68);
  --engine-panel: rgba(10, 16, 24, 0.48);
  --engine-panel-border: rgba(255, 255, 255, 0.18);
  --engine-radius: 1.5rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #080d14;
  scroll-behavior: auto;
  /* 演出で右側へはみ出す要素(粒子・破片・拡大文字)がモバイルの
     レイアウトビューポートを押し広げるのを防ぐ */
  overflow-x: hidden;
  overflow-x: clip;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--engine-ink);
  background: #080d14;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  content: "";
  background: linear-gradient(180deg, rgba(3, 7, 12, 0.16), rgba(3, 7, 12, 0.34));
}

.engine-background-stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: #080d14;
}

.engine-background-layer {
  position: absolute;
  inset: -2%;
  opacity: 0;
  background-position: center;
  background-size: cover;
  will-change: opacity, transform;
}

.chapter-interlude { height: 50svh; }
.chapter-interlude--long { height: 115svh; }

/* レスポンシブ改行: br-wide=PCのみ改行(スマホは自然に流す) / br-narrow=スマホのみ改行 */
br.br-narrow { display: none; }
@media (max-width: 768px) {
  br.br-wide { display: none; }
  br.br-narrow { display: inline; }
  .sep-wide { display: none; }
}

/* 背景の呼吸(アクティブレイヤーのみ・ch0は突き抜けtransformと競合するため除外) */
.engine-background-layer.is-active:not([data-chapter-bg="ch0"]) {
  animation: engine-bg-breath 30s ease-in-out infinite alternate;
}

@keyframes engine-bg-breath {
  from { transform: scale(1.06); }
  to   { transform: scale(1.10); }
}

@media (prefers-reduced-motion: reduce) {
  .engine-background-layer.is-active:not([data-chapter-bg="ch0"]) { animation: none; }
}

.engine-background-layer::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(4, 9, 16, 0.52), rgba(4, 9, 16, 0.08) 52%, rgba(4, 9, 16, 0.45)),
    linear-gradient(180deg, rgba(4, 9, 16, 0.2), rgba(4, 9, 16, 0.65));
}

.chapter {
  position: relative;
  z-index: 2;
  display: grid;
  min-height: 100vh;
  align-items: center;
  padding: clamp(5rem, 10vw, 9rem) clamp(1.25rem, 7vw, 8rem);
  isolation: isolate;
}

.chapter__inner {
  position: relative;
  z-index: 2;
  width: min(100%, 70rem);
  margin: 0 auto;
}

.glass-panel {
  padding: clamp(1.5rem, 4vw, 4.5rem);
  border: 1px solid var(--engine-panel-border);
  border-radius: var(--engine-radius);
  background: var(--engine-panel);
  box-shadow: 0 1.5rem 5rem rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(112%);
  -webkit-backdrop-filter: blur(18px) saturate(112%);
}

.chapter-particles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.58;
}

.chapter-particles canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.chapter__eyebrow {
  margin: 0 0 1.2rem;
  color: var(--engine-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.chapter h1,
.chapter h2,
.chapter h3 {
  margin: 0;
  font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.28;
  /* 見出しは約物(鉤括弧・句読点)の全角アキを詰めて組む */
  font-feature-settings: "palt" 1;
}

/* 見出しの折り返しはフレーズ単位に固定(中間幅での不格好な自然折り返しを防ぐ) */
.chapter h1 .nw,
.chapter h2 .nw {
  display: inline-block;
}

.chapter h1 {
  font-size: clamp(2.8rem, 8vw, 7.8rem);
}

.chapter h2 {
  font-size: clamp(2.4rem, 6vw, 5.4rem);
}

.chapter__label {
  display: block;
  margin-top: 0.8rem;
  color: var(--engine-muted);
  font-size: clamp(0.7rem, 1.4vw, 0.9rem);
  letter-spacing: 0.16em;
}

.chapter__copy {
  max-width: 42rem;
  margin: 2rem 0 0;
  color: rgba(244, 241, 235, 0.88);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 2;
}

.chapter__copy + .chapter__copy {
  margin-top: 1rem;
}

.chapter__rule {
  width: 4rem;
  height: 1px;
  margin: 1.6rem 0;
  border: 0;
  background: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
  .chapter {
    min-height: 100svh;
    padding: 4rem 1rem;
  }

  .glass-panel {
    padding: 1.35rem;
    border-radius: 1rem;
    backdrop-filter: blur(9px) saturate(108%);
    -webkit-backdrop-filter: blur(9px) saturate(108%);
  }

  .engine-background-layer {
    inset: 0;
    background-position: 56% center;
  }

  .chapter-particles {
    opacity: 0.34;
  }

  .chapter__copy {
    line-height: 1.85;
  }
}

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

  .engine-background-layer {
    transition: none;
    transform: none !important;
  }

  .chapter-particles {
    display: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

.profile-line {
  fill: none;
  stroke: #e7b36b;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(231, 179, 107, 0.45));
}
/* Shared fixed line layer: above backgrounds, below chapter content. */
.profile-line-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.profile-line-stage svg {
  display: block;
  width: 100%;
  height: 100%;
}
