/* ==========================================================================
   Claude Code Starter Kit - ドキュメントサイト スタイルシート
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS カスタムプロパティ（カラーパレット）
   -------------------------------------------------------------------------- */

[data-theme="light"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #e0e7ff;
  --bg: #ffffff;
  --bg-secondary: #f8fafc;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

[data-theme="dark"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --bg: #0f172a;
  --bg-secondary: #1e293b;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --border: #334155;
  --code-bg: #1e293b;
  --code-text: #e2e8f0;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

/* --------------------------------------------------------------------------
   リセット・ベーススタイル
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--primary);
  color: white;
}

/* スクロールバー (WebKit) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-hover);
}

/* --------------------------------------------------------------------------
   レイアウト
   -------------------------------------------------------------------------- */

.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .top-header {
  background: rgba(15, 23, 42, 0.8);
}

.layout {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidebar {
  width: 280px;
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 1rem 0;
  z-index: 99;
}

.main-content {
  flex: 1;
  padding: 2rem 3rem;
  max-width: 960px;
  margin: 0 auto;
  margin-left: 280px;
  min-height: calc(100vh - 60px);
}

.content-wrapper {
  width: 100%;
}

/* --------------------------------------------------------------------------
   ヘッダー
   -------------------------------------------------------------------------- */

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 0.3s ease;
}

.header-logo {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--primary);
}

.header-logo:hover {
  text-decoration: none;
}

.header-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text);
  font-size: 1.1rem;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  background: var(--bg-secondary);
  border-color: var(--primary);
}

.github-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 0.2s;
}

.github-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   サイドバー
   -------------------------------------------------------------------------- */

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li a {
  display: block;
  padding: 0.5rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.sidebar-nav li a:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.sidebar-nav li a.active {
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
  background: var(--primary-light);
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 1.5rem 1.5rem 0.5rem;
  list-style: none;
}

/* --------------------------------------------------------------------------
   タイポグラフィ
   -------------------------------------------------------------------------- */

h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-bottom: 1rem;
  color: var(--text);
}

h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

p {
  line-height: 1.8;
  margin-bottom: 1rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  line-height: 1.8;
}

li {
  margin-bottom: 0.25rem;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

strong {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   コードブロック
   -------------------------------------------------------------------------- */

code {
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

/* インラインコード */
code {
  background: var(--bg-secondary);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.875em;
  color: var(--primary);
}

/* コードブロック */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.25rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.7;
  margin: 1.5rem 0;
  position: relative;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* コードヘッダー（ファイル名表示） */
.code-header {
  background: #334155;
  color: #94a3b8;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem 0.75rem 0 0;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-header + pre {
  border-radius: 0 0 0.75rem 0.75rem;
  margin-top: 0;
}

/* コピーボタン */
.copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  padding: 0.3rem 0.6rem;
  border-radius: 0.375rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  transition: all 0.2s;
  opacity: 0;
}

pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

.copy-btn.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   コンポーネント: Feature Cards
   -------------------------------------------------------------------------- */

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  margin: 1rem 0;
  background: var(--bg);
  transition: all 0.3s;
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

a.feature-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

a.feature-card:hover {
  text-decoration: none;
}

.feature-card .card-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}

.feature-card .card-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.feature-card .card-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   コンポーネント: Callout
   -------------------------------------------------------------------------- */

.callout {
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  margin: 1.5rem 0;
  border-left: 4px solid;
}

.callout.info {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: var(--info);
}

.callout.warning {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: var(--warning);
}

.callout.danger {
  background: rgba(239, 68, 68, 0.08);
  border-left-color: var(--danger);
}

.callout.tip {
  background: rgba(16, 185, 129, 0.08);
  border-left-color: var(--success);
}

.callout-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.callout p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   コンポーネント: テーブル
   -------------------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

th {
  background: var(--bg-secondary);
  font-weight: 600;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

tr:hover td {
  background: var(--bg-secondary);
}

/* --------------------------------------------------------------------------
   コンポーネント: Badge
   -------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.15em 0.5em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   コンポーネント: Hero
   -------------------------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 4rem 2rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, #f0f9ff 100%);
  border-radius: 1rem;
  margin-bottom: 3rem;
}

.hero.hero-compact {
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 2rem;
}

.hero.hero-compact h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.hero.hero-compact .hero-subtitle {
  margin-bottom: 0;
}

[data-theme="dark"] .hero {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(59, 130, 246, 0.1) 100%);
}

.hero h1 {
  font-size: 2.75rem;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

/* --------------------------------------------------------------------------
   コンポーネント: 目次 (TOC)
   -------------------------------------------------------------------------- */

.toc {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  background: var(--bg-secondary);
}

.toc-title {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.toc ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 0;
}

.toc li {
  padding: 0.25rem 0;
}

.toc li.toc-h3 {
  padding-left: 1rem;
}

.toc a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
  transition: color 0.2s;
}

.toc a:hover {
  color: var(--primary);
  text-decoration: none;
}

.toc a.active {
  color: var(--primary);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   コンポーネント: 検索
   -------------------------------------------------------------------------- */

.search-wrapper,
.search-container {
  position: relative;
}

.search-input {
  width: 200px;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  transition: all 0.2s;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  width: 260px;
}

.search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-kbd {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 0.1em 0.4em;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  pointer-events: none;
}

/* 検索ハイライト */
mark.search-highlight {
  background: rgba(245, 158, 11, 0.3);
  color: inherit;
  padding: 0.05em 0.15em;
  border-radius: 0.15rem;
}

/* 検索結果ドロップダウン */
.search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 420px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  z-index: 200;
  margin-top: 0.5rem;
}

.search-result-item {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background: var(--bg-secondary);
  text-decoration: none;
}

.search-result-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: var(--primary);
}

.search-result-excerpt {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.search-result-item mark {
  background: rgba(245, 158, 11, 0.3);
  color: inherit;
  padding: 0.05em 0.1em;
  border-radius: 0.15rem;
}

.search-no-results {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  .search-dropdown {
    width: calc(100vw - 2rem);
    right: -1rem;
  }

  .search-input:focus {
    width: 200px;
  }
}

/* --------------------------------------------------------------------------
   コンポーネント: Mermaid ダイアグラム
   -------------------------------------------------------------------------- */

.mermaid {
  margin: 1.5rem 0;
  text-align: center;
  overflow-x: auto;
}

.mermaid svg {
  max-width: 100%;
  height: auto;
}

.diagram-wrapper {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg);
  overflow-x: auto;
}

.diagram-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.75rem;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   オーバーレイ（モバイルサイドバー用）
   -------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 98;
  display: none;
}

.overlay.show {
  display: block;
}

/* --------------------------------------------------------------------------
   レスポンシブ (max-width: 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 60px;
    bottom: 0;
    z-index: 99;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    padding: 1.5rem 1rem;
  }

  .menu-toggle {
    display: flex;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 140px;
  }

  .search-input:focus {
    width: 180px;
  }

  .search-kbd {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   印刷用スタイル
   -------------------------------------------------------------------------- */

@media print {
  .top-header,
  .sidebar,
  .overlay,
  .menu-toggle,
  .theme-toggle,
  .copy-btn,
  .search-wrapper,
.search-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 0;
  }

  .feature-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
