/* mokuji-common.css
   Common styles for VSED table-of-contents pages (mokuji.html / mokuji2.html / mokuji3.html)
*/

html { color-scheme: light dark; }

/* =========================
   Theme tokens (LIGHT default)
   ========================= */
:root{
  /* layout */
  --maxw: 1200px;
  --radius: 14px;

  /* typography */
  --fz: 16px;
  --fz-small: 13px;
  --fz-h1: 22px;
  --lh: 1.65;

  /* light */
  --bg: #ffffff;
  --bg2: #f6f7fb;
  --card: #ffffff;

  --text: #111827;
  --muted: #6b7280;

  --border: rgba(17, 24, 39, 0.14);
  --shadow: 0 8px 22px rgba(0,0,0,0.08);

  --link: #2563eb;
  --link-hover:#1d4ed8;
}

/* DARK override */
@media (prefers-color-scheme: dark){
  :root{
    --bg: #0b1220;
    --bg2: #0f172a;
    --card: #111b2e;

    --text: #e5e7eb;
    --muted: #94a3b8;

    --border: rgba(148, 163, 184, 0.25);
    --shadow: 0 8px 24px rgba(0,0,0,0.45);

    --link: #60a5fa;
    --link-hover:#93c5fd;
  }
}

/* Universal box sizing */
*, *::before, *::after { box-sizing: border-box; }

/* ---------- Base ---------- */
html, body{
  background-color: var(--bg) !important;
  background-image: none !important;
}

body{
  margin: 0;
  color: var(--text);
  font-size: var(--fz);
  line-height: var(--lh);
  -webkit-text-size-adjust: 100%;
  font-family:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Noto Sans JP", "Noto Sans Vietnamese",
    "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo",
    sans-serif;
}

/* legacyの「変な背景画像」だけ除去 */
body *{
  background-image: none !important;
}

/* legacy table bgcolor を無効化（ただし行自体は後でカード色を付ける） */
table, thead, tbody, tfoot, tr, td, th{
  background-color: transparent !important;
  background-image: none !important;
}

/* mokuji.html に多い「黒指定」をダークでも読めるように矯正 */
[style*="color:black"],
[style*="color: black"],
font[color="black"]{
  color: var(--text) !important;
}

/* ---------- Links ---------- */
a{ color: var(--link); text-decoration: none; }
a:hover{ color: var(--link-hover); text-decoration: underline; }

/* ---------- Container helpers ---------- */
.container, .wrap, .page, main, .legacy-wrap{
  max-width: var(--maxw);
  margin-left: auto;
  margin-right: auto;
  padding: 24px 16px 64px;
}

h1, h2{
  margin: 0 0 10px;
  line-height: 1.25;
}
h1{
  font-size: var(--fz-h1);
  letter-spacing: 0.2px;
}
small, .small, .meta, .note{
  font-size: var(--fz-small);
  color: var(--muted);
}

/* ---------- Pills / header actions (optional) ---------- */
.pill, .toolbar, .topbar{
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in oklab, var(--bg2) 78%, transparent);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.toolbar{ flex-wrap: wrap; }
.toolbar a{ font-weight: 600; }

/* ---------- Issue cards (mokuji2/mokuji3 modern) ---------- */
.issue-card, .card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px;
  margin: 16px 0;
}

.issue-grid{
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
}
@media (max-width: 840px){
  .issue-grid{ grid-template-columns: 1fr; }
}

.issue-meta{
  color: var(--muted);
  font-size: var(--fz-small);
}
.issue-meta .no{
  color: var(--text);
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 6px;
}
.issue-body{ padding-left: 0.2rem; }

/* ---------- LIST INDENT FIX (ALL pages) ---------- */
ul, ol{
  margin: 0.35em 0 0.35em 0;
  padding-left: 1.35em !important;
}
li{ margin: 0.32em 0; }
li > ul, li > ol{ margin-top: 0.25em; }

.issue-body ul, .issue-body ol,
.issue-card ul, .issue-card ol,
.card ul, .card ol{
  padding-left: 1.4em !important;
}

/* ---------- Legacy mokuji.html table improvements ---------- */
table{
  border-collapse: separate !important;
  border-spacing: 0 !important;
  width: 100%;
}

table[border], table[border="1"]{
  border: 1px solid var(--border) !important;
}

td, th{
  vertical-align: top;
  padding: 14px 14px !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

td:first-child, th:first-child{
  width: min(220px, 28%) !important;
  white-space: nowrap;
}

/* 行をカードっぽく */
tr{ background: var(--card) !important; }
tbody tr:nth-child(odd){
  background: color-mix(in oklab, var(--bg2) 65%, transparent) !important;
}

/* 旧HTMLで ul/li じゃなくても読みやすくする */
table td + td p,
table td + td div,
table td + td font{
  margin: 0 0 6px 0 !important;
}

/* 右セルに余白 */
table td + td{
  padding: 14px 28px !important;
}

/* ===== mokuji 系：表全体の左インデント ===== */
body table{
  margin-left: 32px !important;
  margin-right: auto;
  max-width: 1200px;
}

.top-links{
  text-align: right;
  margin: 0.3em 2em 0.3em 0;
}

/* 日本語切替ボタン（mokuji2/3） */
.btn-toggle{
  border: none;
  box-shadow: none;
  background: transparent;
  padding: 0;
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}
.btn-toggle:hover{ text-decoration: underline; }

/* 日本語訳OFF（mokuji2=.jp / mokuji3=.ja 両対応） */
body.jp-off .jp,
body.jp-off .ja{
  display: none !important;
}

/* ---------- Print ---------- */
@media print{
  :root{ --shadow:none; }
  .issue-card, .card{ box-shadow: none !important; }
  a{ text-decoration: underline; }
}
