/*
 * HatStaticEngine マニュアル 共通スタイル
 *
 * 姉妹プラグイン HatReserve のマニュアル（plugins/HatReserve/docs/manual/style.css）を
 * 土台にしている。2つのマニュアルで見た目が揃うよう、配色と余白はそのまま引き継ぎ、
 * クラス接頭辞だけ hr- から hse- へ変えたうえで、サイドバー・検索・図・コードブロックを足した。
 */
:root {
  --hse-bg: #f7f8fa;
  --hse-card: #ffffff;
  --hse-border: #e2e8f0;
  --hse-text: #1f2937;
  --hse-muted: #64748b;
  --hse-primary: #2563eb;
  --hse-primary-dark: #1d4ed8;
  --hse-accent: #0f766e;
  --hse-warn-bg: #fff7ed;
  --hse-warn-border: #fed7aa;
  --hse-warn-text: #9a3412;
  --hse-req: #dc2626;
  --hse-th-bg: #f1f5f9;
  --hse-sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: var(--hse-bg);
  color: var(--hse-text);
  line-height: 1.75;
  font-size: 15px;
}

a { color: var(--hse-primary); }

/* ===== レイアウト（サイドバー＋本文の2カラム） ===== */
.hse-layout {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
}
.hse-wrap {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 940px;
  padding: 24px 0 80px;
}

/* ===== サイドバー ===== */
/* JSがナビを描画するまでは何も見えない。JS無効時は表示しない（下の :empty） */
.hse-sidebar {
  flex: 0 0 var(--hse-sidebar-w);
  width: var(--hse-sidebar-w);
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px 0 40px;
}
.hse-sidebar:empty { display: none; }
.hse-sidebar-home {
  display: block;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  color: var(--hse-text);
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  margin-bottom: 12px;
}
.hse-sidebar-home:hover { border-color: var(--hse-primary); }
.hse-sidebar-group {
  font-size: 12px;
  font-weight: 700;
  color: var(--hse-muted);
  margin: 16px 0 4px;
  padding-left: 8px;
  border-left: 3px solid var(--hse-accent);
}
.hse-sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.hse-sidebar li a {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  text-decoration: none;
  color: var(--hse-text);
  padding: 5px 10px;
  border-radius: 5px;
}
.hse-sidebar li a:hover { background: #eef2ff; }
.hse-sidebar li a.is-current {
  background: var(--hse-primary);
  color: #fff;
  font-weight: 600;
}
/* 現在ページの見出しへのジャンプ（ページ内目次） */
.hse-sidebar .hse-toc {
  margin: 2px 0 6px;
  padding-left: 10px;
  border-left: 2px solid var(--hse-border);
}
.hse-sidebar .hse-toc a {
  font-size: 12px;
  color: var(--hse-muted);
  padding: 3px 8px;
}

/* ===== 検索 ===== */
.hse-search { position: relative; margin-bottom: 8px; }
.hse-search input {
  width: 100%;
  font-size: 13px;
  font-family: inherit;
  padding: 8px 10px;
  border: 1px solid var(--hse-border);
  border-radius: 6px;
  background: var(--hse-card);
  color: var(--hse-text);
}
.hse-search input:focus {
  outline: none;
  border-color: var(--hse-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.hse-search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 6px;
  max-height: 60vh;
  overflow-y: auto;
}
.hse-search-results:empty { display: none; }
.hse-search-results li { border-bottom: 1px solid var(--hse-border); }
.hse-search-results li:last-child { border-bottom: none; }
.hse-search-results a {
  display: block;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--hse-text);
}
.hse-search-results a:hover { background: #eef2ff; }
.hse-search-results .hse-hit-title { font-size: 13px; font-weight: 600; }
.hse-search-results .hse-hit-snippet {
  font-size: 11.5px;
  color: var(--hse-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hse-search-results mark { background: #fef08a; padding: 0 1px; }
.hse-search-empty {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--hse-muted);
}

/* ===== ヘッダー ===== */
.hse-header {
  border-bottom: 3px solid var(--hse-primary);
  padding-bottom: 14px;
  margin-bottom: 8px;
}
.hse-breadcrumb {
  font-size: 13px;
  color: var(--hse-muted);
  margin-bottom: 6px;
}
.hse-breadcrumb a { color: var(--hse-muted); }
.hse-header h1 {
  font-size: 26px;
  margin: 0 0 4px;
  letter-spacing: .02em;
}
.hse-header .hse-menu-path {
  font-size: 13px;
  color: var(--hse-muted);
}
.hse-header .hse-menu-path code {
  background: #eef2ff;
  color: var(--hse-primary-dark);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 12px;
}

/* ===== 見出し ===== */
h2.hse-sec {
  font-size: 19px;
  margin: 34px 0 12px;
  padding-left: 11px;
  border-left: 5px solid var(--hse-primary);
  scroll-margin-top: 12px;
}
h3.hse-sub {
  font-size: 16px;
  margin: 24px 0 8px;
  color: var(--hse-accent);
  scroll-margin-top: 12px;
}

/* ===== 概要リード文 ===== */
.hse-lead {
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 16px 0;
}
.hse-lead p:first-child { margin-top: 0; }
.hse-lead p:last-child { margin-bottom: 0; }

/* ===== 項目テーブル ===== */
table.hse-fields {
  width: 100%;
  border-collapse: collapse;
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  overflow: hidden;
  margin: 12px 0;
}
table.hse-fields th, table.hse-fields td {
  border: 1px solid var(--hse-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
table.hse-fields thead th {
  background: var(--hse-th-bg);
  font-size: 13px;
  color: var(--hse-muted);
  white-space: nowrap;
}
table.hse-fields td.hse-item {
  font-weight: 600;
  white-space: nowrap;
  width: 1%;
}
table.hse-fields td.hse-item .hse-key {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--hse-muted);
  margin-top: 2px;
}
.hse-default-badge {
  display: inline-block;
  background: #e0e7ff;
  color: var(--hse-primary-dark);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 400;
}
.hse-req-badge {
  display: inline-block;
  background: var(--hse-req);
  color: #fff;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  font-weight: 400;
}

/* ===== 補足・注意ボックス ===== */
.hse-note {
  background: var(--hse-warn-bg);
  border: 1px solid var(--hse-warn-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  color: var(--hse-warn-text);
}
.hse-note strong { color: var(--hse-warn-text); }
.hse-note ul { margin: 6px 0 0; padding-left: 20px; }
.hse-note p:first-child { margin-top: 0; }
.hse-note p:last-child { margin-bottom: 0; }

.hse-tip {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  color: #065f46;
}
.hse-tip strong { color: #065f46; }
.hse-tip ul { margin: 6px 0 0; padding-left: 20px; }
.hse-tip p:first-child { margin-top: 0; }
.hse-tip p:last-child { margin-bottom: 0; }

/* ===== 手順リスト ===== */
ol.hse-steps {
  counter-reset: hse-step;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}
ol.hse-steps > li {
  counter-increment: hse-step;
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 14px 16px 14px 52px;
  margin-bottom: 10px;
  position: relative;
}
ol.hse-steps > li::before {
  content: counter(hse-step);
  position: absolute;
  left: 14px;
  top: 13px;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 50%;
  background: var(--hse-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
ol.hse-steps > li > strong { display: block; margin-bottom: 4px; }
ol.hse-steps > li p:last-child { margin-bottom: 0; }

/* ===== 操作ボタンの説明リスト ===== */
ul.hse-actions {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}
ul.hse-actions li {
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 6px;
}
ul.hse-actions .hse-btn-label {
  font-weight: 600;
  color: var(--hse-primary-dark);
}

/* ===== コード・パターン ===== */
code {
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Courier New", monospace;
}
pre {
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.7;
}
pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}
/* 設定値のパターンなど、色を付けないほうが読みやすいもの */
pre.hse-pattern {
  background: #f8fafc;
  color: #334155;
  border-style: dashed;
}
.hse-code-caption {
  font-size: 12px;
  color: var(--hse-muted);
  margin: 12px 0 -6px;
}

/* ===== 図（インラインSVG） ===== */
.hse-figure {
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 18px 16px 12px;
  margin: 18px 0;
  text-align: center;
}
.hse-figure svg {
  max-width: 100%;
  height: auto;
}
.hse-figure figcaption {
  font-size: 12.5px;
  color: var(--hse-muted);
  margin-top: 10px;
  text-align: left;
}

/* ===== フッターナビ ===== */
.hse-footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--hse-border);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.hse-footer a {
  color: var(--hse-primary);
  text-decoration: none;
}
.hse-footer a:hover { text-decoration: underline; }

/* ===== 目次(index) ===== */
.hse-index-intro {
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 18px 20px;
  margin: 16px 0 28px;
}
.hse-index-intro p:first-child { margin-top: 0; }
.hse-index-intro p:last-child { margin-bottom: 0; }
.hse-group { margin-bottom: 28px; }
.hse-group h2 {
  font-size: 17px;
  margin: 0 0 4px;
  padding-left: 10px;
  border-left: 5px solid var(--hse-accent);
}
.hse-group .hse-group-desc {
  font-size: 13px;
  color: var(--hse-muted);
  margin: 0 0 12px 15px;
}
.hse-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.hse-card {
  display: block;
  background: var(--hse-card);
  border: 1px solid var(--hse-border);
  border-radius: 8px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--hse-text);
  transition: border-color .15s, box-shadow .15s;
}
.hse-card:hover {
  border-color: var(--hse-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, .12);
}
.hse-card .hse-card-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 3px;
}
.hse-card .hse-card-desc {
  font-size: 12.5px;
  color: var(--hse-muted);
  line-height: 1.5;
}

/* ===== 狭い画面 ===== */
@media (max-width: 900px) {
  .hse-layout { display: block; padding: 0 14px; }
  .hse-sidebar {
    width: auto;
    position: static;
    max-height: none;
    padding: 14px 0 0;
  }
  .hse-sidebar .hse-nav-body { display: none; }
  .hse-sidebar.is-open .hse-nav-body { display: block; }
  .hse-nav-toggle {
    display: block;
    width: 100%;
    font: inherit;
    font-size: 14px;
    text-align: left;
    padding: 9px 12px;
    background: var(--hse-card);
    border: 1px solid var(--hse-border);
    border-radius: 6px;
    color: var(--hse-text);
    cursor: pointer;
  }
  .hse-wrap { padding: 16px 0 60px; max-width: none; }

  /* 表は中で横スクロールさせる。画面ごと横に伸びるのは防ぐ */
  table.hse-fields { display: block; overflow-x: auto; }
  /* ★ ここで white-space: normal にしてはいけない。項目名の列は width:1% なので、
     折り返しを許すと日本語が1文字ずつ縦に並んでしまう（実機で確認） */
  table.hse-fields td.hse-item { white-space: nowrap; }
  /* 2列目には最低限の幅を持たせる（説明文が極端に細くならないように） */
  table.hse-fields td:not(.hse-item) { min-width: 16em; }
}
/* 広い画面では開閉ボタンを出さない（常に開いている） */
@media (min-width: 901px) {
  .hse-nav-toggle { display: none; }
}

/* ===== 印刷 ===== */
@media print {
  body { background: #fff; font-size: 11pt; }
  .hse-sidebar, .hse-footer { display: none; }
  .hse-layout { display: block; max-width: none; padding: 0; }
  .hse-wrap { max-width: none; padding: 0; }
  .hse-lead, .hse-note, .hse-tip, .hse-figure, pre, table.hse-fields {
    break-inside: avoid;
  }
  a { color: inherit; text-decoration: none; }
}
