/* サイドバーの初期状態（右端から隠す） */
.sidebar {
  position: fixed;
  top: var(--site-header-height, 56px);
  right: -250px; /* 閉じたときは右側画面外 */
  width: 250px;
  height: calc(100vh - var(--site-header-height, 56px));
  background-color: #f8f8f8;
  box-shadow: -2px 0 5px rgba(0,0,0,0.1); /* 左影に変更 */
  display: flex;
  flex-direction: column;
  padding: 2rem 1rem;
  transition: right 0.3s ease;
  z-index: 1050;
  overflow-y: auto;  /* ← スクロールできるように追加 */
}

.sidebar.open {
  right: 0; /* 右端に表示 */
}

/* 飛び出し部分を白く覆う（右側） */
.sidebar.open::before {
  content: "";
  position: fixed;
  top: var(--site-header-height, 56px);
  right: 0;
  width: 0;
  height: calc(100vh - var(--site-header-height, 56px));
  background-color: #f8f8f8;
  box-shadow: -2px 0 5px rgba(0,0,0,0.1);
  z-index: 1049;
  pointer-events: none;
}

/* 通常リンク */
.sidebar a {
  text-align: center;
  text-decoration: none;
  color: #333;
  font-size: 1.1rem;
  margin: 1rem 0;
  transition: color 0.2s ease;
}

/* メニュータイトル */
.menu-title {
  display: block;
  font-weight: bold;
  color: #111;
  font-size: 1.1rem;
  padding-right: 1rem;
}

.menu-title:hover {
  color: #007bff;
  text-decoration: underline;
}

/* サブメニュー */
.submenu {
  list-style: none;
  padding-left: 1rem; /* インデント */
  margin: 0;
  border-left: 1px dashed #ccc;
}

.submenu li a {
  display: block;
  text-align: left;
  padding: 0.1px 0;
  font-size: 0.95rem;
  color: #444;
  text-decoration: none;
  padding-left: 1.5rem;
  position: relative;
}

.submenu li a::before {
  content: "ー";
  position: absolute;
  left: 0;
  color: #007bff;
}

/* ハンバーガーボタン（ヘッダー右端。固定レイヤーにはしない） */
.sidebar-toggle {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  font-size: 1.75rem;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 黒いオーバーレイ */
.overlay {
  position: fixed;
  top: var(--site-header-height, 56px);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--site-header-height, 56px));
  background: rgba(0,0,0,0.3);
  z-index: 1040;
}

/* レスポンシブ対応 */
body.header-hidden .sidebar,
body.header-hidden .sidebar.open::before,
body.header-hidden .overlay {
  top: 0;
  height: 100vh;
}

@media (max-width: 768px) {
  .sidebar {
    top: var(--site-header-height, 56px);
    right: -200px;
    width: 200px;
    height: calc(100vh - var(--site-header-height, 56px));
    padding-top: 2rem;
    overflow-y: auto;
  }

  .sidebar.open {
    right: 0;
  }

  .sidebar.open::before {
    top: var(--site-header-height, 56px);
    width: 0;
    height: calc(100vh - var(--site-header-height, 56px));
  }

  .overlay {
    top: var(--site-header-height, 56px);
    height: calc(100vh - var(--site-header-height, 56px));
  }

  .sidebar-toggle {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
  }
}
