/* メインナビ：デスクトップは主要項目＋グループのドロップダウン、モバイルは右下ボタンから開くボトムシート */
body > header #site-nav {
  overflow: visible;
}
body > header #site-nav .nav-group {
  position: relative;
}
body > header #site-nav .nav-group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
body > header #site-nav .nav-group-toggle::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s;
}
body > header #site-nav .nav-group-toggle[aria-expanded="true"]::after {
  margin-top: 3px;
  transform: rotate(225deg);
}
body > header #site-nav .nav-group-toggle:hover {
  border-color: var(--line);
  color: var(--ink);
}
body > header #site-nav .nav-group-toggle.is-current {
  background: #d8b967;
  color: #26352d;
  border-color: #b89a4b;
  box-shadow: 0 2px 5px #00000012;
}
.nav-toggle,
.nav-sheet-head {
  display: none;
}

@media (min-width: 901px) {
  body > header #site-nav .nav-menu {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  body > header #site-nav .nav-group-panel {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 90;
    min-width: 190px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 12px 32px #0000002e;
  }
  body > header #site-nav .nav-group-toggle[aria-expanded="true"] + .nav-group-panel {
    display: grid;
    gap: 2px;
  }
  body > header #site-nav .nav-group-panel a {
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {
  body > header #site-nav {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
  }
  body > header #site-nav.open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    background: #0000008c;
  }
  .nav-toggle {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 85;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 18px 0 16px;
    border: 1px solid #b89a4b;
    border-radius: 999px;
    background: #d8b967;
    color: #26352d;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 6px 20px #00000038;
    cursor: pointer;
  }
  .nav-toggle-icon {
    width: 16px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    box-shadow:
      0 -5px 0 currentColor,
      0 5px 0 currentColor;
  }
  body > header #site-nav .nav-menu {
    display: none;
  }
  body > header #site-nav.open .nav-menu {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 95;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    gap: 7px;
    max-height: min(84vh, 760px);
    padding: 0 16px calc(18px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    background: var(--panel);
    box-shadow: 0 -10px 40px #00000040;
    animation: nav-sheet-in 0.2s ease-out;
  }
  body > header #site-nav .nav-sheet-head {
    grid-column: 1 / -1;
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0 8px;
    background: var(--panel);
    font-size: 17px;
  }
  body > header #site-nav .nav-close {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    font-size: 16px;
    cursor: pointer;
  }
  body > header #site-nav .nav-menu a {
    justify-content: flex-start;
    min-height: 44px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    white-space: normal;
  }
  body > header #site-nav .nav-menu a[aria-current="page"] {
    background: #d8b967;
    color: #26352d;
    border-color: #b89a4b;
  }
  body > header #site-nav .nav-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    order: 1;
    margin-top: 6px;
  }
  body > header #site-nav .nav-group-panel {
    display: contents;
  }
  /* モバイルではグループ見出しとして表示し、配下のリンクは常に展開する */
  body > header #site-nav .nav-group-toggle,
  body > header #site-nav .nav-group-toggle.is-current {
    grid-column: 1 / -1;
    min-height: 0;
    padding: 8px 2px 0;
    border: 0;
    background: none;
    box-shadow: none;
    color: var(--gold);
    font-size: 12px;
    letter-spacing: 2px;
    pointer-events: none;
  }
  body > header #site-nav .nav-group-toggle::after {
    display: none;
  }
  /* テーマ切替は左下のアイコンのみの小さな切替にし、右下の「栏目」ボタンと分ける */
  .theme-switch {
    right: auto;
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    padding: 4px;
  }
  .theme-switch button {
    min-width: 40px;
    min-height: 40px;
    padding: 0 10px;
    font-size: 16px;
  }
  .theme-switch .theme-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .nav-locked,
  .nav-locked body {
    overflow: hidden;
  }
}

@media (max-width: 700px) {
  /* 公開範囲の案内はトップページだけに表示し、各ページのファーストビューを広げる */
  :root:not([data-route="overview"]) .local-notice {
    display: none;
  }
  body > header {
    flex-wrap: nowrap;
    justify-content: space-between;
  }
}

@keyframes nav-sheet-in {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  body > header #site-nav.open .nav-menu {
    animation: none;
  }
}
