/* ============================================================
   土木工事共通仕様書 Web 版 スタイルシート
   ============================================================ */

:root {
  --sidebar-width: 280px;
  --otp-width: 220px;
  --header-height: 50px;
  --color-primary: #1a4c8b;
  --color-text: #333;
  --color-bg: #fff;
  --color-sidebar-bg: #f4f6f9;
  --color-border: #dde3ec;
  --color-inyou-border: #2563eb;
  --color-kurowaku-border: #333;
  --color-pbox-bg: #f3e8ff;
  --font-body: "Noto Serif JP", "游明朝", "Yu Mincho", serif;
  --font-ui: "Noto Sans JP", "游ゴシック", "Yu Gothic", sans-serif;
}

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

html { scroll-behavior: smooth; font-size: 16px; scroll-padding-top: calc(var(--header-height) + 8px); }

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.8;
}

/* ── ヘッダー ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--color-primary);
  color: #fff;
  z-index: 100;
  display: flex;
  align-items: center;
}
.site-header-inner { padding: 0 1rem; }
.site-title {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 700;
}

/* ── レイアウト ── */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* ── サイドバー ── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}
.sidebar-inner { padding: 1rem 0; }

.toc { font-family: var(--font-ui); font-size: 0.85rem; }
.toc > ul { list-style: none; }

.toc-part { border-bottom: 1px solid var(--color-border); }
.toc-part-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-part-link {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text);
  text-decoration: none;
  flex: 1;
  font-weight: 600;
}
.toc-part-link:hover { color: var(--color-primary); }

.toc-expander {
  background: none;
  border: none;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 0.75rem;
  color: #666;
  transition: transform 0.2s;
}
.toc-expander[aria-expanded="true"] { transform: rotate(180deg); }

.toc-sub {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.toc-sub.is-open { max-height: 2000px; }
.toc-sub li a {
  display: block;
  padding: 0.3rem 1rem 0.3rem 1.8rem;
  color: #555;
  text-decoration: none;
  font-size: 0.82rem;
}
.toc-sub li a:hover { color: var(--color-primary); }
.toc-sub li a.is-current { color: var(--color-primary); font-weight: 700; }

/* ── サイドバー内 節リスト（現章の下に展開） ── */
.toc-sec {
  list-style: none;
  padding: 0;
  margin: 0.2rem 0 0.4rem 0;
}
.toc-sec li a {
  display: block;
  padding: 0.2rem 1rem 0.2rem 2.4rem;
  color: #666;
  text-decoration: none;
  font-size: 0.78rem;
  line-height: 1.4;
}
.toc-sec li a:hover { color: var(--color-primary); }
.toc-sec li a.is-current {
  color: var(--color-primary);
  font-weight: 700;
}

/* ── メインコンテンツ ── */
.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem;
}

.sheet { max-width: 900px; }

.sheet header h1 {
  font-size: 1.5rem;
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
}

/* ── 見出し ── */
h2 {
  font-size: 1.3rem;
  color: var(--color-primary);
  border-left: 4px solid var(--color-primary);
  padding: 0.3rem 0.8rem;
  margin: 2rem 0 1rem;
  background: #f0f4fb;
}
h3 {
  font-size: 1.15rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.3rem;
  margin: 1.5rem 0 0.8rem;
}
h4 {
  font-size: 1.05rem;
  margin: 1.2rem 0 0.5rem;
}
h5 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}

/* ── 本文 ── */
p { margin: 0.4rem 0; }
p + p { margin-top: 0.4rem; }

.p-indent { padding-left: 2em; }

/* ── 法令引用 ── */
figure.inyou {
  border-left: 4px solid var(--color-inyou-border);
  background: #eff6ff;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  border-radius: 0 4px 4px 0;
}
figure.inyou p strong { color: var(--color-inyou-border); }

/* ── 参考ブロック ── */
figure.kurowaku {
  border: 1px solid var(--color-kurowaku-border);
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  font-style: italic;
}

/* ── ポイントボックス ── */
div.p-box {
  background: var(--color-pbox-bg);
  border-left: 4px solid #9333ea;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  border-radius: 0 4px 4px 0;
}

/* ── 表 ── */
figure.tbl {
  margin: 1rem 0;
  overflow-x: auto;
}
figure.tbl figcaption {
  font-weight: 700;
  margin-bottom: 0.4rem;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
  table-layout: fixed;
  word-break: break-all;
}
th, td {
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  vertical-align: middle;
}
th {
  background: #e8edf5;
  font-weight: 700;
  vertical-align: middle;
  text-align: center;
}
/* セル内インライン配置（convert_zuhyo.py が生成） */
td span[style*="text-align:center"],
th span[style*="text-align:center"] { text-align: center; }
td span[style*="text-align:right"],
th span[style*="text-align:right"] { text-align: right; }
/* セル内 <br> による複数行テキストの行間 */
td br { display: block; content: ""; margin-top: 0.25rem; }

/* ── 図 ── */
figure.fig {
  margin: 1rem 0;
  text-align: center;
}
figure.fig img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
}
p.c { text-align: center; }
p.r { text-align: right; }

/* ── 図リンク（サムネイル） ── */
p.c a img {
  max-width: 320px;
  cursor: zoom-in;
}

/* ── ページナビ ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}
.page-nav a {
  color: var(--color-primary);
  text-decoration: none;
}
.page-nav a:hover { text-decoration: underline; }

/* ── 図サブページ ── */
body.subpage-wide { padding: 1rem; }
body.subpage-wide .sheet { max-width: 100%; }
body.subpage-wide figure.fig img { max-width: 100%; }
.close-area { text-align: center; margin-top: 1rem; }
.close-area button {
  padding: 0.4rem 1.2rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui);
}

/* ── On This Page パネル ── */
.otp-panel {
  width: var(--otp-width);
  flex-shrink: 0;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  background: var(--color-bg);
}
.otp-inner { display: flex; flex-direction: column; gap: 0; }

.otp-heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 0.5rem;
  margin-top: 1.2rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--color-border);
}
.otp-heading:first-child { margin-top: 0; }

.otp-list, .otp-ref-list { list-style: none; }

.otp-h3 > a {
  display: block;
  padding: 0.25rem 0.4rem;
  color: #555;
  text-decoration: none;
  border-radius: 3px;
  line-height: 1.4;
  font-size: 0.8rem;
}
.otp-h4 > a {
  display: block;
  padding: 0.2rem 0.4rem 0.2rem 1.1rem;
  color: #777;
  text-decoration: none;
  font-size: 0.75rem;
  border-radius: 3px;
  line-height: 1.4;
}
.otp-ref-list li > a {
  display: block;
  padding: 0.2rem 0.4rem;
  color: #777;
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.4;
}
.otp-h3 > a:hover,
.otp-h4 > a:hover,
.otp-ref-list a:hover { color: var(--color-primary); background: #f5f7fb; }

.otp-h3 > a.is-active,
.otp-h4 > a.is-active {
  color: var(--color-primary);
  font-weight: 700;
  background: #eef2fb;
}

/* ── 図表インライン展開（本文ページ） ── */
.fig-inline {
  margin: 1.5rem 0;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: #fafbfd;
  overflow-x: auto;
}
.fig-label {
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}
/* 図表の関連注記（notes）テキスト */
.fig-note {
  font-size: 0.9rem;
  color: #555;
  margin: 0.3rem 0 0.6rem;
  font-style: italic;
}
.fig-missing {
  color: #999;
  font-style: italic;
}

/* ── figure.njk（個別図表ページ） ── */
.fig-desc {
  color: #666;
  font-size: 0.9rem;
  margin: 0.25rem 0 1rem;
}
.fig-content {
  overflow-x: auto;
}
.fig-content img {
  max-width: 100%;
  height: auto;
}
/* EMF変換未対応プレースホルダー */
.img-placeholder {
  background: #fff3cd;
  border: 1px solid #ffc107;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: #856404;
  border-radius: 4px;
  margin: 0.5rem 0;
}
/* 図表ページ「一覧に戻る」リンク */
.close-area {
  margin-top: 1.5rem;
}
.close-area a {
  color: var(--color-primary);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}
.close-area a:hover { text-decoration: underline; }

/* ── レスポンシブ ── */
@media (max-width: 1200px) {
  .otp-panel { display: none; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 1rem; }
}
