/* ==========================================================================
   クッキーラン情報サイト - 共通スタイル (common.css)
   全ページで読み込む共通CSS。ページ固有のスタイルはここに追加しない。
   ========================================================================== */

:root {
  /* --- カラートークン --- */
  --bg: #F7F3EA;
  --surface: #FFFFFF;
  --surface-alt: #EFE7D6;
  --border: #E1D6C0;

  --text: #2B2118;
  --text-muted: #6E5D48;
  --text-faint: #8B7B64;

  --accent: #5B3E8E;       /* サイト共通アクセント（リンク・現在地・フォーカス系） */
  --accent-soft: #EEE6F8;
  --accent-dark: #43306A;

  --kakao: #C6841F;        /* カカオ版タグカラー */
  --kakao-soft: #FBF0DA;
  --classic: #2C7A83;      /* クラシック版タグカラー */
  --classic-soft: #E3F0F1;

  --focus: #2C7FBF;

  /* --- タイポグラフィ --- */
  --font-display: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --font-body: "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;

  /* --- レイアウト寸法 --- */
  --header-h: 64px;
  --sidebar-w: 272px;
  --content-max: 760px;

  --radius-s: 6px;
  --radius-m: 10px;
}

/* ---------- リセット / 基本設定 ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }

button { font: inherit; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ==========================================================================
   ヘッダー
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header__row {
  max-width: 1280px;
  margin: 0 auto;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px;
  flex-wrap: wrap;
}

/* ハンバーガーメニュー（CSSで描画。スマートフォン表示のみ出現） */
.menu-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  background: var(--surface);
  position: relative;
  cursor: pointer;
  flex: 0 0 auto;
}
.menu-toggle span,
.menu-toggle::before,
.menu-toggle::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.menu-toggle::before { top: 14px; }
.menu-toggle span     { top: 19px; }
.menu-toggle::after   { top: 24px; }

.site-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .02em;
  margin-right: auto;
  line-height: 1.3;
}
.site-brand:hover { color: var(--accent); }
.site-brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: .625rem;
  color: var(--text-faint);
  letter-spacing: .08em;
}

/* ゲーム表示切り替え（セグメントコントロール） */
.version-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  background: var(--surface-alt);
  gap: 2px;
}
.version-switch button {
  border: 0;
  background: transparent;
  font-weight: 700;
  font-size: .8125rem;
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.version-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.version-switch button[data-version-btn="kakao"][aria-pressed="true"]   { background: var(--kakao); }
.version-switch button[data-version-btn="classic"][aria-pressed="true"] { background: var(--classic); }

/* ==========================================================================
   レイアウト（サイドメニュー + メイン）
   ========================================================================== */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 auto;
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 24px 12px 40px;
  border-right: 1px solid var(--border);
}

.sidebar-close { display: none; }

.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 32px 24px 80px;
}

.content { max-width: var(--content-max); }

/* ---------- サイドメニュー：カテゴリ（アコーディオン） ---------- */
.sidebar-category { margin-bottom: 4px; }

.category-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .875rem;
  color: var(--text);
  padding: 10px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  text-align: left;
}
.category-toggle:hover { background: var(--surface-alt); }

.category-toggle .chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  transform: rotate(-45deg);
  transition: transform .15s ease;
  flex: 0 0 auto;
  margin-top: -3px;
}
.sidebar-category.is-open .category-toggle .chevron { transform: rotate(45deg); margin-top: 0; }

.category-pages {
  list-style: none;
  margin: 2px 0 8px 12px;
  padding: 2px 0 2px 12px;
  border-left: 2px solid var(--border);
  display: grid;
  gap: 1px;
}
.sidebar-category:not(.is-open) .category-pages { display: none; }

.category-pages a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-s);
  font-size: .8125rem;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.5;
}
.category-pages a:hover { background: var(--surface-alt); color: var(--text); }
.category-pages a.is-current {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* ---------- スマートフォン：ドロワー化 ---------- */
.sidebar-backdrop { display: none; }

@media (max-width: 899px) {
  .menu-toggle { display: inline-block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(84vw, 320px);
    max-height: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 14px 40px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 200;
    box-shadow: 12px 0 32px rgba(30, 22, 12, .18);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(30, 22, 12, .35);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease;
    z-index: 190;
  }
  .sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    margin-left: auto;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    font-size: 1.1rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
  }

  .main { padding: 24px 16px 64px; }
}

/* ==========================================================================
   本文タイポグラフィ
   ========================================================================== */
.breadcrumb {
  font-size: .75rem;
  color: var(--text-faint);
  margin: 0 0 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}
.breadcrumb a { color: var(--text-faint); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
.breadcrumb .current { color: var(--text-muted); }
.breadcrumb .sep { color: var(--border); }

.content h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem);
  font-weight: 900;
  margin: 0 0 6px;
  line-height: 1.4;
}

.content .lead {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 24px;
}

.content h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  margin: 40px 0 12px;
  padding-left: 14px;
  border-left: 5px solid var(--accent);
  line-height: 1.5;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.content h2:first-of-type { margin-top: 8px; }

.content h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 28px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.content h3::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}

.content p { margin: 0 0 16px; }
.content ul, .content ol { margin: 0 0 16px; padding-left: 1.4em; }
.content li { margin-bottom: 6px; }
.content strong { color: var(--text); }

/* 外部リンクにCSSで矢印アイコンを付与（絵文字は使わない） */
.content a[href^="http"]::after,
.related-links a[href^="http"]::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, 1px);
  margin-left: 5px;
  vertical-align: middle;
}

/* ==========================================================================
   ページ先頭：メタ情報カード（フロントマターから生成）
   ========================================================================== */
.page-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 14px 16px;
  margin: 0 0 28px;
}
.page-meta dt { font-size: .6875rem; color: var(--text-faint); margin: 0 0 3px; }
.page-meta dd { font-size: .8125rem; margin: 0; font-weight: 700; color: var(--text); }

/* ==========================================================================
   セクション単位のメタ表示（各見出し直下の「対象バージョン／情報の性質」）
   ========================================================================== */
.section-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px 14px;
}
.meta-chip {
  display: inline-flex;
  align-items: center;
  font-size: .6875rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}
.meta-chip.v-common      { }
.meta-chip.v-kakao-only  { color: var(--kakao);   border-color: var(--kakao);   background: var(--kakao-soft); }
.meta-chip.v-classic-only{ color: var(--classic); border-color: var(--classic); background: var(--classic-soft); }
.meta-chip.v-mixed       { background: linear-gradient(90deg, var(--kakao-soft), var(--classic-soft)); }

/* ==========================================================================
   版別ブロック（::: kakao / ::: classic から変換）
   ========================================================================== */
.v-block {
  border-left: 4px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  padding: 14px 16px 2px;
  margin: 0 0 18px 14px;
}
.v-block .v-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0 0 6px;
}
.v-block.v-kakao          { border-color: var(--kakao);   background: var(--kakao-soft); }
.v-block.v-kakao .v-label { color: var(--kakao); }
.v-block.v-classic          { border-color: var(--classic);   background: var(--classic-soft); }
.v-block.v-classic .v-label { color: var(--classic); }

/* 表示切り替えの本体：html[data-version] によって出し分け */
html[data-version="kakao"]   .v-block.v-classic { display: none; }
html[data-version="classic"] .v-block.v-kakao   { display: none; }
/* both のときは両方表示（打ち消しルールなし） */

/* ==========================================================================
   注記・補足（TBD／情報不足など、版に関係なく常時表示する注意書き）
   ========================================================================== */
.callout {
  border: 1px dashed var(--text-faint);
  border-radius: var(--radius-s);
  padding: 12px 16px;
  margin: 0 0 18px 14px;
  font-size: .9rem;
  color: var(--text-muted);
  background: var(--surface);
}
.callout strong { color: var(--text); }

/* ==========================================================================
   ページ内目次
   ========================================================================== */
.page-toc {
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--surface);
  margin: 0 0 28px;
}
.page-toc summary {
  cursor: pointer;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .875rem;
  list-style: none;
}
.page-toc summary::-webkit-details-marker { display: none; }
.page-toc summary::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  margin-right: 10px;
  transition: transform .15s ease;
}
.page-toc[open] summary::before { transform: rotate(45deg); }
.page-toc ol {
  margin: 0;
  padding: 0 16px 14px 34px;
  font-size: .8125rem;
  columns: 1;
}
.page-toc li { margin-bottom: 6px; }
.page-toc a { color: var(--text-muted); text-decoration: none; }
.page-toc a:hover { color: var(--accent); }

@media (min-width: 700px) {
  .page-toc ol { columns: 2; column-gap: 24px; }
}

/* ==========================================================================
   表
   ========================================================================== */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 20px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
}
.content table { border-collapse: collapse; width: 100%; font-size: .875rem; }
.content th, .content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.content thead th { background: var(--surface-alt); font-family: var(--font-display); }
.content tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   関連ページ・フッター
   ========================================================================== */
.related-links {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .875rem;
  color: var(--text-muted);
}
.related-links strong { color: var(--text); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 20px 40px;
  text-align: center;
  color: var(--text-faint);
  font-size: .75rem;
}

/* ==========================================================================
   トップページ専用コンポーネント
   （トップページのMarkdownから生成される想定の部品。共通CSSに含めてよい）
   ========================================================================== */
.hero-card {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-m);
  padding: 22px 24px;
  margin: 0 0 32px;
}
.hero-card .hero-eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}
.hero-card p { color: rgba(255,255,255,.9); margin: 0 0 14px; }
.hero-card a.cta {
  display: inline-block;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  font-size: .9375rem;
}
.hero-card a.cta:hover { background: var(--accent-soft); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 0 0 8px;
}
.category-grid .category-card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-m);
  padding: 16px 18px;
}
.category-grid .category-card h3 { margin: 0 0 10px; }
.category-grid .category-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.category-grid .category-card a { font-size: .8125rem; color: var(--text-muted); text-decoration: none; }
.category-grid .category-card a:hover { color: var(--accent); text-decoration: underline; }
