/* ══════════════════════════════════════════════════════
   TOKENS  (shared with index.html)
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream:    #f4f0e8;
  --cream2:   #ede8dc;
  --cream3:   #e5dfd0;
  --navy:     #0c1a2e;
  --navy2:    #152540;
  --navy3:    #1e3358;
  --copper:   #b86b2a;
  --copper2:  #d4833a;
  --copper-rgb: 184, 107, 42;
  --text:     #1a2a3a;
  --sub:      #4a607a;
  --dim:      #7a92a8;
  --rule:     rgba(12, 26, 46, 0.12);
  --rule-h:   rgba(12, 26, 46, 0.06);

  --f-display: 'Cormorant Garamond', 'Noto Serif JP', Georgia, serif;
  --f-mono:    'IBM Plex Mono', 'Courier New', monospace;
  --f-body:    'Noto Serif JP', Georgia, serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--cream);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.8;
  overflow-x: hidden;
}

/* Grain + blueprint grid */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none; opacity: 0.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='0.08'/%3E%3C/svg%3E");
}
body::after {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--rule-h) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule-h) 1px, transparent 1px);
  background-size: 60px 60px;
}

.page { position: relative; z-index: 1; }

/* ══════════════════════════════════════════════════════
   NAV
══════════════════════════════════════════════════════ */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 52px;
  height: 64px;
  background: rgba(244, 240, 232, 0.92);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--rule);
}
.logo {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--navy);
  font-family: var(--f-display);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
}
.logo-mark {
  width: 28px; height: 28px;
  border: 1.5px solid var(--copper);
  border-radius: 5px;
  display: grid; place-items: center;
  position: relative;
}
.logo-mark::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--copper);
  border-radius: 2px;
  animation: logobeat 2.8s ease-in-out infinite;
}
@keyframes logobeat {
  0%,100%{ transform:scale(1); opacity:1; }
  50%{ transform:scale(0.55); opacity:0.35; }
}
.nav-links { display: flex; gap: 36px; list-style: none; }
.nav-links a {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--sub); text-decoration: none;
  transition: color 0.2s; position: relative;
}
.nav-links a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 1px; background: var(--copper);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.24s;
}
.nav-links a:hover { color: var(--navy); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); }
.nav-links a.active { color: var(--navy); }

.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-gh {
  font-family: var(--f-mono);
  font-size: 14.5px; font-weight: 500;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--navy); text-decoration: none;
  border: 1px solid var(--rule);
  padding: 7px 16px; border-radius: 6px;
  display: flex; align-items: center; gap: 7px;
  background: transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.nav-gh:hover { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.nav-gh svg { width: 14px; height: 14px; fill: currentColor; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════
   PAGE HERO
══════════════════════════════════════════════════════ */
.ex-hero {
  padding: 128px 52px 64px;
  max-width: 1080px; margin: 0 auto;
}
.ex-hero-index {
  font-family: var(--f-mono);
  font-size: 14px; font-weight: 400;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--copper);
  margin-bottom: 28px;
  display: flex; align-items: center; gap: 12px;
}
.ex-hero-index::before {
  content: ''; width: 32px; height: 1px; background: var(--copper);
}
.ex-hero h1 {
  font-family: var(--f-display);
  font-size: clamp(40px, 5.5vw, 68px);
  font-weight: 300; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--navy);
}
.ex-hero h1 em { font-style: italic; color: var(--copper); font-weight: 300; }
.ex-hero p {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 300;
  color: var(--sub); line-height: 1.85;
  margin-top: 28px; max-width: 640px;
  border-left: 2px solid var(--copper);
  padding-left: 18px;
}
.back-link {
  font-family: var(--f-mono);
  font-size: 14px; letter-spacing: 0.08em;
  color: var(--sub); text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 36px; transition: color 0.2s;
}
.back-link:hover { color: var(--copper); }
.back-link svg { width: 13px; height: 13px; fill: currentColor; }

/* ══════════════════════════════════════════════════════
   EXAMPLE  BLOCK
══════════════════════════════════════════════════════ */
.example {
  max-width: 1080px; margin: 0 auto;
  padding: 0 52px 96px;
}

/* Example header banner */
.ex-banner {
  background: var(--navy);
  border-radius: 12px;
  padding: 44px 44px 40px;
  position: relative; overflow: hidden;
  margin-bottom: 8px;
}
.ex-banner::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--copper), var(--copper2), transparent);
}
.ex-banner::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 44px 44px; pointer-events: none;
}
.ex-banner-inner { position: relative; z-index: 1; }
.ex-num {
  font-family: var(--f-mono);
  font-size: 14px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--copper2); margin-bottom: 18px;
}
.ex-banner h2 {
  font-family: var(--f-display);
  font-size: clamp(30px, 4vw, 44px);
  font-weight: 600; color: var(--cream);
  letter-spacing: -0.02em; line-height: 1.15;
  margin-bottom: 14px;
}
.ex-banner-desc {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 300;
  color: rgba(244,240,232,0.62); line-height: 1.8;
  max-width: 720px;
}
.ex-meta {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; margin-top: 32px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; overflow: hidden;
  background: rgba(255,255,255,0.06);
}
.ex-meta-cell { background: rgba(255,255,255,0.03); padding: 18px 20px; }
.ex-meta-k {
  font-family: var(--f-mono);
  font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgba(244,240,232,0.4); margin-bottom: 8px;
}
.ex-meta-v {
  font-family: var(--f-mono);
  font-size: 14.5px; font-weight: 400;
  color: rgba(244,240,232,0.9); line-height: 1.5;
}
.ex-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.ex-tag {
  font-family: var(--f-mono);
  font-size: 13px; letter-spacing: 0.06em;
  color: var(--copper2);
  border: 1px solid rgba(var(--copper-rgb), 0.4);
  border-radius: 4px; padding: 5px 12px;
}

/* ── Article layout: sticky TOC + content ── */
.article-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 52px;
  margin-top: 56px;
  align-items: start;
}
.toc {
  position: sticky; top: 88px;
  font-family: var(--f-mono);
  border-left: 1px solid var(--rule);
  padding-left: 20px;
}
.toc-title {
  font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--copper); margin-bottom: 16px;
}
.toc ol { list-style: none; display: flex; flex-direction: column; gap: 9px; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  font-size: 13.5px; color: var(--sub);
  text-decoration: none; line-height: 1.4;
  display: flex; gap: 8px; transition: color 0.2s;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--copper); flex-shrink: 0; opacity: 0.7;
}
.toc a:hover { color: var(--navy); }

/* ── Article typography ── */
.article { min-width: 0; }
.article h3 {
  font-family: var(--f-display);
  font-size: 28px; font-weight: 600;
  color: var(--navy); letter-spacing: -0.02em;
  line-height: 1.2; scroll-margin-top: 84px;
  padding-top: 40px; margin-bottom: 8px;
  border-top: 1px solid var(--rule);
}
.article h3:first-child { padding-top: 0; border-top: none; }
.article h3 .h3-n {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 500;
  color: var(--copper); letter-spacing: 0.12em;
  display: block; margin-bottom: 6px;
}
.article h4 {
  font-family: var(--f-display);
  font-size: 20px; font-weight: 600;
  color: var(--navy2); letter-spacing: -0.01em;
  margin-top: 32px; margin-bottom: 6px;
}
.article p {
  font-size: 15.5px; color: var(--text);
  line-height: 1.85; margin-top: 14px;
}
.article ul, .article ol.list { margin: 14px 0 0; padding-left: 4px; list-style: none; }
.article ul li, .article ol.list li {
  font-size: 15px; color: var(--text);
  line-height: 1.75; margin-top: 9px;
  position: relative; padding-left: 24px;
}
.article ul li::before {
  content: '—'; color: var(--copper);
  position: absolute; left: 0; top: 0;
}
.article ol.list { counter-reset: ol; }
.article ol.list li { counter-increment: ol; }
.article ol.list li::before {
  content: counter(ol); color: var(--copper);
  font-family: var(--f-mono); font-size: 14px;
  position: absolute; left: 0; top: 0.08em;
}
.article ul ul { margin-top: 6px; }
.article strong { font-weight: 600; color: var(--navy); }
.article a.inline { color: var(--copper); text-decoration: none; border-bottom: 1px solid rgba(var(--copper-rgb),0.35); }
.article code.ic {
  font-family: var(--f-mono); font-size: 13.5px;
  background: var(--cream3); color: var(--navy2);
  padding: 2px 6px; border-radius: 4px;
}

/* Tables */
.tbl-wrap { overflow-x: auto; margin-top: 20px; border-radius: 8px; border: 1px solid var(--rule); }
table.md {
  border-collapse: collapse; width: 100%;
  font-family: var(--f-mono); font-size: 14px;
  background: var(--cream);
}
table.md thead th {
  background: var(--cream3); color: var(--navy);
  font-weight: 600; text-align: left;
  padding: 12px 16px; letter-spacing: 0.02em;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
table.md tbody td {
  padding: 12px 16px; color: var(--sub);
  border-bottom: 1px solid var(--rule-h);
  vertical-align: top; line-height: 1.6;
}
table.md tbody tr:last-child td { border-bottom: none; }
table.md tbody tr:hover td { background: rgba(255,255,255,0.4); }
table.md td strong { color: var(--copper); }

/* Code blocks */
pre.code {
  margin-top: 20px;
  background: var(--navy);
  border-radius: 8px;
  padding: 22px 24px;
  overflow-x: auto;
  border: 1px solid var(--rule);
  position: relative;
}
pre.code::before {
  content: attr(data-lang);
  position: absolute; top: 10px; right: 14px;
  font-family: var(--f-mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(244,240,232,0.35);
}
pre.code code {
  font-family: var(--f-mono);
  font-size: 13.5px; line-height: 1.75;
  color: rgba(244,240,232,0.88);
  white-space: pre; display: block;
}
pre.code code .cmt { color: rgba(244,240,232,0.4); }
pre.code.ascii code { color: var(--copper2); }

/* Callouts (blockquotes) */
.callout {
  margin-top: 20px;
  background: var(--cream2);
  border-left: 3px solid var(--copper);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  font-size: 14.5px; color: var(--sub);
  line-height: 1.7;
}
.callout.warn {
  border-left-color: #c2571f;
  background: rgba(194, 87, 31, 0.06);
}
.callout strong { color: var(--navy); }
.callout code.ic { background: var(--cream3); }

/* ── Model diagrams block ── */
.models { margin-top: 44px; }
.models-head { margin-bottom: 22px; }
.models-index {
  font-family: var(--f-mono);
  font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--copper); margin-bottom: 12px;
  display: flex; align-items: center; gap: 12px;
}
.models-index::before { content: ''; width: 28px; height: 1px; background: var(--copper); }
.models-head h3 {
  font-family: var(--f-display);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 500; color: var(--navy);
  letter-spacing: -0.02em; line-height: 1.15;
}
.models-head p {
  font-family: var(--f-mono);
  font-size: 14.5px; font-weight: 300;
  color: var(--sub); line-height: 1.8;
  margin-top: 12px; max-width: 760px;
}
figure.diagram {
  margin-top: 26px;
  border: 1px solid var(--rule);
  border-radius: 10px; overflow: hidden;
  background: #ffffff;
  box-shadow: 0 10px 40px rgba(12,26,46,0.08);
}
.diagram-label {
  font-family: var(--f-mono);
  font-size: 13px; letter-spacing: 0.06em;
  color: var(--cream); background: var(--navy);
  padding: 11px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.diagram-label .tag {
  color: var(--copper2); text-transform: uppercase; letter-spacing: 0.14em;
  font-size: 11px;
}
.diagram-scroll { overflow-x: auto; padding: 24px; background: #ffffff; }
figure.diagram img { display: block; height: auto; }
figure.diagram.usecase img { width: 100%; min-width: 640px; max-width: 1000px; margin: 0 auto; }
figure.diagram.classd img { width: 100%; min-width: 1100px; }
figure.diagram figcaption {
  font-family: var(--f-mono);
  font-size: 12.5px; color: var(--dim);
  letter-spacing: 0.04em;
  padding: 11px 18px;
  border-top: 1px solid var(--rule);
  background: var(--cream);
}
figure.diagram figcaption a { color: var(--copper); text-decoration: none; }
figure.diagram figcaption a:hover { text-decoration: underline; }

/* Screenshots / figures */
figure.shot {
  margin-top: 26px;
  border: 1px solid var(--rule);
  border-radius: 10px; overflow: hidden;
  background: var(--cream2);
  box-shadow: 0 10px 40px rgba(12,26,46,0.08);
}
figure.shot img { display: block; width: 100%; height: auto; }
figure.shot figcaption {
  font-family: var(--f-mono);
  font-size: 13px; color: var(--dim);
  letter-spacing: 0.04em;
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
  background: var(--cream);
}
figure.shot figcaption::before {
  content: '▸ '; color: var(--copper);
}

/* ── 縦長・原寸表示の図（俯瞰クラス図など） ── */
figure.diagram.narrow img { width: 100%; min-width: 0; max-width: 820px; margin: 0 auto; }

/* ── ドメイン別クラス図ギャラリー ── */
.diagram-gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px; margin-top: 26px;
}
.dg-item {
  display: flex; flex-direction: column;
  border: 1px solid var(--rule); border-radius: 10px; overflow: hidden;
  background: #fff; text-decoration: none;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.dg-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(12,26,46,.14);
  border-color: rgba(var(--copper-rgb),.45);
}
.dg-thumb { height: 150px; overflow: hidden; background: #fff; border-bottom: 1px solid var(--rule); }
.dg-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.dg-cap {
  font-family: var(--f-mono); font-size: 12.5px; color: var(--navy);
  padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dg-cap .n { color: var(--copper); font-size: 11px; letter-spacing: .1em; }

/* ── iOS device screenshots (portrait) ── */
.ios-shots {
  display: flex; flex-wrap: wrap; gap: 26px 34px;
  justify-content: center; margin-top: 26px;
}
figure.shot-ios {
  margin: 26px auto 6px;
  width: 250px; max-width: 72vw;
  border: 9px solid var(--navy);
  border-radius: 30px;
  overflow: hidden;
  background: var(--navy);
  box-shadow: 0 16px 46px rgba(12,26,46,0.20);
}
.ios-shots figure.shot-ios { margin: 0; }
figure.shot-ios img { display: block; width: 100%; height: auto; border-radius: 21px; }
figure.shot-ios figcaption {
  font-family: var(--f-mono); font-size: 12px; color: var(--dim);
  letter-spacing: 0.04em; text-align: center;
  padding: 10px 10px 2px; background: transparent;
}
figure.shot-ios figcaption::before { content: '▸ '; color: var(--copper); }

/* iOS sub-banner label chip */
.ios-platform {
  display: inline-flex; align-items: center; gap: 8px;
}

/* Source footer note */
.src-note {
  max-width: 1080px; margin: 0 auto;
  padding: 0 52px 96px;
}
.src-note-inner {
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  font-family: var(--f-mono);
  font-size: 13.5px; color: var(--dim);
  font-style: italic; line-height: 1.7;
}

/* ══════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════ */
footer {
  padding: 28px 52px;
  border-top: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
}
.footer-left { font-family: var(--f-mono); font-size: 15px; color: var(--dim); }
.footer-right { display: flex; gap: 28px; list-style: none; }
.footer-right a {
  font-family: var(--f-mono); font-size: 15px;
  color: var(--dim); text-decoration: none;
  transition: color 0.2s;
}
.footer-right a:hover { color: var(--copper); }

/* Reveal */
/* JS が動く場合のみ隠す（JS 失敗時も本文が読めるようにするための保険） */
html.js .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s, transform 0.6s; }
html.js .reveal.in { opacity: 1; transform: none; }

/* 動きを減らす設定の利用者には演出を無効化 */
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; transition: none; }
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  nav { padding: 0 24px; }
  .nav-links { display: none; }
  .ex-hero, .example, .src-note { padding-left: 24px; padding-right: 24px; }
  .article-shell { grid-template-columns: 1fr; gap: 32px; }
  .toc { position: static; border-left: none; padding-left: 0;
         border-top: 1px solid var(--rule); padding-top: 24px; }
  .toc ol { display: grid; grid-template-columns: 1fr 1fr; }
  .ex-meta { grid-template-columns: 1fr; }
  footer { padding: 24px; flex-direction: column; gap: 16px; text-align: center; }
}

/* ══════════════════════════════════════════════════════
   EXAMPLES INDEX CARDS
══════════════════════════════════════════════════════ */
.examples-index { max-width: 1080px; margin: 0 auto; padding: 8px 52px 100px; }
.ex-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.ex-card {
  display: flex; flex-direction: column;
  background: var(--cream2); border: 1px solid var(--rule);
  border-radius: 12px; overflow: hidden; text-decoration: none;
  transition: transform .25s, box-shadow .25s, border-color .25s;
}
.ex-card:hover { transform: translateY(-5px); box-shadow: 0 18px 48px rgba(12,26,46,.14); border-color: rgba(var(--copper-rgb),.4); }
.ex-card-thumb { position: relative; aspect-ratio: 16/9; overflow: hidden; background: var(--navy); border-bottom: 1px solid var(--rule); }
.ex-card-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.ex-card-thumb::before { content:''; position:absolute; top:0; left:0; right:0; height:3px; background: linear-gradient(90deg,var(--copper),var(--copper2),transparent); z-index:1; }
.ex-card-body { padding: 26px 28px 28px; display: flex; flex-direction: column; flex: 1; }
.ex-card-num { font-family: var(--f-mono); font-size: 12px; letter-spacing:.18em; text-transform: uppercase; color: var(--copper); margin-bottom: 12px; }
.ex-card h3 { font-family: var(--f-display); font-size: 27px; font-weight: 600; color: var(--navy); letter-spacing:-.02em; line-height: 1.2; margin-bottom: 10px; }
.ex-card p { font-family: var(--f-mono); font-size: 13.5px; font-weight: 300; color: var(--sub); line-height: 1.7; margin-bottom: 18px; }
.ex-card-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 22px; }
.ex-card-tag { font-family: var(--f-mono); font-size: 12px; color: var(--sub); border:1px solid var(--rule); border-radius: 4px; padding: 4px 10px; }
.ex-card-cta { margin-top: auto; font-family: var(--f-mono); font-size: 14px; letter-spacing:.06em; color: var(--copper); display: inline-flex; align-items: center; gap: 8px; transition: gap .2s; }
.ex-card:hover .ex-card-cta { gap: 13px; }
@media (max-width: 1024px){
  .examples-index { padding-left: 24px; padding-right: 24px; }
  .ex-grid { grid-template-columns: 1fr; }
}
