@charset "utf-8";
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap');

/* ====== 基本配色 ====== */
:root{
  --bg: #c6f1e0;
  --line: #373737;
  --btn: #f5b05b;
}

/* フォント共通設定 */
:root {
  --font-sans: "Zen Kaku Gothic New", system-ui, -apple-system, "Segoe UI", Roboto,
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic",
               Meiryo, sans-serif;
}

html {
  font-family: var(--font-sans);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}
body {
  margin: 0;
  background: var(--bg);
}

/* PC/SP 出し分け */
.pc-layout { display:block; }
.sp-layout { display:none; }

/* ====== ヘッダー（PC） ====== */
.site-header {
  position: sticky;
  margin: 0;
  top: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 2px solid var(--line);
  z-index: 1000;
}
.site-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.header-nav {
  margin-left: auto;
  display: flex;
  gap: 16px;
}
.header-nav a {
  font-weight: 700;
  text-decoration: none;
  color: var(--line);
  padding: 6px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
}
.header-nav a:hover {
  background: var(--btn);
  color: #fff;
}

/* ===== ノベル本体（PC） ===== */
.novel-container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 2rem;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 12px;
}
h1, h2 {
  text-align: center;
}
.novel-body {
  margin-top: 2rem;
  line-height: 2;
  font-size: 1.05rem;
}
.novel-body.vertical {
  writing-mode: vertical-rl;
  text-orientation: upright;
  column-count: 1;
  letter-spacing: 0.08em;
  height: 80vh;
  overflow-y: auto;
  padding-right: 2rem;
}
.novel-body.horizontal {
  writing-mode: horizontal-tb;
}
.novel-body p {
  text-indent: 1em;
  margin-bottom: 1em;
}
.novel-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  border-top: 1px solid #ccc;
  padding-top: 1.5rem;
}
.novel-nav a {
  text-decoration: none;
  color: #333;
  font-weight: bold;
}

/* --- フローティングメニュー（PC） --- */
.float-menu {
  position: fixed;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}
.float-icon {
  width: 70px;
  height: 70px;
  cursor: pointer;
  transition: transform 0.2s;
}
.float-icon:hover {
  transform: scale(1.1);
}
#toggle-layout {
  cursor: pointer;
  font-size: 0.9rem;
  writing-mode: vertical-rl;
}
.float-icon:hover::after {
  content: attr(data-cp);
  position: absolute;
  left: 85px;
  background: #fff;
  border: 1px solid #000;
  padding: 0.3rem 0.6rem;
  white-space: nowrap;
  font-size: 0.9rem;
}

/* ===== 目次ポップアップ（PC） ===== */
.chapter-popup {
  position: fixed;
  left: 90px;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 2px solid #333;
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.16);
  z-index: 2000;
}
.chapter-popup::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 10px 8px 0;
  border-style: solid;
  border-color: transparent #333 transparent transparent;
}
.popup-header,
.popup-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 8px;
  background: #ffffff;
  border-bottom: 1px solid #ddd;
}
.popup-footer {
  border-top: 1px solid #ddd;
  border-bottom: none;
}
#scroll-up,
#scroll-down {
  background: #ffffff;
  border: 1px solid #333;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 12px;
  line-height: 1.4;
  color: #333;
}
#scroll-up:hover,
#scroll-down:hover {
  background: #333;
  color: #ffffff;
}
.popup-list {
  overflow-y: auto;
  flex-grow: 1;
  padding: 0.6rem 0.6rem 0.4rem;
}
.popup-list h3 {
  font-size: 0.9rem;
  margin: 0.4rem 0 0.2rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #ccc;
  color: #222;
}
.popup-list ul {
  list-style: none;
  padding-left: 0;
  margin: 0 0 0.5rem 0;
}
.popup-list li {
  margin: 0.15rem 0;
}
.popup-list a {
  display: block;
  padding: 4px 8px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.85rem;
  color: #333;
  background: #f8f8f8;
  border: 1px solid transparent;
  transition:
    background 0.15s ease,
    transform 0.1s ease,
    border-color 0.15s ease;
}
.popup-list a:hover {
  background: #e0e0e0;
  border-color: #333;
  transform: translateX(2px);
}
.popup-list::-webkit-scrollbar {
  width: 6px;
}
.popup-list::-webkit-scrollbar-track {
  background: transparent;
}
.popup-list::-webkit-scrollbar-thumb {
  background: #bbbbbb;
  border-radius: 999px;
}

/* =========================================
   ▼▼ スマホレイアウト ▼▼
   ========================================= */
@media screen and (max-width: 768px) {

   /* PCレイアウトを全部消す（保険込み） */
  .pc-layout,
  .site-header,
  .float-menu,
  .chapter-popup,
  .novel-container {
    display: none;
  }

  /* スマホレイアウトを表示 */
  .sp-layout {
    display: block;
  }

  html, body {
    height: 100%;
  }

  body {
    background:#f5f5f5;
    overflow: hidden;  /* ← スマホ時はページ自体をスクロールさせない */
  }

  /* ハンバーガー（右上フローティング） */
  .sp-hamburger {
    position: fixed;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 2px solid var(--line);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    z-index: 1100;
    padding: 0;
  }
  .sp-hamburger span {
    width: 18px;
    height: 2px;
    background: var(--line);
    border-radius: 999px;
    display: block;
    transition: transform 0.2s, opacity 0.2s;
  }
  .sp-hamburger.is-open span:nth-child(1) {
    transform: translateY(4px) rotate(45deg);
  }
  .sp-hamburger.is-open span:nth-child(2) {
    opacity: 0;
  }
  .sp-hamburger.is-open span:nth-child(3) {
    transform: translateY(-4px) rotate(-45deg);
  }

  /* メニューのオーバーレイ */
  .sp-menu-overlay {
    position: fixed;
    inset: 0;
    background: transparent;   /* ← ここを rgba(...) から transparent に */
    z-index: 1050;
  }
  .sp-menu-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 50vh;
    background:#fff;
    border-bottom:2px solid var(--line);
    padding: 12px 16px 16px;
  }
  .sp-menu-close {
    border:none;
    background:transparent;
    font-size:1.4rem;
    float:right;
    cursor:pointer;
  }
  .sp-menu-nav {
    margin-top: 32px;
    display:flex;
    flex-direction:column;
    gap:8px;
  }
  .sp-menu-nav a {
    text-decoration:none;
    color:#333;
    font-weight:700;
    padding:8px 4px;
    border-bottom:1px solid #ddd;
  }

  /* ノベル本文エリア */
   .sp-novel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 52px;              /* ← sp-bottom-bar の高さぶん空ける */
    padding: 16px 12px 16px;
    overflow-y: auto;          /* ← ここだけスクロールする */
  }
  .sp-title {
    margin-top: 16px;
    margin-bottom: 4px;
    font-size: 1.2rem;
    text-align: left;
  }
  .sp-view {
    margin: 0 0 10px;
    font-size: 0.85rem;
    color:#555;
  }
  .sp-title.vertical,
  .sp-view.vertical {
    writing-mode: vertical-rl;
    text-orientation: upright;
  }

    #sp-novel-body {
    background:#fff;
    padding: 12px 10px;
    font-size:0.85rem;
    line-height:1.9;
    margin-bottom:16px;

    /* 高さは sp-novel に任せるので指定しない */
    height: auto;
    max-height: none;
    overflow: visible;
  }

  /* 縦書きのときだけ書字方向を変える（位置は変えない） */
  #sp-novel-body.vertical {
    writing-mode: vertical-rl;
    text-orientation: upright;
  }


  /* 横罫線＋矢印ナビ */
  .sp-episode-nav {
    border-top:1px solid #ccc;
    padding-top:8px;
    display:flex;
    justify-content:space-between;
  }
  .sp-episode-nav a {
    text-decoration:none;
    color:#333;
    font-size:1.1rem;
    padding:4px 10px;
  }

  /* 画面下のフローティングバー */
  .sp-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 52px;
    background:#fff;
    border-top:1px solid #ccc;
    display:flex;
    justify-content:space-around;
    align-items:center;
    z-index:1000;
  }
  .sp-bottom-btn {
    border-radius:999px;
    border:1px solid var(--line);
    background:#fff;
    padding:6px 14px;
    font-size:0.9rem;
    cursor:pointer;
  }

  /* CPアイコンバー */
  .sp-cp-strip {
    position: fixed;
    left:0;
    right:0;
    bottom:52px; /* ボトムバーの高さ分 */
    background:#ffffff;
    border-top:1px solid #ccc;
    padding:6px 6px 4px;
    z-index:990;
  }
  .sp-cp-inner {
    display:flex;
    gap:8px;
    overflow-x:auto;
    padding-bottom:4px;
  }
  .sp-cp-icon {
    width:52px;
    height:52px;
    flex:0 0 auto;
    cursor:pointer;
  }
  .sp-cp-inner::-webkit-scrollbar {
    height:4px;
  }
  .sp-cp-inner::-webkit-scrollbar-thumb {
    background:#bbb;
    border-radius:999px;
  }

  /* 目次ボトムシート */
  .sp-toc-sheet {
    position: fixed;
    left:0;
    right:0;
    bottom:0;
    height:50vh;
    background: transparent;   /* ← ここも透明にする */
    z-index:1080;
    display:flex;
    justify-content:center;
    align-items:flex-end;
  }
  .sp-toc-inner {
    width:100%;
    max-height:50vh;
    background:#fff;
    border-top:2px solid #333;
    display:flex;
    flex-direction:column;
  }
  /* popup-header/footer/popup-list はPCと共通クラスを流用 */
  #sp-chapter-list {
    flex-grow:1;
  }
  #sp-scroll-up,
  #sp-scroll-down {
    background:#ffffff;
    border:1px solid #333;
    border-radius:999px;
    font-size:0.9rem;
    cursor:pointer;
    padding:2px 12px;
    line-height:1.4;
    color:#333;
  }
  #sp-scroll-up:hover,
  #sp-scroll-down:hover {
    background:#333;
    color:#ffffff;
  }
}
