/* Cloudflare学習サイト共通スタイル */

:root {
  --bg: #faf9f7;
  --bg-card: #ffffff;
  --bg-code: #f3f1ee;
  --text: #24211d;
  --text-sub: #6b645c;
  --border: #e4e0da;
  --accent: #d95e00;
  --accent-soft: #fdf0e3;
  --accent-border: #f2c9a3;
  --link: #b34b00;
  --node-client: #eceae6;
  --node-client-border: #b8b2aa;
  --node-edge: #fdeedd;
  --node-edge-border: #e8a25c;
  --node-store: #e3edf8;
  --node-store-border: #7fa8d4;
  --node-ai: #eee7f8;
  --node-ai-border: #a98ad4;
  --node-ext: #e5f2e6;
  --node-ext-border: #7fb886;
  --ok: #2f7d3b;
  --ng: #b3403a;
  --shadow: 0 1px 3px rgba(30, 25, 18, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1a17;
    --bg-card: #26231f;
    --bg-code: #302c27;
    --text: #ece8e2;
    --text-sub: #a49c92;
    --border: #3b362f;
    --accent: #f0873a;
    --accent-soft: #38291c;
    --accent-border: #6b4a2b;
    --link: #f49b58;
    --node-client: #32302c;
    --node-client-border: #6b665e;
    --node-edge: #40301f;
    --node-edge-border: #c07f3e;
    --node-store: #24303e;
    --node-store-border: #5d84ad;
    --node-ai: #2f2739;
    --node-ai-border: #8a6cb4;
    --node-ext: #24332a;
    --node-ext-border: #5f9468;
    --ok: #6cbf78;
    --ng: #e08581;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 76px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic Medium", sans-serif;
  line-height: 1.85;
  font-size: 16px;
}

/* ヘッダー */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header .inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.brand .mark {
  display: inline-block;
  width: 22px;
  height: 14px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(135deg, #f6821f, #d95e00);
  flex: none;
}

.site-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 6px 0;
}

.site-nav a {
  color: var(--text-sub);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 8px;
}

.site-nav a:hover { background: var(--bg-code); color: var(--text); }

.site-nav a.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* レイアウト */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.page-title { font-size: 1.7rem; line-height: 1.4; margin: 8px 0 4px; }
.page-lead { color: var(--text-sub); margin: 0 0 28px; max-width: 46em; }

h2 {
  font-size: 1.3rem;
  margin: 52px 0 14px;
  padding-left: 12px;
  border-left: 4px solid var(--accent);
  line-height: 1.45;
}

h3 { font-size: 1.08rem; margin: 30px 0 10px; }

p { margin: 10px 0; }

a { color: var(--link); }

ul, ol { padding-left: 1.4em; }
li { margin: 4px 0; }

code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.86em;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.6;
}

pre code { background: none; border: none; padding: 0; font-size: 0.84rem; }

/* カード */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.card h3 { margin: 0 0 6px; }
.card p { margin: 6px 0; font-size: 0.93rem; color: var(--text-sub); }

a.card-link { text-decoration: none; color: inherit; display: block; }
a.card-link:hover .card { border-color: var(--accent-border); }
a.card-link .more { color: var(--accent); font-weight: 600; font-size: 0.9rem; }

/* バッジ */
.badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  vertical-align: 2px;
  margin-left: 8px;
  white-space: nowrap;
}

.badge.neutral {
  border-color: var(--border);
  background: var(--bg-code);
  color: var(--text-sub);
}

/* サービス解説 */
.service {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 24px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

.service h3 { margin: 0 0 8px; font-size: 1.12rem; }

.service .analogy {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.92rem;
  margin: 10px 0;
}

.service .doc-links { font-size: 0.9rem; margin-top: 10px; }

/* テーブル */
.table-wrap { overflow-x: auto; margin: 14px 0; }

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.92rem;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
}

th { background: var(--bg-code); font-size: 0.87rem; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

td.ok { color: var(--ok); }
td.ng { color: var(--ng); }

/* パターンセクション */
.pattern {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 28px;
  margin: 26px 0;
  box-shadow: var(--shadow);
}

.pattern-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.pattern-no {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
}

.pattern h3 { margin: 0; font-size: 1.22rem; }
.pattern .use-for { color: var(--text-sub); font-size: 0.93rem; margin: 6px 0 0; }

.diagram {
  margin: 18px 0;
  padding: 18px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
}

.diagram svg { display: block; margin: 0 auto; min-width: 640px; max-width: 100%; height: auto; }

/* SVGノード配色 */
.n-client { fill: var(--node-client); stroke: var(--node-client-border); }
.n-edge { fill: var(--node-edge); stroke: var(--node-edge-border); }
.n-store { fill: var(--node-store); stroke: var(--node-store-border); }
.n-ai { fill: var(--node-ai); stroke: var(--node-ai-border); }
.n-ext { fill: var(--node-ext); stroke: var(--node-ext-border); }

svg .node { stroke-width: 1.4; rx: 10; }

svg text {
  fill: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 13px;
}

svg text.sub { fill: var(--text-sub); font-size: 10.5px; }
svg text.flow-label { fill: var(--text-sub); font-size: 10.5px; }
svg .edge { stroke: var(--text-sub); stroke-width: 1.4; fill: none; }
svg .edge.dashed { stroke-dasharray: 5 4; }
svg .arrow-head { fill: var(--text-sub); }
svg .group-box { fill: none; stroke: var(--border); stroke-width: 1.2; stroke-dasharray: 3 4; }
svg text.group-label { fill: var(--text-sub); font-size: 10.5px; letter-spacing: 0.04em; }

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-sub);
  margin: 10px 0 0;
}

.legend span { display: inline-flex; align-items: center; gap: 6px; }

.legend i {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  display: inline-block;
  border: 1px solid;
}

.legend .l-client { background: var(--node-client); border-color: var(--node-client-border); }
.legend .l-edge { background: var(--node-edge); border-color: var(--node-edge-border); }
.legend .l-store { background: var(--node-store); border-color: var(--node-store-border); }
.legend .l-ai { background: var(--node-ai); border-color: var(--node-ai-border); }
.legend .l-ext { background: var(--node-ext); border-color: var(--node-ext-border); }

/* メリット・デメリット */
.pros-cons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}

@media (max-width: 720px) {
  .pros-cons { grid-template-columns: 1fr; }
}

.pros-cons > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.93rem;
}

.pros-cons h4 { margin: 0 0 6px; font-size: 0.92rem; }
.pros h4 { color: var(--ok); }
.cons h4 { color: var(--ng); }
.pros-cons ul { margin: 0; padding-left: 1.3em; }

/* 参考文献 */
.refs {
  border-top: 1px dashed var(--border);
  margin-top: 16px;
  padding-top: 10px;
  font-size: 0.88rem;
}

.refs .refs-title { font-weight: 600; color: var(--text-sub); font-size: 0.84rem; }
.refs ul { margin: 6px 0 0; }

/* 注意書き */
.note {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 0.94rem;
}

.note strong { color: var(--accent); }

/* 想定問答 */
details.qa {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 10px 0;
  padding: 0;
  overflow: hidden;
}

details.qa summary {
  cursor: pointer;
  padding: 12px 18px;
  font-weight: 600;
  list-style: none;
  position: relative;
  padding-right: 40px;
}

details.qa summary::-webkit-details-marker { display: none; }

details.qa summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-size: 1.15rem;
  font-weight: 700;
}

details.qa[open] summary::after { content: "−"; }
details.qa summary:hover { background: var(--bg-code); }

details.qa .qa-body {
  padding: 4px 18px 14px;
  border-top: 1px solid var(--border);
  font-size: 0.94rem;
}

/* ロードマップ */
.roadmap { counter-reset: step; margin: 18px 0; padding: 0; list-style: none; }

.roadmap li {
  position: relative;
  padding: 4px 0 18px 52px;
  margin: 0;
}

.roadmap li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.roadmap li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 17px;
  top: 40px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.roadmap b { display: block; }
.roadmap span { color: var(--text-sub); font-size: 0.92rem; }

/* フッター */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-sub);
  font-size: 0.85rem;
  text-align: center;
  padding: 26px 20px 40px;
}

.site-footer p { max-width: 720px; margin: 6px auto; }

/* ページ内目次 */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 0.92rem;
  margin: 18px 0 8px;
}

.toc b { font-size: 0.86rem; color: var(--text-sub); }
.toc ol { margin: 6px 0 0; }

@media (max-width: 640px) {
  html { scroll-padding-top: 170px; }
  body { font-size: 15px; }
  .page-title { font-size: 1.4rem; }
  .pattern { padding: 20px 16px; }
  .service { padding: 18px 16px; }
}
