/* =========================================================
   全ページ共通：色・文字・ヘッダー・メニュー・フッター
   （以前は各ページの CSS にコピーされていて、ページごとに
     動きがずれていたので、ここ 1 か所にまとめた）
   ========================================================= */

:root {
  --bg: #000;
  --surface: #111;
  --border: #292929;
  --text: #fff;
  --text-sub: #ccc;
  --text-muted: #888;
  --accent: #1da1f2;

  --header-h: 72px;
  --gutter: clamp(16px, 4vw, 30px);
}

@media (max-width: 600px) {
  :root {
    --header-h: 60px;
  }
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  background-color: var(--bg);
  scroll-padding-top: var(--header-h); /* 固定ヘッダーの下に見出しが隠れないように */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh; /* スマホのアドレスバー分のずれを防ぐ */
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
  color: var(--text);
  font-family:
    "Helvetica Neue", Arial,
    "Hiragino Kaku Gothic ProN", "Hiragino Sans",
    "Yu Gothic", "YuGothic", Meiryo, sans-serif;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

img {
  max-width: 100%;
}

a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ===== ヘッダー ===== */
header {
  position: sticky;
  top: 0;
  z-index: 1100; /* メニューより上に置き、×ボタンで閉じられるようにする */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top);
  background-color: var(--surface);
}

.logo {
  min-width: 0;
  color: var(--text);
  font-size: clamp(0.95rem, 3.8vw, 1.2rem);
  font-weight: bold;
  letter-spacing: 0.02em;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== ハンバーガー（指で押しやすい 44px 角） ===== */
.menu-toggle {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  margin-left: auto;
  margin-right: -10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.menu-toggle .bar {
  display: block;
  width: 25px;
  height: 3px;
  background-color: #fff;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.menu-toggle.active .bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active .bar:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active .bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ===== 右から出るメニュー ===== */
#menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  width: min(260px, 80vw);
  height: 100%;
  padding-top: calc(var(--header-h) + env(safe-area-inset-top) + 8px);
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transform: translateX(100%);
  visibility: hidden; /* 閉じている間は Tab キーで入らないように */
  transition: transform 0.3s ease, visibility 0s linear 0.3s;
}

#menu.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s ease, visibility 0s;
}

#menu a {
  display: block;
  padding: 16px 20px;
  color: #fff;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-decoration: none;
}

#menu a:hover,
#menu a:focus-visible {
  background-color: var(--border);
}

#menu a[aria-current="page"] {
  box-shadow: inset 3px 0 0 #fff;
}

/* メニューを開いている間、後ろを暗くする */
body.menu-open::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.5);
}

/* ===== フッター ===== */
footer {
  padding: 20px var(--gutter);
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background-color: var(--surface);
  color: var(--text-sub);
  font-size: 0.85rem;
  line-height: 1.8;
  text-align: center;
}

/* 動きを減らす設定の人にはアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
