/* ============================================
   React 入門ガイド - スタイルシート
   カラースキーム: React のブルーを基調
   ============================================ */

/* --- リセット・基本 --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.8;
  color: #333;
  background: #f4f6f9;
}

a {
  color: #087ea4;
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: #045b78;
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* --- ヘッダー --- */
.site-header {
  background: linear-gradient(135deg, #20232a 0%, #282c34 100%);
  color: #fff;
  padding: 1rem 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header a {
  color: #61dafb;
}

.site-header a:hover {
  color: #a8ecff;
  text-decoration: none;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-logo-link {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-logo {
  width: 40px;
  height: 40px;
  display: block;
}

.site-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
}

.site-title small {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.75;
  margin-left: 0.5rem;
  color: #61dafb;
}

.header-nav {
  display: flex;
  gap: 1.2rem;
  font-size: 0.9rem;
}

/* --- レイアウト --- */
.page-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  padding: 2rem;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  min-width: 0;
  background: #fff;
  border-radius: 8px;
  padding: 2.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* --- サイドバー目次 --- */
.toc {
  position: sticky;
  top: 5rem;
  background: #fff;
  border-radius: 8px;
  padding: 1.2rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
}

.toc h2 {
  font-size: 0.9rem;
  color: #087ea4;
  border-bottom: 2px solid #61dafb;
  padding-bottom: 0.5rem;
  margin-bottom: 0.8rem;
}

.toc ul {
  list-style: none;
}

.toc li {
  margin-bottom: 0.3rem;
}

.toc a {
  display: block;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  color: #555;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.toc a:hover {
  background: #e6f7ff;
  color: #087ea4;
  text-decoration: none;
}

.toc a.active {
  background: #087ea4;
  color: #fff;
}

.toc .toc-h3 {
  padding-left: 1.2rem;
  font-size: 0.8rem;
}

/* --- 見出し --- */
.main-content h1 {
  font-size: 1.8rem;
  color: #20232a;
  border-bottom: 3px solid #61dafb;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

.main-content h2 {
  font-size: 1.4rem;
  color: #333;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-left: 0.8rem;
  border-left: 4px solid #61dafb;
}

.main-content h3 {
  font-size: 1.15rem;
  color: #444;
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
}

.main-content h4 {
  font-size: 1rem;
  color: #555;
  margin-top: 1.2rem;
  margin-bottom: 0.5rem;
}

/* --- 段落・テキスト --- */
.main-content p {
  margin-bottom: 1rem;
}

.main-content ul, .main-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.main-content li {
  margin-bottom: 0.3rem;
}

.lead {
  font-size: 1.1rem;
  color: #555;
  margin-bottom: 1.5rem;
  line-height: 1.9;
}

/* --- コードブロック --- */
pre {
  background: #1e1e2e;
  color: #cdd6f4;
  border-radius: 6px;
  padding: 1.2rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  line-height: 1.6;
  border-left: 4px solid #61dafb;
}

code {
  font-family: "JetBrains Mono", "Source Code Pro", "Consolas", "Monaco", monospace;
  font-size: 0.9em;
}

:not(pre) > code {
  background: #e6f7ff;
  color: #087ea4;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

/* コードブロック内のシンタックスハイライト */
pre .keyword { color: #cba6f7; }
pre .string  { color: #a6e3a1; }
pre .comment { color: #6c7086; font-style: italic; }
pre .annotation { color: #f9e2af; }
pre .type    { color: #89b4fa; }
pre .number  { color: #fab387; }
pre .tag     { color: #f38ba8; }
pre .attr    { color: #a6e3a1; }
pre .attr-val{ color: #f9e2af; }
pre .func    { color: #89dceb; }
pre .component { color: #f9e2af; }
pre .hook    { color: #cba6f7; }
pre .punct   { color: #9399b2; }

/* ファイル名ラベル付きコードブロック */
.code-block {
  margin-bottom: 1.5rem;
}

.code-header {
  background: #313244;
  color: #bac2de;
  padding: 0.4rem 1rem;
  border-radius: 6px 6px 0 0;
  font-size: 0.8rem;
  font-family: "JetBrains Mono", "Source Code Pro", monospace;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-header .file-icon::before {
  content: "\1F4C4";
  margin-right: 0.3rem;
}

.code-block pre {
  border-radius: 0 0 6px 6px;
  margin-bottom: 0;
}

/* --- テーブル --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}

thead th {
  background: #20232a;
  color: #61dafb;
  padding: 0.7rem 1rem;
  text-align: left;
  font-weight: 600;
}

tbody td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #e0e4ea;
}

tbody tr:nth-child(even) {
  background: #f8f9fb;
}

tbody tr:hover {
  background: #e6f7ff;
}

/* --- 比較テーブル --- */
.comparison-table {
  border: 2px solid #61dafb;
  border-radius: 8px;
  overflow: hidden;
}

.comparison-table thead th:first-child {
  width: 30%;
}

/* --- 情報ボックス --- */
.info-box {
  padding: 1rem 1.2rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
}

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

.info-box.tip {
  background: #edf7ed;
  border-left: 4px solid #4caf50;
}

.info-box.tip::before {
  content: "TIP";
  display: block;
  font-weight: 700;
  color: #4caf50;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.info-box.warning {
  background: #fff8e1;
  border-left: 4px solid #ff9800;
}

.info-box.warning::before {
  content: "WARNING";
  display: block;
  font-weight: 700;
  color: #ff9800;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.info-box.note {
  background: #e6f7ff;
  border-left: 4px solid #087ea4;
}

.info-box.note::before {
  content: "NOTE";
  display: block;
  font-weight: 700;
  color: #087ea4;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

.info-box.important {
  background: #fce4ec;
  border-left: 4px solid #e53935;
}

.info-box.important::before {
  content: "IMPORTANT";
  display: block;
  font-weight: 700;
  color: #e53935;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
}

/* --- メリット・デメリットカード --- */
.merit-demerit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.merit, .demerit {
  padding: 1.2rem;
  border-radius: 8px;
}

.merit {
  background: #edf7ed;
  border: 2px solid #4caf50;
}

.merit h3 {
  color: #2e7d32;
  margin-top: 0;
}

.demerit {
  background: #fce4ec;
  border: 2px solid #e57373;
}

.demerit h3 {
  color: #c62828;
  margin-top: 0;
}

/* --- カード（トップページ用） --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.card {
  background: #fff;
  border: 1px solid #e0e4ea;
  border-radius: 8px;
  padding: 1.2rem;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

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

.card .card-number {
  display: inline-block;
  background: #087ea4;
  color: #fff;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.card h3 {
  margin-top: 0.3rem;
  margin-bottom: 0.5rem;
  font-size: 1.05rem;
}

.card h3 a {
  color: #333;
}

.card h3 a:hover {
  color: #087ea4;
}

.card p {
  font-size: 0.88rem;
  color: #666;
  flex: 1;
}

/* --- 前後ナビゲーション --- */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e0e4ea;
  gap: 1rem;
}

.page-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  background: #e6f7ff;
  border-radius: 6px;
  border: 1px solid #61dafb;
  color: #087ea4;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s;
  max-width: 48%;
}

.page-nav a:hover {
  background: #087ea4;
  color: #fff;
  text-decoration: none;
}

.page-nav .prev::before {
  content: "\2190";
  font-size: 1.1rem;
}

.page-nav .next::after {
  content: "\2192";
  font-size: 1.1rem;
}

.page-nav .next {
  margin-left: auto;
  text-align: right;
}

/* --- フッター --- */
.site-footer {
  background: #20232a;
  color: #999;
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  margin-top: 2rem;
}

.site-footer a {
  color: #61dafb;
}

/* --- バッジ --- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-version {
  background: #087ea4;
  color: #fff;
}

.badge-node {
  background: #3c873a;
  color: #fff;
}

.badge-new {
  background: #61dafb;
  color: #20232a;
}

/* --- ステップ手順 --- */
.steps {
  counter-reset: step-counter;
  list-style: none;
  padding-left: 0;
}

.steps li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 3rem;
  margin-bottom: 1.5rem;
}

.steps li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  line-height: 2rem;
  text-align: center;
  background: #087ea4;
  color: #fff;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
}

/* --- コードペア表示 --- */
.code-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.code-pair .code-block {
  margin-bottom: 0;
}

/* --- レスポンシブ --- */
@media (max-width: 900px) {
  .page-wrapper {
    flex-direction: column;
    padding: 1rem;
  }

  .sidebar {
    width: 100%;
    order: -1;
  }

  .toc {
    position: static;
    max-height: none;
  }

  .main-content {
    padding: 1.5rem;
  }

  .code-pair {
    grid-template-columns: 1fr;
  }

  .merit-demerit {
    grid-template-columns: 1fr;
  }

  .header-nav {
    display: none;
  }
}

@media (max-width: 600px) {
  html {
    font-size: 14px;
  }

  .main-content h1 {
    font-size: 1.4rem;
  }

  .main-content h2 {
    font-size: 1.2rem;
  }

  .page-nav {
    flex-direction: column;
  }

  .page-nav a {
    max-width: 100%;
  }

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