/* --- 共通・初期設定 --- */
* { box-sizing: border-box; }
/* --- 背景の親要素 --- */
.bg-decoration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  /* z-indexを「-1」ではなく「-2」にし、bodyを透明にするか、
     あるいはz-indexを少し上げて、他の要素よりは下にします */
  z-index: -1; 
  overflow: hidden;
  pointer-events: none;
  /* 背景色をここ（一番奥のレイヤー）に持ってくる */
  background-color: #e0e0d9; 
}

/* --- bodyの設定を修正 --- */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  /* body自体に色をつけるとz-index:-1の要素が隠れるため、透明にする */
  background-color: transparent; 
  font-family: 'Noto Serif JP', serif;
}

/* --- 雲のアニメーション --- */
.cloud-anim {
  height: 200%; /* 高さを指定してサイズを調整 */
  width: auto;
  min-width: 200vw; /* 画面2枚分の幅を確保 */
  position: absolute;
  top: 10%;
  left: 0;
  opacity: 0.4; /* 少し濃くして見えるか確認 */
  animation: cloudMove 60s linear infinite;
  display: block; /* 明示的にブロック要素にする */
}

/* --- 案内画面（ワンクッション） --- */
.loader {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #e0e0d9; z-index: 1000;
  display: flex; justify-content: center; align-items: center;
  transition: opacity 0.8s ease;
}
.loader.fade-out { opacity: 0; pointer-events: none; }
.loader-content { text-align: center; }
.scroll-icon { font-size: 2rem; margin-bottom: 20px; animation: bounce 2s infinite; color: #AE1F1F; }
@keyframes bounce { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-20px); } }
#startBtn {
  margin-top: 30px; padding: 12px 40px; background: #333; color: #fff;
  border: none; cursor: pointer; font-family: inherit; font-size: 1rem;
}

/* --- 固定UI --- */
.fixed-ui {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 200;
}
.header-container {
  position: absolute; top: 80px; left: 5%; width: 90%;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: auto;
}
.progress-wrapper { flex: 1; height: 20px; position: relative; margin-right: 40px; }
.progress-base-line { position: absolute; top: 50%; width: 100%; height: 1px; background: #333; }
.progress-bar {
  position: absolute; top: 50%; right: 0; height: 3px; background: #AE1F1F; width: 0%;
  transform: translateY(-50%); z-index: 2; transition: width 0.1s linear;
}
.fixed-title {
  font-size: 1.2rem; font-weight: 400; letter-spacing: 0.5em; background: #e0e0d9; padding: 0 20px; white-space: nowrap;
}
.bottom-line { position: absolute; bottom: 80px; left: 5%; width: 90%; height: 1px; background: #333; }

/* --- ハンバーガーボタン --- */
.menu-button { display: flex; align-items: center; gap: 10px; cursor: pointer; z-index: 210; }
.hamburger { width: 30px; height: 20px; position: relative; }
.hamburger span { position: absolute; width: 100%; height: 1px; background: #333; transition: .4s; }
.hamburger span:nth-child(1) { top: 0; }
.hamburger span:nth-child(2) { top: 10px; }
.hamburger span:nth-child(3) { top: 20px; }
.menu-button.active span:nth-child(1) { transform: translateY(10px) rotate(45deg); }
.menu-button.active span:nth-child(2) { opacity: 0; }
.menu-button.active span:nth-child(3) { transform: translateY(-10px) rotate(-45deg); }
.menu-label { writing-mode: vertical-rl; font-size: 0.7rem; margin: 0; }

/* --- メニュー画面 --- */
  /* --- ここを追加：上下端を消すマスク --- */
/* --- page.css の .menu-overlay を書き換え --- */
.menu-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: #e0e0d9; z-index: 150; 
  display: flex; justify-content: center; align-items: flex-start;
  overflow-y: auto; padding: 120px 0; /* 線(80px)より少し内側からコンテンツを開始 */
  opacity: 0; visibility: hidden; pointer-events: none; transition: 0.5s;

  /* 上下の線（80px）の外側では完全に消え、線の内側で徐々に現れる設定 */
  mask-image: linear-gradient(
    to bottom,
    transparent 0px,
    transparent 80px,  /* 上の線までは透明 */
    black 150px,       /* 150px地点で完全に見える */
    black calc(100% - 150px), 
    transparent calc(100% - 80px), /* 下の線から透明に戻る */
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to bottom,
    transparent 0px,
    transparent 80px,
    black 150px,
    black calc(100% - 150px),
    transparent calc(100% - 80px),
    transparent 100%
  );
}
.menu-overlay.active { opacity: 1; visibility: visible; pointer-events: auto; }
.menu-links { list-style: none; text-align: center; padding: 0; }
.menu-links li { margin: 35px 0; }
.menu-links a { text-decoration: none; color: #333; font-size: 1.5rem; letter-spacing: 0.1em; }
.menu-links a.current { border-bottom: 1px solid #AE1F1F; }

/* --- 次の物語ボタン --- */
.next-story-box{
  margin: 0 70px;
}
.next-btn-rect {
  display: block; width: 30px; height: 200px; line-height: 30px;
  writing-mode: vertical-rl; background: #333; color: #fff;
  text-decoration: none; text-align: center; margin: 30px auto;
  font-size: 0.8rem; transition: 0.3s;
}
.next-btn-rect:hover { background: #AE1F1F; }

/* --- スクロールコンテンツ --- */
.scroll-wrapper { width: 100vw; height: 100vh; overflow-x: auto; display: flex; scrollbar-width: none; }
.scroll-wrapper::-webkit-scrollbar { display: none; }
.scroll-track { display: inline-flex; flex-direction: row-reverse; height: 100%; position: relative; }

/* 3. 無限ループの動き */
@keyframes cloudMove {
  from {
    transform: translateX(0);
  }
  to {
    /* 画像が横に2枚並んでいる想定で、半分まで進んだ瞬間に 0 に戻ることで
       無限に繋がっているように見せます */
    transform: translateX(-50%);
  }
}

.panel { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.panel-inner { display: flex; flex-direction: row-reverse; align-items: center; }
.panel-text { writing-mode: vertical-rl; font-size: 1.2rem; line-height: 3; height: 50vh; text-align: justify; }
.panel-image img { height: 40vh; width: auto; margin-right: 50px; }
.panel-text a{
  text-decoration: none;
}

/* --- ポップアップ辞典 --- */
.pop-link { color: #AE1F1F; cursor: pointer; }
.pop-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 300; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: .3s; }
.pop-modal.active { opacity: 1; visibility: visible; }
.pop-content { background: #fff; padding: 40px; width: 350px; position: relative; }
.pop-close { position: absolute; top: 10px; right: 10px; border: none; background: none; font-size: 1.5rem; cursor: pointer; }


.Tpop-link { color: #4c4c4c; cursor: pointer; }
.Tpop-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 300; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: .3s; }
.Tpop-modal.active { opacity: 1; visibility: visible; }
.Tpop-content { background: #fff; padding: 40px; width: 350px; position: relative; }
.Tpop-close { position: absolute; top: 10px; right: 10px; border: none; background: none; font-size: 1.5rem; cursor: pointer; }

/* 用語ポップアップの基本スタイル（pop-modalと同じでOK） */
.Tpop-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 400; /* 神さまモーダルより上にしたい場合は調整 */
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}

.Tpop-modal.active {
  opacity: 1;
  visibility: visible;
}

.Tpop-content {
  background: #fff;
  padding: 40px;
  width: 90%;
  max-width: 400px;
  position: relative;
  border-radius: 5px;
}

/* 用語リンク（本文中の文字）の見た目 */
.term-link {
  color: #2c5d8a; /* 神さま（赤）と色を変えると分かりやすいです */
  cursor: pointer;
}

/* --- 01_page専用：フェードイン初期状態の修正 --- */
/* ... 基本設定などは変更なし ... */

/* カンマ区切りに修正 */
.panel1, .panel2, .panel3, .panel4, .panel5, .panel6, .panel7 {
  flex: 0 0 auto;
  display: flex;
  margin-right: 200px; /* パネル間の余白を統一 */
}

.panel1 { margin-right: 400px; } /* 最初だけ広く */

/* scroll-track の幅を自動で確保 */
.scroll-track {
  display: flex;
  flex-direction: row-reverse;
  height: 100%;
  width: max-content; /* 中身の合計幅に自動調整 */
  position: relative;
  padding: 0 10vw; /* 左右に少し余裕を持たせる */
}

.panel-text {
  /* 文字が流れる範囲を確保するため、z-indexを調整 */
  position: relative;
  z-index: 10;
  /* 縦書きの美しさを保つ */
  writing-mode: vertical-rl;
  /* 文字の間隔を少し広げると、より高級感（河馬印風）が出ます */
  letter-spacing: 0.2em;
  line-height: 2.5;
}


/* --- スマホ・タブレット対応 (768px以下) --- */
@media (max-width: 768px) {
  .header-container {
    top: 25px;
    left: 3%;
    width: 94%;
  }

  .progress-wrapper {
    margin-right: 15px;
  }

  .fixed-title {
    font-size: 1rem;
    padding: 0 10px;
    letter-spacing: 0.2em;
  }

  /* 下の線を少し上げる */
  .bottom-line {
    bottom: 25px;
    left: 3%;
    width: 94%;
  }

  /* パネル内のコンテンツ比率を調整 */
  .panel-text {
    height: 60vh; /* スマホでは文字のエリアを少し広げる */
    font-size: 1rem;
    line-height: 2.2; /* 行間を少し詰めて1画面に入る情報量を調整 */
    letter-spacing: 0.15em;
  }

  .panel-image img {
    height: 25vh; /* スマホでは画像を少し小さくして文字との重なりを防ぐ */
    margin-right: 25px; /* 余白も少し詰める */
  }

  /* パネル間の距離をスマホ用に調整 */
  .panel {
    margin-right: 100px;
  }
  .panel1 {
    margin-right: 150px;
  }

  /* ハンバーガーメニューのラベルを非表示（アイコンのみ）にするか、小さくする */
  .menu-label {
    display: none;
  }

  /* ポップアップ（モーダル）の幅を画面いっぱいに */
  .pop-content, .Tpop-content {
    width: 90%;
    padding: 30px 20px;
  }

  /* メニュー画面の文字サイズ */
  .menu-links a {
    font-size: 1.2rem;
  }

  /* プログレスバー（スマホだと高さが細い方が綺麗） */
  .progress-wrapper {
    height: 10px;
  }
}

